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);
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);
}
bool show_defaults);
extern void cli_show_rip_offset_list(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
+extern void cli_show_rip_passive_default(struct vty *vty,
+ struct lyd_node *dnode,
+ bool show_defaults);
+extern void cli_show_rip_passive_interface(struct vty *vty,
+ struct lyd_node *dnode,
+ bool show_defaults);
+extern void cli_show_rip_non_passive_interface(struct vty *vty,
+ struct lyd_node *dnode,
+ bool show_defaults);
#endif /* _FRR_RIP_CLI_H_ */
struct route_table *rip_enable_network;
/* Vector to store passive-interface name. */
-static int passive_default; /* are we in passive-interface default mode? */
vector Vrip_passive_nondefault;
/* Join to the RIP version 2 multicast group. */
{
struct rip_interface *ri;
+ if (rip == NULL)
+ return;
+
ri = ifp->info;
ri->passive = ((rip_passive_nondefault_lookup(ifp->name) < 0)
- ? passive_default
- : !passive_default);
+ ? rip->passive_default
+ : !rip->passive_default);
if (IS_RIP_DEBUG_ZEBRA)
zlog_debug("interface %s: passive = %d", ifp->name,
}
/* Passive interface. */
-static int rip_passive_nondefault_set(struct vty *vty, const char *ifname)
+int rip_passive_nondefault_set(const char *ifname)
{
if (rip_passive_nondefault_lookup(ifname) >= 0)
- return CMD_WARNING_CONFIG_FAILED;
+ /*
+ * Don't return an error, this can happen after changing
+ * 'passive-default'.
+ */
+ return NB_OK;
vector_set(Vrip_passive_nondefault,
XSTRDUP(MTYPE_RIP_INTERFACE_STRING, ifname));
rip_passive_interface_apply_all();
- return CMD_SUCCESS;
+ return NB_OK;
}
-static int rip_passive_nondefault_unset(struct vty *vty, const char *ifname)
+int rip_passive_nondefault_unset(const char *ifname)
{
int i;
char *str;
i = rip_passive_nondefault_lookup(ifname);
if (i < 0)
- return CMD_WARNING_CONFIG_FAILED;
+ /*
+ * Don't return an error, this can happen after changing
+ * 'passive-default'.
+ */
+ return NB_OK;
str = vector_slot(Vrip_passive_nondefault, i);
XFREE(MTYPE_RIP_INTERFACE_STRING, str);
rip_passive_interface_apply_all();
- return CMD_SUCCESS;
+ return NB_OK;
}
/* Free all configured RIP passive-interface settings. */
return CMD_SUCCESS;
}
-DEFUN (rip_passive_interface,
- rip_passive_interface_cmd,
- "passive-interface <IFNAME|default>",
- "Suppress routing updates on an interface\n"
- "Interface name\n"
- "default for all interfaces\n")
-{
- if (argv[1]->type == WORD_TKN) { // user passed 'default'
- passive_default = 1;
- rip_passive_nondefault_clean();
- return CMD_SUCCESS;
- }
- if (passive_default)
- return rip_passive_nondefault_unset(vty, argv[1]->arg);
- else
- return rip_passive_nondefault_set(vty, argv[1]->arg);
-}
-
-DEFUN (no_rip_passive_interface,
- no_rip_passive_interface_cmd,
- "no passive-interface <IFNAME|default>",
- NO_STR
- "Suppress routing updates on an interface\n"
- "Interface name\n"
- "default for all interfaces\n")
-{
- if (argv[2]->type == WORD_TKN) {
- passive_default = 0;
- rip_passive_nondefault_clean();
- return CMD_SUCCESS;
- }
- if (passive_default)
- return rip_passive_nondefault_set(vty, argv[2]->arg);
- else
- return rip_passive_nondefault_unset(vty, argv[2]->arg);
-}
-
/* Write rip configuration of each interface. */
static int rip_interface_config_write(struct vty *vty)
{
return 0;
}
-int config_write_rip_network(struct vty *vty, int config_mode)
+int rip_show_network_config(struct vty *vty)
{
unsigned int i;
char *ifname;
for (node = route_top(rip_enable_network); node;
node = route_next(node))
if (node->info)
- vty_out(vty, "%s%s/%d\n",
- config_mode ? " network " : " ",
+ vty_out(vty, " %s/%u\n",
inet_ntoa(node->p.u.prefix4),
node->p.prefixlen);
/* Interface name RIP enable statement. */
for (i = 0; i < vector_active(rip_enable_interface); i++)
if ((ifname = vector_slot(rip_enable_interface, i)) != NULL)
- vty_out(vty, "%s%s\n",
- config_mode ? " network " : " ", ifname);
+ vty_out(vty, " %s\n", ifname);
/* RIP neighbors listing. */
for (node = route_top(rip->neighbor); node; node = route_next(node))
if (node->info)
- vty_out(vty, "%s%s\n",
- config_mode ? " neighbor " : " ",
- inet_ntoa(node->p.u.prefix4));
-
- /* RIP passive interface listing. */
- if (config_mode) {
- if (passive_default)
- vty_out(vty, " passive-interface default\n");
- for (i = 0; i < vector_active(Vrip_passive_nondefault); i++)
- if ((ifname = vector_slot(Vrip_passive_nondefault, i))
- != NULL)
- vty_out(vty, " %spassive-interface %s\n",
- (passive_default ? "no " : ""), ifname);
- }
+ vty_out(vty, " %s\n", inet_ntoa(node->p.u.prefix4));
return 0;
}
if_cmd_init();
/* Install commands. */
- install_element(RIP_NODE, &rip_passive_interface_cmd);
- install_element(RIP_NODE, &no_rip_passive_interface_cmd);
-
install_element(INTERFACE_NODE, &ip_rip_send_version_cmd);
install_element(INTERFACE_NODE, &ip_rip_send_version_1_cmd);
install_element(INTERFACE_NODE, &no_ip_rip_send_version_cmd);
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;
}
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);
}
/*
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);
}
/*
{
.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",
yang_get_default_uint8("%s/default-metric", RIP_INSTANCE);
rip->distance =
yang_get_default_uint8("%s/distance/default", RIP_INSTANCE);
+ rip->passive_default =
+ yang_get_default_bool("%s/passive-default", RIP_INSTANCE);
rip->garbage_time = yang_get_default_uint32("%s/timers/flush-interval",
RIP_INSTANCE);
rip->timeout_time = yang_get_default_uint32(
}
vty_out(vty, " Routing for Networks:\n");
- config_write_rip_network(vty, 0);
+ rip_show_network_config(vty);
{
int found_passive = 0;
/* RIP ECMP flag */
bool ecmp;
+ /* Are we in passive-interface default mode? */
+ bool passive_default;
+
/* For redistribute route map. */
struct {
char *name;
extern void rip_clean_network(void);
extern void rip_interfaces_clean(void);
extern void rip_interfaces_reset(void);
+extern int rip_passive_nondefault_set(const char *ifname);
+extern int rip_passive_nondefault_unset(const char *ifname);
extern void rip_passive_nondefault_clean(void);
extern void rip_if_init(void);
extern void rip_if_down_all(void);
extern void rip_distribute_update_interface(struct interface *);
extern void rip_if_rmap_update_interface(struct interface *);
-extern int config_write_rip_network(struct vty *, int);
+extern int rip_show_network_config(struct vty *);
extern int config_write_rip_redistribute(struct vty *, int);
extern void rip_peer_init(void);
DECLARE_HOOK(rip_ifaddr_del, (struct connected * ifc), (ifc))
extern struct route_table *rip_distance_table;
+extern vector Vrip_passive_nondefault;
/* Northbound. */
extern void rip_cli_init(void);