From: Christian Franke Date: Thu, 22 Mar 2018 14:01:15 +0000 (+0100) Subject: vtysh: support fabricd X-Git-Tag: frr-7.0.1~397^2~27 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=770ccdf874da684fce9e821bb7cc92dfbb642d8b;p=mirror_frr.git vtysh: support fabricd Extend extract.pl so it can deal with the isis source code being compiled twice, once for isisd and once for fabricd. Add the fabricd node and client to vtysh. Signed-off-by: Christian Franke --- diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in index 92b5686a9..0eb5944ab 100755 --- a/vtysh/extract.pl.in +++ b/vtysh/extract.pl.in @@ -35,10 +35,12 @@ EOF my $cli_stomp = 0; -foreach (@ARGV) { - $file = $_; +sub scan_file { + my ( $file, $fabricd) = @_; + + $cppadd = $fabricd ? "-DFABRICD=1" : ""; - open (FH, "@CPP@ -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -I@top_builddir@ -I@srcdir@/ -I@srcdir@/.. -I@top_srcdir@/lib -I@top_builddir@/lib -I@top_srcdir@/bgpd -I@top_srcdir@/@LIBRFP@ -I@top_srcdir@/bgpd/rfapi @CPPFLAGS@ $file |"); + open (FH, "@CPP@ -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -I@top_builddir@ -I@srcdir@/ -I@srcdir@/.. -I@top_srcdir@/lib -I@top_builddir@/lib -I@top_srcdir@/bgpd -I@top_srcdir@/@LIBRFP@ -I@top_srcdir@/bgpd/rfapi @CPPFLAGS@ $cppadd $file |"); local $/; undef $/; $line = ; close (FH); @@ -77,6 +79,10 @@ foreach (@ARGV) { $cmd =~ s/^\s+//g; $cmd =~ s/\s+$//g; + if ($fabricd) { + $cmd = "fabricd_" . $cmd; + } + # $protocol is VTYSH_PROTO format for redirection of user input if ($file =~ /lib\/keychain\.c$/) { $protocol = "VTYSH_RIPD"; @@ -107,9 +113,9 @@ foreach (@ARGV) { } elsif ($file =~ /lib\/plist\.c$/) { if ($defun_array[1] =~ m/ipv6/) { - $protocol = "VTYSH_RIPNGD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA|VTYSH_BABELD|VTYSH_ISISD"; + $protocol = "VTYSH_RIPNGD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA|VTYSH_BABELD|VTYSH_ISISD|VTYSH_FABRICD"; } else { - $protocol = "VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD|VTYSH_ZEBRA|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_ISISD"; + $protocol = "VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD|VTYSH_ZEBRA|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_ISISD|VTYSH_FABRICD"; } } elsif ($file =~ /lib\/distribute\.c$/) { @@ -132,6 +138,9 @@ foreach (@ARGV) { elsif ($file =~ /librfp\/.*\.c$/ || $file =~ /rfapi\/.*\.c$/) { $protocol = "VTYSH_BGPD"; } + elsif ($fabricd) { + $protocol = "VTYSH_FABRICD"; + } else { ($protocol) = ($file =~ /^.*\/([a-z0-9]+)\/[a-zA-Z0-9_\-]+\.c$/); $protocol = "VTYSH_" . uc $protocol; @@ -170,6 +179,10 @@ foreach (@ARGV) { $ecmd =~ s/^\s+//g; $ecmd =~ s/\s+$//g; + if ($fabricd) { + $ecmd = "fabricd_" . $ecmd; + } + # Register $ecmd if (defined ($cmd2str{$ecmd})) { my ($key); @@ -187,6 +200,13 @@ foreach (@ARGV) { } } +foreach (@ARGV) { + scan_file($_, 0); + if (/\/isisd\//) { + scan_file($_, 1); + } +} + # When we have cli commands that map to the same function name, we # can introduce subtle bugs due to code not being called when # we think it is. diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index c249115fd..98809b5a2 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -132,6 +132,7 @@ 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}, @@ -1141,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)# ", }; @@ -1653,6 +1658,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" @@ -1767,6 +1781,7 @@ 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: @@ -2042,6 +2057,18 @@ 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") { @@ -2245,7 +2272,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" @@ -2255,7 +2282,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; @@ -2593,7 +2621,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" @@ -2604,6 +2632,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; @@ -2630,7 +2659,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" @@ -2641,6 +2670,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); @@ -3494,6 +3524,7 @@ 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); @@ -3588,6 +3619,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); @@ -3648,6 +3681,7 @@ 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); @@ -3697,6 +3731,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); diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h index 5bff01a50..ee980d512 100644 --- a/vtysh/vtysh.h +++ b/vtysh/vtysh.h @@ -41,6 +41,7 @@ DECLARE_MGROUP(MVTYSH) #define VTYSH_PBRD 0x04000 #define VTYSH_STATICD 0x08000 #define VTYSH_BFDD 0x10000 +#define VTYSH_FABRICD 0x20000 #define VTYSH_WAS_ACTIVE (-2) @@ -49,9 +50,9 @@ DECLARE_MGROUP(MVTYSH) /* watchfrr is not in ALL since library CLI functions should not be * run on it (logging & co. should stay in a fixed/frozen config, and * things like prefix lists are not even initialised) */ -#define VTYSH_ALL VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_LDPD|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_SHARPD|VTYSH_PBRD|VTYSH_STATICD|VTYSH_BFDD -#define VTYSH_RMAP VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_SHARPD -#define VTYSH_INTERFACE VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_PBRD +#define VTYSH_ALL VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_LDPD|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_SHARPD|VTYSH_PBRD|VTYSH_STATICD|VTYSH_BFDD|VTYSH_FABRICD +#define VTYSH_RMAP VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_SHARPD|VTYSH_FABRICD +#define VTYSH_INTERFACE VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_PBRD|VTYSH_FABRICD #define VTYSH_NS VTYSH_ZEBRA #define VTYSH_VRF VTYSH_ZEBRA|VTYSH_PIMD|VTYSH_STATICD diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c index 42f08342c..9f6e20f2b 100644 --- a/vtysh/vtysh_config.c +++ b/vtysh/vtysh_config.c @@ -245,6 +245,9 @@ void vtysh_config_parse_line(void *arg, const char *line) else if (strncmp(line, "router isis", strlen("router isis")) == 0) config = config_get(ISIS_NODE, line); + else if (strncmp(line, "router openfabric", strlen("router openfabric")) + == 0) + config = config_get(OPENFABRIC_NODE, line); else if (strncmp(line, "route-map", strlen("route-map")) == 0) config = config_get(RMAP_NODE, line); else if (strncmp(line, "pbr-map", strlen("pbr-map")) == 0)