summaryrefslogtreecommitdiffstats
path: root/ospfd/ospfd.c
diff options
context:
space:
mode:
authorJafar Al-Gharaibeh <jafar@atcorp.com>2016-04-21 23:22:33 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2016-06-10 21:08:28 +0200
commitecea0cb083a757664a3c105194fba06405f96e58 (patch)
treec388bdb0028d62fe0609d132de4e6370456ccdc3 /ospfd/ospfd.c
parentconfigure.ac: Add back HAVE_SYSTEMD (diff)
downloadfrr-ecea0cb083a757664a3c105194fba06405f96e58.tar.xz
frr-ecea0cb083a757664a3c105194fba06405f96e58.zip
ospfd: fix - correct neighbor index on changing/p2p/virtual links
ospfd keeps a list of neighbor routers for each configured interface. This list is indexed using the neighbor router id in case of point-to-point and virtual link types, otherwise the list is indexed using the neighbor's source IP (RFC 2328, page 96). The router adds itself as a "pseudo" neighbor on each link, and also keeps a pointer called (nbr_self) to the neighbor structure. This takes place when the interface is first configured. Currently ospfd adds this pseudo neighbor before the link parameters are fully configure, including whether the link type is point-to-point or virtual link. This causes the pseudo neighbor to be always indexed using the source IP address regardless of th link type. For point-to-point and virtual links, this causes the lookup for the pseudo neighbor to always fail because the lookup is done using the router id whereas the neighbor was added using its source IP address. This becomes really problematic if there is a state change that requires a rebuild of nbr_self, changing the router id for example. When resetting nbr_self, the router first tries to remove the pseudo neighbor form its neighbor list on each link by looking it up and resetting any references to it before freeing the neighbor structure. since the lookup fails to retrieve any references in the case of point-to-point and virtual links the neighbor structure is freed leaving dangling references to it. Any access to the neighbor list after that is bound to stumble over this dangling pointer causing ospfd to crash. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com> Tested-by: NetDEF CI System <cisystem@netdef.org> (cherry picked from commit bb01bdd740339b0c07d8ed0786811801b2a79192)
Diffstat (limited to 'ospfd/ospfd.c')
-rw-r--r--ospfd/ospfd.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index 5b5014eec..ea66042f2 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -879,9 +879,6 @@ add_ospf_interface (struct interface *ifp, struct ospf_area *area,
oi->params = ospf_lookup_if_params (ifp, oi->address->u.prefix4);
oi->output_cost = ospf_if_get_output_cost (oi);
- /* Add pseudo neighbor. */
- ospf_nbr_add_self (oi);
-
/* Relate ospf interface to ospf instance. */
oi->ospf = area->ospf;
@@ -890,6 +887,9 @@ add_ospf_interface (struct interface *ifp, struct ospf_area *area,
skip network type setting. */
oi->type = IF_DEF_PARAMS (ifp)->type;
+ /* Add pseudo neighbor. */
+ ospf_nbr_self_reset (oi);
+
ospf_area_add_if (oi->area, oi);
return (oi);