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/vlib/unix/plugin.h | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src/vlib/unix/plugin.h') diff --git a/src/vlib/unix/plugin.h b/src/vlib/unix/plugin.h index 1c74cdd2..01fec356 100644 --- a/src/vlib/unix/plugin.h +++ b/src/vlib/unix/plugin.h @@ -56,7 +56,14 @@ * vlib_load_new_plugins(). */ - +/* *INDENT-OFF* */ +typedef CLIB_PACKED(struct { + u8 default_disabled; + const char version[32]; + const char version_required[32]; + const char *early_init; +}) vlib_plugin_registration_t; +/* *INDENT-ON* */ typedef struct { @@ -64,8 +71,20 @@ typedef struct u8 *filename; struct stat file_info; void *handle; + + /* plugin registration */ + vlib_plugin_registration_t *reg; + char *version; } plugin_info_t; +typedef struct +{ + char *name; + u8 is_disabled; + u8 is_enabled; + u8 skip_version_check; +} plugin_config_t; + typedef struct { /* loaded plugin info */ @@ -76,8 +95,9 @@ typedef struct u8 *plugin_path; u8 *plugin_name_filter; - /* handoff structure get callback */ - void *handoff_structure_get_cb; + /* plugin configs and hash by name */ + plugin_config_t *configs; + uword *config_index_by_name; /* usual */ vlib_main_t *vlib_main; @@ -85,10 +105,15 @@ typedef struct extern plugin_main_t vlib_plugin_main; +clib_error_t *vlib_plugin_config (vlib_main_t * vm, unformat_input_t * input); int vlib_plugin_early_init (vlib_main_t * vm); int vlib_load_new_plugins (plugin_main_t * pm, int from_early_init); void *vlib_get_plugin_symbol (char *plugin_name, char *symbol_name); +#define VLIB_PLUGIN_REGISTER() \ + vlib_plugin_registration_t vlib_plugin_registration \ + __attribute__((__section__(".vlib_plugin_registration"))) + #endif /* __included_plugin_h__ */ /* -- cgit 1.2.3-korg