]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Lock originating bgp pointer for vrf route leaking
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 30 May 2018 22:17:17 +0000 (18:17 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 31 May 2018 13:43:07 +0000 (09:43 -0400)
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>
bgpd/bgp_mplsvpn.c
bgpd/bgp_route.c

index b58e9da6f41042aec42f763b6042b80be3be12e5..eef711aa59bf907b1be46e9345a9b250756753ec 100644 (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;
 
index a6322b1e06745b0a195181e68e59b4dad8056918..1bf9db99fd1c66641f3aa7ebd48f288c19eec8bc 100644 (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)