summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-06-21 18:04:46 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2021-06-21 18:04:46 +0300
commitf5eef2d5a8a471fe6e4ec4f6acfa3dbf190eda5d (patch)
tree58ed00dffe8ba1f1c64ca0b6dfa3153da9ec6e43 /lib
parentcd551a0fd5430791ce4e650ccca9b312f02b9701 (diff)
lib: remove vrf-interface config when removing the VRF
If we have the following configuration: ``` vrf red smth exit-vrf ! interface red vrf red smth ``` And we delete the VRF using "no vrf red" command, we end up with: ``` interface red smth ``` Interface config is preserved but moved to the default VRF. This is not an expected behavior. We should remove the interface config when the VRF is deleted. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/vrf.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/vrf.c b/lib/vrf.c
index a04f2ddeb7..03d9a62c0f 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -827,10 +827,24 @@ DEFUN_YANG (no_vrf,
return CMD_WARNING_CONFIG_FAILED;
}
+ if (vrf_get_backend() == VRF_BACKEND_VRF_LITE) {
+ /*
+ * Remove the VRF interface config. Currently, we allow to
+ * remove only inactive VRFs, so we use VRF_DEFAULT_NAME here,
+ * because when the VRF is removed from kernel, the interface
+ * is moved to the default VRF. If we ever allow removing
+ * active VRFs, this code have to be updated accordingly.
+ */
+ snprintf(xpath_list, sizeof(xpath_list),
+ "/frr-interface:lib/interface[name='%s'][vrf='%s']",
+ vrfname, VRF_DEFAULT_NAME);
+ nb_cli_enqueue_change(vty, xpath_list, NB_OP_DESTROY, NULL);
+ }
+
snprintf(xpath_list, sizeof(xpath_list), FRR_VRF_KEY_XPATH, vrfname);
nb_cli_enqueue_change(vty, xpath_list, NB_OP_DESTROY, NULL);
- return nb_cli_apply_changes(vty, xpath_list);
+ return nb_cli_apply_changes(vty, NULL);
}