From: vivek Date: Tue, 23 Feb 2016 23:55:06 +0000 (+0000) Subject: BGP: Fix interface list upon instance creation/deletion X-Git-Tag: frr-2.0-rc1~1103^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b33adb7c40a60b2313c140250eb044058a7b8858;p=mirror%2Ffrr.git BGP: Fix interface list upon instance creation/deletion The BGP instance cleanup was deleting interfaces in that instance after prior fixes, but this ended up deleting the interface list header which was not being re-created. Added code to re-create this at the time an instance is created. Signed-off-by: Vivek Venkatraman Ticket: CM-9466 Reviewed By: CCR-4164 Testing Done: Manual and verified failed test --- diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 38cabed3d5..8fbaad27ad 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -80,6 +80,9 @@ struct bgp_master *bm; /* BGP community-list. */ struct community_list_handler *bgp_clist; +static void bgp_if_init (struct bgp *bgp); +static void bgp_if_finish (struct bgp *bgp); + extern struct zclient *zclient; void @@ -2915,7 +2918,10 @@ bgp_get (struct bgp **bgp_val, as_t *as, const char *name, vrf = bgp_vrf_lookup_by_instance_type (bgp); if (vrf) - bgp_vrf_link (bgp, vrf); + { + bgp_vrf_link (bgp, vrf); + bgp_if_init (bgp); + } } /* Register with Zebra, if needed */ @@ -7160,11 +7166,24 @@ bgp_master_init (void) bgp_process_queue_init(); } +/* + * Initialize interface list for instance, if needed. Invoked upon + * instance create. + */ +static void +bgp_if_init (struct bgp *bgp) +{ + if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) + return; + + vrf_iflist_create (bgp->vrf_id); +} + /* * Free up connected routes and interfaces for a BGP instance. Invoked upon * instance delete (non-default only) or BGP exit. */ -void +static void bgp_if_finish (struct bgp *bgp) { struct listnode *ifnode, *ifnnode; diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 04f5f09586..3a0a679d6f 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1174,7 +1174,6 @@ extern char *peer_uptime (time_t, char *, size_t, u_char, json_object *); extern int bgp_config_write (struct vty *); extern void bgp_config_write_family_header (struct vty *, afi_t, safi_t, int *); -extern void bgp_if_finish (struct bgp *); extern void bgp_master_init (void); extern void bgp_init (void); diff --git a/lib/vrf.c b/lib/vrf.c index a4cddeefb4..fd2b07d505 100644 --- a/lib/vrf.c +++ b/lib/vrf.c @@ -495,6 +495,15 @@ vrf_iflist_get (vrf_id_t vrf_id) return vrf->iflist; } +/* Create the interface list for the specified VRF, if needed. */ +void +vrf_iflist_create (vrf_id_t vrf_id) +{ + struct vrf * vrf = vrf_lookup (vrf_id); + if (vrf && !vrf->iflist) + if_init (vrf_id, &vrf->iflist); +} + /* Free the interface list of the specified VRF. */ void vrf_iflist_terminate (vrf_id_t vrf_id) diff --git a/lib/vrf.h b/lib/vrf.h index 9f3b231735..0d2c142bea 100644 --- a/lib/vrf.h +++ b/lib/vrf.h @@ -180,6 +180,8 @@ extern void *vrf_info_lookup (vrf_id_t); extern struct list *vrf_iflist (vrf_id_t); /* Get the interface list of the specified VRF. Create one if not find. */ extern struct list *vrf_iflist_get (vrf_id_t); +/* Create the interface list for the specified VRF, if needed. */ +extern void vrf_iflist_create (vrf_id_t vrf_id); /* Free the interface list of the specified VRF. */ extern void vrf_iflist_terminate (vrf_id_t vrf_id);