From 7969ea3b41db05294c78a5e0ec0bd3c29ae8c549 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Sun, 11 Apr 2010 10:19:54 +0200 Subject: Fixes a bug in OSPF on NBMA interfaces. A very tricky bug. OSPF on NBMA interfaces probably never really worked. When a packet was sent to multiple destinations, the checksum was calculated multiple times from a packet with already filled checksum field (from previous calculation). Therefore, many packets were sent with an invalid checksum. --- proto/ospf/packet.c | 1 + 1 file changed, 1 insertion(+) (limited to 'proto/ospf/packet.c') diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c index b47cbfc..e78eeea 100644 --- a/proto/ospf/packet.c +++ b/proto/ospf/packet.c @@ -76,6 +76,7 @@ ospf_pkt_finalize(struct ospf_iface *ifa, struct ospf_packet *pkt) } password_cpy(pkt->u.password, passwd->password, sizeof(union ospf_auth)); case OSPF_AUTH_NONE: + pkt->checksum = 0; pkt->checksum = ipsum_calculate(pkt, sizeof(struct ospf_packet) - sizeof(union ospf_auth), (pkt + 1), ntohs(pkt->length) - -- cgit v1.2.3 From 9d1ee1388771a3caa6c23163571a80457adfab2c Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 26 Apr 2010 19:08:57 +0200 Subject: Neighbors on OSPF broadcast networks should be identified by IP address, not RID. Allows simple support for multiple interfaces to the same network. --- proto/ospf/packet.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'proto/ospf/packet.c') diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c index e78eeea..74ce550 100644 --- a/proto/ospf/packet.c +++ b/proto/ospf/packet.c @@ -242,6 +242,19 @@ ospf_pkt_checkauth(struct ospf_neighbor *n, struct ospf_iface *ifa, struct ospf_ #endif +#ifdef OSPFv2 +static inline struct ospf_neighbor * +find_neigh_by_ip(struct ospf_iface *ifa, ip_addr ip) +{ + struct ospf_neighbor *n; + WALK_LIST(n, ifa->neigh_list) + if (ipa_equal(n->ip, ip)) + return n; + return NULL; +} +#endif + + /** * ospf_rx_hook @@ -419,10 +432,16 @@ ospf_rx_hook(sock *sk, int size) return 1; } - /* This is deviation from RFC 2328 - neighbours should be identified by - * IP address on broadcast and NBMA networks. - */ +#ifdef OSPFv2 + /* In OSPFv2, neighbors are identified by either IP or Router ID, base on network type */ + struct ospf_neighbor *n; + if ((ifa->type == OSPF_IT_BCAST) || (ifa->type == OSPF_IT_NBMA)) + n = find_neigh_by_ip(ifa, sk->faddr); + else + n = find_neigh(ifa, rid); +#else struct ospf_neighbor *n = find_neigh(ifa, rid); +#endif if(!n && (ps->type != HELLO_P)) { -- cgit v1.2.3