Skip to content

Commit 72e881c

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 72e881c

File tree

6 files changed

+70
-72
lines changed

6 files changed

+70
-72
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: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ 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,
141+
int if_route_map_handler(struct vty *vty, bool no, const char *dir,
142142
const char *other_dir, const char *ifname,
143143
const char *route_map)
144144
{
@@ -179,67 +179,6 @@ static int if_route_map_handler(struct vty *vty, bool no, const char *dir,
179179
return nb_cli_apply_changes(vty, NULL);
180180
}
181181

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-
243182
void cli_show_if_route_map(struct vty *vty, const struct lyd_node *dnode,
244183
bool show_defaults)
245184
{
@@ -299,11 +238,7 @@ struct if_rmap_ctx *if_rmap_ctx_create(const char *name)
299238
void if_rmap_init(int node)
300239
{
301240
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);
304241
} 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);
307242
}
308243
}
309244

lib/if_rmap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ 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,
46+
const char *other_dir, const char *ifname,
47+
const char *route_map);
4548
void if_rmap_hook_add(struct if_rmap_ctx *ctx,
4649
void (*func)(struct if_rmap_ctx *ctx,
4750
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: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,35 @@ 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,
1264+
route_map);
1265+
}
1266+
1267+
DEFPY_YANG(no_if_ipv4_route_map, no_if_ipv4_route_map_cmd,
1268+
"no route-map [ROUTE-MAP] <in$in|out> IFNAME",
1269+
NO_STR
1270+
"Route map set\n"
1271+
"Route map name\n"
1272+
"Route map set for input filtering\n"
1273+
"Route map set for output filtering\n" INTERFACE_STR)
1274+
{
1275+
const char *dir = in ? "in" : "out";
1276+
const char *other_dir = in ? "out" : "in";
1277+
1278+
return if_route_map_handler(vty, true, dir, other_dir, ifname,
1279+
route_map);
1280+
}
1281+
12531282
/* RIP node structure. */
12541283
static struct cmd_node rip_node = {
12551284
.name = "rip",
@@ -1314,7 +1343,8 @@ void rip_cli_init(void)
13141343

13151344
install_element(ENABLE_NODE, &clear_ip_rip_cmd);
13161345

1317-
if_rmap_init(RIP_NODE);
1346+
install_element(RIP_NODE, &if_ipv4_route_map_cmd);
1347+
install_element(RIP_NODE, &no_if_ipv4_route_map_cmd);
13181348
}
13191349
/* clang-format off */
13201350
const struct frr_yang_module_info frr_ripd_cli_info = {

ripngd/ripng_cli.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,38 @@ 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,
658+
route_map);
659+
}
660+
661+
DEFPY_YANG(no_if_ipv6_route_map, no_if_ipv6_route_map_cmd,
662+
"no route-map [ROUTE-MAP] <in$in|out> IFNAME",
663+
NO_STR
664+
"Route map set\n"
665+
"Route map name\n"
666+
"Route map set for input filtering\n"
667+
"Route map set for output filtering\n" INTERFACE_STR)
668+
{
669+
const char *dir = in ? "in" : "out";
670+
const char *other_dir = in ? "out" : "in";
671+
672+
return if_route_map_handler(vty, true, dir, other_dir, ifname,
673+
route_map);
674+
}
675+
644676
/* RIPng node structure. */
645677
static struct cmd_node cmd_ripng_node = {
646678
.name = "ripng",
@@ -682,7 +714,8 @@ void ripng_cli_init(void)
682714

683715
install_element(ENABLE_NODE, &clear_ipv6_rip_cmd);
684716

685-
if_rmap_init(RIPNG_NODE);
717+
install_element(RIPNG_NODE, &if_ipv6_route_map_cmd);
718+
install_element(RIPNG_NODE, &no_if_ipv6_route_map_cmd);
686719
}
687720

688721
/* clang-format off */

0 commit comments

Comments
 (0)