plugin: Add plugin 'default' disable/enable
[vpp.git] / src / vlib / unix / plugin.c
index 9b341cc..b4eb0b9 100644 (file)
@@ -94,6 +94,9 @@ load_one_plugin (plugin_main_t * pm, plugin_info_t * pi, int from_early_init)
       goto error;
     }
 
+  if (pm->plugins_default_disable)
+    reg->default_disabled = 1;
+
   p = hash_get_mem (pm->config_index_by_name, pi->name);
   if (p)
     {
@@ -137,15 +140,11 @@ load_one_plugin (plugin_main_t * pm, plugin_info_t * pi, int from_early_init)
 
   handle = dlopen ((char *) pi->filename, RTLD_LAZY);
 
-  /*
-   * Note: this can happen if the plugin has an undefined symbol reference,
-   * so print a warning. Otherwise, the poor slob won't know what happened.
-   * Ask me how I know that...
-   */
   if (handle == 0)
     {
       clib_warning ("%s", dlerror ());
-      return -1;
+      clib_warning ("Failed to load plugin '%s'", pi->name);
+      goto error;
     }
 
   pi->handle = handle;
@@ -365,6 +364,20 @@ vlib_plugin_early_init (vlib_main_t * vm)
   return vlib_load_new_plugins (pm, 1 /* from_early_init */ );
 }
 
+u8 *
+vlib_get_vat_plugin_path (void)
+{
+  plugin_main_t *pm = &vlib_plugin_main;
+  return (pm->vat_plugin_path);
+}
+
+u8 *
+vlib_get_vat_plugin_name_filter (void)
+{
+  plugin_main_t *pm = &vlib_plugin_main;
+  return (pm->vat_plugin_name_filter);
+}
+
 static clib_error_t *
 vlib_plugins_show_cmd_fn (vlib_main_t * vm,
                          unformat_input_t * input, vlib_cli_command_t * cmd)
@@ -501,6 +514,19 @@ done:
       u8 *s = 0;
       if (unformat (input, "path %s", &s))
        pm->plugin_path = s;
+      else if (unformat (input, "name-filter %s", &s))
+       pm->plugin_name_filter = s;
+      else if (unformat (input, "vat-path %s", &s))
+       pm->vat_plugin_path = s;
+      else if (unformat (input, "vat-name-filter %s", &s))
+       pm->vat_plugin_name_filter = s;
+      else if (unformat (input, "plugin default %U",
+                        unformat_vlib_cli_sub_input, &sub_input))
+       {
+         pm->plugins_default_disable =
+           unformat (&sub_input, "disable") ? 1 : 0;
+         unformat_free (&sub_input);
+       }
       else if (unformat (input, "plugin %s %U", &s,
                         unformat_vlib_cli_sub_input, &sub_input))
        {