mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 15:33:56 +00:00
ospfd: avoid exhausting memory with OSPF vertices (BZ#476)
This was found in scale testing at OSR; ospfd is adding the same link over and over again to the SPF tree. This fix prevents the resulting memory corruption from happening and adds a debug message to track occurence of this issue and/or confirm a proper fix. (This version was improved by Scott Feldman over the earlier RFC.) * ospfd/ospf_spf.c: (ospf_spf_add_parent) loop over existing vertices and refuse to add duplicates. Tested-by: Martin Winter <mwinter@opensourcerouting.org> Signed-off-by: Scott Feldman <sfeldma@cumulusnetworks.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
aa5cf24b9d
commit
7b92589c22
@ -422,7 +422,8 @@ ospf_spf_add_parent (struct vertex *v, struct vertex *w,
|
|||||||
struct vertex_nexthop *newhop,
|
struct vertex_nexthop *newhop,
|
||||||
unsigned int distance)
|
unsigned int distance)
|
||||||
{
|
{
|
||||||
struct vertex_parent *vp;
|
struct vertex_parent *vp, *wp;
|
||||||
|
struct listnode *node;
|
||||||
|
|
||||||
/* we must have a newhop, and a distance */
|
/* we must have a newhop, and a distance */
|
||||||
assert (v && w && newhop);
|
assert (v && w && newhop);
|
||||||
@ -456,7 +457,19 @@ ospf_spf_add_parent (struct vertex *v, struct vertex *w,
|
|||||||
w->distance = distance;
|
w->distance = distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* new parent is <= existing parents, add it to parent list */
|
/* new parent is <= existing parents, add it to parent list (if nexthop
|
||||||
|
* not on parent list)
|
||||||
|
*/
|
||||||
|
for (ALL_LIST_ELEMENTS_RO(w->parents, node, wp))
|
||||||
|
{
|
||||||
|
if (memcmp(newhop, wp->nexthop, sizeof(*newhop)) == 0)
|
||||||
|
{
|
||||||
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
|
zlog_debug ("%s: ... nexthop already on parent list, skipping add", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vp = vertex_parent_new (v, ospf_lsa_has_link (w->lsa, v->lsa), newhop);
|
vp = vertex_parent_new (v, ospf_lsa_has_link (w->lsa, v->lsa), newhop);
|
||||||
listnode_add (w->parents, vp);
|
listnode_add (w->parents, vp);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user