Skip to content

Commit bddd1fb

Browse files
author
Loïc Sang
committed
if_rmap: move vtysh routemap to daemon
Install daemon specific if_rmap cmd direcly through daemon cli, which are installed by mgmtd. This won't require anymore to filter those commands for vtysh. Signed-off-by: Loïc Sang <[email protected]>
1 parent 5d4c7d2 commit bddd1fb

File tree

6 files changed

+66
-81
lines changed

6 files changed

+66
-81
lines changed

eigrpd/eigrp_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ int main(int argc, char **argv, char **envp)
225225
/*eigrp_route_map_init();
226226
route_map_add_hook (eigrp_rmap_update);
227227
route_map_delete_hook (eigrp_rmap_update);*/
228-
/*if_rmap_init (EIGRP_NODE); */
228+
/* intall eigrp related routemap cmds in eigrp_cli.c */
229229

230230
frr_config_fork();
231231
frr_run(master);

lib/if_rmap.c

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,8 @@ static void if_rmap_unset(struct if_rmap_ctx *ctx, const char *ifname,
138138
}
139139
}
140140

141-
static int if_route_map_handler(struct vty *vty, bool no, const char *dir,
142-
const char *other_dir, const char *ifname,
143-
const char *route_map)
141+
int if_route_map_handler(struct vty *vty, bool no, const char *dir, const char *other_dir,
142+
const char *ifname, const char *route_map)
144143
{
145144
enum nb_operation op = no ? NB_OP_DESTROY : NB_OP_MODIFY;
146145
const struct lyd_node *dnode;
@@ -179,67 +178,6 @@ static int if_route_map_handler(struct vty *vty, bool no, const char *dir,
179178
return nb_cli_apply_changes(vty, NULL);
180179
}
181180

182-
DEFPY_YANG(if_ipv4_route_map, if_ipv4_route_map_cmd,
183-
"route-map ROUTE-MAP <in$in|out> IFNAME",
184-
"Route map set\n"
185-
"Route map name\n"
186-
"Route map set for input filtering\n"
187-
"Route map set for output filtering\n" INTERFACE_STR)
188-
{
189-
const char *dir = in ? "in" : "out";
190-
const char *other_dir = in ? "out" : "in";
191-
192-
return if_route_map_handler(vty, false, dir, other_dir, ifname,
193-
route_map);
194-
}
195-
196-
DEFPY_YANG(no_if_ipv4_route_map, no_if_ipv4_route_map_cmd,
197-
"no route-map [ROUTE-MAP] <in$in|out> IFNAME",
198-
NO_STR
199-
"Route map set\n"
200-
"Route map name\n"
201-
"Route map set for input filtering\n"
202-
"Route map set for output filtering\n" INTERFACE_STR)
203-
{
204-
const char *dir = in ? "in" : "out";
205-
const char *other_dir = in ? "out" : "in";
206-
207-
return if_route_map_handler(vty, true, dir, other_dir, ifname,
208-
route_map);
209-
}
210-
211-
/*
212-
* CLI infra requires new handlers for ripngd
213-
*/
214-
DEFPY_YANG(if_ipv6_route_map, if_ipv6_route_map_cmd,
215-
"route-map ROUTE-MAP <in$in|out> IFNAME",
216-
"Route map set\n"
217-
"Route map name\n"
218-
"Route map set for input filtering\n"
219-
"Route map set for output filtering\n" INTERFACE_STR)
220-
{
221-
const char *dir = in ? "in" : "out";
222-
const char *other_dir = in ? "out" : "in";
223-
224-
return if_route_map_handler(vty, false, dir, other_dir, ifname,
225-
route_map);
226-
}
227-
228-
DEFPY_YANG(no_if_ipv6_route_map, no_if_ipv6_route_map_cmd,
229-
"no route-map [ROUTE-MAP] <in$in|out> IFNAME",
230-
NO_STR
231-
"Route map set\n"
232-
"Route map name\n"
233-
"Route map set for input filtering\n"
234-
"Route map set for output filtering\n" INTERFACE_STR)
235-
{
236-
const char *dir = in ? "in" : "out";
237-
const char *other_dir = in ? "out" : "in";
238-
239-
return if_route_map_handler(vty, true, dir, other_dir, ifname,
240-
route_map);
241-
}
242-
243181
void cli_show_if_route_map(struct vty *vty, const struct lyd_node *dnode,
244182
bool show_defaults)
245183
{
@@ -296,17 +234,6 @@ struct if_rmap_ctx *if_rmap_ctx_create(const char *name)
296234
return ctx;
297235
}
298236

299-
void if_rmap_init(int node)
300-
{
301-
if (node == RIP_NODE) {
302-
install_element(RIP_NODE, &if_ipv4_route_map_cmd);
303-
install_element(RIP_NODE, &no_if_ipv4_route_map_cmd);
304-
} else if (node == RIPNG_NODE) {
305-
install_element(RIPNG_NODE, &if_ipv6_route_map_cmd);
306-
install_element(RIPNG_NODE, &no_if_ipv6_route_map_cmd);
307-
}
308-
}
309-
310237
void if_rmap_terminate(void)
311238
{
312239
}

lib/if_rmap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ extern struct if_rmap_ctx *if_rmap_ctx_create(const char *name);
4242
extern void if_rmap_ctx_delete(struct if_rmap_ctx *ctx);
4343
extern void if_rmap_init(int node);
4444
extern void if_rmap_terminate(void);
45+
int if_route_map_handler(struct vty *vty, bool no, const char *dir, const char *other_dir,
46+
const char *ifname, const char *route_map);
4547
void if_rmap_hook_add(struct if_rmap_ctx *ctx,
4648
void (*func)(struct if_rmap_ctx *ctx,
4749
struct if_rmap *));

python/xref2vtysh.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,6 @@ def _get_daemons(self):
217217
"VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD|VTYSH_ZEBRA|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_ISISD|VTYSH_FABRICD"
218218
}
219219

