summaryrefslogtreecommitdiff
path: root/bgpd/rfapi/rfapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/rfapi/rfapi.c')
-rw-r--r--bgpd/rfapi/rfapi.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c
index 8d6db9d775..67c70431bd 100644
--- a/bgpd/rfapi/rfapi.c
+++ b/bgpd/rfapi/rfapi.c
@@ -51,6 +51,8 @@
#include <execinfo.h>
#endif /* HAVE_GLIBC_BACKTRACE */
+#define DEBUG_CLEANUP 0
+
struct ethaddr rfapi_ethaddr0 = {{0}};
#define DEBUG_RFAPI_STR "RF API debugging/testing command\n"
@@ -3677,11 +3679,36 @@ void rfapi_delete(struct bgp *bgp)
{
extern void rfp_clear_vnc_nve_all(void); /* can't fix correctly yet */
+#if DEBUG_CLEANUP
+ zlog_debug("%s: bgp %p", __func__, bgp);
+#endif
+
/*
* This clears queries and registered routes, and closes nves
*/
if (bgp->rfapi)
rfp_clear_vnc_nve_all();
+
+ /*
+ * close any remaining descriptors
+ */
+ struct rfapi *h = bgp->rfapi;
+
+ if (h && h->descriptors.count) {
+ struct listnode *node, *nnode;
+ struct rfapi_descriptor *rfd;
+#if DEBUG_CLEANUP
+ zlog_debug("%s: descriptor count %u", __func__,
+ h->descriptors.count);
+#endif
+ for (ALL_LIST_ELEMENTS(&h->descriptors, node, nnode, rfd)) {
+#if DEBUG_CLEANUP
+ zlog_debug("%s: closing rfd %p", __func__, rfd);
+#endif
+ (void)rfapi_close(rfd);
+ }
+ }
+
bgp_rfapi_cfg_destroy(bgp, bgp->rfapi_cfg);
bgp->rfapi_cfg = NULL;
bgp_rfapi_destroy(bgp, bgp->rfapi);