bgpd: Lock originating bgp pointer for vrf route leaking

There exists cases where we will attempt to hard delete
the bgp instance( say a `no router bgp` is issued )
when we have vrf route leaking.  If we do have this
lock the bgp instance of the originator and do not
let it be deleted out from under us until we are
finished processing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-05-30 18:17:17 -04:00
parent 122eebd85a
commit 21d88ef761
2 changed files with 14 additions and 6 deletions

View File

@ -573,7 +573,7 @@ leak_update(
new->extra->parent = bgp_info_lock(parent);
bgp_lock_node((struct bgp_node *)((struct bgp_info *)parent)->net);
if (bgp_orig)
new->extra->bgp_orig = bgp_orig;
new->extra->bgp_orig = bgp_lock(bgp_orig);
if (nexthop_orig)
new->extra->nexthop_orig = *nexthop_orig;

View File

@ -206,11 +206,19 @@ struct bgp_info *bgp_info_new(void)
static void bgp_info_free(struct bgp_info *binfo)
{
/* unlink reference to parent, if any. */
if (binfo->extra && binfo->extra->parent) {
bgp_unlock_node((struct bgp_node *)((struct bgp_info *)binfo
->extra->parent)->net);
bgp_info_unlock((struct bgp_info *)binfo->extra->parent);
binfo->extra->parent = NULL;
if (binfo->extra) {
if (binfo->extra->parent) {
bgp_unlock_node(
(struct bgp_node *)((struct bgp_info *)binfo
->extra->parent)
->net);
bgp_info_unlock(
(struct bgp_info *)binfo->extra->parent);
binfo->extra->parent = NULL;
}
if (binfo->extra->bgp_orig)
bgp_unlock(binfo->extra->bgp_orig);
}
if (binfo->attr)