ospfd: PointToPoint neighbors are identified by router ID
According to RFC 2328, section 10.5 PointToPoint neighbors
should be identified by router ID instead of source IP address.
Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
diff --git a/ospfd/ospf_neighbor.c b/ospfd/ospf_neighbor.c
index c3bdf99..23a6417 100644
--- a/ospfd/ospf_neighbor.c
+++ b/ospfd/ospf_neighbor.c
@@ -45,8 +45,8 @@
/* Fill in the the 'key' as appropriate to retrieve the entry for nbr
* from the ospf_interface's nbrs table. Indexed by interface address
- * for all cases except Virtual-link interfaces, where neighbours are
- * indexed by router-ID instead.
+ * for all cases except Virtual-link and PointToPoint interfaces, where
+ * neighbours are indexed by router-ID instead.
*/
static void
ospf_nbr_key (struct ospf_interface *oi, struct ospf_neighbor *nbr,
@@ -56,7 +56,8 @@
key->prefixlen = IPV4_MAX_BITLEN;
/* vlinks are indexed by router-id */
- if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
+ if (oi->type == OSPF_IFTYPE_VIRTUALLINK ||
+ oi->type == OSPF_IFTYPE_POINTOPOINT)
key->u.prefix4 = nbr->router_id;
else
key->u.prefix4 = nbr->src;
@@ -291,8 +292,8 @@
#endif /* HAVE_OPAQUE_LSA */
/* lookup nbr by address - use this only if you know you must
- * otherwise use the ospf_nbr_lookup() wrapper, which deals
- * with virtual link neighbours
+ * otherwise use the ospf_nbr_lookup() wrapper, which deals
+ * with virtual link and PointToPoint neighbours
*/
struct ospf_neighbor *
ospf_nbr_lookup_by_addr (struct route_table *nbrs,
@@ -384,7 +385,8 @@
ospf_nbr_lookup (struct ospf_interface *oi, struct ip *iph,
struct ospf_header *ospfh)
{
- if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
+ if (oi->type == OSPF_IFTYPE_VIRTUALLINK ||
+ oi->type == OSPF_IFTYPE_POINTOPOINT)
return (ospf_nbr_lookup_by_routerid (oi->nbrs, &ospfh->router_id));
else
return (ospf_nbr_lookup_by_addr (oi->nbrs, &iph->ip_src));
@@ -444,8 +446,9 @@
key.family = AF_INET;
key.prefixlen = IPV4_MAX_BITLEN;
- if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
- key.u.prefix4 = ospfh->router_id; /* index vlink nbrs by router-id */
+ if (oi->type == OSPF_IFTYPE_VIRTUALLINK ||
+ oi->type == OSPF_IFTYPE_POINTOPOINT)
+ key.u.prefix4 = ospfh->router_id;/* index vlink and ptp nbrs by router-id */
else
key.u.prefix4 = iph->ip_src;