mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-16 06:53:03 +00:00
ripd: retrofit the 'route' command to the new northbound model
Trivial conversion. Remove the rip->route routing table and associated code because this variable was used only to show the running configuration. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
908f002092
commit
4068787842
@ -612,6 +612,33 @@ void cli_show_rip_redistribute(struct vty *vty, struct lyd_node *dnode,
|
|||||||
vty_out(vty, "\n");
|
vty_out(vty, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XPath: /frr-ripd:ripd/instance/static-route
|
||||||
|
*/
|
||||||
|
DEFPY (rip_route,
|
||||||
|
rip_route_cmd,
|
||||||
|
"[no] route A.B.C.D/M",
|
||||||
|
NO_STR
|
||||||
|
"RIP static route configuration\n"
|
||||||
|
"IP prefix <network>/<length>\n")
|
||||||
|
{
|
||||||
|
struct cli_config_change changes[] = {
|
||||||
|
{
|
||||||
|
.xpath = "./static-route",
|
||||||
|
.operation = no ? NB_OP_DELETE : NB_OP_CREATE,
|
||||||
|
.value = route_str,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return nb_cli_cfg_change(vty, NULL, changes, array_size(changes));
|
||||||
|
}
|
||||||
|
|
||||||
|
void cli_show_rip_route(struct vty *vty, struct lyd_node *dnode,
|
||||||
|
bool show_defaults)
|
||||||
|
{
|
||||||
|
vty_out(vty, " route %s\n", yang_dnode_get_string(dnode, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
void rip_cli_init(void)
|
void rip_cli_init(void)
|
||||||
{
|
{
|
||||||
install_element(CONFIG_NODE, &router_rip_cmd);
|
install_element(CONFIG_NODE, &router_rip_cmd);
|
||||||
@ -634,4 +661,5 @@ void rip_cli_init(void)
|
|||||||
install_element(RIP_NODE, &rip_passive_interface_cmd);
|
install_element(RIP_NODE, &rip_passive_interface_cmd);
|
||||||
install_element(RIP_NODE, &rip_redistribute_cmd);
|
install_element(RIP_NODE, &rip_redistribute_cmd);
|
||||||
install_element(RIP_NODE, &no_rip_redistribute_cmd);
|
install_element(RIP_NODE, &no_rip_redistribute_cmd);
|
||||||
|
install_element(RIP_NODE, &rip_route_cmd);
|
||||||
}
|
}
|
||||||
|
@ -55,5 +55,7 @@ extern void cli_show_rip_non_passive_interface(struct vty *vty,
|
|||||||
bool show_defaults);
|
bool show_defaults);
|
||||||
extern void cli_show_rip_redistribute(struct vty *vty, struct lyd_node *dnode,
|
extern void cli_show_rip_redistribute(struct vty *vty, struct lyd_node *dnode,
|
||||||
bool show_defaults);
|
bool show_defaults);
|
||||||
|
extern void cli_show_rip_route(struct vty *vty, struct lyd_node *dnode,
|
||||||
|
bool show_defaults);
|
||||||
|
|
||||||
#endif /* _FRR_RIP_CLI_H_ */
|
#endif /* _FRR_RIP_CLI_H_ */
|
||||||
|
@ -660,14 +660,34 @@ static int ripd_instance_static_route_create(enum nb_event event,
|
|||||||
const struct lyd_node *dnode,
|
const struct lyd_node *dnode,
|
||||||
union nb_resource *resource)
|
union nb_resource *resource)
|
||||||
{
|
{
|
||||||
/* TODO: implement me. */
|
struct nexthop nh;
|
||||||
|
struct prefix_ipv4 p;
|
||||||
|
|
||||||
|
if (event != NB_EV_APPLY)
|
||||||
|
return NB_OK;
|
||||||
|
|
||||||
|
yang_dnode_get_ipv4p(&p, dnode, NULL);
|
||||||
|
|
||||||
|
memset(&nh, 0, sizeof(nh));
|
||||||
|
nh.type = NEXTHOP_TYPE_IPV4;
|
||||||
|
rip_redistribute_add(ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, &nh, 0, 0,
|
||||||
|
0);
|
||||||
|
|
||||||
return NB_OK;
|
return NB_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ripd_instance_static_route_delete(enum nb_event event,
|
static int ripd_instance_static_route_delete(enum nb_event event,
|
||||||
const struct lyd_node *dnode)
|
const struct lyd_node *dnode)
|
||||||
{
|
{
|
||||||
/* TODO: implement me. */
|
struct prefix_ipv4 p;
|
||||||
|
|
||||||
|
if (event != NB_EV_APPLY)
|
||||||
|
return NB_OK;
|
||||||
|
|
||||||
|
yang_dnode_get_ipv4p(&p, dnode, NULL);
|
||||||
|
|
||||||
|
rip_redistribute_delete(ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, 0);
|
||||||
|
|
||||||
return NB_OK;
|
return NB_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1106,6 +1126,7 @@ const struct frr_yang_module_info frr_ripd_info = {
|
|||||||
.xpath = "/frr-ripd:ripd/instance/static-route",
|
.xpath = "/frr-ripd:ripd/instance/static-route",
|
||||||
.cbs.create = ripd_instance_static_route_create,
|
.cbs.create = ripd_instance_static_route_create,
|
||||||
.cbs.delete = ripd_instance_static_route_delete,
|
.cbs.delete = ripd_instance_static_route_delete,
|
||||||
|
.cbs.cli_show = cli_show_rip_route,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.xpath = "/frr-ripd:ripd/instance/timers/flush-interval",
|
.xpath = "/frr-ripd:ripd/instance/timers/flush-interval",
|
||||||
|
94
ripd/ripd.c
94
ripd/ripd.c
@ -2689,7 +2689,6 @@ int rip_create(int socket)
|
|||||||
|
|
||||||
/* Initialize RIP routig table. */
|
/* Initialize RIP routig table. */
|
||||||
rip->table = route_table_init();
|
rip->table = route_table_init();
|
||||||
rip->route = route_table_init();
|
|
||||||
rip->neighbor = route_table_init();
|
rip->neighbor = route_table_init();
|
||||||
|
|
||||||
/* Make output stream. */
|
/* Make output stream. */
|
||||||
@ -2835,82 +2834,6 @@ DEFUN (no_rip_version,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DEFUN (rip_route,
|
|
||||||
rip_route_cmd,
|
|
||||||
"route A.B.C.D/M",
|
|
||||||
"RIP static route configuration\n"
|
|
||||||
"IP prefix <network>/<length>\n")
|
|
||||||
{
|
|
||||||
int idx_ipv4_prefixlen = 1;
|
|
||||||
int ret;
|
|
||||||
struct nexthop nh;
|
|
||||||
struct prefix_ipv4 p;
|
|
||||||
struct route_node *node;
|
|
||||||
|
|
||||||
memset(&nh, 0, sizeof(nh));
|
|
||||||
nh.type = NEXTHOP_TYPE_IPV4;
|
|
||||||
|
|
||||||
ret = str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p);
|
|
||||||
if (ret < 0) {
|
|
||||||
vty_out(vty, "Malformed address\n");
|
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
|
||||||
}
|
|
||||||
apply_mask_ipv4(&p);
|
|
||||||
|
|
||||||
/* For router rip configuration. */
|
|
||||||
node = route_node_get(rip->route, (struct prefix *)&p);
|
|
||||||
|
|
||||||
if (node->info) {
|
|
||||||
vty_out(vty, "There is already same static route.\n");
|
|
||||||
route_unlock_node(node);
|
|
||||||
return CMD_WARNING;
|
|
||||||
}
|
|
||||||
|
|
||||||
node->info = (void *)1;
|
|
||||||
|
|
||||||
rip_redistribute_add(ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, &nh, 0, 0,
|
|
||||||
0);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFUN (no_rip_route,
|
|
||||||
no_rip_route_cmd,
|
|
||||||
"no route A.B.C.D/M",
|
|
||||||
NO_STR
|
|
||||||
"RIP static route configuration\n"
|
|
||||||
"IP prefix <network>/<length>\n")
|
|
||||||
{
|
|
||||||
int idx_ipv4_prefixlen = 2;
|
|
||||||
int ret;
|
|
||||||
struct prefix_ipv4 p;
|
|
||||||
struct route_node *node;
|
|
||||||
|
|
||||||
ret = str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p);
|
|
||||||
if (ret < 0) {
|
|
||||||
vty_out(vty, "Malformed address\n");
|
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
|
||||||
}
|
|
||||||
apply_mask_ipv4(&p);
|
|
||||||
|
|
||||||
/* For router rip configuration. */
|
|
||||||
node = route_node_lookup(rip->route, (struct prefix *)&p);
|
|
||||||
if (!node) {
|
|
||||||
vty_out(vty, "Can't find route %s.\n",
|
|
||||||
argv[idx_ipv4_prefixlen]->arg);
|
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
rip_redistribute_delete(ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, 0);
|
|
||||||
route_unlock_node(node);
|
|
||||||
|
|
||||||
node->info = NULL;
|
|
||||||
route_unlock_node(node);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static void
|
static void
|
||||||
rip_update_default_metric (void)
|
rip_update_default_metric (void)
|
||||||
@ -3388,7 +3311,6 @@ DEFUN (show_ip_rip_status,
|
|||||||
static int config_write_rip(struct vty *vty)
|
static int config_write_rip(struct vty *vty)
|
||||||
{
|
{
|
||||||
int write = 0;
|
int write = 0;
|
||||||
struct route_node *rn;
|
|
||||||
struct lyd_node *dnode;
|
struct lyd_node *dnode;
|
||||||
|
|
||||||
dnode = yang_dnode_get(running_config->dnode,
|
dnode = yang_dnode_get(running_config->dnode,
|
||||||
@ -3416,13 +3338,6 @@ static int config_write_rip(struct vty *vty)
|
|||||||
|
|
||||||
/* Interface routemap configuration */
|
/* Interface routemap configuration */
|
||||||
write += config_write_if_rmap(vty);
|
write += config_write_if_rmap(vty);
|
||||||
|
|
||||||
/* RIP static route configuration. */
|
|
||||||
for (rn = route_top(rip->route); rn; rn = route_next(rn))
|
|
||||||
if (rn->info)
|
|
||||||
vty_out(vty, " route %s/%d\n",
|
|
||||||
inet_ntoa(rn->p.u.prefix4),
|
|
||||||
rn->p.prefixlen);
|
|
||||||
}
|
}
|
||||||
return write;
|
return write;
|
||||||
}
|
}
|
||||||
@ -3558,12 +3473,6 @@ void rip_clean(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
stream_free(rip->obuf);
|
stream_free(rip->obuf);
|
||||||
/* Static RIP route configuration. */
|
|
||||||
for (rp = route_top(rip->route); rp; rp = route_next(rp))
|
|
||||||
if (rp->info) {
|
|
||||||
rp->info = NULL;
|
|
||||||
route_unlock_node(rp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* RIP neighbor configuration. */
|
/* RIP neighbor configuration. */
|
||||||
for (rp = route_top(rip->neighbor); rp; rp = route_next(rp))
|
for (rp = route_top(rip->neighbor); rp; rp = route_next(rp))
|
||||||
@ -3577,7 +3486,6 @@ void rip_clean(void)
|
|||||||
free(rip->route_map[i].name);
|
free(rip->route_map[i].name);
|
||||||
|
|
||||||
XFREE(MTYPE_ROUTE_TABLE, rip->table);
|
XFREE(MTYPE_ROUTE_TABLE, rip->table);
|
||||||
XFREE(MTYPE_ROUTE_TABLE, rip->route);
|
|
||||||
XFREE(MTYPE_ROUTE_TABLE, rip->neighbor);
|
XFREE(MTYPE_ROUTE_TABLE, rip->neighbor);
|
||||||
|
|
||||||
XFREE(MTYPE_RIP, rip);
|
XFREE(MTYPE_RIP, rip);
|
||||||
@ -3697,8 +3605,6 @@ void rip_init(void)
|
|||||||
install_element(RIP_NODE, &no_rip_version_cmd);
|
install_element(RIP_NODE, &no_rip_version_cmd);
|
||||||
install_element(RIP_NODE, &rip_timers_cmd);
|
install_element(RIP_NODE, &rip_timers_cmd);
|
||||||
install_element(RIP_NODE, &no_rip_timers_cmd);
|
install_element(RIP_NODE, &no_rip_timers_cmd);
|
||||||
install_element(RIP_NODE, &rip_route_cmd);
|
|
||||||
install_element(RIP_NODE, &no_rip_route_cmd);
|
|
||||||
|
|
||||||
/* Debug related init. */
|
/* Debug related init. */
|
||||||
rip_debug_init();
|
rip_debug_init();
|
||||||
|
@ -117,9 +117,6 @@ struct rip {
|
|||||||
/* RIP routing information base. */
|
/* RIP routing information base. */
|
||||||
struct route_table *table;
|
struct route_table *table;
|
||||||
|
|
||||||
/* RIP only static routing information. */
|
|
||||||
struct route_table *route;
|
|
||||||
|
|
||||||
/* RIP neighbor. */
|
/* RIP neighbor. */
|
||||||
struct route_table *neighbor;
|
struct route_table *neighbor;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user