lib: convert route-map to mgmtd

Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
Christian Hopps 2024-01-24 10:59:14 -05:00
parent f7594b55c2
commit dabc92de9e
8 changed files with 79 additions and 12 deletions

View File

@ -3409,7 +3409,7 @@ DEFUN_HIDDEN(show_route_map_pfx_tbl, show_route_map_pfx_tbl_cmd,
} }
/* Initialization of route map vector. */ /* Initialization of route map vector. */
void route_map_init(void) void route_map_init_new(bool in_backend)
{ {
int i; int i;
@ -3424,7 +3424,10 @@ void route_map_init(void)
UNSET_FLAG(rmap_debug, DEBUG_ROUTEMAP); UNSET_FLAG(rmap_debug, DEBUG_ROUTEMAP);
if (!in_backend) {
/* we do not want to handle config commands in the backend */
route_map_cli_init(); route_map_cli_init();
}
/* Install route map top node. */ /* Install route map top node. */
install_node(&rmap_debug_node); install_node(&rmap_debug_node);
@ -3444,3 +3447,8 @@ void route_map_init(void)
install_element(ENABLE_NODE, &show_route_map_pfx_tbl_cmd); install_element(ENABLE_NODE, &show_route_map_pfx_tbl_cmd);
} }
void route_map_init(void)
{
route_map_init_new(false);
}

View File

@ -401,6 +401,7 @@ enum ecommunity_lb_type {
/* Prototypes. */ /* Prototypes. */
extern void route_map_init(void); extern void route_map_init(void);
extern void route_map_init_new(bool in_backend);
/* /*
* This should only be called on shutdown * This should only be called on shutdown
@ -1024,6 +1025,7 @@ routemap_hook_context_insert(struct route_map_index *rmi);
void routemap_hook_context_free(struct routemap_hook_context *rhc); void routemap_hook_context_free(struct routemap_hook_context *rhc);
extern const struct frr_yang_module_info frr_route_map_info; extern const struct frr_yang_module_info frr_route_map_info;
extern const struct frr_yang_module_info frr_route_map_cli_info;
/* routemap_cli.c */ /* routemap_cli.c */
extern int route_map_instance_cmp(const struct lyd_node *dnode1, extern int route_map_instance_cmp(const struct lyd_node *dnode1,

View File

@ -1550,3 +1550,45 @@ const struct frr_yang_module_info frr_route_map_info = {
}, },
} }
}; };
const struct frr_yang_module_info frr_route_map_cli_info = {
.name = "frr-route-map",
.ignore_cfg_cbs = true,
.nodes = {
{
.xpath = "/frr-route-map:lib/route-map/optimization-disabled",
.cbs.cli_show = route_map_optimization_disabled_show,
},
{
.xpath = "/frr-route-map:lib/route-map/entry",
.cbs = {
.cli_cmp = route_map_instance_cmp,
.cli_show = route_map_instance_show,
.cli_show_end = route_map_instance_show_end,
}
},
{
.xpath = "/frr-route-map:lib/route-map/entry/description",
.cbs.cli_show = route_map_description_show,
},
{
.xpath = "/frr-route-map:lib/route-map/entry/call",
.cbs.cli_show = route_map_call_show,
},
{
.xpath = "/frr-route-map:lib/route-map/entry/exit-policy",
.cbs.cli_show = route_map_exit_policy_show,
},
{
.xpath = "/frr-route-map:lib/route-map/entry/match-condition",
.cbs.cli_show = route_map_condition_show,
},
{
.xpath = "/frr-route-map:lib/route-map/entry/set-action",
.cbs.cli_show = route_map_action_show,
},
{
.xpath = NULL,
},
}
};

View File

