This commit is contained in:
lsang6WIND 2025-04-29 16:22:43 +00:00 committed by GitHub
commit e7c970d88f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 66 additions and 81 deletions

View file

@ -225,7 +225,7 @@ int main(int argc, char **argv, char **envp)
/*eigrp_route_map_init(); /*eigrp_route_map_init();
route_map_add_hook (eigrp_rmap_update); route_map_add_hook (eigrp_rmap_update);
route_map_delete_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_config_fork();
frr_run(master); frr_run(master);

View file

@ -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, int if_route_map_handler(struct vty *vty, bool no, const char *dir, const char *other_dir,
const char *other_dir, const char *ifname, const char *ifname, const char *route_map)
const char *route_map)
{ {
enum nb_operation op = no ? NB_OP_DESTROY : NB_OP_MODIFY; enum nb_operation op = no ? NB_OP_DESTROY : NB_OP_MODIFY;
const struct lyd_node *dnode; const struct lyd_node *dnode;
@ -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); 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, void cli_show_if_route_map(struct vty *vty, const struct lyd_node *dnode,
bool show_defaults) bool show_defaults)
{ {
@ -296,17 +234,6 @@ struct if_rmap_ctx *if_rmap_ctx_create(const char *name)
return ctx; 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) void if_rmap_terminate(void)
{ {
} }

View file

@ -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_ctx_delete(struct if_rmap_ctx *ctx);
extern void if_rmap_init(int node); extern void if_rmap_init(int node);
extern void if_rmap_terminate(void); 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 if_rmap_hook_add(struct if_rmap_ctx *ctx,
void (*func)(struct if_rmap_ctx *ctx, void (*func)(struct if_rmap_ctx *ctx,
struct if_rmap *)); struct if_rmap *));

View file

@ -217,9 +217,6 @@ class CommandEntry:
"VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD|VTYSH_ZEBRA|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_ISISD|VTYSH_FABRICD" "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 {} return {}
def __repr__(self): def __repr__(self):

View file

@ -1250,6 +1250,33 @@ DEFPY_YANG (clear_ip_rip,
return nb_cli_rpc(vty, "/frr-ripd:clear-rip-route", NULL); 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. */ /* RIP node structure. */
static struct cmd_node rip_node = { static struct cmd_node rip_node = {
.name = "rip", .name = "rip",
@ -1314,7 +1341,8 @@ void rip_cli_init(void)
install_element(ENABLE_NODE, &clear_ip_rip_cmd); 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 */ /* clang-format off */
const struct frr_yang_module_info frr_ripd_cli_info = { const struct frr_yang_module_info frr_ripd_cli_info = {

View file

@ -641,6 +641,36 @@ DEFPY_YANG (clear_ipv6_rip,
return nb_cli_rpc(vty, "/frr-ripngd:clear-ripng-route", NULL); 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. */ /* RIPng node structure. */
static struct cmd_node cmd_ripng_node = { static struct cmd_node cmd_ripng_node = {
.name = "ripng", .name = "ripng",
@ -682,7 +712,8 @@ void ripng_cli_init(void)
install_element(ENABLE_NODE, &clear_ipv6_rip_cmd); 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 */ /* clang-format off */