diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2018-05-09 01:35:00 -0300 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2018-10-27 16:16:12 -0200 |
| commit | 44f2f852a18dd4f0b93215f46c1020f04676fa64 (patch) | |
| tree | 1cc73b8c9b69868ad4152b33a8614692ab99fe80 /ripd/rip_cli.c | |
| parent | 8c942f65062ac96978fb9c058875a4a602f66dcf (diff) | |
ripd: retrofit the 'passive-interface' command to the new northbound model
In ripd, the "passive-interface default" command has the following
behavior:
* All interfaces are converted to the passive mode;
* The "passive-interface IFNAME" command becomes a no-operation and
"passive-interface IFNAME" statements are removed from the running
configuration.
* The "no passive-interface IFNAME" can be used to remove interfaces
from the passive mode.
This command was modeled using the following YANG data nodes in the
frr-ripd module:
leaf passive-default {
type boolean;
default "false";
description
"Control whether interfaces are in the passive mode
by default or not.";
}
leaf-list passive-interface {
when "../passive-default = 'false'";
type string {
length "1..16";
}
description
"A list of interfaces where the sending of RIP packets
is disabled.";
}
leaf-list non-passive-interface {
when "../passive-default = 'true'";
type string {
length "1..16";
}
description
"A list of interfaces where the sending of RIP packets
is enabled.";
}
The 'when' statements guarantee that the list of passive interfaces
is cleared when the "passive-interface default" command is entered
(likewise, they guarantee that the list of non-passive interfaces is
cleared when the "passive-interface default" command is removed). This
matches exactly the behavior we want to model.
Finally, move the 'passive_default' global variable into the
'rip' structure where it belongs. This fixed the bug where the
"passive-interface default" command was being retained after a "no router
rip" + "router rip".
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ripd/rip_cli.c')
| -rw-r--r-- | ripd/rip_cli.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/ripd/rip_cli.c b/ripd/rip_cli.c index 10db5d967e..ae7e05cc18 100644 --- a/ripd/rip_cli.c +++ b/ripd/rip_cli.c @@ -465,6 +465,77 @@ void cli_show_rip_offset_list(struct vty *vty, struct lyd_node *dnode, vty_out(vty, "\n"); } +/* + * XPath: /frr-ripd:ripd/instance/passive-default + */ +DEFPY (rip_passive_default, + rip_passive_default_cmd, + "[no] passive-interface default", + NO_STR + "Suppress routing updates on an interface\n" + "default for all interfaces\n") +{ + struct cli_config_change changes[] = { + { + .xpath = "./passive-default", + .operation = NB_OP_MODIFY, + .value = no ? "false" : "true", + }, + }; + + return nb_cli_cfg_change(vty, NULL, changes, array_size(changes)); +} + +void cli_show_rip_passive_default(struct vty *vty, struct lyd_node *dnode, + bool show_defaults) +{ + if (!yang_dnode_get_bool(dnode, NULL)) + vty_out(vty, " no"); + + vty_out(vty, " passive-interface default\n"); +} + +/* + * XPath: /frr-ripd:ripd/instance/passive-interface + * /frr-ripd:ripd/instance/non-passive-interface + */ +DEFPY (rip_passive_interface, + rip_passive_interface_cmd, + "[no] passive-interface IFNAME", + NO_STR + "Suppress routing updates on an interface\n" + "Interface name\n") +{ + struct cli_config_change changes[] = { + { + .xpath = "./passive-interface", + .operation = no ? NB_OP_DELETE : NB_OP_CREATE, + .value = ifname, + }, + { + .xpath = "./non-passive-interface", + .operation = no ? NB_OP_CREATE : NB_OP_DELETE, + .value = ifname, + }, + }; + + return nb_cli_cfg_change(vty, NULL, changes, array_size(changes)); +} + +void cli_show_rip_passive_interface(struct vty *vty, struct lyd_node *dnode, + bool show_defaults) +{ + vty_out(vty, " passive-interface %s\n", + yang_dnode_get_string(dnode, NULL)); +} + +void cli_show_rip_non_passive_interface(struct vty *vty, struct lyd_node *dnode, + bool show_defaults) +{ + vty_out(vty, " no passive-interface %s\n", + yang_dnode_get_string(dnode, NULL)); +} + void rip_cli_init(void) { install_element(CONFIG_NODE, &router_rip_cmd); @@ -483,4 +554,6 @@ void rip_cli_init(void) install_element(RIP_NODE, &rip_network_if_cmd); install_element(RIP_NODE, &rip_offset_list_cmd); install_element(RIP_NODE, &no_rip_offset_list_cmd); + install_element(RIP_NODE, &rip_passive_default_cmd); + install_element(RIP_NODE, &rip_passive_interface_cmd); } |
