aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-05-14 18:01:44 -0400
committerFlorin Coras <florin.coras@gmail.com>2019-05-16 16:11:23 +0000
commitf8d50682cd1245f6f5ce4c846ca6f1bdc11255a6 (patch)
tree8ecc60e4715db88bdbc8ea6bd0170fbae6f645eb /src/vnet
parentc1f93067ed4b9954bbba82e2c9c104b22e2f7f33 (diff)
init / exit function ordering
The vlib init function subsystem now supports a mix of procedural and formally-specified ordering constraints. We should eliminate procedural knowledge wherever possible. The following schemes are *roughly* equivalent: static clib_error_t *init_runs_first (vlib_main_t *vm) { clib_error_t *error; ... do some stuff... if ((error = vlib_call_init_function (init_runs_next))) return error; ... } VLIB_INIT_FUNCTION (init_runs_first); and static clib_error_t *init_runs_first (vlib_main_t *vm) { ... do some stuff... } VLIB_INIT_FUNCTION (init_runs_first) = { .runs_before = VLIB_INITS("init_runs_next"), }; The first form will [most likely] call "init_runs_next" on the spot. The second form means that "init_runs_first" runs before "init_runs_next," possibly much earlier in the sequence. Please DO NOT construct sets of init functions where A before B actually means A *right before* B. It's not necessary - simply combine A and B - and it leads to hugely annoying debugging exercises when trying to switch from ad-hoc procedural ordering constraints to formal ordering constraints. Change-Id: I5e4353503bf43b4acb11a45fb33c79a5ade8426c Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/adj/adj_bfd.c14
-rw-r--r--src/vnet/classify/in_out_acl.c12
-rw-r--r--src/vnet/cop/cop.c63
-rw-r--r--src/vnet/devices/virtio/vhost_user.c12
-rw-r--r--src/vnet/dpo/dpo.c13
-rw-r--r--src/vnet/ethernet/arp.c12
-rw-r--r--src/vnet/ethernet/ethernet.h1
-rw-r--r--src/vnet/ethernet/init.c35
-rwxr-xr-xsrc/vnet/ethernet/node.c10
-rw-r--r--src/vnet/fib/fib.c14
-rw-r--r--src/vnet/fib/fib_bfd.c14
-rw-r--r--src/vnet/ip/ip_init.c60
-rw-r--r--src/vnet/ipfix-export/flow_report.c2
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe_adjacency.c2
-rw-r--r--src/vnet/misc.c37
-rw-r--r--src/vnet/mpls/mpls_input.c21
-rw-r--r--src/vnet/udp/udp.c19
-rw-r--r--src/vnet/unix/tuntap.c12
-rw-r--r--src/vnet/vxlan-gbp/vxlan_gbp.c13
19 files changed, 166 insertions, 200 deletions
diff --git a/src/vnet/adj/adj_bfd.c b/src/vnet/adj/adj_bfd.c
index b7ff64dcccf..2d787d41ab6 100644
--- a/src/vnet/adj/adj_bfd.c
+++ b/src/vnet/adj/adj_bfd.c
@@ -280,16 +280,16 @@ const static adj_delegate_vft_t adj_delegate_vft = {
static clib_error_t *
adj_bfd_main_init (vlib_main_t * vm)
{
- clib_error_t * error = NULL;
-
- if ((error = vlib_call_init_function (vm, bfd_main_init)))
- return (error);
-
bfd_register_listener(adj_bfd_notify);
adj_delegate_register_type (ADJ_DELEGATE_BFD, &adj_delegate_vft);
- return (error);
+ return (0);
}
-VLIB_INIT_FUNCTION (adj_bfd_main_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (adj_bfd_main_init)=
+{
+ .runs_after = VLIB_INITS("bfd_main_init"),
+};
+/* *INDENT-ON* */
diff --git a/src/vnet/classify/in_out_acl.c b/src/vnet/classify/in_out_acl.c
index 553c353b7ae..7f5a926212c 100644
--- a/src/vnet/classify/in_out_acl.c
+++ b/src/vnet/classify/in_out_acl.c
@@ -251,10 +251,6 @@ clib_error_t *
in_out_acl_init (vlib_main_t * vm)
{
in_out_acl_main_t *am = &in_out_acl_main;
- clib_error_t *error = 0;
-
- if ((error = vlib_call_init_function (vm, ip_in_out_acl_init)))
- return error;
am->vlib_main = vm;
am->vnet_main = vnet_get_main ();
@@ -262,8 +258,12 @@ in_out_acl_init (vlib_main_t * vm)
return 0;
}
-
-VLIB_INIT_FUNCTION (in_out_acl_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (in_out_acl_init) =
+{
+ .runs_after = VLIB_INITS("ip_in_out_acl_init"),
+};
+/* *INDENT-ON* */
uword
unformat_acl_type (unformat_input_t * input, va_list * args)
diff --git a/src/vnet/cop/cop.c b/src/vnet/cop/cop.c
index 700bd7348ed..edd09856092 100644
--- a/src/vnet/cop/cop.c
+++ b/src/vnet/cop/cop.c
@@ -29,7 +29,7 @@ cop_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
clib_memset (data, 0, sizeof(*data));
- /*
+ /*
* Ignore local interface, pg interfaces. $$$ need a #define for the
* first "real" interface. The answer is 5 at the moment.
*/
@@ -41,7 +41,7 @@ cop_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
{
ccm = &cm->cop_config_mains[address_family];
- /*
+ /*
* Once-only code to initialize the per-address-family
* cop feature subgraphs.
* Since the (single) start-node, cop-input, must be able
@@ -60,8 +60,8 @@ cop_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
[IP4_RX_COP_WHITELIST] = "ip4-cop-whitelist",
[IP4_RX_COP_INPUT] = "ip4-input",
};
-
- vnet_config_init (vm, &ccm->config_main,
+
+ vnet_config_init (vm, &ccm->config_main,
start_nodes, ARRAY_LEN(start_nodes),
feature_nodes, ARRAY_LEN(feature_nodes));
}
@@ -73,7 +73,7 @@ cop_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
[IP6_RX_COP_WHITELIST] = "ip6-cop-whitelist",
[IP6_RX_COP_INPUT] = "ip6-input",
};
- vnet_config_init (vm, &ccm->config_main,
+ vnet_config_init (vm, &ccm->config_main,
start_nodes, ARRAY_LEN(start_nodes),
feature_nodes, ARRAY_LEN(feature_nodes));
}
@@ -86,7 +86,7 @@ cop_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
[DEFAULT_RX_COP_WHITELIST] = "default-cop-whitelist",
[DEFAULT_RX_COP_INPUT] = "ethernet-input",
};
- vnet_config_init (vm, &ccm->config_main,
+ vnet_config_init (vm, &ccm->config_main,
start_nodes, ARRAY_LEN(start_nodes),
feature_nodes, ARRAY_LEN(feature_nodes));
}
@@ -109,15 +109,15 @@ cop_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
default_next = IP6_RX_COP_INPUT;
else
default_next = DEFAULT_RX_COP_INPUT;
-
+
if (is_add)
ci = vnet_config_add_feature (vm, &ccm->config_main,
- ci,
+ ci,
default_next,
data, sizeof(*data));
else
ci = vnet_config_del_feature (vm, &ccm->config_main,
- ci,
+ ci,
default_next,
data, sizeof(*data));
@@ -132,13 +132,6 @@ static clib_error_t *
cop_init (vlib_main_t *vm)
{
cop_main_t * cm = &cop_main;
- clib_error_t * error;
-
- if ((error = vlib_call_init_function (vm, ip4_whitelist_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, ip6_whitelist_init)))
- return error;
cm->vlib_main = vm;
cm->vnet_main = vnet_get_main();
@@ -146,7 +139,12 @@ cop_init (vlib_main_t *vm)
return 0;
}
-VLIB_INIT_FUNCTION (cop_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (cop_init) =
+{
+ .runs_after = VLIB_INITS ("ip4_whitelist_init", "ip6_whitelist_init"),
+};
+/* *INDENT-ON* */
int cop_interface_enable_disable (u32 sw_if_index, int enable_disable)
{
@@ -159,11 +157,11 @@ int cop_interface_enable_disable (u32 sw_if_index, int enable_disable)
sw = vnet_get_sw_interface (cm->vnet_main, sw_if_index);
if (sw->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
-
- /*
+
+ /*
* Redirect pkts from the driver to the cop node.
* Returns VNET_API_ERROR_UNIMPLEMENTED if the h/w driver
- * doesn't implement the API.
+ * doesn't implement the API.
*
* Node_index = ~0 => shut off redirection
*/
@@ -180,7 +178,7 @@ cop_enable_disable_command_fn (vlib_main_t * vm,
cop_main_t * cm = &cop_main;
u32 sw_if_index = ~0;
int enable_disable = 1;
-
+
int rv;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
@@ -195,7 +193,7 @@ cop_enable_disable_command_fn (vlib_main_t * vm,
if (sw_if_index == ~0)
return clib_error_return (0, "Please specify an interface...");
-
+
rv = cop_interface_enable_disable (sw_if_index, enable_disable);
switch(rv) {
@@ -203,7 +201,7 @@ cop_enable_disable_command_fn (vlib_main_t * vm,
break;
case VNET_API_ERROR_INVALID_SW_IF_INDEX:
- return clib_error_return
+ return clib_error_return
(0, "Invalid interface, only works on physical ports");
break;
@@ -220,7 +218,7 @@ cop_enable_disable_command_fn (vlib_main_t * vm,
VLIB_CLI_COMMAND (cop_interface_command, static) = {
.path = "cop interface",
- .short_help =
+ .short_help =
"cop interface <interface-name> [disable]",
.function = cop_enable_disable_command_fn,
};
@@ -246,10 +244,10 @@ int cop_whitelist_enable_disable (cop_whitelist_enable_disable_args_t *a)
*/
for (address_family = VNET_COP_IP4; address_family < VNET_N_COPS;
- address_family++)
+ address_family++)
{
ccm = &cm->cop_config_mains[address_family];
-
+
switch(address_family)
{
case VNET_COP_IP4:
@@ -267,7 +265,7 @@ int cop_whitelist_enable_disable (cop_whitelist_enable_disable_args_t *a)
continue;
}
break;
-
+
case VNET_COP_IP6:
is_add = (a->ip6 != 0);
next_to_add_del = IP6_RX_COP_WHITELIST;
@@ -287,7 +285,7 @@ int cop_whitelist_enable_disable (cop_whitelist_enable_disable_args_t *a)
is_add = (a->default_cop != 0);
next_to_add_del = DEFAULT_RX_COP_WHITELIST;
break;
-
+
default:
clib_warning ("BUG");
}
@@ -343,7 +341,7 @@ cop_whitelist_enable_disable_command_fn (vlib_main_t * vm,
if (sw_if_index == ~0)
return clib_error_return (0, "Please specify an interface...");
-
+
a->sw_if_index = sw_if_index;
a->ip4 = ip4;
a->ip6 = ip6;
@@ -357,12 +355,12 @@ cop_whitelist_enable_disable_command_fn (vlib_main_t * vm,
break;
case VNET_API_ERROR_INVALID_SW_IF_INDEX:
- return clib_error_return
+ return clib_error_return
(0, "Invalid interface, only works on physical ports");
break;
case VNET_API_ERROR_NO_SUCH_FIB:
- return clib_error_return
+ return clib_error_return
(0, "Invalid fib");
break;
@@ -380,8 +378,7 @@ cop_whitelist_enable_disable_command_fn (vlib_main_t * vm,
VLIB_CLI_COMMAND (cop_whitelist_command, static) = {
.path = "cop whitelist",
- .short_help =
+ .short_help =
"cop whitelist <interface-name> [ip4][ip6][default][fib-id <NN>][disable]",
.function = cop_whitelist_enable_disable_command_fn,
};
-
diff --git a/src/vnet/devices/virtio/vhost_user.c b/src/vnet/devices/virtio/vhost_user.c
index 1d52b42b73b..72b71f98763 100644
--- a/src/vnet/devices/virtio/vhost_user.c
+++ b/src/vnet/devices/virtio/vhost_user.c
@@ -953,14 +953,9 @@ vhost_user_socksvr_accept_ready (clib_file_t * uf)
static clib_error_t *
vhost_user_init (vlib_main_t * vm)
{
- clib_error_t *error;
vhost_user_main_t *vum = &vhost_user_main;
vlib_thread_main_t *tm = vlib_get_thread_main ();
- error = vlib_call_init_function (vm, ip4_init);
- if (error)
- return error;
-
vum->log_default = vlib_log_register_class ("vhost-user", 0);
vum->coalesce_frames = 32;
@@ -983,7 +978,12 @@ vhost_user_init (vlib_main_t * vm)
return 0;
}
-VLIB_INIT_FUNCTION (vhost_user_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (vhost_user_init) =
+{
+ .runs_after = VLIB_INITS("ip4_init"),
+};
+/* *INDENT-ON* */
static uword
vhost_user_send_interrupt_process (vlib_main_t * vm,
diff --git a/src/vnet/dpo/dpo.c b/src/vnet/dpo/dpo.c
index df78456bf60..13ae37a74a8 100644
--- a/src/vnet/dpo/dpo.c
+++ b/src/vnet/dpo/dpo.c
@@ -16,7 +16,7 @@
* @brief
* A Data-Path Object is an object that represents actions that are
* applied to packets are they are switched through VPP.
- *
+ *
* The DPO is a base class that is specialised by other objects to provide
* concrete actions
*
@@ -267,10 +267,10 @@ dpo_copy (dpo_id_t *dst,
* the destination is written in a single u64 write - hence atomically w.r.t
* any packets inflight.
*/
- *((u64*)dst) = *(u64*)src;
+ *((u64*)dst) = *(u64*)src;
dpo_lock(dst);
- dpo_unlock(&tmp);
+ dpo_unlock(&tmp);
}
int
@@ -592,7 +592,12 @@ dpo_module_init (vlib_main_t * vm)
return (NULL);
}
-VLIB_INIT_FUNCTION(dpo_module_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION(dpo_module_init) =
+{
+ .runs_before = VLIB_INITS ("ip_main_init"),
+};
+/* *INDENT-ON* */
static clib_error_t *
dpo_memory_show (vlib_main_t * vm,
diff --git a/src/vnet/ethernet/arp.c b/src/vnet/ethernet/arp.c
index 12c3fa47eac..f294893d846 100644
--- a/src/vnet/ethernet/arp.c
+++ b/src/vnet/ethernet/arp.c
@@ -1761,12 +1761,8 @@ ethernet_arp_init (vlib_main_t * vm)
{
ethernet_arp_main_t *am = &ethernet_arp_main;
ip4_main_t *im = &ip4_main;
- clib_error_t *error;
pg_node_t *pn;
- if ((error = vlib_call_init_function (vm, ethernet_init)))
- return error;
-
ethernet_register_input_type (vm, ETHERNET_TYPE_ARP, arp_input_node.index);
pn = pg_get_node (arp_input_node.index);
@@ -1809,8 +1805,12 @@ ethernet_arp_init (vlib_main_t * vm)
return 0;
}
-
-VLIB_INIT_FUNCTION (ethernet_arp_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (ethernet_arp_init) =
+{
+ .runs_after = VLIB_INITS("ethernet_init"),
+};
+/* *INDENT-ON* */
static void
arp_entry_free (ethernet_arp_interface_t * eai, ethernet_arp_ip4_entry_t * e)
diff --git a/src/vnet/ethernet/ethernet.h b/src/vnet/ethernet/ethernet.h
index 94322a715f9..344705b0cc3 100644
--- a/src/vnet/ethernet/ethernet.h
+++ b/src/vnet/ethernet/ethernet.h
@@ -544,6 +544,7 @@ u8 *ethernet_build_rewrite (vnet_main_t * vnm,
vnet_link_t link_type, const void *dst_address);
const u8 *ethernet_ip4_mcast_dst_addr (void);
const u8 *ethernet_ip6_mcast_dst_addr (void);
+void ethernet_input_init (vlib_main_t * vm, ethernet_main_t * em);
extern vlib_node_registration_t ethernet_input_node;
diff --git a/src/vnet/ethernet/init.c b/src/vnet/ethernet/init.c
index 5d10c60fd5f..9fd95f1b75a 100644
--- a/src/vnet/ethernet/init.c
+++ b/src/vnet/ethernet/init.c
@@ -83,14 +83,6 @@ 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;
@@ -101,17 +93,28 @@ ethernet_init (vlib_main_t * vm)
#include "types.def"
#undef ethernet_type
- if ((error = vlib_call_init_function (vm, llc_init)))
- return error;
- if ((error = vlib_call_init_function (vm, ethernet_input_init)))
- return error;
- if ((error = vlib_call_init_function (vm, vnet_feature_init)))
- return error;
-
+ /*
+ * ethernet_input_init is effectively part of this function.
+ * Simply ensuring that it happens after we set up the hash tables
+ * is not sufficient.
+ */
+ ethernet_input_init (vm, em);
return 0;
}
-VLIB_INIT_FUNCTION (ethernet_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (ethernet_init) =
+{
+ /*
+ * Set up the L2 path before ethernet_init, or we'll wipe out the L2 ARP
+ * registration set up by ethernet_arp_init.
+ */
+ .init_order = VLIB_INITS("l2_init",
+ "ethernet_init",
+ "llc_init",
+ "vnet_feature_init"),
+};
+/* *INDENT-ON* */
ethernet_main_t *
ethernet_get_main (vlib_main_t * vm)
diff --git a/src/vnet/ethernet/node.c b/src/vnet/ethernet/node.c
index 87c447f44d3..286ec3c0e78 100755
--- a/src/vnet/ethernet/node.c
+++ b/src/vnet/ethernet/node.c
@@ -2025,11 +2025,9 @@ next_by_ethertype_register (next_by_ethertype_t * l3_next,
return 0;
}
-
-static clib_error_t *
-ethernet_input_init (vlib_main_t * vm)
+void
+ethernet_input_init (vlib_main_t * vm, ethernet_main_t * em)
{
- ethernet_main_t *em = &ethernet_main;
__attribute__ ((unused)) vlan_table_t *invalid_vlan_table;
__attribute__ ((unused)) qinq_table_t *invalid_qinq_table;
@@ -2048,12 +2046,8 @@ ethernet_input_init (vlib_main_t * vm)
pool_get (em->vlan_pool, invalid_vlan_table); // first id = 0
// The first qinq pool will always be reserved for an invalid table
pool_get (em->qinq_pool, invalid_qinq_table); // first id = 0
-
- return 0;
}
-VLIB_INIT_FUNCTION (ethernet_input_init);
-
void
ethernet_register_input_type (vlib_main_t * vm,
ethernet_type_t type, u32 node_index)
diff --git a/src/vnet/fib/fib.c b/src/vnet/fib/fib.c
index 413f93e893c..28e18dded23 100644
--- a/src/vnet/fib/fib.c
+++ b/src/vnet/fib/fib.c
@@ -22,13 +22,6 @@
static clib_error_t *
fib_module_init (vlib_main_t * vm)
{
- clib_error_t * error;
-
- if ((error = vlib_call_init_function (vm, dpo_module_init)))
- return (error);
- if ((error = vlib_call_init_function (vm, adj_module_init)))
- return (error);
-
fib_entry_module_init();
fib_entry_src_module_init();
fib_path_module_init();
@@ -38,4 +31,9 @@ fib_module_init (vlib_main_t * vm)
return (NULL);
}
-VLIB_INIT_FUNCTION (fib_module_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (fib_module_init) =
+{
+ .runs_after = VLIB_INITS("dpo_module_init", "adj_module_init"),
+};
+/* *INDENT-ON* */
diff --git a/src/vnet/fib/fib_bfd.c b/src/vnet/fib/fib_bfd.c
index ae7ceec1a6b..f785ba2e68f 100644
--- a/src/vnet/fib/fib_bfd.c
+++ b/src/vnet/fib/fib_bfd.c
@@ -183,14 +183,14 @@ fib_bfd_notify (bfd_listen_event_e event,
static clib_error_t *
fib_bfd_main_init (vlib_main_t * vm)
{
- clib_error_t * error = NULL;
-
- if ((error = vlib_call_init_function (vm, bfd_main_init)))
- return (error);
-
bfd_register_listener(fib_bfd_notify);
- return (error);
+ return (NULL);
}
-VLIB_INIT_FUNCTION (fib_bfd_main_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (fib_bfd_main_init) =
+{
+ .runs_after = VLIB_INITS("bfd_main_init"),
+};
+/* *INDENT-ON* */
diff --git a/src/vnet/ip/ip_init.c b/src/vnet/ip/ip_init.c
index 638cbd167db..b3ab90d6dc3 100644
--- a/src/vnet/ip/ip_init.c
+++ b/src/vnet/ip/ip_init.c
@@ -101,50 +101,28 @@ do { \
}
}
- if ((error = vlib_call_init_function (vm, vnet_main_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, ip4_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, ip6_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, icmp4_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, icmp6_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, ip6_hop_by_hop_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, udp_local_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, udp_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, ip_classify_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, in_out_acl_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, policer_classify_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, flow_classify_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, dns_init)))
- return error;
-
return error;
}
-VLIB_INIT_FUNCTION (ip_main_init);
-
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (ip_main_init) =
+{
+ .init_order =
+ VLIB_INITS ("vnet_main_init",
+ "ip4_init",
+ "ip6_init",
+ "icmp4_init",
+ "icmp6_init",
+ "ip6_hop_by_hop_init",
+ "udp_local_init",
+ "udp_init",
+ "ip_classify_init",
+ "in_out_acl_init",
+ "policer_classify_init",
+ "flow_classify_init",
+ "dns_init"),
+};
+/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vnet/ipfix-export/flow_report.c b/src/vnet/ipfix-export/flow_report.c
index 103392ad81e..d904479c9c9 100644
--- a/src/vnet/ipfix-export/flow_report.c
+++ b/src/vnet/ipfix-export/flow_report.c
@@ -607,7 +607,7 @@ flow_report_init (vlib_main_t * vm)
return 0;
}
-VLIB_INIT_FUNCTION (flow_report_init)
+VLIB_INIT_FUNCTION (flow_report_init);
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vnet/lisp-gpe/lisp_gpe_adjacency.c b/src/vnet/lisp-gpe/lisp_gpe_adjacency.c
index 7361e8eb0d6..1b53e4dd9fe 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_adjacency.c
+++ b/src/vnet/lisp-gpe/lisp_gpe_adjacency.c
@@ -592,7 +592,7 @@ lisp_gpe_adj_module_init (vlib_main_t * vm)
return (NULL);
}
-VLIB_INIT_FUNCTION (lisp_gpe_adj_module_init)
+VLIB_INIT_FUNCTION (lisp_gpe_adj_module_init);
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vnet/misc.c b/src/vnet/misc.c
index ff85e3dedfe..ab0f823cb65 100644
--- a/src/vnet/misc.c
+++ b/src/vnet/misc.c
@@ -74,31 +74,9 @@ clib_error_t *
vnet_main_init (vlib_main_t * vm)
{
vnet_main_t *vnm = vnet_get_main ();
- clib_error_t *error;
u32 hw_if_index;
vnet_hw_interface_t *hw;
- if ((error = vlib_call_init_function (vm, vnet_interface_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, fib_module_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, mfib_module_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, ip_main_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, ip4_lookup_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, ip6_lookup_init)))
- return error;
-
- if ((error = vlib_call_init_function (vm, mpls_init)))
- return error;
-
vnm->vlib_main = vm;
hw_if_index = vnet_register_interface
@@ -117,7 +95,20 @@ vnet_main_init (vlib_main_t * vm)
return 0;
}
-VLIB_INIT_FUNCTION (vnet_main_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (vnet_main_init)=
+{
+ .init_order = VLIB_INITS("vnet_interface_init",
+ "ethernet_init",
+ "fib_module_init",
+ "mfib_module_init",
+ "ip_main_init",
+ "ip4_lookup_init",
+ "ip6_lookup_init",
+ "mpls_init",
+ "vnet_main_init"),
+};
+/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vnet/mpls/mpls_input.c b/src/vnet/mpls/mpls_input.c
index 1dd5e326a3c..37fa1aead12 100644
--- a/src/vnet/mpls/mpls_input.c
+++ b/src/vnet/mpls/mpls_input.c
@@ -50,8 +50,8 @@ format_mpls_input_trace (u8 * s, va_list * args)
#define _(a,b) if (t->next_index == MPLS_INPUT_NEXT_##a) next_name = b;
foreach_mpls_input_next;
#undef _
-
- s = format (s, "MPLS: next %s[%d] label %d ttl %d exp %d",
+
+ s = format (s, "MPLS: next %s[%d] label %d ttl %d exp %d",
next_name, t->next_index,
vnet_mpls_uc_get_label(label),
vnet_mpls_uc_get_ttl(label),
@@ -209,9 +209,9 @@ mpls_input_inline (vlib_main_t * vm,
vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1);
}
- if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
+ if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
{
- mpls_input_trace_t *tr = vlib_add_trace (vm, node,
+ mpls_input_trace_t *tr = vlib_add_trace (vm, node,
b0, sizeof (*tr));
tr->next_index = next0;
tr->label_net_byte_order = *(u32*)h0;
@@ -278,16 +278,15 @@ mpls_setup_nodes (vlib_main_t * vm)
static clib_error_t * mpls_input_init (vlib_main_t * vm)
{
- clib_error_t * error;
-
- error = vlib_call_init_function (vm, mpls_init);
- if (error)
- clib_error_report (error);
-
mpls_setup_nodes (vm);
return 0;
}
-VLIB_INIT_FUNCTION (mpls_input_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (mpls_input_init) =
+{
+ .runs_after = VLIB_INITS("mpls_init"),
+};
+/* *INDENT-ON* */
#endif /* CLIB_MARCH_VARIANT */
diff --git a/src/vnet/udp/udp.c b/src/vnet/udp/udp.c
index d5166d9142e..81bdb8bd0e4 100644
--- a/src/vnet/udp/udp.c
+++ b/src/vnet/udp/udp.c
@@ -395,17 +395,9 @@ udp_init (vlib_main_t * vm)
ip_main_t *im = &ip_main;
vlib_thread_main_t *tm = vlib_get_thread_main ();
u32 num_threads;
- clib_error_t *error = 0;
ip_protocol_info_t *pi;
int i;
- if ((error = vlib_call_init_function (vm, ip_main_init)))
- return error;
- if ((error = vlib_call_init_function (vm, ip4_lookup_init)))
- return error;
- if ((error = vlib_call_init_function (vm, ip6_lookup_init)))
- return error;
-
/*
* Registrations
*/
@@ -443,10 +435,17 @@ udp_init (vlib_main_t * vm)
clib_spinlock_init (&um->peekers_readers_locks[i]);
clib_spinlock_init (&um->peekers_write_locks[i]);
}
- return error;
+ return 0;
}
-VLIB_INIT_FUNCTION (udp_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (udp_init) =
+{
+ .runs_after = VLIB_INITS("ip_main_init", "ip4_lookup_init",
+ "ip6_lookup_init"),
+};
+/* *INDENT-ON* */
+
static clib_error_t *
show_udp_punt_fn (vlib_main_t * vm, unformat_input_t * input,
diff --git a/src/vnet/unix/tuntap.c b/src/vnet/unix/tuntap.c
index 103b6496a34..9d6f8992414 100644
--- a/src/vnet/unix/tuntap.c
+++ b/src/vnet/unix/tuntap.c
@@ -1011,7 +1011,6 @@ VNET_DEVICE_CLASS (tuntap_dev_class,static) = {
static clib_error_t *
tuntap_init (vlib_main_t * vm)
{
- clib_error_t *error;
ip4_main_t *im4 = &ip4_main;
ip6_main_t *im6 = &ip6_main;
ip4_add_del_interface_address_callback_t cb4;
@@ -1019,10 +1018,6 @@ tuntap_init (vlib_main_t * vm)
tuntap_main_t *tm = &tuntap_main;
vlib_thread_main_t *m = vlib_get_thread_main ();
- error = vlib_call_init_function (vm, ip4_init);
- if (error)
- return error;
-
mhash_init (&tm->subif_mhash, sizeof (u32), sizeof (subif_address_t));
cb4.function = tuntap_ip4_add_del_interface_address;
@@ -1038,7 +1033,12 @@ tuntap_init (vlib_main_t * vm)
return 0;
}
-VLIB_INIT_FUNCTION (tuntap_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (tuntap_init) =
+{
+ .runs_after = VLIB_INITS("ip4_init"),
+};
+/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vnet/vxlan-gbp/vxlan_gbp.c b/src/vnet/vxlan-gbp/vxlan_gbp.c
index e39c26fc5d1..001de73b840 100644
--- a/src/vnet/vxlan-gbp/vxlan_gbp.c
+++ b/src/vnet/vxlan-gbp/vxlan_gbp.c
@@ -1144,14 +1144,10 @@ clib_error_t *
vxlan_gbp_init (vlib_main_t * vm)
{
vxlan_gbp_main_t *vxm = &vxlan_gbp_main;
- clib_error_t *error;
vxm->vnet_main = vnet_get_main ();
vxm->vlib_main = vm;
- if ((error = vlib_call_init_function (vm, punt_init)))
- return (error);
-
/* initialize the ip6 hash */
clib_bihash_init_16_8 (&vxm->vxlan4_gbp_tunnel_by_key, "vxlan4-gbp",
VXLAN_GBP_HASH_NUM_BUCKETS,
@@ -1175,10 +1171,15 @@ vxlan_gbp_init (vlib_main_t * vm)
"VXLAN-GBP-no-such-v6-tunnel",
&vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP6]);
- return (error);
+ return (0);
}
-VLIB_INIT_FUNCTION (vxlan_gbp_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (vxlan_gbp_init) =
+{
+ .runs_after = VLIB_INITS("punt_init"),
+};
+/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON