diff --git a/babeld/babel_main.c b/babeld/babel_main.c index 9ea123c8f9..2b87bed0fb 100644 --- a/babeld/babel_main.c +++ b/babeld/babel_main.c @@ -196,9 +196,6 @@ main(int argc, char **argv) /* this replace kernel_setup && kernel_setup_socket */ babelz_zebra_init (); - /* Get zebra configuration file. */ - vty_read_config (babeld_di.config_file, babel_config_default); - /* init buffer */ rc = resize_receive_buffer(1500); if(rc < 0) diff --git a/ldpd/ldp_vty_cmds.c b/ldpd/ldp_vty_cmds.c index d77a3e7e93..8eed089900 100644 --- a/ldpd/ldp_vty_cmds.c +++ b/ldpd/ldp_vty_cmds.c @@ -29,7 +29,7 @@ #include "ldpd/ldp_vty_cmds_clippy.c" #endif -DEFUN_NOSH(ldp_mpls_ldp, +DEFPY_NOSH(ldp_mpls_ldp, ldp_mpls_ldp_cmd, "mpls ldp", "Global MPLS configuration subcommands\n" @@ -48,21 +48,15 @@ DEFPY (no_ldp_mpls_ldp, return (ldp_vty_mpls_ldp(vty, "no")); } -DEFUN_NOSH(ldp_l2vpn, +DEFPY_NOSH(ldp_l2vpn, ldp_l2vpn_cmd, - "l2vpn WORD type vpls", + "l2vpn WORD$l2vpn_name type vpls", "Configure l2vpn commands\n" "L2VPN name\n" "L2VPN type\n" "Virtual Private LAN Service\n") { - int idx = 0; - const char *name; - - argv_find(argv, argc, "WORD", &idx); - name = argv[idx]->arg; - - return (ldp_vty_l2vpn(vty, 0, name)); + return (ldp_vty_l2vpn(vty, NULL, l2vpn_name)); } DEFPY (no_ldp_l2vpn, @@ -77,20 +71,14 @@ DEFPY (no_ldp_l2vpn, return (ldp_vty_l2vpn(vty, "no", l2vpn_name)); } -DEFUN_NOSH(ldp_address_family, +DEFPY_NOSH(ldp_address_family, ldp_address_family_cmd, - "address-family ", + "address-family $af", "Configure Address Family and its parameters\n" "IPv4\n" "IPv6\n") { - int idx = 0; - const char *af; - - argv_find(argv, argc, "address-family", &idx); - af = argv[idx + 1]->text; - - return (ldp_vty_address_family(vty, 0, af)); + return (ldp_vty_address_family(vty, NULL, af)); } DEFPY (no_ldp_address_family, @@ -104,7 +92,7 @@ DEFPY (no_ldp_address_family, return (ldp_vty_address_family(vty, "no", af)); } -DEFUN_NOSH(ldp_exit_address_family, +DEFPY_NOSH(ldp_exit_address_family, ldp_exit_address_family_cmd, "exit-address-family", "Exit from Address Family configuration mode\n") @@ -361,19 +349,13 @@ DEFPY (ldp_session_holdtime, return (ldp_vty_af_session_holdtime(vty, no, holdtime)); } -DEFUN_NOSH(ldp_interface, +DEFPY_NOSH(ldp_interface, ldp_interface_cmd, - "interface IFNAME", + "interface IFNAME$ifname", "Enable LDP on an interface and enter interface submode\n" "Interface's name\n") { - int idx = 0; - const char *ifname; - - argv_find(argv, argc, "IFNAME", &idx); - ifname = argv[idx]->arg; - - return (ldp_vty_interface(vty, 0, ifname)); + return (ldp_vty_interface(vty, NULL, ifname)); } DEFPY (no_ldp_interface, @@ -439,20 +421,14 @@ DEFPY (ldp_member_interface, return (ldp_vty_l2vpn_interface(vty, no, ifname)); } -DEFUN_NOSH(ldp_member_pseudowire, +DEFPY_NOSH(ldp_member_pseudowire, ldp_member_pseudowire_cmd, - "member pseudowire IFNAME", + "member pseudowire IFNAME$ifname", "L2VPN member configuration\n" "Pseudowire interface\n" "Interface's name\n") { - int idx = 0; - const char *ifname; - - argv_find(argv, argc, "IFNAME", &idx); - ifname = argv[idx]->arg; - - return (ldp_vty_l2vpn_pseudowire(vty, 0, ifname)); + return (ldp_vty_l2vpn_pseudowire(vty, NULL, ifname)); } DEFPY (no_ldp_member_pseudowire, @@ -759,7 +735,7 @@ DEFPY (ldp_show_l2vpn_atom_vc, return (ldp_vty_show_atom_vc(vty, peer_str, ifname, vcid_str, json)); } -DEFUN_NOSH (ldp_show_debugging_mpls_ldp, +DEFPY_NOSH (ldp_show_debugging_mpls_ldp, ldp_show_debugging_mpls_ldp_cmd, "show debugging [mpls ldp]", "Show running system information\n" diff --git a/lib/command.h b/lib/command.h index a001a90e2e..da9b92ec6d 100644 --- a/lib/command.h +++ b/lib/command.h @@ -220,6 +220,9 @@ struct cmd_node { DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \ funcdecl_##funcname +#define DEFPY_NOSH(funcname, cmdname, cmdstr, helpstr) \ + DEFPY(funcname, cmdname, cmdstr, helpstr) + #define DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \ DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) \ funcdecl_##funcname @@ -302,6 +305,9 @@ struct cmd_node { #define DEFPY(funcname, cmdname, cmdstr, helpstr) \ DEFUN(funcname, cmdname, cmdstr, helpstr) +#define DEFPY_NOSH(funcname, cmdname, cmdstr, helpstr) \ + DEFUN_NOSH(funcname, cmdname, cmdstr, helpstr) + #define DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \ DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, attr) #endif /* VTYSH_EXTRACT_PL */ diff --git a/lib/defun_lex.l b/lib/defun_lex.l index 9c995db266..d901c26a2e 100644 --- a/lib/defun_lex.l +++ b/lib/defun_lex.l @@ -132,6 +132,7 @@ SPECIAL [(),] "DEFUN_NOSH" value = strdup(yytext); return DEFUNNY; "DEFUN_HIDDEN" value = strdup(yytext); return DEFUNNY; "DEFPY" value = strdup(yytext); return DEFUNNY; +"DEFPY_NOSH" value = strdup(yytext); return DEFUNNY; "DEFPY_ATTR" value = strdup(yytext); return DEFUNNY; "DEFPY_HIDDEN" value = strdup(yytext); return DEFUNNY; "ALIAS" value = strdup(yytext); return DEFUNNY; diff --git a/lib/if.c b/lib/if.c index e31ccd8563..dd7d210381 100644 --- a/lib/if.c +++ b/lib/if.c @@ -626,7 +626,7 @@ static struct interface *if_sunwzebra_get(char *name, vrf_id_t vrf_id) } #endif /* SUNOS_5 */ -DEFUN (interface, +DEFUN_NOSH (interface, interface_cmd, "interface IFNAME [vrf NAME]", "Select an interface to configure\n" @@ -669,13 +669,13 @@ DEFUN (interface, return CMD_SUCCESS; } -DEFUN_NOSH (no_interface, - no_interface_cmd, - "no interface IFNAME [vrf NAME]", - NO_STR - "Delete a pseudo interface's configuration\n" - "Interface's name\n" - VRF_CMD_HELP_STR) +DEFUN (no_interface, + no_interface_cmd, + "no interface IFNAME [vrf NAME]", + NO_STR + "Delete a pseudo interface's configuration\n" + "Interface's name\n" + VRF_CMD_HELP_STR) { int idx_vrf = 4; const char *ifname = argv[2]->arg; diff --git a/lib/linklist.c b/lib/linklist.c index 86649dd495..effd384e46 100644 --- a/lib/linklist.c +++ b/lib/linklist.c @@ -70,6 +70,26 @@ void listnode_add(struct list *list, void *val) list->count++; } +void listnode_add_head(struct list *list, void *val) +{ + struct listnode *node; + + assert(val != NULL); + + node = listnode_new(); + + node->next = list->head; + node->data = val; + + if (list->head == NULL) + list->head = node; + else + list->head->prev = node; + list->head = node; + + list->count++; +} + void listnode_add_sort(struct list *list, void *val) { struct listnode *n; diff --git a/lib/linklist.h b/lib/linklist.h index cee6c1e505..f5cd44efb0 100644 --- a/lib/linklist.h +++ b/lib/linklist.h @@ -82,6 +82,19 @@ extern struct list *list_new(void); */ extern void listnode_add(struct list *list, void *data); +/* + * Add a new element to the beginning of a list. + * + * Runtime is O(1). + * + * list + * list to operate on + * + * data + * element to add + */ +extern void listnode_add_head(struct list *list, void *data); + /* * Insert a new element into a list with insertion sort. * diff --git a/lib/vrf.c b/lib/vrf.c index ca50c1e70e..4f29bad5f2 100644 --- a/lib/vrf.c +++ b/lib/vrf.c @@ -711,12 +711,12 @@ DEFUN_NOSH (vrf, return vrf_handler_create(vty, vrfname, NULL); } -DEFUN_NOSH (no_vrf, - no_vrf_cmd, - "no vrf NAME", - NO_STR - "Delete a pseudo VRF's configuration\n" - "VRF's name\n") +DEFUN (no_vrf, + no_vrf_cmd, + "no vrf NAME", + NO_STR + "Delete a pseudo VRF's configuration\n" + "VRF's name\n") { const char *vrfname = argv[2]->arg; @@ -744,7 +744,7 @@ DEFUN_NOSH (no_vrf, struct cmd_node vrf_node = {VRF_NODE, "%s(config-vrf)# ", 1}; -DEFUN (vrf_netns, +DEFUN_NOSH (vrf_netns, vrf_netns_cmd, "netns NAME", "Attach VRF to a Namespace\n" @@ -771,7 +771,7 @@ DEFUN (vrf_netns, return ret; } -DEFUN (no_vrf_netns, +DEFUN_NOSH (no_vrf_netns, no_vrf_netns_cmd, "no netns [NAME]", NO_STR diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index 44e14c5477..a4b87f99d9 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -580,6 +580,9 @@ static int pbr_interface_config_write(struct vty *vty) vty_frame(vty, "interface %s vrf %s\n", ifp->name, vrf->name); + if (ifp->desc) + vty_out(vty, " description %s\n", ifp->desc); + pbr_map_write_interfaces(vty, ifp); vty_endframe(vty, "!\n"); diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c index f4d833c26f..88be195bee 100644 --- a/pimd/pim_vty.c +++ b/pimd/pim_vty.c @@ -258,6 +258,11 @@ int pim_interface_config_write(struct vty *vty) ifp->name, vrf->name); ++writes; + if (ifp->desc) { + vty_out(vty, " description %s\n", ifp->desc); + ++writes; + } + if (ifp->info) { struct pim_interface *pim_ifp = ifp->info; diff --git a/vtysh/Makefile.am b/vtysh/Makefile.am index 6d0b4a8fdb..9f81b42e32 100644 --- a/vtysh/Makefile.am +++ b/vtysh/Makefile.am @@ -154,7 +154,7 @@ vtysh_cmd_FILES = $(vtysh_scan) \ $(top_srcdir)/lib/keychain.c $(top_srcdir)/lib/routemap.c \ $(top_srcdir)/lib/filter.c $(top_srcdir)/lib/plist.c \ $(top_srcdir)/lib/distribute.c $(top_srcdir)/lib/if_rmap.c \ - $(top_srcdir)/lib/vrf.c \ + $(top_srcdir)/lib/vrf.c $(top_srcdir)/lib/if.c \ $(top_srcdir)/lib/vty.c $(top_srcdir)/zebra/debug.c \ $(top_srcdir)/lib/logicalrouter.c \ $(top_srcdir)/lib/nexthop_group.c \ diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in index c0277b3d61..92b5686a94 100755 --- a/vtysh/extract.pl.in +++ b/vtysh/extract.pl.in @@ -85,7 +85,10 @@ foreach (@ARGV) { $protocol = "VTYSH_RMAP"; } elsif ($file =~ /lib\/vrf\.c$/) { - $protocol = "VTYSH_ALL"; + $protocol = "VTYSH_VRF"; + } + elsif ($file =~ /lib\/if\.c$/) { + $protocol = "VTYSH_INTERFACE"; } elsif ($file =~ /lib\/logicalrouter\.c$/) { $protocol = "VTYSH_ALL"; diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index e25a576926..229337d82f 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -2018,18 +2018,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 +2058,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 +2107,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") { @@ -3577,8 +3559,6 @@ void vtysh_init_vty(void) 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); @@ -3682,17 +3662,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. */ diff --git a/zebra/zebra_pw.c b/zebra/zebra_pw.c index bf76f7e86b..c6db1463f2 100644 --- a/zebra/zebra_pw.c +++ b/zebra/zebra_pw.c @@ -308,15 +308,14 @@ void zebra_pw_exit(struct zebra_vrf *zvrf) DEFUN_NOSH (pseudowire_if, pseudowire_if_cmd, - "[no] pseudowire IFNAME", - NO_STR + "pseudowire IFNAME", "Static pseudowire configuration\n" "Pseudowire name\n") { struct zebra_vrf *zvrf; struct zebra_pw *pw; - int idx = 0; const char *ifname; + int idx = 0; zvrf = vrf_info_lookup(VRF_DEFAULT); if (!zvrf) @@ -324,19 +323,13 @@ DEFUN_NOSH (pseudowire_if, argv_find(argv, argc, "IFNAME", &idx); ifname = argv[idx]->arg; + pw = zebra_pw_find(zvrf, ifname); if (pw && pw->protocol != ZEBRA_ROUTE_STATIC) { vty_out(vty, "%% Pseudowire is not static\n"); return CMD_WARNING; } - if (argv_find(argv, argc, "no", &idx)) { - if (!pw) - return CMD_SUCCESS; - zebra_pw_del(zvrf, pw); - return CMD_SUCCESS; - } - if (!pw) pw = zebra_pw_add(zvrf, ifname, ZEBRA_ROUTE_STATIC, NULL); VTY_PUSH_CONTEXT(PW_NODE, pw); @@ -344,6 +337,37 @@ DEFUN_NOSH (pseudowire_if, return CMD_SUCCESS; } +DEFUN (no_pseudowire_if, + no_pseudowire_if_cmd, + "no pseudowire IFNAME", + NO_STR + "Static pseudowire configuration\n" + "Pseudowire name\n") +{ + struct zebra_vrf *zvrf; + struct zebra_pw *pw; + const char *ifname; + int idx = 0; + + zvrf = vrf_info_lookup(VRF_DEFAULT); + if (!zvrf) + return CMD_WARNING; + + argv_find(argv, argc, "IFNAME", &idx); + ifname = argv[idx]->arg; + + pw = zebra_pw_find(zvrf, ifname); + if (pw) { + if (pw->protocol != ZEBRA_ROUTE_STATIC) { + vty_out(vty, "%% Pseudowire is not static\n"); + return CMD_WARNING; + } + zebra_pw_del(zvrf, pw); + } + + return CMD_SUCCESS; +} + DEFUN (pseudowire_labels, pseudowire_labels_cmd, "[no] mpls label local (16-1048575) remote (16-1048575)", @@ -531,6 +555,7 @@ void zebra_pw_vty_init(void) install_default(PW_NODE); install_element(CONFIG_NODE, &pseudowire_if_cmd); + install_element(CONFIG_NODE, &no_pseudowire_if_cmd); install_element(PW_NODE, &pseudowire_labels_cmd); install_element(PW_NODE, &pseudowire_neighbor_cmd); install_element(PW_NODE, &pseudowire_control_word_cmd);