1/*- 2 * Copyright (c) 2006-2009 University of Zagreb 3 * Copyright (c) 2006-2009 FreeBSD Foundation 4 * All rights reserved. 5 * 6 * This software was developed by the University of Zagreb and the 7 * FreeBSD Foundation under sponsorship by the Stichting NLnet and the 8 * FreeBSD Foundation. --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * |
35 * $FreeBSD: head/sys/net/vnet.h 274225 2014-11-07 09:39:05Z glebius $ |
36 */ 37 38/*- 39 * This header file defines several sets of interfaces supporting virtualized 40 * network stacks: 41 * 42 * - Definition of 'struct vnet' and functions and macros to allocate/free/ 43 * manipulate it. --- 70 unchanged lines hidden (view full) --- 114static void \ 115vnet_##name##_uninit(const void *unused) \ 116{ \ 117 VNET_PCPUSTAT_FREE(name); \ 118} \ 119VNET_SYSUNINIT(vnet_ ## name ## _uninit, SI_SUB_PROTO_IFATTACHDOMAIN, \ 120 SI_ORDER_ANY, vnet_ ## name ## _uninit, NULL) 121 |
122#ifdef SYSCTL_OID |
123#define SYSCTL_VNET_PCPUSTAT(parent, nbr, name, type, array, desc) \ 124static int \ 125array##_sysctl(SYSCTL_HANDLER_ARGS) \ 126{ \ 127 type s; \ 128 CTASSERT((sizeof(type) / sizeof(uint64_t)) == \ 129 (sizeof(VNET(array)) / sizeof(counter_u64_t))); \ 130 COUNTER_ARRAY_COPY(VNET(array), &s, sizeof(type) / sizeof(uint64_t));\ 131 if (req->newptr) \ 132 COUNTER_ARRAY_ZERO(VNET(array), \ 133 sizeof(type) / sizeof(uint64_t)); \ 134 return (SYSCTL_OUT(req, &s, sizeof(type))); \ 135} \ |
136SYSCTL_PROC(parent, nbr, name, CTLFLAG_VNET | CTLTYPE_OPAQUE | CTLFLAG_RW, \ 137 NULL, 0, array ## _sysctl, "I", desc) 138#endif /* SYSCTL_OID */ |
139 140#ifdef VIMAGE 141#include <sys/lock.h> 142#include <sys/proc.h> /* for struct thread */ 143#include <sys/rwlock.h> 144#include <sys/sx.h> 145 146/* --- 133 unchanged lines hidden (view full) --- 280/* 281 * Virtual network stack allocator interfaces from the kernel linker. 282 */ 283void *vnet_data_alloc(int size); 284void vnet_data_copy(void *start, int size); 285void vnet_data_free(void *start_arg, int size); 286 287/* |
288 * Virtual sysinit mechanism, allowing network stack components to declare 289 * startup and shutdown methods to be run when virtual network stack 290 * instances are created and destroyed. 291 */ 292#include <sys/kernel.h> 293 294/* 295 * SYSINIT/SYSUNINIT variants that provide per-vnet constructors and --- 106 unchanged lines hidden (view full) --- 402 */ 403#define VNET_VNET_PTR(vnet, n) (&(n)) 404#define VNET_VNET(vnet, n) (n) 405 406#define VNET_PTR(n) (&(n)) 407#define VNET(n) (n) 408 409/* |
410 * When VIMAGE isn't compiled into the kernel, VNET_SYSINIT/VNET_SYSUNINIT 411 * map into normal sysinits, which have the same ordering properties. 412 */ 413#define VNET_SYSINIT(ident, subsystem, order, func, arg) \ 414 SYSINIT(ident, subsystem, order, func, arg) 415#define VNET_SYSUNINIT(ident, subsystem, order, func, arg) \ 416 SYSUNINIT(ident, subsystem, order, func, arg) 417 418/* 419 * Without VIMAGE revert to the default implementation. 420 */ 421#define VNET_GLOBAL_EVENTHANDLER_REGISTER_TAG(tag, name, func, arg, priority) \ 422 (tag) = eventhandler_register(NULL, #name, func, arg, priority) 423#define VNET_GLOBAL_EVENTHANDLER_REGISTER(name, func, arg, priority) \ 424 eventhandler_register(NULL, #name, func, arg, priority) 425#endif /* VIMAGE */ 426#endif /* _KERNEL */ 427 428#endif /* !_NET_VNET_H_ */ |