From 3b46cba8f4e909bc363403c6c92215159abb2f11 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Mon, 23 Jan 2017 21:13:45 +0100 Subject: Plugin infrastructure improvements This patch replaces requirement for vlib_plugin_register function in the plugin so file and introduces new macro: VLIB_PLUGIN_REGISTER () = { .version = "version string", .version_required = "requred version", .default_disabled = 1, .early_init = "early_init_function_name", }; Plugin will nor be loaded if .default_disabled is set to 1 unless explicitely enabled in startup.conf. If .verstion_required is set, plugin will not be loaded if there is version mismatch between plugin and vpp. This can be bypassed by setting "skip-version-check" for specific plugin. If .early-init string is present, plugin loader will try to resolve this specific symbol in the plugin namespace and make a function call. Following startup.conf configuration is added: plugins { path /path/to/plugin/directory plugin ila_plugin.so { enable skip-version-check } plugin acl_plugin.so { disable } } Change-Id: I706c691dd34d94ffe9e02b59831af8859a95f061 Signed-off-by: Damjan Marion --- src/plugins/acl/acl.c | 29 ++++++----------------------- src/plugins/acl/acl.h | 2 -- src/plugins/acl/l2sess.c | 13 ------------- src/plugins/acl/l2sess.h | 1 - 4 files changed, 6 insertions(+), 39 deletions(-) (limited to 'src/plugins/acl') diff --git a/src/plugins/acl/acl.c b/src/plugins/acl/acl.c index f4db2013..85c9113b 100644 --- a/src/plugins/acl/acl.c +++ b/src/plugins/acl/acl.c @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -128,29 +129,11 @@ _(MACIP_ACL_INTERFACE_ADD_DEL, macip_acl_interface_add_del) \ _(MACIP_ACL_DUMP, macip_acl_dump) \ _(MACIP_ACL_INTERFACE_GET, macip_acl_interface_get) -/* - * This routine exists to convince the vlib plugin framework that - * we haven't accidentally copied a random .dll into the plugin directory. - * - * Also collects global variable pointers passed from the vpp engine - */ - -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, - int from_early_init) -{ - acl_main_t *am = &acl_main; - clib_error_t *error = 0; - - am->vlib_main = vm; - am->vnet_main = h->vnet_main; - am->ethernet_main = h->ethernet_main; - - l2sess_vlib_plugin_register(vm, h, from_early_init); - - return error; -} - +/* *INDENT-OFF* */ +VLIB_PLUGIN_REGISTER () = { + .version = VPP_BUILD_VER, +}; +/* *INDENT-ON* */ static void vl_api_acl_plugin_get_version_t_handler (vl_api_acl_plugin_get_version_t * mp) diff --git a/src/plugins/acl/acl.h b/src/plugins/acl/acl.h index afc9b289..62046788 100644 --- a/src/plugins/acl/acl.h +++ b/src/plugins/acl/acl.h @@ -17,7 +17,6 @@ #include #include -#include #include @@ -139,7 +138,6 @@ typedef struct { /* convenience */ vlib_main_t * vlib_main; vnet_main_t * vnet_main; - ethernet_main_t * ethernet_main; } acl_main_t; extern acl_main_t acl_main; diff --git a/src/plugins/acl/l2sess.c b/src/plugins/acl/l2sess.c index cc9bde44..b0385be1 100644 --- a/src/plugins/acl/l2sess.c +++ b/src/plugins/acl/l2sess.c @@ -30,19 +30,6 @@ #include #include -void -l2sess_vlib_plugin_register (vlib_main_t * vm, void* hh, - int from_early_init) -{ - l2sess_main_t *sm = &l2sess_main; - vnet_plugin_handoff_t * h = hh; - memset (sm, 0, sizeof (*sm)); - - sm->vlib_main = vm; - sm->vnet_main = h->vnet_main; - sm->ethernet_main = h->ethernet_main; -} - void l2sess_init_next_features_input (vlib_main_t * vm, l2sess_main_t * sm) { diff --git a/src/plugins/acl/l2sess.h b/src/plugins/acl/l2sess.h index db899917..888b5301 100644 --- a/src/plugins/acl/l2sess.h +++ b/src/plugins/acl/l2sess.h @@ -132,7 +132,6 @@ foreach_l2sess_node /* convenience */ vlib_main_t * vlib_main; vnet_main_t * vnet_main; - ethernet_main_t * ethernet_main; /* Counter(s) */ u64 counter_attempted_delete_free_session; -- cgit 1.2.3-korg