]> git.proxmox.com Git - mirror_frr.git/commitdiff
BGP: Fix interface list upon instance creation/deletion
authorvivek <vivek@cumulusnetworks.com>
Tue, 23 Feb 2016 23:55:06 +0000 (23:55 +0000)
committervivek <vivek@cumulusnetworks.com>
Wed, 24 Feb 2016 04:09:21 +0000 (04:09 +0000)
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 <vivek@cumulusnetworks.com>
Ticket: CM-9466
Reviewed By: CCR-4164
Testing Done: Manual and verified failed test

bgpd/bgpd.c
bgpd/bgpd.h
lib/vrf.c
lib/vrf.h

index 38cabed3d511731a64956106e60e8da8cdabfa15..8fbaad27ad3d58a23163227fc77a68a9fd3bc85b 100644 (file)
@@ -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;
index 04f5f09586715c632738a9c521579bb768391481..3a0a679d6fd5b19106c93d2db84b9e4882e2663b 100644 (file)
@@ -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);
index a4cddeefb4e522d8636fb95165dc9cbe8302c1d2..fd2b07d5056fc20fad0fa28001e28a5e8477346a 100644 (file)
--- 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)
index 9f3b2317354ec810a455a998f09093af2d0e2689..0d2c142bea1583b0df5f6c2331dc7062db75c5ee 100644 (file)
--- 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);