220-
if defun_file == "lib/if_rmap.c":
221-
return {"VTYSH_MGMTD"}
222-
223220
return {}
224221

225222
def __repr__(self):

ripd/rip_cli.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,33 @@ DEFPY_YANG (clear_ip_rip,
12501250
return nb_cli_rpc(vty, "/frr-ripd:clear-rip-route", NULL);
12511251
}
12521252

1253+
DEFPY_YANG(if_ipv4_route_map, if_ipv4_route_map_cmd,
1254+
"route-map ROUTE-MAP <in$in|out> IFNAME",
1255+
"Route map set\n"
1256+
"Route map name\n"
1257+
"Route map set for input filtering\n"
1258+
"Route map set for output filtering\n" INTERFACE_STR)
1259+
{
1260+
const char *dir = in ? "in" : "out";
1261+
const char *other_dir = in ? "out" : "in";
1262+
1263+
return if_route_map_handler(vty, false, dir, other_dir, ifname, route_map);
1264+
}
1265+
1266+
DEFPY_YANG(no_if_ipv4_route_map, no_if_ipv4_route_map_cmd,
1267+
"no route-map [ROUTE-MAP] <in$in|out> IFNAME",
1268+
NO_STR
1269+
"Route map set\n"
1270+
"Route map name\n"
1271+
"Route map set for input filtering\n"
1272+
"Route map set for output filtering\n" INTERFACE_STR)
1273+
{
1274+
const char *dir = in ? "in" : "out";
1275+
const char *other_dir = in ? "out" : "in";
1276+
1277+
return if_route_map_handler(vty, true, dir, other_dir, ifname, route_map);
1278+
}
1279+
12531280
/* RIP node structure. */
12541281
static struct cmd_node rip_node = {
12551282
.name = "rip",
@@ -1314,7 +1341,8 @@ void rip_cli_init(void)
13141341

13151342
install_element(ENABLE_NODE, &clear_ip_rip_cmd);
13161343

1317-
if_rmap_init(RIP_NODE);
1344+
install_element(RIP_NODE, &if_ipv4_route_map_cmd);
1345+
install_element(RIP_NODE, &no_if_ipv4_route_map_cmd);
13181346
}
13191347
/* clang-format off */
13201348
const struct frr_yang_module_info frr_ripd_cli_info = {

ripngd/ripng_cli.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,36 @@ DEFPY_YANG (clear_ipv6_rip,
641641
return nb_cli_rpc(vty, "/frr-ripngd:clear-ripng-route", NULL);
642642
}
643643

644+
/*
645+
* CLI infra requires new handlers for ripngd
646+
*/
647+
DEFPY_YANG(if_ipv6_route_map, if_ipv6_route_map_cmd,
648+
"route-map ROUTE-MAP <in$in|out> IFNAME",
649+
"Route map set\n"
650+
"Route map name\n"
651+
"Route map set for input filtering\n"
652+
"Route map set for output filtering\n" INTERFACE_STR)
653+
{
654+
const char *dir = in ? "in" : "out";
655+
const char *other_dir = in ? "out" : "in";
656+
657+
return if_route_map_handler(vty, false, dir, other_dir, ifname, route_map);
658+
}
659+
660+
DEFPY_YANG(no_if_ipv6_route_map, no_if_ipv6_route_map_cmd,
661+
"no route-map [ROUTE-MAP] <in$in|out> IFNAME",
662+
NO_STR
663+
"Route map set\n"
664+
"Route map name\n"
665+
"Route map set for input filtering\n"
666+
"Route map set for output filtering\n" INTERFACE_STR)
667+
{
668+
const char *dir = in ? "in" : "out";
669+
const char *other_dir = in ? "out" : "in";
670+
671+
return if_route_map_handler(vty, true, dir, other_dir, ifname, route_map);
672+
}
673+
644674
/* RIPng node structure. */
645675
static struct cmd_node cmd_ripng_node = {
646676
.name = "ripng",
@@ -682,7 +712,8 @@ void ripng_cli_init(void)
682712

683713
install_element(ENABLE_NODE, &clear_ipv6_rip_cmd);
684714

685-
if_rmap_init(RIPNG_NODE);
715+
install_element(RIPNG_NODE, &if_ipv6_route_map_cmd);
716+
install_element(RIPNG_NODE, &no_if_ipv6_route_map_cmd);
686717
}
687718

688719
/* clang-format off */

0 commit comments

Comments
 (0)