summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vlib/vlib/init.h8
-rw-r--r--vlib/vlib/unix/main.c3
-rw-r--r--vnet/Makefile.am14
-rw-r--r--vnet/vnet/ethernet/arp.c4
-rw-r--r--vnet/vnet/ethernet/ethernet.h3
-rw-r--r--vnet/vnet/ethernet/init.c7
-rw-r--r--vnet/vnet/ethernet/node.c16
-rw-r--r--vnet/vnet/srp/node.c9
-rw-r--r--vnet/vnet/srp/srp.h1
-rw-r--r--vpp/Makefile.am4
-rw-r--r--vpp/vnet/main.c100
11 files changed, 56 insertions, 113 deletions
diff --git a/vlib/vlib/init.h b/vlib/vlib/init.h
index 9d940d0745f..c2a4014fd5b 100644
--- a/vlib/vlib/init.h
+++ b/vlib/vlib/init.h
@@ -169,6 +169,14 @@ static void __vlib_add_config_function_##x (void) \
_error; \
})
+/* Don't call given init function: used to suppress parts of the netstack */
+#define vlib_mark_init_function_complete(vm, x) \
+ ({ \
+ extern vlib_init_function_t * VLIB_INIT_FUNCTION_SYMBOL (x); \
+ vlib_init_function_t * _f = VLIB_INIT_FUNCTION_SYMBOL (x); \
+ hash_set1 (vm->init_functions_called, _f); \
+ })
+
#define vlib_call_post_graph_init_function(vm, x) \
({ \
extern vlib_init_function_t * VLIB_POST_GRAPH_INIT_FUNCTION_SYMBOL (x); \
diff --git a/vlib/vlib/unix/main.c b/vlib/vlib/unix/main.c
index 6ff63f84733..d6976b10751 100644
--- a/vlib/vlib/unix/main.c
+++ b/vlib/vlib/unix/main.c
@@ -431,7 +431,8 @@ int vlib_unix_main (int argc, char * argv[])
return i;
unformat_init_command_line (&input, (char **)vm->argv);
- vm->init_functions_called = hash_create (0, /* value bytes */ 0);
+ if (vm->init_functions_called == 0)
+ vm->init_functions_called = hash_create (0, /* value bytes */ 0);
e = vlib_call_all_config_functions (vm, &input, 1 /* early */);
if (e != 0)
{
diff --git a/vnet/Makefile.am b/vnet/Makefile.am
index f44bb12492c..fc5a3ec9b70 100644
--- a/vnet/Makefile.am
+++ b/vnet/Makefile.am
@@ -16,7 +16,6 @@ AUTOMAKE_OPTIONS = foreign subdir-objects
AM_CFLAGS = -Wall @DPDK@ @VIRL@ @IPSEC@ @VCGN@ @IPV6SR@
libvnet_la_SOURCES =
-libvnetplugin_la_SOURCES =
nobase_include_HEADERS =
noinst_PROGRAMS =
@@ -42,6 +41,7 @@ nobase_include_HEADERS += \
vnet/interface_funcs.h \
vnet/l3_types.h \
vnet/pipeline.h \
+ vnet/plugin/plugin.h \
vnet/replication.h \
vnet/rewrite.h \
vnet/vnet.h
@@ -620,17 +620,7 @@ nobase_include_HEADERS += \
vnet/unix/tuntap.h \
vnet/unix/tapcli.h
-########################################
-# Plugin client library
-########################################
-
-libvnetplugin_la_SOURCES += \
- vnet/plugin/p1.c
-
-nobase_include_HEADERS += \
- vnet/plugin/plugin.h
-
-lib_LTLIBRARIES = libvnet.la libvnetplugin.la
+lib_LTLIBRARIES = libvnet.la
dpdk_libs =
diff --git a/vnet/vnet/ethernet/arp.c b/vnet/vnet/ethernet/arp.c
index 3548831688a..3eb6a11391e 100644
--- a/vnet/vnet/ethernet/arp.c
+++ b/vnet/vnet/ethernet/arp.c
@@ -1246,6 +1246,10 @@ static clib_error_t * ethernet_arp_init (vlib_main_t * vm)
{
ethernet_arp_main_t * am = &ethernet_arp_main;
pg_node_t * pn;
+ clib_error_t * error;
+
+ if ((error = vlib_call_init_function (vm, ethernet_init)))
+ return error;
ethernet_register_input_type (vm, ETHERNET_TYPE_ARP, arp_input_node.index);
diff --git a/vnet/vnet/ethernet/ethernet.h b/vnet/vnet/ethernet/ethernet.h
index 266e1d79afb..04e07b71bf7 100644
--- a/vnet/vnet/ethernet/ethernet.h
+++ b/vnet/vnet/ethernet/ethernet.h
@@ -218,6 +218,9 @@ typedef struct {
/* Set to one to use AB.CD.EF instead of A:B:C:D:E:F as ethernet format. */
int format_ethernet_address_16bit;
+ /* debug: make sure we don't wipe out an ethernet registration by mistake */
+ u8 next_by_ethertype_register_called;
+
} ethernet_main_t;
ethernet_main_t ethernet_main;
diff --git a/vnet/vnet/ethernet/init.c b/vnet/vnet/ethernet/init.c
index 4ac14e208be..42788f02c27 100644
--- a/vnet/vnet/ethernet/init.c
+++ b/vnet/vnet/ethernet/init.c
@@ -66,6 +66,13 @@ static clib_error_t * ethernet_init (vlib_main_t * vm)
ethernet_main_t * em = &ethernet_main;
clib_error_t * error;
+ /*
+ * Set up the L2 path now, or we'll wipe out the L2 ARP
+ * registration set up by ethernet_arp_init.
+ */
+ if ((error = vlib_call_init_function(vm, l2_init)))
+ return error;
+
em->vlib_main = vm;
em->type_info_by_name = hash_create_string (0, sizeof (uword));
diff --git a/vnet/vnet/ethernet/node.c b/vnet/vnet/ethernet/node.c
index 9c943992b68..9aed302f407 100644
--- a/vnet/vnet/ethernet/node.c
+++ b/vnet/vnet/ethernet/node.c
@@ -960,6 +960,16 @@ clib_error_t * next_by_ethertype_init (next_by_ethertype_t * l3_next)
l3_next->sparse_index_by_input_next_index[ETHERNET_INPUT_NEXT_PUNT]
= SPARSE_VEC_INVALID_INDEX;
+ /*
+ * Make sure we don't wipe out an ethernet registration by mistake
+ * Can happen if init function ordering constraints are missing.
+ */
+ if (CLIB_DEBUG > 0)
+ {
+ ethernet_main_t * em = &ethernet_main;
+ ASSERT(em->next_by_ethertype_register_called == 0);
+ }
+
return 0;
}
@@ -972,6 +982,12 @@ clib_error_t * next_by_ethertype_register (next_by_ethertype_t * l3_next,
u16 * n;
ethernet_main_t * em = &ethernet_main;
+ if (CLIB_DEBUG > 0)
+ {
+ ethernet_main_t * em = &ethernet_main;
+ em->next_by_ethertype_register_called = 1;
+ }
+
/* Setup ethernet type -> next index sparse vector mapping. */
n = sparse_vec_validate (l3_next->input_next_by_type, ethertype);
n[0] = next_index;
diff --git a/vnet/vnet/srp/node.c b/vnet/vnet/srp/node.c
index 42143ef6e9d..0b23258249f 100644
--- a/vnet/vnet/srp/node.c
+++ b/vnet/vnet/srp/node.c
@@ -269,7 +269,7 @@ static char * srp_error_strings[] = {
#undef _
};
-VLIB_REGISTER_NODE (srp_input_node,static) = {
+vlib_node_registration_t srp_input_node = {
.function = srp_input,
.name = "srp-input",
/* Takes a vector of packets. */
@@ -444,7 +444,7 @@ srp_control_input (vlib_main_t * vm,
return from_frame->n_vectors;
}
-VLIB_REGISTER_NODE (srp_control_input_node,static) = {
+static vlib_node_registration_t srp_control_input_node = {
.function = srp_control_input,
.name = "srp-control",
/* Takes a vector of packets. */
@@ -908,7 +908,7 @@ srp_ips_process (vlib_main_t * vm,
return 0;
}
-VLIB_REGISTER_NODE (srp_ips_process_node) = {
+vlib_node_registration_t srp_ips_process_node = {
.function = srp_ips_process,
.type = VLIB_NODE_TYPE_PROCESS,
.name = "srp-ips-process",
@@ -921,6 +921,9 @@ static clib_error_t * srp_init (vlib_main_t * vm)
sm->default_data_ttl = 255;
sm->vlib_main = vm;
+ vlib_register_node (vm, &srp_ips_process_node);
+ vlib_register_node (vm, &srp_input_node);
+ vlib_register_node (vm, &srp_control_input_node);
srp_setup_node (vm, srp_input_node.index);
return 0;
diff --git a/vnet/vnet/srp/srp.h b/vnet/vnet/srp/srp.h
index 1b241710409..48c447b7bfd 100644
--- a/vnet/vnet/srp/srp.h
+++ b/vnet/vnet/srp/srp.h
@@ -150,6 +150,7 @@ void srp_interface_set_hw_wrap_function (u32 hw_if_index, srp_hw_wrap_function_t
void srp_interface_set_hw_enable_function (u32 hw_if_index, srp_hw_enable_function_t * f);
vlib_node_registration_t srp_ips_process_node;
+vlib_node_registration_t srp_input_node;
/* Called when an IPS control packet is received on given interface. */
void srp_ips_rx_packet (u32 sw_if_index, srp_ips_header_t * ips_packet);
diff --git a/vpp/Makefile.am b/vpp/Makefile.am
index 0f2cf83f9b0..15f8d126fe7 100644
--- a/vpp/Makefile.am
+++ b/vpp/Makefile.am
@@ -64,12 +64,10 @@ app/version.h:
vpp_LDADD = -lvlibapi -lvlibmemory -lvlib_unix -lvlib
-vpp_LDADD += -l:libvnet.a
+vpp_LDADD += -lvnet
vpp_LDADD += -lsvm -lsvmdb -lrt
-vpp_LDADD += -lvnetplugin
-
if WITH_DPDK
vpp_LDADD += -l:libdpdk.a
endif
diff --git a/vpp/vnet/main.c b/vpp/vnet/main.c
index bfd5ad598f4..08e8813fd5e 100644
--- a/vpp/vnet/main.c
+++ b/vpp/vnet/main.c
@@ -27,109 +27,18 @@
*
*/
-static clib_error_t *
+static void
vpe_main_init (vlib_main_t * vm)
{
- clib_error_t * error = 0;
- void vnet_library_plugin_reference(void);
-
if (CLIB_DEBUG > 0)
vlib_unix_cli_set_prompt ("DBGvpp# ");
else
vlib_unix_cli_set_prompt ("vpp# ");
- vnet_library_plugin_reference();
-
- if ((error = vlib_call_init_function (vm, pg_init)))
- return error;
- if ((error = vlib_call_init_function (vm, ip_main_init)))
- return error;
- if ((error = vlib_call_init_function (vm, osi_init)))
- return error;
- if ((error = vlib_call_init_function (vm, l2_init)))
- return error;
- if ((error = vlib_call_init_function (vm, ethernet_init)))
- return error;
- if ((error = vlib_call_init_function (vm, ethernet_arp_init)))
- return error;
- if ((error = vlib_call_init_function (vm, map_init)))
- return error;
- if ((error = vlib_call_init_function (vm, sixrd_init)))
- return error;
- if ((error = vlib_call_init_function (vm, llc_init)))
- return error;
- if ((error = vlib_call_init_function (vm, snap_init)))
- return error;
- if ((error = vlib_call_init_function (vm, cdp_init)))
- return error;
- if ((error = vlib_call_init_function (vm, nsh_gre_init)))
- return error;
- if ((error = vlib_call_init_function (vm, nsh_vxlan_gpe_init)))
- return error;
- if ((error = vlib_call_init_function (vm, lisp_gpe_init)))
- return error;
-
-#if DPDK == 1
- if ((error = vlib_call_init_function (vm, dpdk_init)))
- return error;
- if ((error = vlib_call_init_function (vm, dpdk_thread_init)))
- return error;
- if ((error = vlib_call_init_function (vm, vhost_user_init)))
- return error;
-#if IPSEC > 0
- if ((error = vlib_call_init_function (vm, ipsec_init)))
- return error;
-#endif /* IPSEC */
-#endif
- if ((error = vlib_call_init_function (vm, vlibmemory_init)))
- return error;
- if ((error = vlib_call_init_function (vm, l2tp_init)))
- return error;
- if ((error = vlib_call_init_function (vm, gre_init)))
- return error;
- if ((error = vlib_call_init_function (vm, gre_interface_init)))
- return error;
- if ((error = vlib_call_init_function (vm, mpls_init)))
- return error;
- if ((error = vlib_call_init_function (vm, mpls_interface_init)))
- return error;
- if ((error = vlib_call_init_function (vm, dhcp_proxy_init)))
- return error;
- if ((error = vlib_call_init_function (vm, dhcpv6_proxy_init)))
- return error;
- if ((error = vlib_call_init_function (vm, tapcli_init)))
- return error;
- if ((error = vlib_call_init_function (vm, gdb_func_init)))
- return error;
- if ((error = unix_physmem_init
- (vm, 0 /* fail_if_physical_memory_not_present */)))
- return error;
- if ((error = vlib_call_init_function (vm, tuntap_init)))
- return error;
-#if IPV6SR > 0
- if ((error = vlib_call_init_function (vm, sr_init)))
- return error;
-#endif
- if ((error = vlib_call_init_function (vm, l2_classify_init)))
- return error;
- if ((error = vlib_call_init_function (vm, policer_init)))
- return error;
- if ((error = vlib_call_init_function (vm, vxlan_init)))
- return error;
-#if VCGN > 0
- if ((error = vlib_call_init_function (vm, vcgn_init)))
- return error;
-#endif
- if ((error = vlib_call_init_function (vm, li_init)))
- return error;
- if ((error = vlib_call_init_function (vm, cop_init)))
- return error;
-
- return error;
+ /* Turn off network stack components which we don't want */
+ vlib_mark_init_function_complete (vm, srp_init);
}
-VLIB_INIT_FUNCTION (vpe_main_init);
-
/*
* Load plugins from /usr/lib/vpp_plugins by default
*/
@@ -147,6 +56,7 @@ void *vnet_get_handoff_structure (void)
int main (int argc, char * argv[])
{
int i;
+ vlib_main_t * vm = &vlib_global_main;
void vl_msg_api_set_first_available_msg_id (u16);
uword main_heap_size = (1ULL << 30);
u8 * sizep;
@@ -254,6 +164,8 @@ defaulted:
/* Allocate main heap */
if (clib_mem_init (0, main_heap_size)) {
+ vm->init_functions_called = hash_create (0, /* value bytes */ 0);
+ vpe_main_init(vm);
vlib_set_get_handoff_structure_cb (&vnet_get_handoff_structure);
return vlib_unix_main (argc, argv);
} else {