summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2016-11-16 07:00:52 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2016-12-01 17:25:56 +0100
commit0b84f294904959a4be58db6fe0e89d71b2c1f401 (patch)
treef52c765644294f314ede33506f29b6888439b904
parentMerge branch 'stable/2.0' (diff)
downloadfrr-0b84f294904959a4be58db6fe0e89d71b2c1f401.tar.xz
frr-0b84f294904959a4be58db6fe0e89d71b2c1f401.zip
*: make DEFUN installations file-local
This moves all install_element calls into the file where the DEFUNs are located. This fixes several small related bugs: - ospf6d wasn't installing a "no interface FOO" command - zebra had a useless copy of "interface FOO" - pimd's copy of "interface FOO" was not setting qobj_index, which means "description LINE" commands would fail with an error The next commit will do the actual act of making "foo_cmd" static. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
-rw-r--r--isisd/isis_circuit.c7
-rw-r--r--ldpd/ldp_vty_conf.c9
-rw-r--r--lib/command.c37
-rw-r--r--lib/command.h7
-rw-r--r--lib/if.c18
-rw-r--r--lib/if.h18
-rw-r--r--lib/thread.c7
-rw-r--r--lib/thread.h3
-rw-r--r--lib/vty.c2
-rw-r--r--lib/workqueue.c6
-rw-r--r--lib/workqueue.h4
-rw-r--r--ospf6d/ospf6_interface.c5
-rw-r--r--ospfd/ospf_vty.c9
-rw-r--r--pimd/pim_cmd.c51
-rw-r--r--ripd/rip_interface.c6
-rw-r--r--ripngd/ripng_interface.c8
-rw-r--r--vtysh/vtysh.c9
-rw-r--r--zebra/interface.c38
18 files changed, 85 insertions, 159 deletions
diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c
index c5812a658..8479d7f31 100644
--- a/isisd/isis_circuit.c
+++ b/isisd/isis_circuit.c
@@ -1418,12 +1418,7 @@ isis_circuit_init ()
/* Install interface node */
install_node (&interface_node, isis_interface_config_write);
- install_element (CONFIG_NODE, &interface_cmd);
- install_element (CONFIG_NODE, &no_interface_cmd);
-
- install_default (INTERFACE_NODE);
- install_element (INTERFACE_NODE, &interface_desc_cmd);
- install_element (INTERFACE_NODE, &no_interface_desc_cmd);
+ if_cmd_init ();
isis_vty_init ();
}
diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c
index e5acada18..f2b21d817 100644
--- a/ldpd/ldp_vty_conf.c
+++ b/ldpd/ldp_vty_conf.c
@@ -1618,14 +1618,7 @@ ldp_vty_if_init(void)
{
/* Install interface node. */
install_node (&interface_node, interface_config_write);
-
- install_element(CONFIG_NODE, &interface_cmd);
- install_element(CONFIG_NODE, &no_interface_cmd);
- install_default(INTERFACE_NODE);
-
- /* "description" commands. */
- install_element(INTERFACE_NODE, &interface_desc_cmd);
- install_element(INTERFACE_NODE, &no_interface_desc_cmd);
+ if_cmd_init ();
}
struct iface *
diff --git a/lib/command.c b/lib/command.c
index 3c429ce1a..8e935acf9 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -1051,6 +1051,13 @@ DEFUN (config_exit,
"exit",
"Exit current mode and down to previous mode\n")
{
+ cmd_exit (vty);
+ return CMD_SUCCESS;
+}
+
+void
+cmd_exit (struct vty *vty)
+{
switch (vty->node)
{
case VIEW_NODE:
@@ -1118,7 +1125,6 @@ DEFUN (config_exit,
default:
break;
}
- return CMD_SUCCESS;
}
/* ALIAS_FIXME */
@@ -1264,17 +1270,12 @@ permute (struct graph_node *start, struct vty *vty)
list_delete_node (position, listtail(position));
}
-/* Help display function for all node. */
-DEFUN (config_list,
- config_list_cmd,
- "list [permutations]",
- "Print command list\n"
- "Print all possible command permutations\n")
+int
+cmd_list_cmds (struct vty *vty, int do_permute)
{
struct cmd_node *node = vector_slot (cmdvec, vty->node);
- if ((strmatch (argv[0]->text, "list") && argc == 2) ||
- (strmatch (argv[0]->text, "show") && argc == 3))
+ if (do_permute)
permute (vector_slot (node->cmdgraph->nodes, 0), vty);
else
{
@@ -1289,13 +1290,23 @@ DEFUN (config_list,
return CMD_SUCCESS;
}
+/* Help display function for all node. */
+DEFUN (config_list,
+ config_list_cmd,
+ "list [permutations]",
+ "Print command list\n"
+ "Print all possible command permutations\n")
+{
+ return cmd_list_cmds (vty, argc == 2);
+}
+
DEFUN (show_commandtree,
show_commandtree_cmd,
"show commandtree [permutations]",
SHOW_STR
"Show command tree\n")
{
- return config_list (self, vty, argc, argv);
+ return cmd_list_cmds (vty, argc == 3);
}
/* Write current configuration into file. */
@@ -2352,10 +2363,8 @@ cmd_init (int terminal)
install_element (ENABLE_NODE, &config_logmsg_cmd);
install_default (CONFIG_NODE);
- install_element (VIEW_NODE, &show_thread_cpu_cmd);
- install_element (ENABLE_NODE, &clear_thread_cpu_cmd);
-
- install_element (VIEW_NODE, &show_work_queues_cmd);
+ thread_cmd_init ();
+ workqueue_cmd_init ();
}
install_element (CONFIG_NODE, &hostname_cmd);
diff --git a/lib/command.h b/lib/command.h
index f120063ea..a170a9549 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -414,6 +414,8 @@ extern int cmd_execute_command (vector, struct vty *, const struct cmd_element *
extern int cmd_execute_command_strict (vector, struct vty *, const struct cmd_element **);
extern void cmd_init (int);
extern void cmd_terminate (void);
+extern void cmd_exit (struct vty *vty);
+extern int cmd_list_cmds (struct vty *vty, int do_permute);
/* memory management for cmd_element */
void
@@ -430,11 +432,6 @@ struct cmd_token *
copy_cmd_token (struct cmd_token *);
/* Export typical functions. */
-extern struct cmd_element config_end_cmd;
-extern struct cmd_element config_exit_cmd;
-extern struct cmd_element config_quit_cmd;
-extern struct cmd_element config_help_cmd;
-extern struct cmd_element config_list_cmd;
extern const char *host_config_get (void);
extern void host_config_set (const char *);
diff --git a/lib/if.c b/lib/if.c
index dadf35574..c323ae9da 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -832,6 +832,17 @@ DEFUN_NOSH (no_interface,
return CMD_SUCCESS;
}
+void
+if_cmd_init (void)
+{
+ install_element (CONFIG_NODE, &interface_cmd);
+ install_element (CONFIG_NODE, &no_interface_cmd);
+
+ install_default (INTERFACE_NODE);
+ install_element (INTERFACE_NODE, &interface_desc_cmd);
+ install_element (INTERFACE_NODE, &no_interface_desc_cmd);
+}
+
DEFUN (vrf,
vrf_cmd,
"vrf NAME",
@@ -890,6 +901,13 @@ DEFUN_NOSH (no_vrf,
return CMD_SUCCESS;
}
+void
+vrf_cmd_init (void)
+{
+ install_element (CONFIG_NODE, &vrf_cmd);
+ install_element (CONFIG_NODE, &no_vrf_cmd);
+ install_default (VRF_NODE);
+}
/* For debug purpose. */
DEFUN (show_address,
diff --git a/lib/if.h b/lib/if.h
index 7fdd46d3f..cf6f3bc00 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -445,11 +445,14 @@ extern int if_is_pointopoint (struct interface *);
extern int if_is_multicast (struct interface *);
extern void if_add_hook (int, int (*)(struct interface *));
extern void if_init (struct list **);
+extern void if_cmd_init (void);
extern void if_terminate (struct list **);
extern void if_dump_all (void);
extern const char *if_flag_dump(unsigned long);
extern const char *if_link_type_str (enum zebra_link_type);
+extern void vrf_cmd_init (void);
+
/* Please use ifindex2ifname instead of if_indextoname where possible;
ifindex2ifname uses internal interface info, whereas if_indextoname must
make a system call. */
@@ -483,19 +486,4 @@ struct nbr_connected *nbr_connected_check (struct interface *, struct prefix *);
struct if_link_params *if_link_params_get (struct interface *);
void if_link_params_free (struct interface *);
-/* Exported variables. */
-extern struct cmd_element interface_desc_cmd;
-extern struct cmd_element no_interface_desc_cmd;
-extern struct cmd_element interface_cmd;
-extern struct cmd_element no_interface_cmd;
-extern struct cmd_element interface_vrf_cmd;
-extern struct cmd_element no_interface_vrf_cmd;
-extern struct cmd_element interface_pseudo_cmd;
-extern struct cmd_element no_interface_pseudo_cmd;
-extern struct cmd_element show_address_cmd;
-extern struct cmd_element show_address_vrf_cmd;
-extern struct cmd_element show_address_vrf_all_cmd;
-extern struct cmd_element vrf_cmd;
-extern struct cmd_element no_vrf_cmd;
-
#endif /* _ZEBRA_IF_H */
diff --git a/lib/thread.c b/lib/thread.c
index ce93530ff..eac7f3250 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -423,6 +423,13 @@ DEFUN (clear_thread_cpu,
return CMD_SUCCESS;
}
+void
+thread_cmd_init (void)
+{
+ install_element (VIEW_NODE, &show_thread_cpu_cmd);
+ install_element (ENABLE_NODE, &clear_thread_cpu_cmd);
+}
+
static int
thread_timer_cmp(void *a, void *b)
{
diff --git a/lib/thread.h b/lib/thread.h
index e41e96dec..5c6b96a32 100644
--- a/lib/thread.h
+++ b/lib/thread.h
@@ -244,8 +244,7 @@ extern void thread_set_yield_time (struct thread *, unsigned long);
/* Internal libzebra exports */
extern void thread_getrusage (RUSAGE_T *);
-extern struct cmd_element show_thread_cpu_cmd;
-extern struct cmd_element clear_thread_cpu_cmd;
+extern void thread_cmd_init (void);
/* replacements for the system gettimeofday(), clock_gettime() and
* time() functions, providing support for non-decrementing clock on
diff --git a/lib/vty.c b/lib/vty.c
index 54399b023..d5ecb1db5 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -715,7 +715,7 @@ static void
vty_down_level (struct vty *vty)
{
vty_out (vty, "%s", VTY_NEWLINE);
- (*config_exit_cmd.func)(NULL, vty, 0, NULL);
+ cmd_exit (vty);
vty_prompt (vty);
vty->cp = 0;
}
diff --git a/lib/workqueue.c b/lib/workqueue.c
index 549bb2360..51017b34e 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -222,6 +222,12 @@ DEFUN (show_work_queues,
return CMD_SUCCESS;
}
+void
+workqueue_cmd_init (void)
+{
+ install_element (VIEW_NODE, &show_work_queues_cmd);
+}
+
/* 'plug' a queue: Stop it from being scheduled,
* ie: prevent the queue from draining.
*/
diff --git a/lib/workqueue.h b/lib/workqueue.h
index eaf857490..548f96d8b 100644
--- a/lib/workqueue.h
+++ b/lib/workqueue.h
@@ -129,5 +129,7 @@ bool work_queue_is_scheduled (struct work_queue *);
/* Helpers, exported for thread.c and command.c */
extern int work_queue_run (struct thread *);
-extern struct cmd_element show_work_queues_cmd;
+
+extern void workqueue_cmd_init (void);
+
#endif /* _QUAGGA_WORK_QUEUE_H */
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index 8ea4b1695..74c9ac739 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -1845,15 +1845,12 @@ ospf6_interface_init (void)
{
/* Install interface node. */
install_node (&interface_node, config_write_ospf6_interface);
+ if_cmd_init ();
install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
- install_element (CONFIG_NODE, &interface_cmd);
- install_default (INTERFACE_NODE);
- install_element (INTERFACE_NODE, &interface_desc_cmd);
- install_element (INTERFACE_NODE, &no_interface_desc_cmd);
install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
install_element (INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 8662eb425..8173835d9 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -9250,14 +9250,7 @@ ospf_vty_if_init (void)
{
/* Install interface node. */
install_node (&interface_node, config_write_interface);
-
- install_element (CONFIG_NODE, &interface_cmd);
- install_element (CONFIG_NODE, &no_interface_cmd);
- install_default (INTERFACE_NODE);
-
- /* "description" commands. */
- install_element (INTERFACE_NODE, &interface_desc_cmd);
- install_element (INTERFACE_NODE, &no_interface_desc_cmd);
+ if_cmd_init ();
/* "ip ospf authentication" commands. */
install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index afc42a956..8d7579aaf 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -1527,47 +1527,6 @@ static void clear_interfaces()
clear_pim_interfaces();
}
-DEFUN (pim_interface,
- pim_interface_cmd,
- "interface IFNAME",
- "Select an interface to configure\n"
- "Interface's name\n")
-{
- int idx_ifname = 1;
- struct interface *ifp;
- const char *ifname = argv[idx_ifname]->arg;
- size_t sl;
-
- sl = strlen(ifname);
- if (sl > INTERFACE_NAMSIZ) {
- vty_out(vty, "%% Interface name %s is invalid: length exceeds "
- "%d characters%s",
- ifname, INTERFACE_NAMSIZ, VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- ifp = if_lookup_by_name_len(ifname, sl);
- if (!ifp) {
- vty_out(vty, "%% Interface %s does not exist%s", ifname, VTY_NEWLINE);
-
- /* Returning here would prevent pimd from booting when there are
- interface commands in pimd.conf, since all interfaces are
- unknown at pimd boot time (the zebra daemon has not been
- contacted for interface discovery). */
-
- ifp = if_get_by_name_len(ifname, sl);
- if (!ifp) {
- vty_out(vty, "%% Could not create interface %s%s", ifname, VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
-
- vty->index = ifp;
- vty->node = INTERFACE_NODE;
-
- return CMD_SUCCESS;
-}
-
DEFUN (clear_ip_interfaces,
clear_ip_interfaces_cmd,
"clear ip interfaces",
@@ -4832,6 +4791,7 @@ void pim_cmd_init()
{
install_node (&pim_global_node, pim_global_config_write); /* PIM_NODE */
install_node (&interface_node, pim_interface_config_write); /* INTERFACE_NODE */
+ if_cmd_init ();
install_element (CONFIG_NODE, &ip_multicast_routing_cmd);
install_element (CONFIG_NODE, &no_ip_multicast_routing_cmd);
@@ -4839,14 +4799,7 @@ void pim_cmd_init()
install_element (CONFIG_NODE, &no_ip_pim_rp_cmd);
install_element (CONFIG_NODE, &ip_ssmpingd_cmd);
install_element (CONFIG_NODE, &no_ip_ssmpingd_cmd);
-#if 0
- install_element (CONFIG_NODE, &interface_cmd); /* from if.h */
-#else
- install_element (CONFIG_NODE, &pim_interface_cmd);
-#endif
- install_element (CONFIG_NODE, &no_interface_cmd); /* from if.h */
-
- install_default (INTERFACE_NODE);
+
install_element (INTERFACE_NODE, &interface_ip_igmp_cmd);
install_element (INTERFACE_NODE, &interface_no_ip_igmp_cmd);
install_element (INTERFACE_NODE, &interface_ip_igmp_join_cmd);
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 8c5092d78..f2ce7e760 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -2004,13 +2004,9 @@ rip_if_init (void)
/* Install interface node. */
install_node (&interface_node, rip_interface_config_write);
+ if_cmd_init ();
/* Install commands. */
- install_element (CONFIG_NODE, &interface_cmd);
- install_element (CONFIG_NODE, &no_interface_cmd);
- install_default (INTERFACE_NODE);
- install_element (INTERFACE_NODE, &interface_desc_cmd);
- install_element (INTERFACE_NODE, &no_interface_desc_cmd);
install_element (RIP_NODE, &rip_network_cmd);
install_element (RIP_NODE, &no_rip_network_cmd);
install_element (RIP_NODE, &rip_neighbor_cmd);
diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c
index 7bee7625d..393ca2e7a 100644
--- a/ripngd/ripng_interface.c
+++ b/ripngd/ripng_interface.c
@@ -1190,13 +1190,7 @@ ripng_if_init ()
/* Install interface node. */
install_node (&interface_node, interface_config_write);
-
- /* Install commands. */
- install_element (CONFIG_NODE, &interface_cmd);
- install_element (CONFIG_NODE, &no_interface_cmd);
- install_default (INTERFACE_NODE);
- install_element (INTERFACE_NODE, &interface_desc_cmd);
- install_element (INTERFACE_NODE, &no_interface_desc_cmd);
+ if_cmd_init ();
install_element (RIPNG_NODE, &ripng_network_cmd);
install_element (RIPNG_NODE, &no_ripng_network_cmd);
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index b622fa974..0a83b56be 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -2796,6 +2796,15 @@ DEFUN (vtysh_start_zsh,
}
#endif
+DEFUN (config_list,
+ config_list_cmd,
+ "list [permutations]",
+ "Print command list\n"
+ "Print all possible command permutations\n")
+{
+ return cmd_list_cmds (vty, argc == 2);
+}
+
static void
vtysh_install_default (enum node_type node)
{
diff --git a/zebra/interface.c b/zebra/interface.c
index 91dbe5276..e9cbd72af 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -1223,32 +1223,6 @@ if_dump_vty (struct vty *vty, struct interface *ifp)
#endif /* HAVE_NET_RT_IFLIST */
}
-/* Wrapper hook point for zebra daemon so that ifindex can be set
- * DEFUN macro not used as extract.pl HAS to ignore this
- * See also interface_cmd in lib/if.c
- */
-DEFUN_NOSH (zebra_interface,
- zebra_interface_cmd,
- "interface IFNAME",
- "Select an interface to configure\n"
- "Interface's name\n")
-{
- int ret;
-
- /* Call lib interface() */
- if ((ret = interface_cmd.func (self, vty, argc, argv)) != CMD_SUCCESS)
- return ret;
-
- VTY_DECLVAR_CONTEXT (interface, ifp);
-
- if (ifp->ifindex == IFINDEX_INTERNAL)
- /* Is this really necessary? Shouldn't status be initialized to 0
- in that case? */
- UNSET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE);
-
- return ret;
-}
-
static void
interface_update_stats (void)
{
@@ -1269,6 +1243,7 @@ struct cmd_node interface_node =
1
};
+#if 0
/* Wrapper hook point for zebra daemon so that ifindex can be set
* DEFUN macro not used as extract.pl HAS to ignore this
* See also interface_cmd in lib/if.c
@@ -1288,6 +1263,7 @@ DEFUN_NOSH (zebra_vrf,
return ret;
}
+#endif
struct cmd_node vrf_node =
{
@@ -2934,6 +2910,7 @@ zebra_if_init (void)
install_node (&interface_node, if_config_write);
install_node (&link_params_node, NULL);
install_node (&vrf_node, vrf_config_write);
+ if_cmd_init ();
install_element (VIEW_NODE, &show_interface_cmd);
install_element (VIEW_NODE, &show_interface_vrf_all_cmd);
@@ -2942,11 +2919,6 @@ zebra_if_init (void)
install_element (ENABLE_NODE, &show_interface_desc_cmd);
install_element (ENABLE_NODE, &show_interface_desc_vrf_all_cmd);
- install_element (CONFIG_NODE, &zebra_interface_cmd);
- install_element (CONFIG_NODE, &no_interface_cmd);
- install_default (INTERFACE_NODE);
- install_element (INTERFACE_NODE, &interface_desc_cmd);
- install_element (INTERFACE_NODE, &no_interface_desc_cmd);
install_element (INTERFACE_NODE, &multicast_cmd);
install_element (INTERFACE_NODE, &no_multicast_cmd);
install_element (INTERFACE_NODE, &linkdetect_cmd);
@@ -2991,7 +2963,5 @@ zebra_if_init (void)
install_element(LINK_PARAMS_NODE, &no_link_params_use_bw_cmd);
install_element(LINK_PARAMS_NODE, &exit_link_params_cmd);
- install_element (CONFIG_NODE, &zebra_vrf_cmd);
- install_element (CONFIG_NODE, &no_vrf_cmd);
- install_default (VRF_NODE);
+ vrf_cmd_init();
}