summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-05-30 18:17:17 -0400
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-05-31 09:43:07 -0400
commit21d88ef7611a0c5a26bde88aab2d3bb2d03989e5 (patch)
tree7881ed63bb2768bcb7732bc6710576163a7e334c
parent122eebd85a9562391af33451d1c323aa87ab400b (diff)
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>
-rw-r--r--bgpd/bgp_mplsvpn.c2
-rw-r--r--bgpd/bgp_route.c18
2 files changed, 14 insertions, 6 deletions
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index b58e9da6f4..eef711aa59 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -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;
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index a6322b1e06..1bf9db99fd 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -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)