diff options
Diffstat (limited to 'sys/net/vnet.c')
-rw-r--r-- | sys/net/vnet.c | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/sys/net/vnet.c b/sys/net/vnet.c index 323ed0855630..8013f5ed5949 100644 --- a/sys/net/vnet.c +++ b/sys/net/vnet.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include <sys/sdt.h> #include <sys/systm.h> #include <sys/sysctl.h> +#include <sys/eventhandler.h> #include <sys/linker_set.h> #include <sys/lock.h> #include <sys/malloc.h> @@ -55,6 +56,8 @@ __FBSDID("$FreeBSD$"); #include <sys/sx.h> #include <sys/sysctl.h> +#include <machine/stdarg.h> + #ifdef DDB #include <ddb/ddb.h> #include <ddb/db_sym.h> @@ -151,15 +154,6 @@ struct vnet *vnet0; */ /* - * Location of the kernel's 'set_vnet' linker set. - */ -extern uintptr_t *__start_set_vnet; -extern uintptr_t *__stop_set_vnet; - -#define VNET_START (uintptr_t)&__start_set_vnet -#define VNET_STOP (uintptr_t)&__stop_set_vnet - -/* * Number of bytes of data in the 'set_vnet' linker set, and hence the total * size of all kernel virtualized global variables, and the malloc(9) type * that will be used to allocate it. @@ -637,6 +631,39 @@ vnet_sysuninit(void) VNET_SYSINIT_RUNLOCK(); } +/* + * EVENTHANDLER(9) extensions. + */ +/* + * Invoke the eventhandler function originally registered with the possibly + * registered argument for all virtual network stack instances. + * + * This iterator can only be used for eventhandlers that do not take any + * additional arguments, as we do ignore the variadic arguments from the + * EVENTHANDLER_INVOKE() call. + */ +void +vnet_global_eventhandler_iterator_func(void *arg, ...) +{ + VNET_ITERATOR_DECL(vnet_iter); + struct eventhandler_entry_vimage *v_ee; + + /* + * There is a bug here in that we should actually cast things to + * (struct eventhandler_entry_ ## name *) but that's not easily + * possible in here so just re-using the variadic version we + * defined for the generic vimage case. + */ + v_ee = arg; + VNET_LIST_RLOCK(); + VNET_FOREACH(vnet_iter) { + CURVNET_SET(vnet_iter); + ((vimage_iterator_func_t)v_ee->func)(v_ee->ee_arg); + CURVNET_RESTORE(); + } + VNET_LIST_RUNLOCK(); +} + #ifdef VNET_DEBUG struct vnet_recursion { SLIST_ENTRY(vnet_recursion) vnr_le; @@ -696,6 +723,9 @@ vnet_log_recursion(struct vnet *old_vnet, const char *old_fn, int line) } #endif /* VNET_DEBUG */ +/* + * DDB(4). + */ #ifdef DDB DB_SHOW_COMMAND(vnets, db_show_vnets) { |