summaryrefslogtreecommitdiffstats
path: root/src/vpp
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2020-02-05 17:31:09 -0500
committerDamjan Marion <dmarion@me.com>2020-02-06 16:58:30 +0000
commit8dc954a4e7931c07051ce22f8446d6e5dfb9ce7d (patch)
tree489b0f34397e73c1cf2bd844d79c71d1bf25cdf1 /src/vpp
parent190dc1f6782eba4c49511636570eef678d1bac16 (diff)
vlib: add plugin override support
Allow a plugin to override (suppress loading of) other plugins. This mechanism allows a developer to prevent specific plugins from being loaded. To do so, provide an "overrides" list in the plugin definition: VLIB_PLUGIN_REGISTER () = { <snip> .overrides = "avf_plugin.so,ioam_plugin.so,dpdk_plugin.so", }; or some such. Simply list the plugins in question as shown above. The .overrides structure member is limited to 256 octets. The named .elf section mechanism used to discover the vlib_plugin_registration_t's precludes the use of a variable-length array of strings. Use the vlib log to eliminate plugin and built-in vat plugin loader console spew. Added vlib_log_register_class_rate_limit(...) to allow procedural configuration of the log rate-limit. We *never* want to rate-limit plugin loader messages. Type: feature Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I0a9327b8cf5508482f057342783252112cb44170
Diffstat (limited to 'src/vpp')
-rw-r--r--src/vpp/api/plugin.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/vpp/api/plugin.c b/src/vpp/api/plugin.c
index 73a20d42dc1..410d497a0aa 100644
--- a/src/vpp/api/plugin.c
+++ b/src/vpp/api/plugin.c
@@ -23,6 +23,15 @@
plugin_main_t vat_plugin_main;
+static vlib_log_class_t vat_builtin_logger;
+
+#define PLUGIN_LOG_DBG(...) \
+ do {vlib_log_debug (vat_builtin_logger, __VA_ARGS__);} while(0)
+#define PLUGIN_LOG_ERR(...) \
+ do {vlib_log_err (vat_builtin_logger, __VA_ARGS__);} while(0)
+#define PLUGIN_LOG_NOTICE(...) \
+ do {vlib_log_notice (vat_builtin_logger, __VA_ARGS__);} while(0)
+
static int
load_one_vat_plugin (plugin_main_t * pm, plugin_info_t * pi)
{
@@ -39,7 +48,7 @@ load_one_vat_plugin (plugin_main_t * pm, plugin_info_t * pi)
*/
if (handle == 0)
{
- clib_warning ("%s", dlerror ());
+ PLUGIN_LOG_ERR ("%s", dlerror ());
return 0;
}
@@ -48,7 +57,7 @@ load_one_vat_plugin (plugin_main_t * pm, plugin_info_t * pi)
register_handle = dlsym (pi->handle, "vat_plugin_register");
if (register_handle == 0)
{
- clib_warning ("%s: symbol vat_plugin_register not found", pi->name);
+ PLUGIN_LOG_ERR ("%s: symbol vat_plugin_register not found", pi->name);
dlclose (handle);
return 0;
}
@@ -59,12 +68,15 @@ load_one_vat_plugin (plugin_main_t * pm, plugin_info_t * pi)
if (error)
{
- clib_error_report (error);
+ u8 *err = format (0, "%U%c", format_clib_error, error, 0);
+ PLUGIN_LOG_ERR ((char *) err);
+ clib_error_free (error);
dlclose (handle);
+ pi->handle = 0;
return 1;
}
- clib_warning ("Loaded plugin: %s", pi->name);
+ PLUGIN_LOG_NOTICE ("Loaded plugin: %s", pi->name);
return 0;
}
@@ -190,6 +202,10 @@ vat_plugin_init (vat_main_t * vam)
u8 *plugin_path;
u8 *plugin_name_filter;
+ vat_builtin_logger =
+ vlib_log_register_class_rate_limit ("vat-plug", "load",
+ 0x7FFFFFFF /* aka no rate limit */ );
+
plugin_path = vlib_get_vat_plugin_path ();
plugin_name_filter = vlib_get_vat_plugin_name_filter ();