X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=vtysh%2Fvtysh.c;h=6a92b9081377f32f5ad3bff15e39fb91abb722af;hb=e991eff5b5773e8a85c3f4c4f92c09fe30cf680b;hp=e25a576926072fe574dd22cd0e6a284f33e32d31;hpb=7e24fdf333e8ffe78403788d824eae110c6e65bf;p=mirror_frr.git diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index e25a57692..6a92b9081 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -45,6 +45,7 @@ #include "libfrr.h" #include "command_graph.h" #include "frrstr.h" +#include "json.h" DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CMD, "Vtysh cmd copy") @@ -131,9 +132,11 @@ struct vtysh_client vtysh_client[] = { {.fd = -1, .name = "eigrpd", .flag = VTYSH_EIGRPD, .next = NULL}, {.fd = -1, .name = "babeld", .flag = VTYSH_BABELD, .next = NULL}, {.fd = -1, .name = "sharpd", .flag = VTYSH_SHARPD, .next = NULL}, + {.fd = -1, .name = "fabricd", .flag = VTYSH_FABRICD, .next = NULL}, {.fd = -1, .name = "watchfrr", .flag = VTYSH_WATCHFRR, .next = NULL}, {.fd = -1, .name = "pbrd", .flag = VTYSH_PBRD, .next = NULL}, {.fd = -1, .name = "staticd", .flag = VTYSH_STATICD, .next = NULL}, + {.fd = -1, .name = "bfdd", .flag = VTYSH_BFDD, .next = NULL}, }; enum vtysh_write_integrated vtysh_write_integrated = @@ -1110,7 +1113,7 @@ static char *command_generator(const char *text, int state) return NULL; } -static char **new_completion(char *text, int start, int end) +static char **new_completion(const char *text, int start, int end) { char **matches; @@ -1139,6 +1142,10 @@ static struct cmd_node isis_node = { ISIS_NODE, "%s(config-router)# ", }; +static struct cmd_node openfabric_node = { + OPENFABRIC_NODE, "%s(config-router)# ", +}; + static struct cmd_node interface_node = { INTERFACE_NODE, "%s(config-if)# ", }; @@ -1250,9 +1257,19 @@ struct cmd_node link_params_node = { LINK_PARAMS_NODE, "%s(config-link-params)# ", }; -#if defined(HAVE_RPKI) static struct cmd_node rpki_node = {RPKI_NODE, "%s(config-rpki)# ", 1}; -#endif + +#if HAVE_BFDD > 0 +static struct cmd_node bfd_node = { + BFD_NODE, + "%s(config-bfd)# ", +}; + +static struct cmd_node bfd_peer_node = { + BFD_PEER_NODE, + "%s(config-bfd-peer)# ", +}; +#endif /* HAVE_BFDD */ /* Defined in lib/vty.c */ extern struct cmd_node vty_node; @@ -1410,7 +1427,6 @@ DEFUNSH(VTYSH_BGPD, address_family_ipv6_labeled_unicast, return CMD_SUCCESS; } -#if defined(HAVE_RPKI) DEFUNSH(VTYSH_BGPD, rpki, rpki_cmd, @@ -1421,26 +1437,6 @@ DEFUNSH(VTYSH_BGPD, return CMD_SUCCESS; } -DEFUNSH(VTYSH_BGPD, - rpki_exit, - rpki_exit_cmd, - "exit", - "Exit current mode and down to previous mode\n") -{ - vty->node = CONFIG_NODE; - return CMD_SUCCESS; -} - -DEFUNSH(VTYSH_BGPD, - rpki_quit, - rpki_quit_cmd, - "quit", - "Exit current mode and down to previous mode\n") -{ - return rpki_exit(self, vty, argc, argv); -} -#endif - DEFUNSH(VTYSH_BGPD, address_family_evpn, address_family_evpn_cmd, "address-family ", "Enter Address Family command mode\n" @@ -1657,6 +1653,15 @@ DEFUNSH(VTYSH_ISISD, router_isis, router_isis_cmd, "router isis WORD", return CMD_SUCCESS; } +DEFUNSH(VTYSH_FABRICD, router_openfabric, router_openfabric_cmd, "router openfabric WORD", + ROUTER_STR + "OpenFabric routing protocol\n" + "ISO Routing area tag\n") +{ + vty->node = OPENFABRIC_NODE; + return CMD_SUCCESS; +} + DEFUNSH(VTYSH_RMAP, vtysh_route_map, vtysh_route_map_cmd, "route-map WORD (1-65535)", "Create route-map or enter route-map command mode\n" @@ -1680,6 +1685,32 @@ DEFUNSH(VTYSH_PBRD, vtysh_pbr_map, vtysh_pbr_map_cmd, return CMD_SUCCESS; } +#if HAVE_BFDD > 0 +DEFUNSH(VTYSH_BFDD, bfd_enter, bfd_enter_cmd, "bfd", "Configure BFD peers\n") +{ + vty->node = BFD_NODE; + return CMD_SUCCESS; +} + +DEFUNSH(VTYSH_BFDD, bfd_peer_enter, bfd_peer_enter_cmd, + "peer [{multihop|local-address |interface IFNAME|vrf NAME}]", + "Configure peer\n" + "IPv4 peer address\n" + "IPv6 peer address\n" + "Configure multihop\n" + "Configure local address\n" + "IPv4 local address\n" + "IPv6 local address\n" + INTERFACE_STR + "Configure interface name to use\n" + "Configure VRF\n" + "Configure VRF name\n") +{ + vty->node = BFD_PEER_NODE; + return CMD_SUCCESS; +} +#endif /* HAVE_BFDD */ + DEFSH(VTYSH_PBRD, vtysh_no_pbr_map_cmd, "no pbr-map WORD [seq (1-700)]", NO_STR "Delete pbr-map\n" @@ -1745,10 +1776,13 @@ static int vtysh_exit(struct vty *vty) case LDP_NODE: case LDP_L2VPN_NODE: case ISIS_NODE: + case OPENFABRIC_NODE: case RMAP_NODE: case PBRMAP_NODE: case VTY_NODE: case KEYCHAIN_NODE: + case BFD_NODE: + case RPKI_NODE: vtysh_execute("end"); vtysh_execute("configure terminal"); vty->node = CONFIG_NODE; @@ -1792,6 +1826,9 @@ static int vtysh_exit(struct vty *vty) case LINK_PARAMS_NODE: vty->node = INTERFACE_NODE; break; + case BFD_PEER_NODE: + vty->node = BFD_NODE; + break; default: break; } @@ -1839,6 +1876,20 @@ DEFUNSH(VTYSH_BGPD, exit_vnc_config, exit_vnc_config_cmd, "exit-vnc", || vty->node == BGP_VNC_L2_GROUP_NODE) vty->node = BGP_NODE; return CMD_SUCCESS; + +} + +DEFUNSH(VTYSH_BGPD, rpki_exit, rpki_exit_cmd, "exit", + "Exit current mode and down to previous mode\n") +{ + vtysh_exit(vty); + return CMD_SUCCESS; +} + +DEFUNSH(VTYSH_BGPD, rpki_quit, rpki_quit_cmd, "quit", + "Exit current mode and down to previous mode\n") +{ + return rpki_exit(self, vty, argc, argv); } DEFUNSH(VTYSH_PIMD|VTYSH_ZEBRA, exit_vrf_config, exit_vrf_config_cmd, "exit-vrf", @@ -1988,6 +2039,29 @@ DEFUNSH(VTYSH_ISISD, vtysh_quit_isisd, vtysh_quit_isisd_cmd, "quit", return vtysh_exit_isisd(self, vty, argc, argv); } +#if HAVE_BFDD > 0 +DEFUNSH(VTYSH_BFDD, vtysh_exit_bfdd, vtysh_exit_bfdd_cmd, "exit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit(vty); +} + +ALIAS(vtysh_exit_bfdd, vtysh_quit_bfdd_cmd, "quit", + "Exit current mode and down to previous mode\n") +#endif + +DEFUNSH(VTYSH_FABRICD, vtysh_exit_fabricd, vtysh_exit_fabricd_cmd, "exit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit(vty); +} + +DEFUNSH(VTYSH_FABRICD, vtysh_quit_fabricd, vtysh_quit_fabricd_cmd, "quit", + "Exit current mode and down to previous mode\n") +{ + return vtysh_exit_fabricd(self, vty, argc, argv); +} + DEFUNSH(VTYSH_ALL, vtysh_exit_line_vty, vtysh_exit_line_vty_cmd, "exit", "Exit current mode and down to previous mode\n") { @@ -2018,18 +2092,6 @@ DEFUNSH(VTYSH_ZEBRA, vtysh_pseudowire, vtysh_pseudowire_cmd, return CMD_SUCCESS; } -/* TODO Implement "no interface command in isisd. */ -DEFSH(VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D - | VTYSH_EIGRPD, - vtysh_no_interface_cmd, "no interface IFNAME", NO_STR - "Delete a pseudo interface's configuration\n" - "Interface's name\n") - -DEFSH(VTYSH_ZEBRA, vtysh_no_interface_vrf_cmd, "no interface IFNAME vrf NAME", - NO_STR - "Delete a pseudo interface's configuration\n" - "Interface's name\n" VRF_CMD_HELP_STR) - DEFUNSH(VTYSH_ZEBRA, vtysh_logicalrouter, vtysh_logicalrouter_cmd, "logical-router (1-65535) ns NAME", "Enable a logical-router\n" @@ -2070,9 +2132,16 @@ DEFUNSH(VTYSH_VRF, vtysh_vrf, vtysh_vrf_cmd, "vrf NAME", return CMD_SUCCESS; } -DEFSH(VTYSH_ZEBRA, vtysh_no_vrf_cmd, "no vrf NAME", NO_STR - "Delete a pseudo vrf's configuration\n" - "VRF's name\n") +DEFSH(VTYSH_ZEBRA, vtysh_vrf_netns_cmd, + "netns NAME", + "Attach VRF to a Namespace\n" + "The file name in " NS_RUN_DIR ", or a full pathname\n") + +DEFSH(VTYSH_ZEBRA, vtysh_no_vrf_netns_cmd, + "no netns [NAME]", + NO_STR + "Detach VRF from a Namespace\n" + "The file name in " NS_RUN_DIR ", or a full pathname\n") DEFUNSH(VTYSH_NS, vtysh_exit_logicalrouter, vtysh_exit_logicalrouter_cmd, "exit", @@ -2112,19 +2181,6 @@ DEFUNSH(VTYSH_VRF, vtysh_quit_nexthop_group, vtysh_quit_nexthop_group_cmd, return vtysh_exit_nexthop_group(self, vty, argc, argv); } -/* - * TODO Implement interface description commands in ripngd, ospf6d - * and isisd. - */ -DEFSH(VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_OSPFD | VTYSH_EIGRPD, - vtysh_interface_desc_cmd, "description LINE...", - "Interface specific description\n" - "Characters describing this interface\n") - -DEFSH(VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_OSPFD | VTYSH_EIGRPD, - vtysh_no_interface_desc_cmd, "no description", - NO_STR "Interface specific description\n") - DEFUNSH(VTYSH_INTERFACE, vtysh_exit_interface, vtysh_exit_interface_cmd, "exit", "Exit current mode and down to previous mode\n") { @@ -2209,7 +2265,7 @@ DEFUN (vtysh_show_work_queues, DEFUN (vtysh_show_work_queues_daemon, vtysh_show_work_queues_daemon_cmd, - "show work-queues ", + "show work-queues ", SHOW_STR "Work Queue information\n" "For the zebra daemon\n" @@ -2219,7 +2275,8 @@ DEFUN (vtysh_show_work_queues_daemon, "For the ospfv6 daemon\n" "For the bgp daemon\n" "For the isis daemon\n" - "For the pbr daemon\n") + "For the pbr daemon\n" + "For the fabricd daemon\n") { int idx_protocol = 2; unsigned int i; @@ -2308,6 +2365,28 @@ DEFUN (vtysh_show_debugging_hashtable, "Hashtable statistics for %s:\n"); } +DEFUN (vtysh_show_error_code, + vtysh_show_error_code_cmd, + "show error <(1-4294967296)|all> [json]", + SHOW_STR + "Information on errors\n" + "Error code to get info about\n" + "Information on all errors\n" + JSON_STR) +{ + char *fcmd = argv_concat(argv, argc, 0); + char cmd[256]; + int rv; + + snprintf(cmd, sizeof(cmd), "do %s", fcmd); + + /* FIXME: Needs to determine which daemon to send to via code ranges */ + rv = show_per_daemon(cmd, ""); + + XFREE(MTYPE_TMP, fcmd); + return rv; +} + /* Memory */ DEFUN (vtysh_show_memory, vtysh_show_memory_cmd, @@ -2535,7 +2614,7 @@ DEFUNSH(VTYSH_ALL, no_vtysh_config_enable_password, DEFUN (vtysh_write_terminal, vtysh_write_terminal_cmd, - "write terminal []", + "write terminal []", "Write running configuration to memory, network, or terminal\n" "Write to terminal\n" "For the zebra daemon\n" @@ -2546,6 +2625,7 @@ DEFUN (vtysh_write_terminal, "For the ldpd daemon\n" "For the bgp daemon\n" "For the isis daemon\n" + "For the fabricd daemon\n" "For the pim daemon\n") { unsigned int i; @@ -2572,7 +2652,7 @@ DEFUN (vtysh_write_terminal, DEFUN (vtysh_show_running_config, vtysh_show_running_config_cmd, - "show running-config []", + "show running-config []", SHOW_STR "Current operating configuration\n" "For the zebra daemon\n" @@ -2583,6 +2663,7 @@ DEFUN (vtysh_show_running_config, "For the ldp daemon\n" "For the bgp daemon\n" "For the isis daemon\n" + "For the fabricd daemon\n" "For the pim daemon\n") { return vtysh_write_terminal(self, vty, argc, argv); @@ -3328,8 +3409,7 @@ void vtysh_readline_init(void) rl_initialize(); rl_bind_key('?', (rl_command_func_t *)vtysh_rl_describe); rl_completion_entry_function = vtysh_completion_entry_function; - rl_attempted_completion_function = - (rl_completion_func_t *)new_completion; + rl_attempted_completion_function = new_completion; } char *vtysh_prompt(void) @@ -3436,10 +3516,13 @@ void vtysh_init_vty(void) install_node(&keychain_node, NULL); install_node(&keychain_key_node, NULL); install_node(&isis_node, NULL); + install_node(&openfabric_node, NULL); install_node(&vty_node, NULL); -#if defined(HAVE_RPKI) install_node(&rpki_node, NULL); -#endif +#if HAVE_BFDD > 0 + install_node(&bfd_node, NULL); + install_node(&bfd_peer_node, NULL); +#endif /* HAVE_BFDD */ struct cmd_node *node; for (unsigned int i = 0; i < vector_active(cmdvec); i++) { @@ -3526,6 +3609,8 @@ void vtysh_init_vty(void) #endif install_element(ISIS_NODE, &vtysh_exit_isisd_cmd); install_element(ISIS_NODE, &vtysh_quit_isisd_cmd); + install_element(OPENFABRIC_NODE, &vtysh_exit_fabricd_cmd); + install_element(OPENFABRIC_NODE, &vtysh_quit_fabricd_cmd); install_element(KEYCHAIN_NODE, &vtysh_exit_ripd_cmd); install_element(KEYCHAIN_NODE, &vtysh_quit_ripd_cmd); install_element(KEYCHAIN_KEY_NODE, &vtysh_exit_ripd_cmd); @@ -3534,6 +3619,21 @@ void vtysh_init_vty(void) install_element(RMAP_NODE, &vtysh_quit_rmap_cmd); install_element(PBRMAP_NODE, &vtysh_exit_pbr_map_cmd); install_element(PBRMAP_NODE, &vtysh_quit_pbr_map_cmd); +#if HAVE_BFDD > 0 + /* Enter node. */ + install_element(CONFIG_NODE, &bfd_enter_cmd); + install_element(BFD_NODE, &bfd_peer_enter_cmd); + + /* Exit/quit node. */ + install_element(BFD_NODE, &vtysh_exit_bfdd_cmd); + install_element(BFD_NODE, &vtysh_quit_bfdd_cmd); + install_element(BFD_PEER_NODE, &vtysh_exit_bfdd_cmd); + install_element(BFD_PEER_NODE, &vtysh_quit_bfdd_cmd); + + /* End/exit all. */ + install_element(BFD_NODE, &vtysh_end_all_cmd); + install_element(BFD_PEER_NODE, &vtysh_end_all_cmd); +#endif /* HAVE_BFDD */ install_element(VTY_NODE, &vtysh_exit_line_vty_cmd); install_element(VTY_NODE, &vtysh_quit_line_vty_cmd); @@ -3571,14 +3671,13 @@ void vtysh_init_vty(void) install_element(BGP_VNC_NVE_GROUP_NODE, &vtysh_end_all_cmd); install_element(BGP_VNC_L2_GROUP_NODE, &vtysh_end_all_cmd); install_element(ISIS_NODE, &vtysh_end_all_cmd); + install_element(OPENFABRIC_NODE, &vtysh_end_all_cmd); install_element(KEYCHAIN_NODE, &vtysh_end_all_cmd); install_element(KEYCHAIN_KEY_NODE, &vtysh_end_all_cmd); install_element(RMAP_NODE, &vtysh_end_all_cmd); install_element(PBRMAP_NODE, &vtysh_end_all_cmd); install_element(VTY_NODE, &vtysh_end_all_cmd); - install_element(INTERFACE_NODE, &vtysh_interface_desc_cmd); - install_element(INTERFACE_NODE, &vtysh_no_interface_desc_cmd); install_element(INTERFACE_NODE, &vtysh_end_all_cmd); install_element(INTERFACE_NODE, &vtysh_exit_interface_cmd); install_element(LINK_PARAMS_NODE, &exit_link_params_cmd); @@ -3622,6 +3721,7 @@ void vtysh_init_vty(void) install_element(LDP_L2VPN_NODE, &ldp_member_pseudowire_ifname_cmd); #endif install_element(CONFIG_NODE, &router_isis_cmd); + install_element(CONFIG_NODE, &router_openfabric_cmd); install_element(CONFIG_NODE, &router_bgp_cmd); install_element(BGP_NODE, &address_family_vpnv4_cmd); install_element(BGP_NODE, &address_family_vpnv6_cmd); @@ -3657,12 +3757,10 @@ void vtysh_init_vty(void) install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); -#if defined(HAVE_RPKI) install_element(CONFIG_NODE, &rpki_cmd); install_element(RPKI_NODE, &rpki_exit_cmd); install_element(RPKI_NODE, &rpki_quit_cmd); install_element(RPKI_NODE, &vtysh_end_all_cmd); -#endif /* EVPN commands */ install_element(BGP_EVPN_NODE, &bgp_evpn_vni_cmd); @@ -3682,17 +3780,16 @@ void vtysh_init_vty(void) install_element(KEYCHAIN_NODE, &key_chain_cmd); install_element(KEYCHAIN_KEY_NODE, &key_chain_cmd); install_element(CONFIG_NODE, &vtysh_interface_cmd); - install_element(CONFIG_NODE, &vtysh_no_interface_cmd); - install_element(CONFIG_NODE, &vtysh_no_interface_vrf_cmd); install_element(CONFIG_NODE, &vtysh_pseudowire_cmd); install_element(INTERFACE_NODE, &vtysh_link_params_cmd); install_element(ENABLE_NODE, &vtysh_show_running_config_cmd); install_element(ENABLE_NODE, &vtysh_copy_running_config_cmd); + install_element(CONFIG_NODE, &vtysh_vrf_cmd); + install_element(VRF_NODE, &vtysh_vrf_netns_cmd); + install_element(VRF_NODE, &vtysh_no_vrf_netns_cmd); install_element(VRF_NODE, &exit_vrf_config_cmd); - install_element(CONFIG_NODE, &vtysh_vrf_cmd); - install_element(CONFIG_NODE, &vtysh_no_vrf_cmd); install_element(CONFIG_NODE, &vtysh_no_nexthop_group_cmd); /* "write terminal" command. */ @@ -3728,6 +3825,7 @@ void vtysh_init_vty(void) /* debugging */ install_element(VIEW_NODE, &vtysh_show_debugging_cmd); + install_element(VIEW_NODE, &vtysh_show_error_code_cmd); install_element(VIEW_NODE, &vtysh_show_debugging_hashtable_cmd); install_element(ENABLE_NODE, &vtysh_debug_all_cmd); install_element(CONFIG_NODE, &vtysh_debug_all_cmd);