summaryrefslogtreecommitdiffstats
path: root/ripd/rip_northbound.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2018-05-09 06:35:00 +0200
committerRenato Westphal <renato@opensourcerouting.org>2018-10-27 20:16:12 +0200
commit44f2f852a18dd4f0b93215f46c1020f04676fa64 (patch)
tree1cc73b8c9b69868ad4152b33a8614692ab99fe80 /ripd/rip_northbound.c
parentripd: retrofit the 'offset-list' command to the new northbound model (diff)
downloadfrr-44f2f852a18dd4f0b93215f46c1020f04676fa64.tar.xz
frr-44f2f852a18dd4f0b93215f46c1020f04676fa64.zip
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_northbound.c')
-rw-r--r--ripd/rip_northbound.c50
1 files changed, 41 insertions, 9 deletions
diff --git a/ripd/rip_northbound.c b/ripd/rip_northbound.c
index bdad4004d..08dcac62c 100644
--- a/ripd/rip_northbound.c
+++ b/ripd/rip_northbound.c
@@ -463,7 +463,12 @@ static int ripd_instance_passive_default_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ rip->passive_default = yang_dnode_get_bool(dnode, NULL);
+ rip_passive_nondefault_clean();
+
return NB_OK;
}
@@ -474,15 +479,27 @@ static int ripd_instance_passive_interface_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ const char *ifname;
+
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ ifname = yang_dnode_get_string(dnode, NULL);
+
+ return rip_passive_nondefault_set(ifname);
}
static int ripd_instance_passive_interface_delete(enum nb_event event,
const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ const char *ifname;
+
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ ifname = yang_dnode_get_string(dnode, NULL);
+
+ return rip_passive_nondefault_unset(ifname);
}
/*
@@ -493,16 +510,28 @@ ripd_instance_non_passive_interface_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ const char *ifname;
+
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ ifname = yang_dnode_get_string(dnode, NULL);
+
+ return rip_passive_nondefault_unset(ifname);
}
static int
ripd_instance_non_passive_interface_delete(enum nb_event event,
const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ const char *ifname;
+
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ ifname = yang_dnode_get_string(dnode, NULL);
+
+ return rip_passive_nondefault_set(ifname);
}
/*
@@ -981,16 +1010,19 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/passive-default",
.cbs.modify = ripd_instance_passive_default_modify,
+ .cbs.cli_show = cli_show_rip_passive_default,
},
{
.xpath = "/frr-ripd:ripd/instance/passive-interface",
.cbs.create = ripd_instance_passive_interface_create,
.cbs.delete = ripd_instance_passive_interface_delete,
+ .cbs.cli_show = cli_show_rip_passive_interface,
},
{
.xpath = "/frr-ripd:ripd/instance/non-passive-interface",
.cbs.create = ripd_instance_non_passive_interface_create,
.cbs.delete = ripd_instance_non_passive_interface_delete,
+ .cbs.cli_show = cli_show_rip_non_passive_interface,
},
{
.xpath = "/frr-ripd:ripd/instance/redistribute",