--- embedaddon/quagga/vtysh/vtysh.c 2012/10/09 09:22:29 1.1.1.2 +++ embedaddon/quagga/vtysh/vtysh.c 2016/11/02 10:09:10 1.1.1.4 @@ -35,6 +35,7 @@ #include "vtysh/vtysh.h" #include "log.h" #include "bgpd/bgp_vty.h" +#include "vrf.h" /* Struct VTY. */ struct vty *vty; @@ -58,10 +59,9 @@ struct vtysh_client { .fd = -1, .name = "ospf6d", .flag = VTYSH_OSPF6D, .path = OSPF6_VTYSH_PATH}, { .fd = -1, .name = "bgpd", .flag = VTYSH_BGPD, .path = BGP_VTYSH_PATH}, { .fd = -1, .name = "isisd", .flag = VTYSH_ISISD, .path = ISIS_VTYSH_PATH}, - { .fd = -1, .name = "babeld", .flag = VTYSH_BABELD, .path = BABEL_VTYSH_PATH}, + { .fd = -1, .name = "pimd", .flag = VTYSH_PIMD, .path = PIM_VTYSH_PATH}, }; -#define VTYSH_INDEX_MAX (sizeof(vtysh_client)/sizeof(vtysh_client[0])) /* We need direct access to ripd to implement vtysh_exit_ripd_only. */ static struct vtysh_client *ripd_client = NULL; @@ -87,9 +87,9 @@ vclient_close (struct vtysh_client *vclient) /* Following filled with debug code to trace a problematic condition * under load - it SHOULD handle it. */ -#define ERR_WHERE_STRING "vtysh(): vtysh_client_config(): " +#define ERR_WHERE_STRING "vtysh(): vtysh_client_execute(): " static int -vtysh_client_config (struct vtysh_client *vclient, char *line) +vtysh_client_execute (struct vtysh_client *vclient, const char *line, FILE *fp) { int ret; char *buf; @@ -100,6 +100,7 @@ vtysh_client_config (struct vtysh_client *vclient, cha int nbytes; int i; int readln; + int numnulls = 0; if (vclient->fd < 0) return CMD_SUCCESS; @@ -145,121 +146,89 @@ vtysh_client_config (struct vtysh_client *vclient, cha XFREE(MTYPE_TMP, buf); return CMD_SUCCESS; } + /* If we have already seen 3 nulls, then current byte is ret code */ + if ((numnulls == 3) && (nbytes == 1)) + { + ret = pbuf[0]; + break; + } pbuf[nbytes] = '\0'; - if (nbytes >= 4) - { - i = nbytes - 4; - if (pbuf[i] == '\0' && pbuf[i + 1] == '\0' && pbuf[i + 2] == '\0') - { - ret = pbuf[i + 3]; - break; - } - } - pbuf += nbytes; + /* If the config needs to be written in file or stdout */ + if (fp) + { + fputs(pbuf, fp); + fflush (fp); + } - /* See if a line exists in buffer, if so parse and consume it, and - * reset read position. */ - if ((eoln = strrchr(buf, '\n')) == NULL) - continue; + /* At max look last four bytes */ + if (nbytes >= 4) + { + i = nbytes - 4; + numnulls = 0; + } + else + i = 0; - if (eoln >= ((buf + bufsz) - 1)) - { - fprintf (stderr, ERR_WHERE_STRING \ - "warning - eoln beyond buffer end.\n"); - } - vtysh_config_parse(buf); + /* Count the numnulls */ + while (i < nbytes && numnulls <3) + { + if (pbuf[i++] == '\0') + numnulls++; + else + numnulls = 0; + } + /* We might have seen 3 consecutive nulls so store the ret code before updating pbuf*/ + ret = pbuf[nbytes-1]; + pbuf += nbytes; - eoln++; - left = (size_t)(buf + bufsz - eoln); - memmove(buf, eoln, left); - buf[bufsz-1] = '\0'; - pbuf = buf + strlen(buf); - } + /* See if a line exists in buffer, if so parse and consume it, and + * reset read position. If 3 nulls has been encountered consume the buffer before + * next read. + */ + if (((eoln = strrchr(buf, '\n')) == NULL) && (numnulls<3)) + continue; - /* Parse anything left in the buffer. */ + if (eoln >= ((buf + bufsz) - 1)) + { + fprintf (stderr, ERR_WHERE_STRING \ + "warning - eoln beyond buffer end.\n"); + } - vtysh_config_parse (buf); + /* If the config needs parsing, consume it */ + if(!fp) + vtysh_config_parse(buf); - XFREE(MTYPE_TMP, buf); - return ret; -} + eoln++; + left = (size_t)(buf + bufsz - eoln); + /* + * This check is required since when a config line split between two consecutive reads, + * then buf will have first half of config line and current read will bring rest of the + * line. So in this case eoln will be 1 here, hence calculation of left will be wrong. + * In this case we don't need to do memmove, because we have already seen 3 nulls. + */ + if(left < bufsz) + memmove(buf, eoln, left); -static int -vtysh_client_execute (struct vtysh_client *vclient, const char *line, FILE *fp) -{ - int ret; - char buf[1001]; - int nbytes; - int i; - int numnulls = 0; - - if (vclient->fd < 0) - return CMD_SUCCESS; - - ret = write (vclient->fd, line, strlen (line) + 1); - if (ret <= 0) - { - vclient_close (vclient); - return CMD_SUCCESS; + buf[bufsz-1] = '\0'; + pbuf = buf + strlen(buf); + /* got 3 or more trailing NULs? */ + if ((numnulls >=3) && (i < nbytes)) + { + break; + } } - - while (1) - { - nbytes = read (vclient->fd, buf, sizeof(buf)-1); - if (nbytes <= 0 && errno != EINTR) - { - vclient_close (vclient); - return CMD_SUCCESS; - } + if(!fp) + vtysh_config_parse (buf); - if (nbytes > 0) - { - if ((numnulls == 3) && (nbytes == 1)) - return buf[0]; - - buf[nbytes] = '\0'; - fputs (buf, fp); - fflush (fp); - - /* check for trailling \0\0\0, - * even if split across reads - * (see lib/vty.c::vtysh_read) - */ - if (nbytes >= 4) - { - i = nbytes-4; - numnulls = 0; - } - else - i = 0; - - while (i < nbytes && numnulls < 3) - { - if (buf[i++] == '\0') - numnulls++; - else - numnulls = 0; - } - - /* got 3 or more trailing NULs? */ - if ((numnulls >= 3) && (i < nbytes)) - return (buf[nbytes-1]); - } - } + XFREE(MTYPE_TMP, buf); + return ret; } + void -vtysh_exit_ripd_only (void) -{ - if (ripd_client) - vtysh_client_execute (ripd_client, "exit", stdout); -} - - -void vtysh_pager_init (void) { char *pager_defined; @@ -311,7 +280,9 @@ vtysh_execute_func (const char *line, int pager) * to move into node in the vtysh where it succeeded. */ if (ret == CMD_SUCCESS || ret == CMD_SUCCESS_DAEMON || ret == CMD_WARNING) { - if ((saved_node == BGP_VPNV4_NODE || saved_node == BGP_IPV4_NODE + if ((saved_node == BGP_VPNV4_NODE || saved_node == BGP_VPNV6_NODE + || saved_node == BGP_ENCAP_NODE || saved_node == BGP_ENCAPV6_NODE + || saved_node == BGP_IPV4_NODE || saved_node == BGP_IPV6_NODE || saved_node == BGP_IPV4M_NODE || saved_node == BGP_IPV6M_NODE) && (tried == 1)) @@ -374,7 +345,7 @@ vtysh_execute_func (const char *line, int pager) if (! strcmp(cmd->string,"configure terminal")) { - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) { cmd_stat = vtysh_client_execute(&vtysh_client[i], line, fp); if (cmd_stat == CMD_WARNING) @@ -413,7 +384,7 @@ vtysh_execute_func (const char *line, int pager) } cmd_stat = CMD_SUCCESS; - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) { if (cmd->daemon & vtysh_client[i].flag) { @@ -457,54 +428,12 @@ int vtysh_config_from_file (struct vty *vty, FILE *fp) { int ret; - vector vline; struct cmd_element *cmd; while (fgets (vty->buf, VTY_BUFSIZ, fp)) { - if (vty->buf[0] == '!' || vty->buf[1] == '#') - continue; + ret = command_config_read_one_line (vty, &cmd, 1); - vline = cmd_make_strvec (vty->buf); - - /* In case of comment line. */ - if (vline == NULL) - continue; - - /* Execute configuration command : this is strict match. */ - ret = cmd_execute_command_strict (vline, vty, &cmd); - - /* Try again with setting node to CONFIG_NODE. */ - if (ret != CMD_SUCCESS - && ret != CMD_SUCCESS_DAEMON - && ret != CMD_WARNING) - { - if (vty->node == KEYCHAIN_KEY_NODE) - { - vty->node = KEYCHAIN_NODE; - vtysh_exit_ripd_only (); - ret = cmd_execute_command_strict (vline, vty, &cmd); - - if (ret != CMD_SUCCESS - && ret != CMD_SUCCESS_DAEMON - && ret != CMD_WARNING) - { - vtysh_exit_ripd_only (); - vty->node = CONFIG_NODE; - ret = cmd_execute_command_strict (vline, vty, &cmd); - } - } - else - { - vtysh_execute ("end"); - vtysh_execute ("configure terminal"); - vty->node = CONFIG_NODE; - ret = cmd_execute_command_strict (vline, vty, &cmd); - } - } - - cmd_free_strvec (vline); - switch (ret) { case CMD_WARNING: @@ -525,7 +454,7 @@ vtysh_config_from_file (struct vty *vty, FILE *fp) u_int i; int cmd_stat = CMD_SUCCESS; - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) { if (cmd->daemon & vtysh_client[i].flag) { @@ -547,7 +476,7 @@ vtysh_config_from_file (struct vty *vty, FILE *fp) } /* We don't care about the point of the cursor when '?' is typed. */ -int +static int vtysh_rl_describe (void) { int ret; @@ -555,7 +484,7 @@ vtysh_rl_describe (void) vector vline; vector describe; int width; - struct desc *desc; + struct cmd_token *token; vline = cmd_make_strvec (rl_line_buffer); @@ -563,11 +492,11 @@ vtysh_rl_describe (void) if (vline == NULL) { vline = vector_init (1); - vector_set (vline, '\0'); + vector_set (vline, NULL); } else if (rl_end && isspace ((int) rl_line_buffer[rl_end - 1])) - vector_set (vline, '\0'); + vector_set (vline, NULL); describe = cmd_describe_command (vline, vty, &ret); @@ -593,15 +522,15 @@ vtysh_rl_describe (void) /* Get width of command string. */ width = 0; for (i = 0; i < vector_active (describe); i++) - if ((desc = vector_slot (describe, i)) != NULL) + if ((token = vector_slot (describe, i)) != NULL) { int len; - if (desc->cmd[0] == '\0') + if (token->cmd[0] == '\0') continue; - len = strlen (desc->cmd); - if (desc->cmd[0] == '.') + len = strlen (token->cmd); + if (token->cmd[0] == '.') len--; if (width < len) @@ -609,19 +538,19 @@ vtysh_rl_describe (void) } for (i = 0; i < vector_active (describe); i++) - if ((desc = vector_slot (describe, i)) != NULL) + if ((token = vector_slot (describe, i)) != NULL) { - if (desc->cmd[0] == '\0') + if (token->cmd[0] == '\0') continue; - if (! desc->str) + if (! token->desc) fprintf (stdout," %-s\n", - desc->cmd[0] == '.' ? desc->cmd + 1 : desc->cmd); + token->cmd[0] == '.' ? token->cmd + 1 : token->cmd); else fprintf (stdout," %-*s %s\n", width, - desc->cmd[0] == '.' ? desc->cmd + 1 : desc->cmd, - desc->str); + token->cmd[0] == '.' ? token->cmd + 1 : token->cmd, + token->desc); } cmd_free_strvec (vline); @@ -657,7 +586,7 @@ command_generator (const char *text, int state) return NULL; if (rl_end && isspace ((int) rl_line_buffer[rl_end - 1])) - vector_set (vline, '\0'); + vector_set (vline, NULL); matched = cmd_complete_command (vline, vty, &complete_status); } @@ -678,8 +607,9 @@ new_completion (char *text, int start, int end) if (matches) { rl_point = rl_end; - if (complete_status == CMD_COMPLETE_FULL_MATCH) - rl_pending_input = ' '; + if (complete_status != CMD_COMPLETE_FULL_MATCH) + /* only append a space on full match */ + rl_completion_append_character = '\0'; } return matches; @@ -756,6 +686,24 @@ static struct cmd_node bgp_vpnv4_node = "%s(config-router-af)# " }; +static struct cmd_node bgp_vpnv6_node = +{ + BGP_VPNV6_NODE, + "%s(config-router-af)# " +}; + +static struct cmd_node bgp_encap_node = +{ + BGP_ENCAP_NODE, + "%s(config-router-af)# " +}; + +static struct cmd_node bgp_encapv6_node = +{ + BGP_ENCAPV6_NODE, + "%s(config-router-af)# " +}; + static struct cmd_node bgp_ipv4_node = { BGP_IPV4_NODE, @@ -820,7 +768,7 @@ static struct cmd_node keychain_key_node = extern struct cmd_node vty_node; /* When '^Z' is received from vty, move down to the enable mode. */ -int +static int vtysh_end (void) { switch (vty->node) @@ -891,6 +839,62 @@ DEFUNSH (VTYSH_BGPD, } DEFUNSH (VTYSH_BGPD, + address_family_vpnv6, + address_family_vpnv6_cmd, + "address-family vpnv6", + "Enter Address Family command mode\n" + "Address family\n") +{ + vty->node = BGP_VPNV6_NODE; + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_BGPD, + address_family_vpnv6_unicast, + address_family_vpnv6_unicast_cmd, + "address-family vpnv6 unicast", + "Enter Address Family command mode\n" + "Address family\n" + "Address Family Modifier\n") +{ + vty->node = BGP_VPNV6_NODE; + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_BGPD, + address_family_encap, + address_family_encap_cmd, + "address-family encap", + "Enter Address Family command mode\n" + "Address family\n") +{ + vty->node = BGP_ENCAP_NODE; + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_BGPD, + address_family_encapv4, + address_family_encapv4_cmd, + "address-family encapv4", + "Enter Address Family command mode\n" + "Address family\n") +{ + vty->node = BGP_ENCAP_NODE; + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_BGPD, + address_family_encapv6, + address_family_encapv6_cmd, + "address-family encapv6", + "Enter Address Family command mode\n" + "Address family\n") +{ + vty->node = BGP_ENCAPV6_NODE; + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_BGPD, address_family_ipv4_unicast, address_family_ipv4_unicast_cmd, "address-family ipv4 unicast", @@ -1016,17 +1020,6 @@ DEFUNSH (VTYSH_OSPF6D, return CMD_SUCCESS; } -DEFUNSH (VTYSH_BABELD, - router_babel, - router_babel_cmd, - "router babel", - ROUTER_STR - "Babel") -{ - vty->node = BABEL_NODE; - return CMD_SUCCESS; -} - DEFUNSH (VTYSH_ISISD, router_isis, router_isis_cmd, @@ -1126,6 +1119,9 @@ vtysh_exit (struct vty *vty) vty->node = CONFIG_NODE; break; case BGP_VPNV4_NODE: + case BGP_VPNV6_NODE: + case BGP_ENCAP_NODE: + case BGP_ENCAPV6_NODE: case BGP_IPV4_NODE: case BGP_IPV4M_NODE: case BGP_IPV6_NODE: @@ -1164,6 +1160,9 @@ DEFUNSH (VTYSH_BGPD, if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE || vty->node == BGP_VPNV4_NODE + || vty->node == BGP_VPNV6_NODE + || vty->node == BGP_ENCAP_NODE + || vty->node == BGP_ENCAPV6_NODE || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE) vty->node = BGP_NODE; @@ -1307,6 +1306,14 @@ DEFUNSH (VTYSH_INTERFACE, return CMD_SUCCESS; } +ALIAS_SH (VTYSH_ZEBRA, + vtysh_interface, + vtysh_interface_vrf_cmd, + "interface IFNAME " VRF_CMD_STR, + "Select an interface to configure\n" + "Interface's name\n" + VRF_CMD_HELP_STR) + /* TODO Implement "no interface command in isisd. */ DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D, vtysh_no_interface_cmd, @@ -1315,6 +1322,14 @@ DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD "Delete a pseudo interface's configuration\n" "Interface's name\n") +DEFSH (VTYSH_ZEBRA, + vtysh_no_interface_vrf_cmd, + "no interface IFNAME " VRF_CMD_STR, + NO_STR + "Delete a pseudo interface's configuration\n" + "Interface's name\n" + VRF_CMD_HELP_STR) + /* TODO Implement interface description commands in ripngd, ospf6d * and isisd. */ DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD, @@ -1343,6 +1358,52 @@ ALIAS (vtysh_exit_interface, "quit", "Exit current mode and down to previous mode\n") +DEFUN (vtysh_show_thread, + vtysh_show_thread_cmd, + "show thread cpu [FILTER]", + SHOW_STR + "Thread information\n" + "Thread CPU usage\n" + "Display filter (rwtexb)\n") +{ + unsigned int i; + int ret = CMD_SUCCESS; + char line[100]; + + sprintf(line, "show thread cpu %s\n", (argc == 1) ? argv[0] : ""); + for (i = 0; i < array_size(vtysh_client); i++) + if ( vtysh_client[i].fd >= 0 ) + { + fprintf (stdout, "Thread statistics for %s:\n", + vtysh_client[i].name); + ret = vtysh_client_execute (&vtysh_client[i], line, stdout); + fprintf (stdout,"\n"); + } + return ret; +} + +DEFUN (vtysh_show_work_queues, + vtysh_show_work_queues_cmd, + "show work-queues", + SHOW_STR + "Work Queue information\n") +{ + unsigned int i; + int ret = CMD_SUCCESS; + char line[] = "show work-queues\n"; + + for (i = 0; i < array_size(vtysh_client); i++) + if ( vtysh_client[i].fd >= 0 ) + { + fprintf (stdout, "Work queue statistics for %s:\n", + vtysh_client[i].name); + ret = vtysh_client_execute (&vtysh_client[i], line, stdout); + fprintf (stdout,"\n"); + } + + return ret; +} + /* Memory */ DEFUN (vtysh_show_memory, vtysh_show_memory_cmd, @@ -1354,7 +1415,7 @@ DEFUN (vtysh_show_memory, int ret = CMD_SUCCESS; char line[] = "show memory\n"; - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) if ( vtysh_client[i].fd >= 0 ) { fprintf (stdout, "Memory statistics for %s:\n", @@ -1377,7 +1438,7 @@ DEFUN (vtysh_show_logging, int ret = CMD_SUCCESS; char line[] = "show logging\n"; - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) if ( vtysh_client[i].fd >= 0 ) { fprintf (stdout,"Logging configuration for %s:\n", @@ -1712,7 +1773,6 @@ DEFUN (vtysh_write_terminal, "Write to terminal\n") { u_int i; - int ret; char line[] = "write terminal\n"; FILE *fp = NULL; @@ -1733,8 +1793,8 @@ DEFUN (vtysh_write_terminal, VTY_NEWLINE); vty_out (vty, "!%s", VTY_NEWLINE); - for (i = 0; i < VTYSH_INDEX_MAX; i++) - ret = vtysh_client_config (&vtysh_client[i], line); + for (i = 0; i < array_size(vtysh_client); i++) + vtysh_client_execute (&vtysh_client[i], line, NULL); /* Integrate vtysh specific configuration. */ vtysh_config_write (); @@ -1757,6 +1817,34 @@ DEFUN (vtysh_write_terminal, return CMD_SUCCESS; } +DEFUN (vtysh_write_terminal_daemon, + vtysh_write_terminal_daemon_cmd, + "write terminal (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|babeld)", + "Write running configuration to memory, network, or terminal\n" + "Write to terminal\n" + "For the zebra daemon\n" + "For the rip daemon\n" + "For the ripng daemon\n" + "For the ospf daemon\n" + "For the ospfv6 daemon\n" + "For the bgp daemon\n" + "For the isis daemon\n" + "For the babel daemon\n") +{ + unsigned int i; + int ret = CMD_SUCCESS; + + for (i = 0; i < array_size(vtysh_client); i++) + { + if (strcmp(vtysh_client[i].name, argv[0]) == 0) + break; + } + + ret = vtysh_client_execute(&vtysh_client[i], "show running-config\n", stdout); + + return ret; +} + DEFUN (vtysh_integrated_config, vtysh_integrated_config_cmd, "service integrated-vtysh-config", @@ -1782,7 +1870,6 @@ static int write_config_integrated(void) { u_int i; - int ret; char line[] = "write terminal\n"; FILE *fp; char *integrate_sav = NULL; @@ -1807,8 +1894,8 @@ write_config_integrated(void) return CMD_SUCCESS; } - for (i = 0; i < VTYSH_INDEX_MAX; i++) - ret = vtysh_client_config (&vtysh_client[i], line); + for (i = 0; i < array_size(vtysh_client); i++) + vtysh_client_execute (&vtysh_client[i], line, NULL); vtysh_config_dump (fp); @@ -1844,7 +1931,7 @@ DEFUN (vtysh_write_memory, fprintf (stdout,"Building Configuration...\n"); - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) ret = vtysh_client_execute (&vtysh_client[i], line, stdout); fprintf (stdout,"[OK]\n"); @@ -1876,6 +1963,20 @@ ALIAS (vtysh_write_terminal, SHOW_STR "Current operating configuration\n") +ALIAS (vtysh_write_terminal_daemon, + vtysh_show_running_config_daemon_cmd, + "show running-config (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|babeld)", + SHOW_STR + "Current operating configuration\n" + "For the zebra daemon\n" + "For the rip daemon\n" + "For the ripng daemon\n" + "For the ospf daemon\n" + "For the ospfv6 daemon\n" + "For the bgp daemon\n" + "For the isis daemon\n" + "For the babel daemon\n") + DEFUN (vtysh_terminal_length, vtysh_terminal_length_cmd, "terminal length <0-512>", @@ -1934,7 +2035,7 @@ DEFUN (vtysh_show_daemons, { u_int i; - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) if ( vtysh_client[i].fd >= 0 ) vty_out(vty, " %s", vtysh_client[i].name); vty_out(vty, "%s", VTY_NEWLINE); @@ -1947,7 +2048,6 @@ static int execute_command (const char *command, int argc, const char *arg1, const char *arg2) { - int ret; pid_t pid; int status; @@ -1966,13 +2066,13 @@ execute_command (const char *command, int argc, const switch (argc) { case 0: - ret = execlp (command, command, (const char *)NULL); + execlp (command, command, (const char *)NULL); break; case 1: - ret = execlp (command, command, arg1, (const char *)NULL); + execlp (command, command, arg1, (const char *)NULL); break; case 2: - ret = execlp (command, command, arg1, arg2, (const char *)NULL); + execlp (command, command, arg1, arg2, (const char *)NULL); break; } @@ -1984,7 +2084,7 @@ execute_command (const char *command, int argc, const { /* This is parent. */ execute_flag = 1; - ret = wait4 (pid, &status, 0, NULL); + wait4 (pid, &status, 0, NULL); execute_flag = 0; } return 0; @@ -2184,7 +2284,7 @@ vtysh_connect_all(const char *daemon_name) int rc = 0; int matches = 0; - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) { if (!daemon_name || !strcmp(daemon_name, vtysh_client[i].name)) { @@ -2212,12 +2312,9 @@ void vtysh_readline_init (void) { /* readline related settings. */ - rl_bind_key ('?', (Function *) vtysh_rl_describe); + rl_bind_key ('?', (rl_command_func_t *) vtysh_rl_describe); rl_completion_entry_function = vtysh_completion_entry_function; - rl_attempted_completion_function = (CPPFunction *)new_completion; - /* do not append space after completion. It will be appended - * in new_completion() function explicitly. */ - rl_completion_append_character = '\0'; + rl_attempted_completion_function = (rl_completion_func_t *)new_completion; } char * @@ -2260,6 +2357,9 @@ vtysh_init_vty (void) install_node (&rmap_node, NULL); install_node (&zebra_node, NULL); install_node (&bgp_vpnv4_node, NULL); + install_node (&bgp_vpnv6_node, NULL); + install_node (&bgp_encap_node, NULL); + install_node (&bgp_encapv6_node, NULL); install_node (&bgp_ipv4_node, NULL); install_node (&bgp_ipv4m_node, NULL); /* #ifdef HAVE_IPV6 */ @@ -2286,6 +2386,9 @@ vtysh_init_vty (void) vtysh_install_default (RMAP_NODE); vtysh_install_default (ZEBRA_NODE); vtysh_install_default (BGP_VPNV4_NODE); + vtysh_install_default (BGP_VPNV6_NODE); + vtysh_install_default (BGP_ENCAP_NODE); + vtysh_install_default (BGP_ENCAPV6_NODE); vtysh_install_default (BGP_IPV4_NODE); vtysh_install_default (BGP_IPV4M_NODE); vtysh_install_default (BGP_IPV6_NODE); @@ -2322,6 +2425,12 @@ vtysh_init_vty (void) install_element (BGP_NODE, &vtysh_quit_bgpd_cmd); install_element (BGP_VPNV4_NODE, &vtysh_exit_bgpd_cmd); install_element (BGP_VPNV4_NODE, &vtysh_quit_bgpd_cmd); + install_element (BGP_VPNV6_NODE, &vtysh_exit_bgpd_cmd); + install_element (BGP_VPNV6_NODE, &vtysh_quit_bgpd_cmd); + install_element (BGP_ENCAP_NODE, &vtysh_exit_bgpd_cmd); + install_element (BGP_ENCAP_NODE, &vtysh_quit_bgpd_cmd); + install_element (BGP_ENCAPV6_NODE, &vtysh_exit_bgpd_cmd); + install_element (BGP_ENCAPV6_NODE, &vtysh_quit_bgpd_cmd); install_element (BGP_IPV4_NODE, &vtysh_exit_bgpd_cmd); install_element (BGP_IPV4_NODE, &vtysh_quit_bgpd_cmd); install_element (BGP_IPV4M_NODE, &vtysh_exit_bgpd_cmd); @@ -2353,6 +2462,9 @@ vtysh_init_vty (void) install_element (BGP_IPV4_NODE, &vtysh_end_all_cmd); install_element (BGP_IPV4M_NODE, &vtysh_end_all_cmd); install_element (BGP_VPNV4_NODE, &vtysh_end_all_cmd); + install_element (BGP_VPNV6_NODE, &vtysh_end_all_cmd); + install_element (BGP_ENCAP_NODE, &vtysh_end_all_cmd); + install_element (BGP_ENCAPV6_NODE, &vtysh_end_all_cmd); install_element (BGP_IPV6_NODE, &vtysh_end_all_cmd); install_element (BGP_IPV6M_NODE, &vtysh_end_all_cmd); install_element (ISIS_NODE, &vtysh_end_all_cmd); @@ -2374,12 +2486,15 @@ vtysh_init_vty (void) #ifdef HAVE_IPV6 install_element (CONFIG_NODE, &router_ospf6_cmd); #endif - install_element (CONFIG_NODE, &router_babel_cmd); install_element (CONFIG_NODE, &router_isis_cmd); install_element (CONFIG_NODE, &router_bgp_cmd); install_element (CONFIG_NODE, &router_bgp_view_cmd); install_element (BGP_NODE, &address_family_vpnv4_cmd); install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd); + install_element (BGP_NODE, &address_family_vpnv6_cmd); + install_element (BGP_NODE, &address_family_vpnv6_unicast_cmd); + install_element (BGP_NODE, &address_family_encap_cmd); + install_element (BGP_NODE, &address_family_encapv6_cmd); install_element (BGP_NODE, &address_family_ipv4_unicast_cmd); install_element (BGP_NODE, &address_family_ipv4_multicast_cmd); #ifdef HAVE_IPV6 @@ -2387,6 +2502,9 @@ vtysh_init_vty (void) install_element (BGP_NODE, &address_family_ipv6_unicast_cmd); #endif install_element (BGP_VPNV4_NODE, &exit_address_family_cmd); + install_element (BGP_VPNV6_NODE, &exit_address_family_cmd); + install_element (BGP_ENCAP_NODE, &exit_address_family_cmd); + install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd); install_element (BGP_IPV4_NODE, &exit_address_family_cmd); install_element (BGP_IPV4M_NODE, &exit_address_family_cmd); install_element (BGP_IPV6_NODE, &exit_address_family_cmd); @@ -2399,13 +2517,17 @@ vtysh_init_vty (void) 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_interface_vrf_cmd); + install_element (CONFIG_NODE, &vtysh_no_interface_vrf_cmd); install_element (ENABLE_NODE, &vtysh_show_running_config_cmd); + install_element (ENABLE_NODE, &vtysh_show_running_config_daemon_cmd); install_element (ENABLE_NODE, &vtysh_copy_runningconfig_startupconfig_cmd); install_element (ENABLE_NODE, &vtysh_write_file_cmd); install_element (ENABLE_NODE, &vtysh_write_cmd); /* "write terminal" command. */ install_element (ENABLE_NODE, &vtysh_write_terminal_cmd); + install_element (ENABLE_NODE, &vtysh_write_terminal_daemon_cmd); install_element (CONFIG_NODE, &vtysh_integrated_config_cmd); install_element (CONFIG_NODE, &no_vtysh_integrated_config_cmd); @@ -2448,6 +2570,12 @@ vtysh_init_vty (void) install_element (VIEW_NODE, &vtysh_show_memory_cmd); install_element (ENABLE_NODE, &vtysh_show_memory_cmd); + + install_element (VIEW_NODE, &vtysh_show_work_queues_cmd); + install_element (ENABLE_NODE, &vtysh_show_work_queues_cmd); + + install_element (VIEW_NODE, &vtysh_show_thread_cmd); + install_element (ENABLE_NODE, &vtysh_show_thread_cmd); /* Logging */ install_element (ENABLE_NODE, &vtysh_show_logging_cmd);