From 1f49ed666af8b9cb889f9ea61f084341d0b6c4f4 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Wed, 24 Feb 2016 11:29:06 -0500 Subject: Link the vpp application against libvnet.so, not libvnet.a Turn of srp, mainly as an example of how to restructure a featurette for selective disablement. Change-Id: Id3364c58a8711b103939f4434adfa67177380f67 Signed-off-by: Dave Barach --- vnet/Makefile.am | 14 ++------------ vnet/vnet/ethernet/arp.c | 4 ++++ vnet/vnet/ethernet/ethernet.h | 3 +++ vnet/vnet/ethernet/init.c | 7 +++++++ vnet/vnet/ethernet/node.c | 16 ++++++++++++++++ vnet/vnet/srp/node.c | 9 ++++++--- vnet/vnet/srp/srp.h | 1 + 7 files changed, 39 insertions(+), 15 deletions(-) (limited to 'vnet') diff --git a/vnet/Makefile.am b/vnet/Makefile.am index f44bb124..fc5a3ec9 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 35488316..3eb6a113 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 = ðernet_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 266e1d79..04e07b71 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 4ac14e20..42788f02 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 = ðernet_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 9c943992..9aed302f 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 = ðernet_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 = ðernet_main; + if (CLIB_DEBUG > 0) + { + ethernet_main_t * em = ðernet_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 42143ef6..0b232582 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 1b241710..48c447b7 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); -- cgit 1.2.3-korg