summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-11-06 03:36:48 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2021-11-11 14:57:18 +0300
commit6502e5f1044082bb492935ca2dcdc839c023146e (patch)
tree3be728f08c9e93bbca28e38c9e416385f9799e80
parent0ac8055ca1a9662d6e8197dff9a91759331991e7 (diff)
zebra: fix netns deletion
We don't receive interface down/delete notifications from kernel when a netns is deleted. Therefore we have to manually replicate the necessary actions, otherwise interfaces are kept in the system with stale pointers to the deleted netns. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
-rw-r--r--zebra/zebra_netns_notify.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/zebra/zebra_netns_notify.c b/zebra/zebra_netns_notify.c
index 5b9539904f..391f28d18f 100644
--- a/zebra/zebra_netns_notify.c
+++ b/zebra/zebra_netns_notify.c
@@ -42,6 +42,7 @@
#include "zebra_netns_notify.h"
#include "zebra_netns_id.h"
#include "zebra_errors.h"
+#include "interface.h"
#ifdef HAVE_NETLINK
@@ -154,6 +155,7 @@ static int zebra_ns_continue_read(struct zebra_netns_info *zns_info,
static int zebra_ns_delete(char *name)
{
struct vrf *vrf = vrf_lookup_by_name(name);
+ struct interface *ifp, *tmp;
struct ns *ns;
if (!vrf) {
@@ -161,6 +163,25 @@ static int zebra_ns_delete(char *name)
"NS notify : no VRF found using NS %s", name);
return 0;
}
+
+ /*
+ * We don't receive interface down/delete notifications from kernel
+ * when a netns is deleted. Therefore we have to manually replicate
+ * the necessary actions here.
+ */
+ RB_FOREACH_SAFE (ifp, if_name_head, &vrf->ifaces_by_name, tmp) {
+ if (!CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE))
+ continue;
+
+ if (if_is_no_ptm_operative(ifp)) {
+ UNSET_FLAG(ifp->flags, IFF_RUNNING);
+ if_down(ifp);
+ }
+
+ UNSET_FLAG(ifp->flags, IFF_UP);
+ if_delete_update(ifp);
+ }
+
ns = (struct ns *)vrf->ns_ctxt;
/* the deletion order is the same
* as the one used when siging signal is received