46 void *handle, *register_handle;
49 void *handoff_structure;
51 handle = dlopen ((
char *) pi->
name, RTLD_LAZY);
67 register_handle = dlsym (pi->
handle,
"vlib_plugin_register");
68 if (register_handle == 0)
71 clib_warning (
"Plugin missing vlib_plugin_register: %s\n",
80 if (handoff_structure == 0)
83 error = (*fp) (pm->
vlib_main, handoff_structure, from_early_init);
128 struct dirent *entry;
137 for (i = 0; i <
vec_len (plugin_path); i++)
139 dp = opendir ((
char *) plugin_path[i]);
144 while ((entry = readdir (dp)))
156 plugin_name =
format (0,
"%s/%s%c", plugin_path[i],
160 char *ext = strrchr ((
const char *) plugin_name,
'.');
162 if (!ext || (strcmp (ext,
".so") != 0) ||
163 stat ((
char *) plugin_name, &statb) < 0)
171 if (!S_ISREG (statb.st_mode))
178 pi->
name = plugin_name;
187 memset (pi, 0,
sizeof (*pi));
201 char *vlib_plugin_path __attribute__ ((weak));
202 char *vlib_plugin_path =
"";
203 char *vlib_plugin_name_filter __attribute__ ((weak));
204 char *vlib_plugin_name_filter = 0;
215 if (vlib_plugin_name_filter)
235 if (vlib_plugin_name_filter)
236 s =
format (s,
" Plugin filter: %s\n", vlib_plugin_name_filter);
238 s =
format (s,
" Plugins loaded: \n");
242 s = format (s,
" %d.%s\n", index, key); index++;}
252 .path =
"show plugins",.short_help =
"show loaded plugins",.function =
sll srl srl sll sra u16x4 i
int vlib_load_new_plugins(plugin_main_t *pm, int from_early_init)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define hash_set_mem(h, key, value)
#define clib_error_report(e)
static void * vnet_get_handoff_structure(void)
#define clib_warning(format, args...)
static clib_error_t * vlib_plugins_show_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vlib_set_get_handoff_structure_cb(void *cb)
#define hash_create_string(elts, value_bytes)
static u8 ** split_plugin_path(plugin_main_t *pm)
plugin_main_t vlib_plugin_main
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define hash_foreach_mem(key_var, value_var, h, body)
int vlib_plugin_early_init(vlib_main_t *vm)
uword * plugin_by_name_hash
#define vec_free(V)
Free vector's memory (no header).
static int load_one_plugin(plugin_main_t *pm, plugin_info_t *pi, int from_early_init)
void * handoff_structure_get_cb
plugin_info_t * plugin_info
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define hash_get_mem(h, key)
#define clib_error_return(e, args...)