@ -172,7 +172,7 @@ const struct frr_yang_module_info zebra_route_map_info = {
static const struct frr_yang_module_info *const mgmt_yang_modules[] = { static const struct frr_yang_module_info *const mgmt_yang_modules[] = {
&frr_filter_info, &frr_filter_info,
&frr_interface_info, &frr_interface_info,
&frr_route_map_info, &frr_route_map_cli_info,
&frr_routing_info, &frr_routing_info,
&frr_vrf_info, &frr_vrf_info,

View File

@ -12,6 +12,7 @@
#include "json.h" #include "json.h"
#include "network.h" #include "network.h"
#include "northbound_cli.h" #include "northbound_cli.h"
#include "routemap.h"
#include "mgmtd/mgmt.h" #include "mgmtd/mgmt.h"
#include "mgmtd/mgmt_be_adapter.h" #include "mgmtd/mgmt_be_adapter.h"
@ -560,6 +561,11 @@ static struct cmd_node mgmtd_node = {
void mgmt_vty_init(void) void mgmt_vty_init(void)
{ {
/*
* Library based CLI handlers
*/
route_map_cli_init();
/* /*
* Initialize command handling from VTYSH connection. * Initialize command handling from VTYSH connection.
* Call command initialization routines defined by * Call command initialization routines defined by

View File

@ -37,14 +37,14 @@ daemon_flags = {
"lib/filter_cli.c": "VTYSH_ACL", "lib/filter_cli.c": "VTYSH_ACL",
"lib/if.c": "VTYSH_INTERFACE", "lib/if.c": "VTYSH_INTERFACE",
"lib/keychain.c": "VTYSH_KEYS", "lib/keychain.c": "VTYSH_KEYS",
"lib/mgmt_be_client.c": "VTYSH_STATICD|VTYSH_ZEBRA", "lib/mgmt_be_client.c": "VTYSH_MGMT_BACKEND",
"lib/mgmt_fe_client.c": "VTYSH_MGMTD", "lib/mgmt_fe_client.c": "VTYSH_MGMT_FRONTEND",
"lib/lib_vty.c": "VTYSH_ALL", "lib/lib_vty.c": "VTYSH_ALL",
"lib/log_vty.c": "VTYSH_ALL", "lib/log_vty.c": "VTYSH_ALL",
"lib/nexthop_group.c": "VTYSH_NH_GROUP", "lib/nexthop_group.c": "VTYSH_NH_GROUP",
"lib/resolver.c": "VTYSH_NHRPD|VTYSH_BGPD", "lib/resolver.c": "VTYSH_NHRPD|VTYSH_BGPD",
"lib/routemap.c": "VTYSH_RMAP", "lib/routemap.c": "VTYSH_RMAP_SHOW",
"lib/routemap_cli.c": "VTYSH_RMAP", "lib/routemap_cli.c": "VTYSH_RMAP_CONFIG",
"lib/spf_backoff.c": "VTYSH_ISISD", "lib/spf_backoff.c": "VTYSH_ISISD",
"lib/event.c": "VTYSH_ALL", "lib/event.c": "VTYSH_ALL",
"lib/vrf.c": "VTYSH_VRF", "lib/vrf.c": "VTYSH_VRF",

View File

@ -2303,7 +2303,7 @@ DEFUNSH(VTYSH_AFFMAP, no_affinity_map, vtysh_no_affinity_map_cmd,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
DEFUNSH(VTYSH_RMAP, vtysh_route_map, vtysh_route_map_cmd, DEFUNSH(VTYSH_RMAP_CONFIG, vtysh_route_map, vtysh_route_map_cmd,
"route-map RMAP_NAME <deny|permit> (1-65535)", "route-map RMAP_NAME <deny|permit> (1-65535)",
"Create route-map or enter route-map command mode\n" "Create route-map or enter route-map command mode\n"
"Route map tag\n" "Route map tag\n"
@ -2572,13 +2572,13 @@ DEFUNSH(VTYSH_RIPNGD, vtysh_quit_ripngd, vtysh_quit_ripngd_cmd, "quit",
} }
#endif /* HAVE_RIPNGD */ #endif /* HAVE_RIPNGD */
DEFUNSH(VTYSH_RMAP, vtysh_exit_rmap, vtysh_exit_rmap_cmd, "exit", DEFUNSH(VTYSH_RMAP_CONFIG, vtysh_exit_rmap, vtysh_exit_rmap_cmd, "exit",
"Exit current mode and down to previous mode\n") "Exit current mode and down to previous mode\n")
{ {
return vtysh_exit(vty); return vtysh_exit(vty);
} }
DEFUNSH(VTYSH_RMAP, vtysh_quit_rmap, vtysh_quit_rmap_cmd, "quit", DEFUNSH(VTYSH_RMAP_CONFIG, vtysh_quit_rmap, vtysh_quit_rmap_cmd, "quit",
"Exit current mode and down to previous mode\n") "Exit current mode and down to previous mode\n")
{ {
return vtysh_exit_rmap(self, vty, argc, argv); return vtysh_exit_rmap(self, vty, argc, argv);
@ -3455,7 +3455,7 @@ static void show_route_map_send(const char *route_map, bool json)
const struct vtysh_client *client = &vtysh_client[i]; const struct vtysh_client *client = &vtysh_client[i];
bool is_connected = true; bool is_connected = true;
if (!CHECK_FLAG(client->flag, VTYSH_RMAP)) if (!CHECK_FLAG(client->flag, VTYSH_RMAP_SHOW))
continue; continue;
for (; client; client = client->next) for (; client; client = client->next)

View File

@ -51,7 +51,14 @@ extern struct event_loop *master;
VTYSH_FABRICD | VTYSH_VRRPD | VTYSH_PATHD | VTYSH_MGMTD VTYSH_FABRICD | VTYSH_VRRPD | VTYSH_PATHD | VTYSH_MGMTD
#define VTYSH_ACL VTYSH_BFDD|VTYSH_BABELD|VTYSH_BGPD|VTYSH_EIGRPD|VTYSH_ISISD|VTYSH_FABRICD|VTYSH_LDPD|VTYSH_NHRPD|VTYSH_OSPF6D|VTYSH_OSPFD|VTYSH_PBRD|VTYSH_PIMD|VTYSH_PIM6D|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_VRRPD|VTYSH_ZEBRA #define VTYSH_ACL VTYSH_BFDD|VTYSH_BABELD|VTYSH_BGPD|VTYSH_EIGRPD|VTYSH_ISISD|VTYSH_FABRICD|VTYSH_LDPD|VTYSH_NHRPD|VTYSH_OSPF6D|VTYSH_OSPFD|VTYSH_PBRD|VTYSH_PIMD|VTYSH_PIM6D|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_VRRPD|VTYSH_ZEBRA
#define VTYSH_AFFMAP VTYSH_ZEBRA | VTYSH_ISISD #define VTYSH_AFFMAP VTYSH_ZEBRA | VTYSH_ISISD
#define VTYSH_RMAP VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_FABRICD #define VTYSH_RMAP_CONFIG \
VTYSH_ZEBRA | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D | VTYSH_BGPD | \
VTYSH_ISISD | VTYSH_PIMD | VTYSH_EIGRPD | VTYSH_FABRICD | \
VTYSH_MGMTD
#define VTYSH_RMAP_SHOW \
VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D | \
VTYSH_BGPD | VTYSH_ISISD | VTYSH_PIMD | VTYSH_EIGRPD | \
VTYSH_FABRICD
#define VTYSH_INTERFACE_SUBSET \ #define VTYSH_INTERFACE_SUBSET \
VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D | \ VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D | \
VTYSH_ISISD | VTYSH_PIMD | VTYSH_PIM6D | VTYSH_NHRPD | \ VTYSH_ISISD | VTYSH_PIMD | VTYSH_PIM6D | VTYSH_NHRPD | \
@ -64,6 +71,8 @@ extern struct event_loop *master;
#define VTYSH_NH_GROUP VTYSH_PBRD|VTYSH_SHARPD #define VTYSH_NH_GROUP VTYSH_PBRD|VTYSH_SHARPD
#define VTYSH_SR VTYSH_ZEBRA|VTYSH_PATHD #define VTYSH_SR VTYSH_ZEBRA|VTYSH_PATHD
#define VTYSH_DPDK VTYSH_ZEBRA #define VTYSH_DPDK VTYSH_ZEBRA
#define VTYSH_MGMT_BACKEND VTYSH_RIPD | VTYSH_STATICD | VTYSH_ZEBRA
#define VTYSH_MGMT_FRONTEND VTYSH_MGMTD
enum vtysh_write_integrated { enum vtysh_write_integrated {
WRITE_INTEGRATED_UNSPECIFIED, WRITE_INTEGRATED_UNSPECIFIED,