diff options
author | Igor Ryzhov <iryzhov@nfware.com> | 2021-06-21 17:04:46 +0200 |
---|---|---|
committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-06-21 17:04:46 +0200 |
commit | f5eef2d5a8a471fe6e4ec4f6acfa3dbf190eda5d (patch) | |
tree | 58ed00dffe8ba1f1c64ca0b6dfa3153da9ec6e43 | |
parent | Merge pull request #8841 from volta-networks/fix_ospf6_bad_seqnum (diff) | |
download | frr-f5eef2d5a8a471fe6e4ec4f6acfa3dbf190eda5d.tar.xz frr-f5eef2d5a8a471fe6e4ec4f6acfa3dbf190eda5d.zip |
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>
-rw-r--r-- | babeld/babeld.c | 2 | ||||
-rw-r--r-- | eigrpd/eigrp_cli.c | 2 | ||||
-rw-r--r-- | isisd/isisd.c | 2 | ||||
-rw-r--r-- | lib/vrf.c | 16 | ||||
-rw-r--r-- | nhrpd/nhrp_main.c | 1 | ||||
-rw-r--r-- | nhrpd/nhrp_vty.c | 2 | ||||
-rw-r--r-- | ospf6d/ospf6_top.c | 2 | ||||
-rw-r--r-- | ospfd/ospf_vty.c | 2 | ||||
-rw-r--r-- | pbrd/pbr_main.c | 1 | ||||
-rw-r--r-- | pbrd/pbr_vty.c | 4 | ||||
-rw-r--r-- | ripd/ripd.c | 2 | ||||
-rw-r--r-- | ripngd/ripngd.c | 2 | ||||
-rw-r--r-- | vrrpd/vrrp_vty.c | 1 | ||||
-rw-r--r-- | vtysh/vtysh.h | 2 |
14 files changed, 39 insertions, 2 deletions
diff --git a/babeld/babeld.c b/babeld/babeld.c index 4d4dd2e19..b9623b64b 100644 --- a/babeld/babeld.c +++ b/babeld/babeld.c @@ -819,6 +819,8 @@ babeld_quagga_init(void) install_element(BABEL_NODE, &babel_ipv6_distribute_list_cmd); install_element(BABEL_NODE, &babel_no_ipv6_distribute_list_cmd); + vrf_cmd_init(NULL, &babeld_privs); + babel_if_init(); /* Access list install. */ diff --git a/eigrpd/eigrp_cli.c b/eigrpd/eigrp_cli.c index 3a978cae3..47de929fc 100644 --- a/eigrpd/eigrp_cli.c +++ b/eigrpd/eigrp_cli.c @@ -919,6 +919,8 @@ eigrp_cli_init(void) install_element(EIGRP_NODE, &eigrp_neighbor_cmd); install_element(EIGRP_NODE, &eigrp_redistribute_source_metric_cmd); + vrf_cmd_init(NULL, &eigrpd_privs); + install_node(&eigrp_interface_node); if_cmd_init(); diff --git a/isisd/isisd.c b/isisd/isisd.c index 7f56903fc..7e78e0ce6 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -716,6 +716,8 @@ void isis_vrf_init(void) { vrf_init(isis_vrf_new, isis_vrf_enable, isis_vrf_disable, isis_vrf_delete, isis_vrf_enable); + + vrf_cmd_init(NULL, &isisd_privs); } void isis_terminate() @@ -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); } diff --git a/nhrpd/nhrp_main.c b/nhrpd/nhrp_main.c index c2111a770..54b785020 100644 --- a/nhrpd/nhrp_main.c +++ b/nhrpd/nhrp_main.c @@ -118,6 +118,7 @@ static struct quagga_signal_t sighandlers[] = { static const struct frr_yang_module_info *const nhrpd_yang_modules[] = { &frr_filter_info, &frr_interface_info, + &frr_vrf_info, }; FRR_DAEMON_INFO(nhrpd, NHRP, .vty_port = NHRP_VTY_PORT, diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c index 420ea12ec..963fa4d99 100644 --- a/nhrpd/nhrp_vty.c +++ b/nhrpd/nhrp_vty.c @@ -1260,6 +1260,8 @@ void nhrp_config_init(void) install_element(CONFIG_NODE, &nhrp_multicast_nflog_group_cmd); install_element(CONFIG_NODE, &no_nhrp_multicast_nflog_group_cmd); + vrf_cmd_init(NULL, &nhrpd_privs); + /* interface specific commands */ install_node(&nhrp_interface_node); diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index cd1b5b99f..7e4604e98 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -232,6 +232,8 @@ void ospf6_vrf_init(void) { vrf_init(ospf6_vrf_new, ospf6_vrf_enable, ospf6_vrf_disable, ospf6_vrf_delete, ospf6_vrf_enable); + + vrf_cmd_init(NULL, &ospf6d_privs); } static void ospf6_top_lsdb_hook_add(struct ospf6_lsa *lsa) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index cb64187d7..54ce248d8 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -12959,6 +12959,8 @@ void ospf_vty_init(void) install_element(OSPF_NODE, &ospf_max_multipath_cmd); install_element(OSPF_NODE, &no_ospf_max_multipath_cmd); + vrf_cmd_init(NULL, &ospfd_privs); + /* Init interface related vty commands. */ ospf_vty_if_init(); diff --git a/pbrd/pbr_main.c b/pbrd/pbr_main.c index 1badaf95b..786155903 100644 --- a/pbrd/pbr_main.c +++ b/pbrd/pbr_main.c @@ -119,6 +119,7 @@ struct quagga_signal_t pbr_signals[] = { static const struct frr_yang_module_info *const pbrd_yang_modules[] = { &frr_filter_info, &frr_interface_info, + &frr_vrf_info, }; FRR_DAEMON_INFO(pbrd, PBR, .vty_port = PBR_VTY_PORT, diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index 216834fe0..3d56fc3da 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -1143,10 +1143,14 @@ static const struct cmd_variable_handler pbr_map_name[] = { } }; +extern struct zebra_privs_t pbr_privs; + void pbr_vty_init(void) { cmd_variable_handler_register(pbr_map_name); + vrf_cmd_init(NULL, &pbr_privs); + install_node(&interface_node); if_cmd_init(); diff --git a/ripd/ripd.c b/ripd/ripd.c index c6c82fb65..7d940efd9 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -3690,6 +3690,8 @@ void rip_vrf_init(void) { vrf_init(rip_vrf_new, rip_vrf_enable, rip_vrf_disable, rip_vrf_delete, rip_vrf_enable); + + vrf_cmd_init(NULL, &ripd_privs); } void rip_vrf_terminate(void) diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 3b8d2076f..a0ea18f3e 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -2691,6 +2691,8 @@ void ripng_vrf_init(void) { vrf_init(ripng_vrf_new, ripng_vrf_enable, ripng_vrf_disable, ripng_vrf_delete, ripng_vrf_enable); + + vrf_cmd_init(NULL, &ripngd_privs); } void ripng_vrf_terminate(void) diff --git a/vrrpd/vrrp_vty.c b/vrrpd/vrrp_vty.c index 6c3863132..7af9148a8 100644 --- a/vrrpd/vrrp_vty.c +++ b/vrrpd/vrrp_vty.c @@ -771,6 +771,7 @@ void vrrp_vty_init(void) install_node(&debug_node); install_node(&interface_node); install_node(&vrrp_node); + vrf_cmd_init(NULL, &vrrp_privs); if_cmd_init(); install_element(VIEW_NODE, &vrrp_vrid_show_cmd); diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h index 87f1f6744..71f672554 100644 --- a/vtysh/vtysh.h +++ b/vtysh/vtysh.h @@ -56,7 +56,7 @@ DECLARE_MGROUP(MVTYSH); #define VTYSH_ACL VTYSH_BFDD|VTYSH_BABELD|VTYSH_BGPD|VTYSH_EIGRPD|VTYSH_ISISD|VTYSH_FABRICD|VTYSH_LDPD|VTYSH_NHRPD|VTYSH_OSPF6D|VTYSH_OSPFD|VTYSH_PBRD|VTYSH_PIMD|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_VRRPD|VTYSH_ZEBRA #define VTYSH_RMAP VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_FABRICD #define VTYSH_INTERFACE VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_PBRD|VTYSH_FABRICD|VTYSH_VRRPD -#define VTYSH_VRF VTYSH_ZEBRA|VTYSH_PIMD|VTYSH_STATICD +#define VTYSH_VRF VTYSH_INTERFACE|VTYSH_STATICD #define VTYSH_KEYS VTYSH_RIPD|VTYSH_EIGRPD /* Daemons who can process nexthop-group configs */ #define VTYSH_NH_GROUP VTYSH_PBRD|VTYSH_SHARPD |