From 35cadacd2bb9383686753731e31bd7e145fb2506 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 06:24:32 +0200 Subject: Merging upstream version 10.0. Signed-off-by: Daniel Baumann --- vtysh/.gitignore | 1 - vtysh/subdir.am | 10 --- vtysh/vtysh.c | 225 ++++++++++++++++++++++++++++++++++++--------------- vtysh/vtysh.h | 31 +++++-- vtysh/vtysh_config.c | 27 ++++++- vtysh/vtysh_main.c | 6 +- 6 files changed, 210 insertions(+), 90 deletions(-) (limited to 'vtysh') diff --git a/vtysh/.gitignore b/vtysh/.gitignore index 09e90e5..a6c3d4a 100644 --- a/vtysh/.gitignore +++ b/vtysh/.gitignore @@ -1,6 +1,5 @@ vtysh vtysh_cmd.c -vtysh_daemons.h # does not exist anymore - remove 2023-10-04 or so extract.pl diff --git a/vtysh/subdir.am b/vtysh/subdir.am index a1b81f5..2eae16d 100644 --- a/vtysh/subdir.am +++ b/vtysh/subdir.am @@ -29,13 +29,3 @@ noinst_HEADERS += \ vtysh_vtysh_LDADD = lib/libfrr.la $(LIBCAP) $(LIBREADLINE) $(LIBS) $(LIBPAM) EXTRA_DIST += vtysh/daemons.pl - -BUILT_SOURCES += vtysh/vtysh_daemons.h - -# force vtysh_daemons.h -$(vtysh_vtysh_OBJECTS): vtysh/vtysh_daemons.h - -CLEANFILES += vtysh/vtysh_daemons.h -vtysh/vtysh_daemons.h: - @$(MKDIR_P) vtysh - $(PERL) $(top_srcdir)/vtysh/daemons.pl $(vtysh_daemons) > vtysh/vtysh_daemons.h diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index e87a69d..f90f898 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -5,6 +5,9 @@ #include +#include +#include + #include #include #include @@ -28,7 +31,7 @@ #include "network.h" #include "filter.h" #include "vtysh/vtysh.h" -#include "vtysh/vtysh_daemons.h" +#include "lib/vtysh_daemons.h" #include "log.h" #include "vrf.h" #include "libfrr.h" @@ -1335,6 +1338,13 @@ static struct cmd_node srv6_loc_node = { .prompt = "%s(config-srv6-locator)# ", }; +static struct cmd_node srv6_encap_node = { + .name = "srv6-encap", + .node = SRV6_ENCAP_NODE, + .parent_node = SRV6_NODE, + .prompt = "%s(config-srv6-encap)# " +}; + #ifdef HAVE_PBRD static struct cmd_node pbr_map_node = { .name = "pbr-map", @@ -1605,7 +1615,6 @@ struct cmd_node link_params_node = { .node = LINK_PARAMS_NODE, .parent_node = INTERFACE_NODE, .prompt = "%s(config-link-params)# ", - .no_xpath = true, }; #ifdef HAVE_BGPD @@ -1615,6 +1624,14 @@ static struct cmd_node rpki_node = { .parent_node = CONFIG_NODE, .prompt = "%s(config-rpki)# ", }; + +static struct cmd_node rpki_vrf_node = { + .name = "rpki", + .node = RPKI_VRF_NODE, + .parent_node = VRF_NODE, + .prompt = "%s(config-vrf-rpki)# ", +}; + #endif /* HAVE_BGPD */ #if HAVE_BFDD > 0 @@ -1652,7 +1669,6 @@ static int vtysh_end(void) /* Nothing to do. */ break; default: - vty->vtysh_file_locked = false; vty->node = ENABLE_NODE; break; } @@ -1692,6 +1708,14 @@ DEFUNSH(VTYSH_ZEBRA, srv6_locator, srv6_locator_cmd, return CMD_SUCCESS; } +DEFUNSH(VTYSH_ZEBRA, srv6_encap, srv6_encap_cmd, + "encapsulation", + "Segment Routing SRv6 encapsulation\n") +{ + vty->node = SRV6_ENCAP_NODE; + return CMD_SUCCESS; +} + #ifdef HAVE_BGPD DEFUNSH(VTYSH_BGPD, router_bgp, router_bgp_cmd, "router bgp [ASNUM [ VIEWVRFNAME] [as-notation ]]", @@ -1837,7 +1861,10 @@ DEFUNSH(VTYSH_BGPD, "rpki", "Enable rpki and enter rpki configuration mode\n") { - vty->node = RPKI_NODE; + if (vty->node == CONFIG_NODE) + vty->node = RPKI_NODE; + else + vty->node = RPKI_VRF_NODE; return CMD_SUCCESS; } @@ -1977,7 +2004,7 @@ DEFUNSH(VTYSH_KEYS, key, key_cmd, "key (0-2147483647)", } #ifdef HAVE_RIPD -DEFUNSH(VTYSH_RIPD, router_rip, router_rip_cmd, "router rip [vrf NAME]", +DEFUNSH(VTYSH_MGMTD, router_rip, router_rip_cmd, "router rip [vrf NAME]", ROUTER_STR "RIP\n" VRF_CMD_HELP_STR) { vty->node = RIP_NODE; @@ -1986,7 +2013,7 @@ DEFUNSH(VTYSH_RIPD, router_rip, router_rip_cmd, "router rip [vrf NAME]", #endif /* HAVE_RIPD */ #ifdef HAVE_RIPNGD -DEFUNSH(VTYSH_RIPNGD, router_ripng, router_ripng_cmd, "router ripng [vrf NAME]", +DEFUNSH(VTYSH_MGMTD, router_ripng, router_ripng_cmd, "router ripng [vrf NAME]", ROUTER_STR "RIPng\n" VRF_CMD_HELP_STR) { vty->node = RIPNG_NODE; @@ -2274,7 +2301,7 @@ DEFUNSH(VTYSH_AFFMAP, no_affinity_map, vtysh_no_affinity_map_cmd, 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 (1-65535)", "Create route-map or enter route-map command mode\n" "Route map tag\n" @@ -2365,23 +2392,12 @@ DEFUNSH(VTYSH_REALLYALL, vtysh_disable, vtysh_disable_cmd, "disable", } DEFUNSH(VTYSH_REALLYALL, vtysh_config_terminal, vtysh_config_terminal_cmd, - "configure [terminal]", - "Configuration from vty interface\n" - "Configuration terminal\n") -{ - vty->node = CONFIG_NODE; - return CMD_SUCCESS; -} - -DEFUNSH(VTYSH_REALLYALL, vtysh_config_terminal_file_lock, - vtysh_config_terminal_file_lock_cmd, - "configure terminal file-lock", + "configure [terminal [file-lock]]", "Configuration from vty interface\n" "Configuration terminal\n" "Configuration with locked datastores\n") { vty->node = CONFIG_NODE; - vty->vtysh_file_locked = true; return CMD_SUCCESS; } @@ -2396,21 +2412,6 @@ static int vtysh_exit(struct vty *vty) if (cnode->parent_node) vty->node = cnode->parent_node; - if (vty->node == CONFIG_NODE) { - bool locked = vty->vtysh_file_locked; - - /* resync in case one of the daemons is somewhere else */ - vtysh_execute("end"); - /* NOTE: a rather expensive thing to do, can we avoid it? */ - - if (locked) - vtysh_execute("configure terminal file-lock"); - else - vtysh_execute("configure terminal"); - } else if (vty->node == ENABLE_NODE) { - vty->vtysh_file_locked = false; - } - return CMD_SUCCESS; } @@ -2507,14 +2508,22 @@ DEFUNSH(VTYSH_ZEBRA, exit_srv6_loc_config, exit_srv6_loc_config_cmd, "exit", return CMD_SUCCESS; } +DEFUNSH(VTYSH_ZEBRA, exit_srv6_encap, exit_srv6_encap_cmd, "exit", + "Exit from SRv6-encapsulation configuration mode\n") +{ + if (vty->node == SRV6_ENCAP_NODE) + vty->node = SRV6_NODE; + return CMD_SUCCESS; +} + #ifdef HAVE_RIPD -DEFUNSH(VTYSH_RIPD, vtysh_exit_ripd, vtysh_exit_ripd_cmd, "exit", +DEFUNSH(VTYSH_MGMTD, vtysh_exit_ripd, vtysh_exit_ripd_cmd, "exit", "Exit current mode and down to previous mode\n") { return vtysh_exit(vty); } -DEFUNSH(VTYSH_RIPD, vtysh_quit_ripd, vtysh_quit_ripd_cmd, "quit", +DEFUNSH(VTYSH_MGMTD, vtysh_quit_ripd, vtysh_quit_ripd_cmd, "quit", "Exit current mode and down to previous mode\n") { return vtysh_exit_ripd(self, vty, argc, argv); @@ -2522,26 +2531,26 @@ DEFUNSH(VTYSH_RIPD, vtysh_quit_ripd, vtysh_quit_ripd_cmd, "quit", #endif /* HAVE_RIPD */ #ifdef HAVE_RIPNGD -DEFUNSH(VTYSH_RIPNGD, vtysh_exit_ripngd, vtysh_exit_ripngd_cmd, "exit", +DEFUNSH(VTYSH_MGMTD, vtysh_exit_ripngd, vtysh_exit_ripngd_cmd, "exit", "Exit current mode and down to previous mode\n") { return vtysh_exit(vty); } -DEFUNSH(VTYSH_RIPNGD, vtysh_quit_ripngd, vtysh_quit_ripngd_cmd, "quit", +DEFUNSH(VTYSH_MGMTD, vtysh_quit_ripngd, vtysh_quit_ripngd_cmd, "quit", "Exit current mode and down to previous mode\n") { return vtysh_exit_ripngd(self, vty, argc, argv); } #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") { 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") { return vtysh_exit_rmap(self, vty, argc, argv); @@ -2917,35 +2926,38 @@ static int show_one_daemon(struct vty *vty, struct cmd_token **argv, int argc, return ret; } -DEFUN (vtysh_show_thread_timer, - vtysh_show_thread_timer_cmd, - "show thread timers", +#if CONFDATE > 20240707 + CPP_NOTICE("Remove `show thread ...` commands") +#endif +DEFUN (vtysh_show_event_timer, + vtysh_show_event_timer_cmd, + "show event timers", SHOW_STR - "Thread information\n" + "Event information\n" "Show all timers and how long they have in the system\n") { - return show_per_daemon(vty, argv, argc, "Thread timers for %s:\n"); + return show_per_daemon(vty, argv, argc, "Event timers for %s:\n"); } -DEFUN (vtysh_show_poll, - vtysh_show_poll_cmd, - "show thread poll", +DEFUN (vtysh_show_event_poll, + vtysh_show_event_poll_cmd, + "show event poll", SHOW_STR - "Thread information\n" - "Thread Poll Information\n") + "Event information\n" + "Event Poll Information\n") { - return show_per_daemon(vty, argv, argc, "Thread statistics for %s:\n"); + return show_per_daemon(vty, argv, argc, "Event statistics for %s:\n"); } -DEFUN (vtysh_show_thread, - vtysh_show_thread_cmd, - "show thread cpu [FILTER]", +DEFUN (vtysh_show_event, + vtysh_show_event_cpu_cmd, + "show event cpu [FILTER]", SHOW_STR - "Thread information\n" - "Thread CPU usage\n" + "Event information\n" + "Event CPU usage\n" "Display filter (rwtexb)\n") { - return show_per_daemon(vty, argv, argc, "Thread statistics for %s:\n"); + return show_per_daemon(vty, argv, argc, "Event statistics for %s:\n"); } DEFUN (vtysh_show_work_queues, @@ -2968,14 +2980,22 @@ DEFUN (vtysh_show_work_queues_daemon, return show_one_daemon(vty, argv, argc - 1, argv[argc - 1]->text); } -DEFUNSH(VTYSH_ZEBRA, vtysh_link_params, vtysh_link_params_cmd, "link-params", +DEFUNSH(VTYSH_MGMTD, vtysh_link_params, vtysh_link_params_cmd, "link-params", LINK_PARAMS_STR) { vty->node = LINK_PARAMS_NODE; return CMD_SUCCESS; } -DEFUNSH(VTYSH_ZEBRA, exit_link_params, exit_link_params_cmd, "exit-link-params", +DEFUNSH_HIDDEN(VTYSH_MGMTD, no_link_params_enable, no_link_params_enable_cmd, + "no enable", NO_STR "Disable link parameters on this interface\n") +{ + if (vty->node == LINK_PARAMS_NODE) + vty->node = INTERFACE_NODE; + return CMD_SUCCESS; +} + +DEFUNSH(VTYSH_MGMTD, exit_link_params, exit_link_params_cmd, "exit-link-params", "Exit from Link Params configuration node\n") { if (vty->node == LINK_PARAMS_NODE) @@ -2983,7 +3003,7 @@ DEFUNSH(VTYSH_ZEBRA, exit_link_params, exit_link_params_cmd, "exit-link-params", return CMD_SUCCESS; } -DEFUNSH(VTYSH_ZEBRA, vtysh_exit_link_params, vtysh_exit_link_params_cmd, "exit", +DEFUNSH(VTYSH_MGMTD, vtysh_exit_link_params, vtysh_exit_link_params_cmd, "exit", "Exit current mode and down to previous mode\n") { if (vty->node == LINK_PARAMS_NODE) @@ -2991,7 +3011,7 @@ DEFUNSH(VTYSH_ZEBRA, vtysh_exit_link_params, vtysh_exit_link_params_cmd, "exit", return CMD_SUCCESS; } -DEFUNSH(VTYSH_ZEBRA, vtysh_quit_link_params, vtysh_quit_link_params_cmd, "quit", +DEFUNSH(VTYSH_MGMTD, vtysh_quit_link_params, vtysh_quit_link_params_cmd, "quit", "Exit current mode and down to previous mode\n") { return vtysh_exit_link_params(self, vty, argc, argv); @@ -3073,7 +3093,7 @@ DEFUN (vtysh_show_error_code, } /* Northbound. */ -DEFUN_HIDDEN (show_config_running, +DEFUN (show_config_running, show_config_running_cmd, "show configuration running\ [ [translate WORD]]\ @@ -3149,7 +3169,7 @@ DEFUNSH(VTYSH_ALL, debug_nb, debug_nb_cmd, "[no] debug northbound\ [<\ - callbacks [{configuration|state|rpc}]\ + callbacks [{configuration|state|rpc|notify}]\ |notifications\ |events\ |libyang\ @@ -3162,6 +3182,7 @@ DEFUNSH(VTYSH_ALL, debug_nb, "State\n" "RPC\n" "Notifications\n" + "Notifications\n" "Events\n" "libyang debugging\n") { @@ -3396,6 +3417,63 @@ DEFUN (vtysh_show_running_config, return vtysh_write_terminal(self, vty, argc, argv); } +static void show_route_map_send(const char *route_map, bool json) +{ + unsigned int i; + bool first = true; + char command_line[128]; + + snprintf(command_line, sizeof(command_line), "show route-map "); + if (route_map) + strlcat(command_line, route_map, sizeof(command_line)); + if (json) + strlcat(command_line, " json", sizeof(command_line)); + + if (json) + vty_out(vty, "{"); + + for (i = 0; i < array_size(vtysh_client); i++) { + const struct vtysh_client *client = &vtysh_client[i]; + bool is_connected = true; + + if (!CHECK_FLAG(client->flag, VTYSH_RMAP_SHOW)) + continue; + + for (; client; client = client->next) + if (client->fd < 0) + is_connected = false; + + if (!is_connected) + continue; + + if (json && !first) + vty_out(vty, ","); + else + first = false; + + if (json) + vty_out(vty, "\"%s\":", vtysh_client[i].name); + + vtysh_client_execute_name(vtysh_client[i].name, command_line); + } + + if (json) + vty_out(vty, "}\n"); +} + +DEFPY (show_route_map, + show_route_map_cmd, + "show route-map [WORD]$route_map [json]$json", + SHOW_STR + "route-map information\n" + "route-map name\n" + JSON_STR) +{ + show_route_map_send(route_map, !!json); + + return CMD_SUCCESS; +} + DEFUN (vtysh_integrated_config, vtysh_integrated_config_cmd, "service integrated-vtysh-config", @@ -4967,6 +5045,7 @@ void vtysh_init_vty(void) install_node(&link_params_node); install_element(INTERFACE_NODE, &vtysh_link_params_cmd); + install_element(LINK_PARAMS_NODE, &no_link_params_enable_cmd); install_element(LINK_PARAMS_NODE, &exit_link_params_cmd); install_element(LINK_PARAMS_NODE, &vtysh_end_all_cmd); install_element(LINK_PARAMS_NODE, &vtysh_exit_link_params_cmd); @@ -4985,6 +5064,12 @@ void vtysh_init_vty(void) install_element(VRF_NODE, &vtysh_exit_vrf_cmd); install_element(VRF_NODE, &vtysh_quit_vrf_cmd); + install_node(&rpki_vrf_node); + install_element(VRF_NODE, &rpki_cmd); + install_element(RPKI_VRF_NODE, &rpki_exit_cmd); + install_element(RPKI_VRF_NODE, &rpki_quit_cmd); + install_element(RPKI_VRF_NODE, &vtysh_end_all_cmd); + install_element(CONFIG_NODE, &vtysh_affinity_map_cmd); install_element(CONFIG_NODE, &vtysh_no_affinity_map_cmd); @@ -5014,7 +5099,6 @@ void vtysh_init_vty(void) if (!user_mode) install_element(VIEW_NODE, &vtysh_enable_cmd); install_element(ENABLE_NODE, &vtysh_config_terminal_cmd); - install_element(ENABLE_NODE, &vtysh_config_terminal_file_lock_cmd); install_element(ENABLE_NODE, &vtysh_disable_cmd); /* "exit" command. */ @@ -5033,6 +5117,7 @@ void vtysh_init_vty(void) install_element(SRV6_NODE, &srv6_locators_cmd); install_element(SRV6_NODE, &exit_srv6_config_cmd); install_element(SRV6_NODE, &vtysh_end_all_cmd); + install_element(SRV6_NODE, &srv6_encap_cmd); install_node(&srv6_locs_node); install_element(SRV6_LOCS_NODE, &srv6_locator_cmd); @@ -5043,10 +5128,16 @@ void vtysh_init_vty(void) install_element(SRV6_LOC_NODE, &exit_srv6_loc_config_cmd); install_element(SRV6_LOC_NODE, &vtysh_end_all_cmd); + install_node(&srv6_encap_node); + install_element(SRV6_ENCAP_NODE, &exit_srv6_encap_cmd); + install_element(SRV6_ENCAP_NODE, &vtysh_end_all_cmd); + install_element(ENABLE_NODE, &vtysh_show_running_config_cmd); install_element(ENABLE_NODE, &vtysh_copy_running_config_cmd); install_element(ENABLE_NODE, &vtysh_copy_to_running_cmd); + install_element(ENABLE_NODE, &show_route_map_cmd); + /* "write terminal" command. */ install_element(ENABLE_NODE, &vtysh_write_terminal_cmd); @@ -5112,9 +5203,9 @@ void vtysh_init_vty(void) install_element(VIEW_NODE, &vtysh_show_modules_cmd); install_element(VIEW_NODE, &vtysh_show_work_queues_cmd); install_element(VIEW_NODE, &vtysh_show_work_queues_daemon_cmd); - install_element(VIEW_NODE, &vtysh_show_thread_cmd); - install_element(VIEW_NODE, &vtysh_show_poll_cmd); - install_element(VIEW_NODE, &vtysh_show_thread_timer_cmd); + install_element(VIEW_NODE, &vtysh_show_event_cpu_cmd); + install_element(VIEW_NODE, &vtysh_show_event_poll_cmd); + install_element(VIEW_NODE, &vtysh_show_event_timer_cmd); /* Logging */ install_element(VIEW_NODE, &vtysh_show_logging_cmd); diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h index 65733ca..7758cea 100644 --- a/vtysh/vtysh.h +++ b/vtysh/vtysh.h @@ -49,21 +49,40 @@ extern struct event_loop *master; VTYSH_PIM6D | VTYSH_NHRPD | VTYSH_EIGRPD | VTYSH_BABELD | \ VTYSH_SHARPD | VTYSH_PBRD | VTYSH_STATICD | VTYSH_BFDD | \ 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_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_INTERFACE_SUBSET \ +#define VTYSH_ACL_CONFIG \ + 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_VRRPD | VTYSH_MGMTD +#define VTYSH_ACL_SHOW \ + 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_ISISD | VTYSH_MGMTD +#define VTYSH_RMAP_CONFIG \ + 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 \ + VTYSH_OSPFD | VTYSH_OSPF6D | \ VTYSH_ISISD | VTYSH_PIMD | VTYSH_PIM6D | VTYSH_NHRPD | \ VTYSH_EIGRPD | VTYSH_BABELD | VTYSH_PBRD | VTYSH_FABRICD | \ - VTYSH_VRRPD + VTYSH_VRRPD | VTYSH_MGMTD #define VTYSH_INTERFACE VTYSH_INTERFACE_SUBSET | VTYSH_BGPD -#define VTYSH_VRF VTYSH_INTERFACE_SUBSET | VTYSH_MGMTD +#define VTYSH_VRF VTYSH_INTERFACE_SUBSET | VTYSH_BGPD #define VTYSH_KEYS VTYSH_RIPD | VTYSH_EIGRPD | VTYSH_OSPF6D | VTYSH_OSPFD /* Daemons who can process nexthop-group configs */ #define VTYSH_NH_GROUP VTYSH_PBRD|VTYSH_SHARPD #define VTYSH_SR VTYSH_ZEBRA|VTYSH_PATHD #define VTYSH_DPDK VTYSH_ZEBRA +#define VTYSH_MGMT_BACKEND \ + VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_STATICD | VTYSH_ZEBRA +#define VTYSH_MGMT_FRONTEND VTYSH_MGMTD enum vtysh_write_integrated { WRITE_INTEGRATED_UNSPECIFIED, diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c index ae64d51..c207e4d 100644 --- a/vtysh/vtysh_config.c +++ b/vtysh/vtysh_config.c @@ -315,11 +315,20 @@ void vtysh_config_parse_line(void *arg, const char *line) } else if (!strncmp(line, " ip mroute", strlen(" ip mroute"))) { config_add_line_uniq_end(config->line, line); + } else if ((strncmp(line, " rpki", strlen(" rpki")) == + 0) && + config->index == VRF_NODE) { + config_add_line(config->line, line); + config->index = RPKI_VRF_NODE; } else if (config->index == RMAP_NODE || config->index == INTERFACE_NODE || config->index == VTY_NODE) config_add_line_uniq(config->line, line); - else if (config->index == NH_GROUP_NODE) { + else if (config->index == RPKI_VRF_NODE && + strncmp(line, " exit", strlen(" exit")) == 0) { + config_add_line(config->line, line); + config->index = VRF_NODE; + } else if (config->index == NH_GROUP_NODE) { if (strncmp(line, " resilient", strlen(" resilient")) == 0) config_add_line_head(config->line, @@ -455,6 +464,12 @@ void vtysh_config_parse_line(void *arg, const char *line) else if (strncmp(line, "debug resolver", strlen("debug resolver")) == 0) config = config_get(RESOLVER_DEBUG_NODE, line); + else if (strncmp(line, "debug mgmt client frontend", + strlen("debug mgmt client frontend")) == 0) + config = config_get(MGMT_FE_DEBUG_NODE, line); + else if (strncmp(line, "debug mgmt client backend", + strlen("debug mgmt client backend")) == 0) + config = config_get(MGMT_BE_DEBUG_NODE, line); else if (strncmp(line, "debug", strlen("debug")) == 0) config = config_get(DEBUG_NODE, line); else if (strncmp(line, "password", strlen("password")) == 0 @@ -601,8 +616,13 @@ static int vtysh_read_file(FILE *confp, bool dry_run) vty->node = CONFIG_NODE; vtysh_execute_no_pager("enable"); - vtysh_execute_no_pager("conf term file-lock"); - vty->vtysh_file_locked = true; + /* + * When reading the config, we need to wait until the lock is acquired. + * If we ignore the failure and continue without the lock, the config + * will be fully ignored. + */ + while (vtysh_execute_no_pager("conf term file-lock") == CMD_WARNING_CONFIG_FAILED) + usleep(100000); if (!dry_run) vtysh_execute_no_pager("XFRR_start_configuration"); @@ -614,7 +634,6 @@ static int vtysh_read_file(FILE *confp, bool dry_run) vtysh_execute_no_pager("XFRR_end_configuration"); vtysh_execute_no_pager("end"); - vty->vtysh_file_locked = false; vtysh_execute_no_pager("disable"); vty_close(vty); diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index c57e8c7..464d82c 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -5,6 +5,9 @@ #include +#include +#include +#include #include #include #include @@ -362,8 +365,7 @@ int main(int argc, char **argv, char **env) strlcpy(sysconfdir, frr_sysconfdir, sizeof(sysconfdir)); - frr_init_vtydir(); - strlcpy(vtydir, frr_vtydir, sizeof(vtydir)); + strlcpy(vtydir, frr_runstatedir, sizeof(vtydir)); /* Option handling. */ while (1) { -- cgit v1.2.3