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
This commit is contained in:

committed by
Damjan Marion

parent
190dc1f678
commit
8dc954a4e7
@ -172,8 +172,8 @@ syslog:
|
||||
|
||||
}
|
||||
|
||||
vlib_log_class_t
|
||||
vlib_log_register_class (char *class, char *subclass)
|
||||
static vlib_log_class_t
|
||||
vlib_log_register_class_internal (char *class, char *subclass, u32 limit)
|
||||
{
|
||||
vlib_log_main_t *lm = &log_main;
|
||||
vlib_log_class_data_t *c = NULL;
|
||||
@ -199,12 +199,26 @@ vlib_log_register_class (char *class, char *subclass)
|
||||
vec_add2 (c->subclasses, s, 1);
|
||||
s->index = s - c->subclasses;
|
||||
s->name = subclass ? format (0, "%s", subclass) : 0;
|
||||
s->rate_limit = lm->default_rate_limit;
|
||||
s->rate_limit = (limit == 0) ? lm->default_rate_limit : limit;
|
||||
s->level = lm->default_log_level;
|
||||
s->syslog_level = lm->default_syslog_log_level;
|
||||
return (c->index << 16) | (s->index);
|
||||
}
|
||||
|
||||
vlib_log_class_t
|
||||
vlib_log_register_class (char *class, char *subclass)
|
||||
{
|
||||
return vlib_log_register_class_internal (class, subclass,
|
||||
0 /* default rate limit */ );
|
||||
}
|
||||
|
||||
vlib_log_class_t
|
||||
vlib_log_register_class_rate_limit (char *class, char *subclass, u32 limit)
|
||||
{
|
||||
return vlib_log_register_class_internal (class, subclass, limit);
|
||||
}
|
||||
|
||||
|
||||
u8 *
|
||||
format_vlib_log_level (u8 * s, va_list * args)
|
||||
{
|
||||
|
@ -90,6 +90,9 @@ typedef struct
|
||||
extern vlib_log_main_t log_main;
|
||||
|
||||
vlib_log_class_t vlib_log_register_class (char *vlass, char *subclass);
|
||||
vlib_log_class_t
|
||||
vlib_log_register_class_rate_limit (char *class, char *subclass,
|
||||
u32 rate_limit);
|
||||
u32 vlib_log_get_indent ();
|
||||
void vlib_log (vlib_log_level_t level, vlib_log_class_t class, char *fmt,
|
||||
...);
|
||||
|
@ -2021,8 +2021,6 @@ vlib_main (vlib_main_t * volatile vm, unformat_input_t * input)
|
||||
|
||||
vm->queue_signal_callback = dummy_queue_signal_callback;
|
||||
|
||||
clib_time_init (&vm->clib_time);
|
||||
|
||||
/* Turn on event log. */
|
||||
if (!vm->elog_main.event_ring_size)
|
||||
vm->elog_main.event_ring_size = 128 << 10;
|
||||
|
@ -685,6 +685,8 @@ vlib_unix_main (int argc, char *argv[])
|
||||
(((uword) vm->heap_base) & ~(VLIB_FRAME_ALIGN - 1));
|
||||
ASSERT (vm->heap_base);
|
||||
|
||||
clib_time_init (&vm->clib_time);
|
||||
|
||||
unformat_init_command_line (&input, (char **) vm->argv);
|
||||
if ((e = vlib_plugin_config (vm, &input)))
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -61,6 +61,7 @@ typedef CLIB_PACKED(struct {
|
||||
u8 default_disabled;
|
||||
const char version[32];
|
||||
const char version_required[32];
|
||||
const char overrides[256];
|
||||
const char *early_init;
|
||||
const char *description;
|
||||
}) vlib_plugin_registration_t;
|
||||
@ -91,6 +92,7 @@ typedef struct
|
||||
/* loaded plugin info */
|
||||
plugin_info_t *plugin_info;
|
||||
uword *plugin_by_name_hash;
|
||||
uword *plugin_overrides_by_name_hash;
|
||||
|
||||
/* paths and name filters */
|
||||
u8 *plugin_path;
|
||||
@ -103,6 +105,9 @@ typedef struct
|
||||
plugin_config_t *configs;
|
||||
uword *config_index_by_name;
|
||||
|
||||
/* Plugin log, avoid filling syslog w/ junk */
|
||||
vlib_log_class_t logger;
|
||||
|
||||
/* usual */
|
||||
vlib_main_t *vlib_main;
|
||||
} plugin_main_t;
|
||||
|
@ -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 ();
|
||||
|
||||
|
Reference in New Issue
Block a user