diff options
author | Dave Barach <dave@barachs.net> | 2019-05-14 18:01:44 -0400 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2019-05-16 16:11:23 +0000 |
commit | f8d50682cd1245f6f5ce4c846ca6f1bdc11255a6 (patch) | |
tree | 8ecc60e4715db88bdbc8ea6bd0170fbae6f645eb /src/plugins | |
parent | c1f93067ed4b9954bbba82e2c9c104b22e2f7f33 (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/plugins')
30 files changed, 194 insertions, 192 deletions
diff --git a/src/plugins/abf/abf_itf_attach.c b/src/plugins/abf/abf_itf_attach.c index 151fb988edf..9569306ec2a 100644 --- a/src/plugins/abf/abf_itf_attach.c +++ b/src/plugins/abf/abf_itf_attach.c @@ -764,7 +764,12 @@ abf_itf_bond_init (vlib_main_t * vm) return (NULL); } -VLIB_INIT_FUNCTION (abf_itf_bond_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (abf_itf_bond_init) = +{ + .runs_after = VLIB_INITS("acl_init"), +}; +/* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c index 7d01149a1a0..74b6ab4e4b0 100644 --- a/src/plugins/avf/device.c +++ b/src/plugins/avf/device.c @@ -1433,12 +1433,8 @@ clib_error_t * avf_init (vlib_main_t * vm) { avf_main_t *am = &avf_main; - clib_error_t *error; vlib_thread_main_t *tm = vlib_get_thread_main (); - if ((error = vlib_call_init_function (vm, pci_bus_init))) - return error; - vec_validate_aligned (am->per_thread_data, tm->n_vlib_mains - 1, CLIB_CACHE_LINE_BYTES); @@ -1448,7 +1444,12 @@ avf_init (vlib_main_t * vm) return 0; } -VLIB_INIT_FUNCTION (avf_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (avf_init) = +{ + .runs_after = VLIB_INITS ("pci_bus_init"), +}; +/* *INDENT-OFF* */ /* * fd.io coding-style-patch-verification: ON diff --git a/src/plugins/cdp/cdp_input.c b/src/plugins/cdp/cdp_input.c index 946aaf7f845..dbe179ad095 100644 --- a/src/plugins/cdp/cdp_input.c +++ b/src/plugins/cdp/cdp_input.c @@ -408,15 +408,11 @@ cdp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0) static clib_error_t * cdp_input_init (vlib_main_t * vm) { - clib_error_t *error; cdp_main_t *cm = &cdp_main; void vnet_cdp_node_reference (void); vnet_cdp_node_reference (); - if ((error = vlib_call_init_function (vm, cdp_periodic_init))) - return error; - cm->vlib_main = vm; cm->vnet_main = vnet_get_main (); cm->neighbor_by_sw_if_index = hash_create (0, sizeof (uword)); @@ -424,7 +420,12 @@ cdp_input_init (vlib_main_t * vm) return 0; } -VLIB_INIT_FUNCTION (cdp_input_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (cdp_input_init) = +{ + .runs_after = VLIB_INITS("cdp_periodic_init"), +}; +/* *INDENT-ON* */ static u8 * diff --git a/src/plugins/crypto_ia32/main.c b/src/plugins/crypto_ia32/main.c index 45bf34e7814..a02fc38f99e 100644 --- a/src/plugins/crypto_ia32/main.c +++ b/src/plugins/crypto_ia32/main.c @@ -97,10 +97,7 @@ crypto_ia32_init (vlib_main_t * vm) { crypto_ia32_main_t *cm = &crypto_ia32_main; vlib_thread_main_t *tm = vlib_get_thread_main (); - clib_error_t *error; - - if ((error = vlib_call_init_function (vm, vnet_crypto_init))) - return error; + clib_error_t *error = 0; vec_validate_aligned (cm->per_thread_data, tm->n_vlib_mains - 1, CLIB_CACHE_LINE_BYTES); @@ -124,7 +121,12 @@ error: return error; } -VLIB_INIT_FUNCTION (crypto_ia32_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (crypto_ia32_init) = +{ + .runs_after = VLIB_INITS ("vnet_crypto_init"), +}; +/* *INDENT-ON* */ #include <vpp/app/version.h> diff --git a/src/plugins/crypto_ipsecmb/ipsecmb.c b/src/plugins/crypto_ipsecmb/ipsecmb.c index 7495452eb29..fccc697cba3 100644 --- a/src/plugins/crypto_ipsecmb/ipsecmb.c +++ b/src/plugins/crypto_ipsecmb/ipsecmb.c @@ -475,9 +475,6 @@ crypto_ipsecmb_init (vlib_main_t * vm) u32 eidx; u8 *name; - if ((error = vlib_call_init_function (vm, vnet_crypto_init))) - return error; - if (!clib_cpu_supports_aes ()) return 0; @@ -547,7 +544,12 @@ crypto_ipsecmb_init (vlib_main_t * vm) return (NULL); } -VLIB_INIT_FUNCTION (crypto_ipsecmb_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (crypto_ipsecmb_init) = +{ + .runs_after = VLIB_INITS ("vnet_crypto_init"), +}; +/* *INDENT-ON* */ /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = diff --git a/src/plugins/crypto_openssl/main.c b/src/plugins/crypto_openssl/main.c index f6e153798c4..2132c5bb15a 100644 --- a/src/plugins/crypto_openssl/main.c +++ b/src/plugins/crypto_openssl/main.c @@ -232,13 +232,9 @@ crypto_openssl_init (vlib_main_t * vm) vlib_thread_main_t *tm = vlib_get_thread_main (); openssl_per_thread_data_t *ptd; u8 *seed_data = 0; - clib_error_t *error; time_t t; pid_t pid; - if ((error = vlib_call_init_function (vm, vnet_crypto_init))) - return error; - u32 eidx = vnet_crypto_register_engine (vm, "openssl", 50, "OpenSSL"); #define _(m, a, b) \ @@ -284,7 +280,13 @@ crypto_openssl_init (vlib_main_t * vm) return 0; } -VLIB_INIT_FUNCTION (crypto_openssl_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (crypto_openssl_init) = +{ + .runs_after = VLIB_INITS ("vnet_crypto_init"), +}; +/* *INDENT-ON* */ + /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { diff --git a/src/plugins/dpdk/api/dpdk_api.c b/src/plugins/dpdk/api/dpdk_api.c index 97c4bc75721..5ff8d5f2f41 100755 --- a/src/plugins/dpdk/api/dpdk_api.c +++ b/src/plugins/dpdk/api/dpdk_api.c @@ -297,10 +297,6 @@ dpdk_api_init (vlib_main_t * vm) dpdk_main_t *dm = &dpdk_main; clib_error_t *error = 0; - /* init CLI */ - if ((error = vlib_call_init_function (vm, dpdk_init))) - return error; - u8 *name; name = format (0, "dpdk_%08x%c", api_version, 0); @@ -320,8 +316,11 @@ dpdk_api_init (vlib_main_t * vm) return error; } -VLIB_INIT_FUNCTION (dpdk_api_init); - +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (dpdk_api_init) = +{ + .runs_after = VLIB_INITS ("dpdk_init"), +/* *INDENT-OFF* */ /* * fd.io coding-style-patch-verification: ON diff --git a/src/plugins/dpdk/device/cli.c b/src/plugins/dpdk/device/cli.c index 765b298f8a9..04cf37f5304 100644 --- a/src/plugins/dpdk/device/cli.c +++ b/src/plugins/dpdk/device/cli.c @@ -1737,6 +1737,12 @@ VLIB_CLI_COMMAND (show_vpe_version_command, static) = { }; /* *INDENT-ON* */ +/* Dummy function to get us linked in. */ +void +dpdk_cli_reference (void) +{ +} + clib_error_t * dpdk_cli_init (vlib_main_t * vm) { diff --git a/src/plugins/dpdk/device/dpdk.h b/src/plugins/dpdk/device/dpdk.h index bd9b35901d5..f79465cf8b4 100644 --- a/src/plugins/dpdk/device/dpdk.h +++ b/src/plugins/dpdk/device/dpdk.h @@ -512,6 +512,7 @@ clib_error_t *unformat_hqos (unformat_input_t * input, struct rte_pci_device *dpdk_get_pci_device (const struct rte_eth_dev_info *info); +void dpdk_cli_reference (void); #if CLI_DEBUG int dpdk_buffer_validate_trajectory_all (u32 * uninitialized); diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c index c83b2b57c4c..22ea659094b 100644 --- a/src/plugins/dpdk/device/init.c +++ b/src/plugins/dpdk/device/init.c @@ -1734,6 +1734,8 @@ dpdk_init (vlib_main_t * vm) STATIC_ASSERT (RTE_CACHE_LINE_SIZE == 1 << CLIB_LOG2_CACHE_LINE_BYTES, "DPDK RTE CACHE LINE SIZE does not match with 1<<CLIB_LOG2_CACHE_LINE_BYTES"); + dpdk_cli_reference (); + dm->vlib_main = vm; dm->vnet_main = vnet_get_main (); dm->conf = &dpdk_config_main; @@ -1751,10 +1753,6 @@ dpdk_init (vlib_main_t * vm) dm->stat_poll_interval = DPDK_STATS_POLL_INTERVAL; dm->link_state_poll_interval = DPDK_LINK_POLL_INTERVAL; - /* init CLI */ - if ((error = vlib_call_init_function (vm, dpdk_cli_init))) - return error; - dm->log_default = vlib_log_register_class ("dpdk", 0); return error; @@ -1762,7 +1760,6 @@ dpdk_init (vlib_main_t * vm) VLIB_INIT_FUNCTION (dpdk_init); - /* * fd.io coding-style-patch-verification: ON * diff --git a/src/plugins/dpdk/main.c b/src/plugins/dpdk/main.c index d22b671e008..a1ea9e32c93 100644 --- a/src/plugins/dpdk/main.c +++ b/src/plugins/dpdk/main.c @@ -85,16 +85,18 @@ static clib_error_t * dpdk_main_init (vlib_main_t * vm) dm->vlib_main = vm; dm->vnet_main = vnet_get_main (); - if ((error = vlib_call_init_function (vm, dpdk_init))) - return error; - /* register custom delay function */ rte_delay_us_callback_register (rte_delay_us_override_cb); return error; } -VLIB_INIT_FUNCTION (dpdk_main_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (dpdk_main_init) = +{ + .runs_after = VLIB_INITS("dpdk_init"), +}; +/* *INDENT-ON* */ clib_error_t * diff --git a/src/plugins/gbp/gbp_vxlan.c b/src/plugins/gbp/gbp_vxlan.c index 49dae7e9f4c..de635d0aa14 100644 --- a/src/plugins/gbp/gbp_vxlan.c +++ b/src/plugins/gbp/gbp_vxlan.c @@ -678,25 +678,24 @@ static clib_error_t * gbp_vxlan_init (vlib_main_t * vm) { vxlan_gbp_main_t *vxm = &vxlan_gbp_main; - clib_error_t *error; gt_logger = vlib_log_register_class ("gbp", "tun"); - if ((error = vlib_call_init_function (vm, punt_init))) - return error; - if ((error = vlib_call_init_function (vm, vxlan_gbp_init))) - return error; - punt_hdl = vlib_punt_client_register ("gbp-vxlan"); vlib_punt_register (punt_hdl, vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP4], "gbp-vxlan4"); - return (error); + return (0); } -VLIB_INIT_FUNCTION (gbp_vxlan_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (gbp_vxlan_init) = +{ + .runs_after = VLIB_INITS("punt_init", "vxlan_gbp_init"), +}; +/* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON diff --git a/src/plugins/igmp/igmp.c b/src/plugins/igmp/igmp.c index 7f828619331..4e2fce1b916 100644 --- a/src/plugins/igmp/igmp.c +++ b/src/plugins/igmp/igmp.c @@ -479,24 +479,24 @@ igmp_enable_disable (u32 sw_if_index, u8 enable, igmp_mode_t mode) static clib_error_t * igmp_init (vlib_main_t * vm) { - clib_error_t *error; igmp_main_t *im = &igmp_main; - if ((error = vlib_call_init_function (vm, ip4_lookup_init))) - return error; - im->igmp_api_client_by_client_index = hash_create (0, sizeof (u32)); im->logger = vlib_log_register_class ("igmp", 0); IGMP_DBG ("initialized"); - return (error); + return (0); } -VLIB_INIT_FUNCTION (igmp_init); /* *INDENT-OFF* */ -VLIB_PLUGIN_REGISTER () = { +VLIB_INIT_FUNCTION (igmp_init) = +{ + .runs_after = VLIB_INITS("ip4_lookup_init"), +}; +VLIB_PLUGIN_REGISTER () = +{ .version = VPP_BUILD_VER, .description = "Internet Group Management Protocol (IGMP)", }; diff --git a/src/plugins/igmp/igmp_input.c b/src/plugins/igmp/igmp_input.c index 83e11ec6cc5..d5f714bc033 100644 --- a/src/plugins/igmp/igmp_input.c +++ b/src/plugins/igmp/igmp_input.c @@ -445,19 +445,19 @@ VLIB_REGISTER_NODE (igmp_parse_report_node) = static clib_error_t * igmp_input_init (vlib_main_t * vm) { - clib_error_t *error; - - if ((error = vlib_call_init_function (vm, igmp_init))) - return error; - ip4_register_protocol (IP_PROTOCOL_IGMP, igmp_input_node.index); IGMP_DBG ("input-initialized"); - return (error); + return (0); } -VLIB_INIT_FUNCTION (igmp_input_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (igmp_input_init) = +{ + .runs_after = VLIB_INITS("igmp_init"), +}; +/* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON diff --git a/src/plugins/igmp/igmp_ssm_range.c b/src/plugins/igmp/igmp_ssm_range.c index 3d12712d3db..c74d312b508 100644 --- a/src/plugins/igmp/igmp_ssm_range.c +++ b/src/plugins/igmp/igmp_ssm_range.c @@ -138,20 +138,19 @@ VLIB_CLI_COMMAND (igmp_show_timers_command, static) = { static clib_error_t * igmp_ssm_range_init (vlib_main_t * vm) { - clib_error_t *error; - - if ((error = vlib_call_init_function (vm, igmp_init))) - return error; - igmp_ssm_range_populate (); IGMP_DBG ("ssm-range-initialized"); - return (error); + return (0); } -VLIB_INIT_FUNCTION (igmp_ssm_range_init); - +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (igmp_ssm_range_init) = +{ + .runs_after = VLIB_INITS("igmp_init"), +}; +/* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON diff --git a/src/plugins/ikev2/ikev2.c b/src/plugins/ikev2/ikev2.c index 2340137bb9c..e7b2f92941d 100644 --- a/src/plugins/ikev2/ikev2.c +++ b/src/plugins/ikev2/ikev2.c @@ -3295,13 +3295,9 @@ clib_error_t * ikev2_init (vlib_main_t * vm) { ikev2_main_t *km = &ikev2_main; - clib_error_t *error; vlib_thread_main_t *tm = vlib_get_thread_main (); int thread_id; - if ((error = vlib_call_init_function (vm, ipsec_init))) - return error; - clib_memset (km, 0, sizeof (ikev2_main_t)); km->vnet_main = vnet_get_main (); km->vlib_main = vm; @@ -3319,16 +3315,20 @@ ikev2_init (vlib_main_t * vm) km->sa_by_ispi = hash_create (0, sizeof (uword)); - - if ((error = vlib_call_init_function (vm, ikev2_cli_init))) - return error; - udp_register_dst_port (vm, 500, ikev2_node.index, 1); + ikev2_cli_reference (); + return 0; } -VLIB_INIT_FUNCTION (ikev2_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (ikev2_init) = +{ + .runs_after = VLIB_INITS("ipsec_init"), +}; +/* *INDENT-ON* */ + static u8 ikev2_mngr_process_child_sa (ikev2_sa_t * sa, ikev2_child_sa_t * csa) diff --git a/src/plugins/ikev2/ikev2.h b/src/plugins/ikev2/ikev2.h index 55731bff975..2feecf73fdb 100644 --- a/src/plugins/ikev2/ikev2.h +++ b/src/plugins/ikev2/ikev2.h @@ -422,6 +422,7 @@ uword unformat_ikev2_transform_dh_type (unformat_input_t * input, va_list * args); uword unformat_ikev2_transform_esn_type (unformat_input_t * input, va_list * args); +void ikev2_cli_reference (void); #endif /* __included_ikev2_h__ */ diff --git a/src/plugins/ikev2/ikev2_cli.c b/src/plugins/ikev2/ikev2_cli.c index 8801793be0b..0933667c4bd 100644 --- a/src/plugins/ikev2/ikev2_cli.c +++ b/src/plugins/ikev2/ikev2_cli.c @@ -584,15 +584,11 @@ VLIB_CLI_COMMAND (ikev2_initiate_command, static) = { }; /* *INDENT-ON* */ - -clib_error_t * -ikev2_cli_init (vlib_main_t * vm) +void +ikev2_cli_reference (void) { - return 0; } -VLIB_INIT_FUNCTION (ikev2_cli_init); - /* * fd.io coding-style-patch-verification: ON * diff --git a/src/plugins/ioam/analyse/ioam_summary_export.c b/src/plugins/ioam/analyse/ioam_summary_export.c index c16e8398bd3..4851491012b 100644 --- a/src/plugins/ioam/analyse/ioam_summary_export.c +++ b/src/plugins/ioam/analyse/ioam_summary_export.c @@ -427,15 +427,15 @@ ioam_flow_create (u8 del) clib_error_t * ioam_flow_report_init (vlib_main_t * vm) { - clib_error_t *error; - - if ((error = vlib_call_init_function (vm, flow_report_init))) - return error; - return 0; } -VLIB_INIT_FUNCTION (ioam_flow_report_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (ioam_flow_report_init) = +{ + .runs_after = VLIB_INITS("flow_report_init"), +}; +/* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON diff --git a/src/plugins/ioam/encap/ip6_ioam_e2e.c b/src/plugins/ioam/encap/ip6_ioam_e2e.c index cdaf740d251..58714083fe4 100644 --- a/src/plugins/ioam/encap/ip6_ioam_e2e.c +++ b/src/plugins/ioam/encap/ip6_ioam_e2e.c @@ -44,7 +44,7 @@ static u8 * ioam_e2e_trace_handler (u8 * s, return s; } -int +int ioam_e2e_config_handler (void *data, u8 disable) { int *analyse = data; @@ -171,13 +171,6 @@ VLIB_CLI_COMMAND (ioam_show_e2e_cmd, static) = { static clib_error_t * ioam_e2e_init (vlib_main_t * vm) { - clib_error_t * error; - - if ((error = vlib_call_init_function (vm, ip6_hop_by_hop_ioam_init))) - { - return(error); - } - /* * As of now we have only PPC under E2E header. */ @@ -213,4 +206,9 @@ ioam_e2e_init (vlib_main_t * vm) * Init function for the E2E lib. * ip6_hop_by_hop_ioam_e2e_init gets called during init. */ -VLIB_INIT_FUNCTION (ioam_e2e_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (ioam_e2e_init) = +{ + .runs_after = VLIB_INITS("ip6_hop_by_hop_ioam_init"), +}; +/* *INDENT-ON* */ diff --git a/src/plugins/ioam/encap/ip6_ioam_pot.c b/src/plugins/ioam/encap/ip6_ioam_pot.c index 8dd06c144e3..71c0cc92709 100644 --- a/src/plugins/ioam/encap/ip6_ioam_pot.c +++ b/src/plugins/ioam/encap/ip6_ioam_pot.c @@ -29,7 +29,7 @@ _(PROCESSED, "Pkts with ip6 hop-by-hop pot options") \ _(PROFILE_MISS, "Pkts with ip6 hop-by-hop pot options but no profile set") \ _(PASSED, "Pkts with POT in Policy") \ - _(FAILED, "Pkts with POT out of Policy") + _(FAILED, "Pkts with POT out of Policy") static char * ip6_hop_by_hop_ioam_pot_stats_strings[] = { #define _(sym,string) string, @@ -47,7 +47,7 @@ typedef enum { typedef struct { /* stats */ u64 counters[ARRAY_LEN(ip6_hop_by_hop_ioam_pot_stats_strings)]; - + /* convenience */ vlib_main_t * vlib_main; vnet_main_t * vnet_main; @@ -55,7 +55,7 @@ typedef struct { ip6_hop_by_hop_ioam_pot_main_t ip6_hop_by_hop_ioam_pot_main; -always_inline void +always_inline void ip6_ioam_stats_increment_counter (u32 counter_index, u64 increment) { ip6_hop_by_hop_ioam_pot_main_t *hm = &ip6_hop_by_hop_ioam_pot_main; @@ -69,13 +69,13 @@ static u8 * format_ioam_pot (u8 * s, va_list * args) ioam_pot_option_t * pot0 = va_arg (*args, ioam_pot_option_t *); u64 random, cumulative; random = cumulative = 0; - if (pot0) - { + if (pot0) + { random = clib_net_to_host_u64 (pot0->random); cumulative = clib_net_to_host_u64 (pot0->cumulative); } - s = format (s, "random = 0x%Lx, Cumulative = 0x%Lx, Index = 0x%x", + s = format (s, "random = 0x%Lx, Cumulative = 0x%Lx, Index = 0x%x", random, cumulative, pot0 ? pot0->reserved_profile_id : ~0); return s; } @@ -117,22 +117,22 @@ ip6_hbh_ioam_proof_of_transit_handler (vlib_buffer_t *b, pot0->reserved_profile_id = pot_profile_index & PROFILE_ID_MASK; pot_profile_incr_usage_stats(pot_profile); - } - else + } + else { /* Non encap node */ - if (PREDICT_FALSE(pot0->reserved_profile_id != - pot_profile_index || pot_profile == 0)) + if (PREDICT_FALSE(pot0->reserved_profile_id != + pot_profile_index || pot_profile == 0)) { /* New profile announced by encap node. */ new_profile = - pot_profile_find(pot0->reserved_profile_id); + pot_profile_find(pot0->reserved_profile_id); if (PREDICT_FALSE(new_profile == 0 || - new_profile->valid == 0)) + new_profile->valid == 0)) { ip6_ioam_stats_increment_counter (IP6_IOAM_POT_PROFILE_MISS, 1); return(-1); - } - else + } + else { pot_profile_index = pot0->reserved_profile_id; pot_profile = new_profile; @@ -143,7 +143,7 @@ ip6_hbh_ioam_proof_of_transit_handler (vlib_buffer_t *b, pot_profile_incr_usage_stats(pot_profile); } - if (pot0->random == 0) + if (pot0->random == 0) { pot0->random = clib_host_to_net_u64(pot_generate_random(pot_profile)); pot0->cumulative = 0; @@ -196,7 +196,7 @@ int ip6_hop_by_hop_ioam_pot_rewrite_handler (u8 *rewrite_string, u8 *rewrite_siz pot_option = (ioam_pot_option_t *)rewrite_string; pot_option->hdr.type = HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT | HBH_OPTION_TYPE_DATA_CHANGE_ENROUTE; - pot_option->hdr.length = sizeof (ioam_pot_option_t) - + pot_option->hdr.length = sizeof (ioam_pot_option_t) - sizeof (ip6_hop_by_hop_option_t); return(0); } @@ -235,15 +235,11 @@ static clib_error_t * ip6_hop_by_hop_ioam_pot_init (vlib_main_t * vm) { ip6_hop_by_hop_ioam_pot_main_t * hm = &ip6_hop_by_hop_ioam_pot_main; - clib_error_t * error; - - if ((error = vlib_call_init_function (vm, ip6_hop_by_hop_ioam_init))) - return(error); hm->vlib_main = vm; hm->vnet_main = vnet_get_main(); clib_memset(hm->counters, 0, sizeof(hm->counters)); - + if (ip6_hbh_register_option(HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT, ip6_hbh_ioam_proof_of_transit_handler, ip6_hbh_ioam_proof_of_transit_trace_handler) < 0) return (clib_error_create("registration of HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT failed")); @@ -260,6 +256,9 @@ ip6_hop_by_hop_ioam_pot_init (vlib_main_t * vm) return (0); } -VLIB_INIT_FUNCTION (ip6_hop_by_hop_ioam_pot_init); - - +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (ip6_hop_by_hop_ioam_pot_init) = +{ + .runs_after = VLIB_INITS("ip6_hop_by_hop_ioam_init"), +}; +/* *INDENT-OFF* */ diff --git a/src/plugins/ioam/encap/ip6_ioam_trace.c b/src/plugins/ioam/encap/ip6_ioam_trace.c index ddd9ae99dd5..53fb63ea6fd 100644 --- a/src/plugins/ioam/encap/ip6_ioam_trace.c +++ b/src/plugins/ioam/encap/ip6_ioam_trace.c @@ -417,16 +417,6 @@ static clib_error_t * ip6_hop_by_hop_ioam_trace_init (vlib_main_t * vm) { ip6_hop_by_hop_ioam_trace_main_t *hm = &ip6_hop_by_hop_ioam_trace_main; - clib_error_t *error; - - if ((error = vlib_call_init_function (vm, ip_main_init))) - return (error); - - if ((error = vlib_call_init_function (vm, ip6_lookup_init))) - return error; - - if ((error = vlib_call_init_function (vm, ip6_hop_by_hop_ioam_init))) - return (error); hm->vlib_main = vm; hm->vnet_main = vnet_get_main (); @@ -452,6 +442,14 @@ ip6_hop_by_hop_ioam_trace_init (vlib_main_t * vm) return (0); } +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (ip6_hop_by_hop_ioam_trace_init) = +{ + .runs_after = VLIB_INITS ("ip_main_init", "ip6_lookup_init", + "ip6_hop_by_hop_ioam_init"), +}; +/* *INDENT-ON* */ + int ip6_trace_profile_cleanup (void) { @@ -490,9 +488,6 @@ ip6_trace_profile_setup (void) return (0); } - -VLIB_INIT_FUNCTION (ip6_hop_by_hop_ioam_trace_init); - /* * fd.io coding-style-patch-verification: ON * diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam_trace.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam_trace.c index e2c130c00df..c51d251bee3 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam_trace.c +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam_trace.c @@ -436,16 +436,6 @@ static clib_error_t * vxlan_gpe_ioam_trace_init (vlib_main_t * vm) { vxlan_gpe_ioam_trace_main_t *hm = &vxlan_gpe_ioam_trace_main; - clib_error_t *error; - - if ((error = vlib_call_init_function (vm, ip_main_init))) - return (error); - - if ((error = vlib_call_init_function (vm, ip6_lookup_init))) - return error; - - if ((error = vlib_call_init_function (vm, vxlan_gpe_init))) - return (error); hm->vlib_main = vm; hm->vnet_main = vnet_get_main (); @@ -470,7 +460,14 @@ vxlan_gpe_ioam_trace_init (vlib_main_t * vm) return (0); } -VLIB_INIT_FUNCTION (vxlan_gpe_ioam_trace_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (vxlan_gpe_ioam_trace_init) = +{ + .runs_after = VLIB_INITS("ip_main_init", "ip6_lookup_init", + "vxlan_gpe_init"), +}; +/* *INDENT-ON* */ + int vxlan_gpe_trace_profile_cleanup (void) diff --git a/src/plugins/ioam/udp-ping/udp_ping_export.c b/src/plugins/ioam/udp-ping/udp_ping_export.c index 7a7cad4934a..d25eb1041dd 100644 --- a/src/plugins/ioam/udp-ping/udp_ping_export.c +++ b/src/plugins/ioam/udp-ping/udp_ping_export.c @@ -290,15 +290,16 @@ VLIB_CLI_COMMAND (set_udp_ping_export_command, static) = { clib_error_t * udp_ping_flow_report_init (vlib_main_t * vm) { - clib_error_t *error; - - if ((error = vlib_call_init_function (vm, flow_report_init))) - return error; - return 0; } -VLIB_INIT_FUNCTION (udp_ping_flow_report_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (udp_ping_flow_report_init) = +{ + .runs_after = VLIB_INITS ("flow_report_init"), +}; +/* *INDENT-ON* */ + /* * fd.io coding-style-patch-verification: ON diff --git a/src/plugins/ioam/udp-ping/udp_ping_node.c b/src/plugins/ioam/udp-ping/udp_ping_node.c index 59e4511eb7d..e5916dbd0e1 100644 --- a/src/plugins/ioam/udp-ping/udp_ping_node.c +++ b/src/plugins/ioam/udp-ping/udp_ping_node.c @@ -819,21 +819,21 @@ VLIB_REGISTER_NODE (udp_ping_local, static) = static clib_error_t * udp_ping_init (vlib_main_t * vm) { - clib_error_t *error = 0; - udp_ping_main.vlib_main = vm; udp_ping_main.vnet_main = vnet_get_main (); udp_ping_main.timer_interval = 1e9; - if ((error = vlib_call_init_function (vm, ip_main_init))) - return (error); - ip6_register_protocol (IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS, udp_ping_local.index); return 0; } -VLIB_INIT_FUNCTION (udp_ping_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (udp_ping_init) = +{ + .runs_after = VLIB_INITS("ip_main_init"), +}; +/* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON diff --git a/src/plugins/ixge/ixge.c b/src/plugins/ixge/ixge.c index 8faa9a91ca2..c27042df8b2 100644 --- a/src/plugins/ixge/ixge.c +++ b/src/plugins/ixge/ixge.c @@ -2788,7 +2788,6 @@ clib_error_t * ixge_init (vlib_main_t * vm) { ixge_main_t *xm = &ixge_main; - clib_error_t *error; xm->vlib_main = vm; clib_memset (&xm->tx_descriptor_template, 0, @@ -2807,13 +2806,15 @@ ixge_init (vlib_main_t * vm) | IXGE_TX_DESCRIPTOR_STATUS0_REPORT_STATUS); xm->tx_descriptor_template_mask.status1 &= ~(IXGE_TX_DESCRIPTOR_STATUS1_DONE); - - error = vlib_call_init_function (vm, pci_bus_init); - - return error; + return 0; } -VLIB_INIT_FUNCTION (ixge_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (ixge_init) = +{ + .runs_before = VLIB_INITS("pci_bus_init"), +}; +/* *INDENT-ON* */ static void diff --git a/src/plugins/lacp/input.c b/src/plugins/lacp/input.c index 8212b119784..ef7cca9c442 100644 --- a/src/plugins/lacp/input.c +++ b/src/plugins/lacp/input.c @@ -233,15 +233,15 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0) static clib_error_t * lacp_init (vlib_main_t * vm) { - clib_error_t *error; - - if ((error = vlib_call_init_function (vm, lacp_periodic_init))) - return error; - return 0; } -VLIB_INIT_FUNCTION (lacp_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (lacp_init) = +{ + .runs_after = VLIB_INITS("lacp_periodic_init"), +}; +/* *INDENT-ON* */ /* * packet trace format function, very similar to diff --git a/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam_trace.c b/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam_trace.c index bd56a6ab7b1..c40e89b52be 100644 --- a/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam_trace.c +++ b/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam_trace.c @@ -354,13 +354,6 @@ nsh_md2_ioam_trace_init (vlib_main_t * vm) { nsh_md2_ioam_trace_main_t *hm = &nsh_md2_ioam_trace_main; nsh_md2_ioam_main_t *gm = &nsh_md2_ioam_main; - clib_error_t *error; - - if ((error = vlib_call_init_function (vm, nsh_init))) - return (error); - - if ((error = vlib_call_init_function (vm, nsh_md2_ioam_init))) - return (error); hm->vlib_main = vm; hm->vnet_main = vnet_get_main (); @@ -384,7 +377,12 @@ nsh_md2_ioam_trace_init (vlib_main_t * vm) return (0); } -VLIB_INIT_FUNCTION (nsh_md2_ioam_trace_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (nsh_md2_ioam_trace_init) = +{ + .runs_after = VLIB_INITS ("nsh_init", "nsh_md2_ioam_init"), +}; +/* *INDENT-ON* */ int nsh_md2_ioam_trace_profile_cleanup (void) diff --git a/src/plugins/tlsmbedtls/tls_mbedtls.c b/src/plugins/tlsmbedtls/tls_mbedtls.c index e356088d619..73112323f0e 100644 --- a/src/plugins/tlsmbedtls/tls_mbedtls.c +++ b/src/plugins/tlsmbedtls/tls_mbedtls.c @@ -635,14 +635,10 @@ tls_mbedtls_init (vlib_main_t * vm) { vlib_thread_main_t *vtm = vlib_get_thread_main (); mbedtls_main_t *mm = &mbedtls_main; - clib_error_t *error; u32 num_threads; num_threads = 1 /* main thread */ + vtm->n_threads; - if ((error = vlib_call_init_function (vm, tls_init))) - return error; - if (tls_init_ca_chain ()) { clib_warning ("failed to initialize TLS CA chain"); @@ -667,7 +663,12 @@ tls_mbedtls_init (vlib_main_t * vm) return 0; } -VLIB_INIT_FUNCTION (tls_mbedtls_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (tls_mbedtls_init) = +{ + .runs_after = VLIB_INITS("tls_init"), +}; +/* *INDENT-ON* */ /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { diff --git a/src/plugins/tlsopenssl/tls_openssl.c b/src/plugins/tlsopenssl/tls_openssl.c index f6de0e003e8..4d4c4c37170 100644 --- a/src/plugins/tlsopenssl/tls_openssl.c +++ b/src/plugins/tlsopenssl/tls_openssl.c @@ -835,14 +835,10 @@ tls_openssl_init (vlib_main_t * vm) { vlib_thread_main_t *vtm = vlib_get_thread_main (); openssl_main_t *om = &openssl_main; - clib_error_t *error; u32 num_threads; num_threads = 1 /* main thread */ + vtm->n_threads; - if ((error = vlib_call_init_function (vm, tls_init))) - return error; - SSL_library_init (); SSL_load_error_strings (); @@ -864,6 +860,12 @@ tls_openssl_init (vlib_main_t * vm) return 0; } +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (tls_openssl_init) = +{ + .runs_after = VLIB_INITS("tls_init"), +}; +/* *INDENT-ON* */ #ifdef HAVE_OPENSSL_ASYNC static clib_error_t * @@ -938,9 +940,6 @@ VLIB_CLI_COMMAND (tls_openssl_set_command, static) = /* *INDENT-ON* */ #endif - -VLIB_INIT_FUNCTION (tls_openssl_init); - /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { .version = VPP_BUILD_VER, |