Skip to content

if_rmap: move vtysh routemap to daemon #18686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eigrpd/eigrp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ int main(int argc, char **argv, char **envp)
/*eigrp_route_map_init();
route_map_add_hook (eigrp_rmap_update);
route_map_delete_hook (eigrp_rmap_update);*/
/*if_rmap_init (EIGRP_NODE); */
/* intall eigrp related routemap cmds in eigrp_cli.c */

frr_config_fork();
frr_run(master);
Expand Down
77 changes: 2 additions & 75 deletions lib/if_rmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ static void if_rmap_unset(struct if_rmap_ctx *ctx, const char *ifname,
}
}

static int if_route_map_handler(struct vty *vty, bool no, const char *dir,
const char *other_dir, const char *ifname,
const char *route_map)
int if_route_map_handler(struct vty *vty, bool no, const char *dir, const char *other_dir,
const char *ifname, const char *route_map)
{
enum nb_operation op = no ? NB_OP_DESTROY : NB_OP_MODIFY;
const struct lyd_node *dnode;
Expand Down Expand Up @@ -179,67 +178,6 @@ static int if_route_map_handler(struct vty *vty, bool no, const char *dir,
return nb_cli_apply_changes(vty, NULL);
}

DEFPY_YANG(if_ipv4_route_map, if_ipv4_route_map_cmd,
"route-map ROUTE-MAP <in$in|out> IFNAME",
"Route map set\n"
"Route map name\n"
"Route map set for input filtering\n"
"Route map set for output filtering\n" INTERFACE_STR)
{
const char *dir = in ? "in" : "out";
const char *other_dir = in ? "out" : "in";

return if_route_map_handler(vty, false, dir, other_dir, ifname,
route_map);
}

DEFPY_YANG(no_if_ipv4_route_map, no_if_ipv4_route_map_cmd,
"no route-map [ROUTE-MAP] <in$in|out> IFNAME",
NO_STR
"Route map set\n"
"Route map name\n"
"Route map set for input filtering\n"
"Route map set for output filtering\n" INTERFACE_STR)
{
const char *dir = in ? "in" : "out";
const char *other_dir = in ? "out" : "in";

return if_route_map_handler(vty, true, dir, other_dir, ifname,
route_map);
}

/*
* CLI infra requires new handlers for ripngd
*/
DEFPY_YANG(if_ipv6_route_map, if_ipv6_route_map_cmd,
"route-map ROUTE-MAP <in$in|out> IFNAME",
"Route map set\n"
"Route map name\n"
"Route map set for input filtering\n"
"Route map set for output filtering\n" INTERFACE_STR)
{
const char *dir = in ? "in" : "out";
const char *other_dir = in ? "out" : "in";

return if_route_map_handler(vty, false, dir, other_dir, ifname,
route_map);
}

DEFPY_YANG(no_if_ipv6_route_map, no_if_ipv6_route_map_cmd,
"no route-map [ROUTE-MAP] <in$in|out> IFNAME",
NO_STR
"Route map set\n"
"Route map name\n"
"Route map set for input filtering\n"
"Route map set for output filtering\n" INTERFACE_STR)
{
const char *dir = in ? "in" : "out";
const char *other_dir = in ? "out" : "in";

return if_route_map_handler(vty, true, dir, other_dir, ifname,
route_map);
}

void cli_show_if_route_map(struct vty *vty, const struct lyd_node *dnode,
bool show_defaults)
{
Expand Down Expand Up @@ -296,17 +234,6 @@ struct if_rmap_ctx *if_rmap_ctx_create(const char *name)
return ctx;
}

void if_rmap_init(int node)
{
if (node == RIP_NODE) {
install_element(RIP_NODE, &if_ipv4_route_map_cmd);
install_element(RIP_NODE, &no_if_ipv4_route_map_cmd);
} else if (node == RIPNG_NODE) {
install_element(RIPNG_NODE, &if_ipv6_route_map_cmd);
install_element(RIPNG_NODE, &no_if_ipv6_route_map_cmd);
}
}

void if_rmap_terminate(void)
{
}
2 changes: 2 additions & 0 deletions lib/if_rmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ extern struct if_rmap_ctx *if_rmap_ctx_create(const char *name);
extern void if_rmap_ctx_delete(struct if_rmap_ctx *ctx);
extern void if_rmap_init(int node);
extern void if_rmap_terminate(void);
int if_route_map_handler(struct vty *vty, bool no, const char *dir, const char *other_dir,
const char *ifname, const char *route_map);
void if_rmap_hook_add(struct if_rmap_ctx *ctx,
void (*func)(struct if_rmap_ctx *ctx,
struct if_rmap *));
Expand Down
3 changes: 0 additions & 3 deletions python/xref2vtysh.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,6 @@ def _get_daemons(self):
"VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD|VTYSH_ZEBRA|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_ISISD|VTYSH_FABRICD"
}

if defun_file == "lib/if_rmap.c":
return {"VTYSH_MGMTD"}

return {}

def __repr__(self):
Expand Down
30 changes: 29 additions & 1 deletion ripd/rip_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,33 @@ DEFPY_YANG (clear_ip_rip,
return nb_cli_rpc(vty, "/frr-ripd:clear-rip-route", NULL);
}

DEFPY_YANG(if_ipv4_route_map, if_ipv4_route_map_cmd,
"route-map ROUTE-MAP <in$in|out> IFNAME",
"Route map set\n"
"Route map name\n"
"Route map set for input filtering\n"
"Route map set for output filtering\n" INTERFACE_STR)
{
const char *dir = in ? "in" : "out";
const char *other_dir = in ? "out" : "in";

return if_route_map_handler(vty, false, dir, other_dir, ifname, route_map);
}

DEFPY_YANG(no_if_ipv4_route_map, no_if_ipv4_route_map_cmd,
"no route-map [ROUTE-MAP] <in$in|out> IFNAME",
NO_STR
"Route map set\n"
"Route map name\n"
"Route map set for input filtering\n"
"Route map set for output filtering\n" INTERFACE_STR)
{
const char *dir = in ? "in" : "out";
const char *other_dir = in ? "out" : "in";

return if_route_map_handler(vty, true, dir, other_dir, ifname, route_map);
}

/* RIP node structure. */
static struct cmd_node rip_node = {
.name = "rip",
Expand Down Expand Up @@ -1314,7 +1341,8 @@ void rip_cli_init(void)

install_element(ENABLE_NODE, &clear_ip_rip_cmd);

if_rmap_init(RIP_NODE);
install_element(RIP_NODE, &if_ipv4_route_map_cmd);
install_element(RIP_NODE, &no_if_ipv4_route_map_cmd);
}
/* clang-format off */
const struct frr_yang_module_info frr_ripd_cli_info = {
Expand Down
33 changes: 32 additions & 1 deletion ripngd/ripng_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,36 @@ DEFPY_YANG (clear_ipv6_rip,
return nb_cli_rpc(vty, "/frr-ripngd:clear-ripng-route", NULL);
}

/*
* CLI infra requires new handlers for ripngd
*/
DEFPY_YANG(if_ipv6_route_map, if_ipv6_route_map_cmd,
"route-map ROUTE-MAP <in$in|out> IFNAME",
"Route map set\n"
"Route map name\n"
"Route map set for input filtering\n"
"Route map set for output filtering\n" INTERFACE_STR)
{
const char *dir = in ? "in" : "out";
const char *other_dir = in ? "out" : "in";

return if_route_map_handler(vty, false, dir, other_dir, ifname, route_map);
}

DEFPY_YANG(no_if_ipv6_route_map, no_if_ipv6_route_map_cmd,
"no route-map [ROUTE-MAP] <in$in|out> IFNAME",
NO_STR
"Route map set\n"
"Route map name\n"
"Route map set for input filtering\n"
"Route map set for output filtering\n" INTERFACE_STR)
{
const char *dir = in ? "in" : "out";
const char *other_dir = in ? "out" : "in";

return if_route_map_handler(vty, true, dir, other_dir, ifname, route_map);
}

/* RIPng node structure. */
static struct cmd_node cmd_ripng_node = {
.name = "ripng",
Expand Down Expand Up @@ -682,7 +712,8 @@ void ripng_cli_init(void)

install_element(ENABLE_NODE, &clear_ipv6_rip_cmd);

if_rmap_init(RIPNG_NODE);
install_element(RIPNG_NODE, &if_ipv6_route_map_cmd);
install_element(RIPNG_NODE, &no_if_ipv6_route_map_cmd);
}

/* clang-format off */
Expand Down
Loading