Date: Sun, 5 Oct 2014 21:27:26 +0000 (UTC) From: Hiroki Sato <hrs@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272572 - head/sys/net Message-ID: <201410052127.s95LRQlY024235@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hrs Date: Sun Oct 5 21:27:26 2014 New Revision: 272572 URL: https://svnweb.freebsd.org/changeset/base/272572 Log: Virtualize if_edsc(4). Modified: head/sys/net/if_edsc.c Modified: head/sys/net/if_edsc.c ============================================================================== --- head/sys/net/if_edsc.c Sun Oct 5 20:30:49 2014 (r272571) +++ head/sys/net/if_edsc.c Sun Oct 5 21:27:26 2014 (r272572) @@ -51,6 +51,7 @@ #include <net/if_clone.h> /* network interface cloning */ #include <net/if_types.h> /* IFT_ETHER and friends */ #include <net/if_var.h> /* kernel-only part of ifnet(9) */ +#include <net/vnet.h> static const char edscname[] = "edsc"; @@ -69,7 +70,8 @@ struct edsc_softc { /* * Attach to the interface cloning framework. */ -static struct if_clone *edsc_cloner; +static VNET_DEFINE(struct if_clone *, edsc_cloner); +#define V_edsc_cloner VNET(edsc_cloner) static int edsc_clone_create(struct if_clone *, int, caddr_t); static void edsc_clone_destroy(struct ifnet *); @@ -307,6 +309,36 @@ edsc_start(struct ifnet *ifp) */ } +static void +vnet_edsc_init(const void *unused __unused) +{ + + /* + * Connect to the network interface cloning framework. + * The last argument is the number of units to be created + * from the outset. It's also the minimum number of units + * allowed. We don't want any units created as soon as the + * driver is loaded. + */ + V_edsc_cloner = if_clone_simple(edscname, edsc_clone_create, + edsc_clone_destroy, 0); +} +VNET_SYSINIT(vnet_edsc_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, + vnet_edsc_init, NULL); + +static void +vnet_edsc_uninit(const void *unused __unused) +{ + + /* + * Disconnect from the cloning framework. + * Existing interfaces will be disposed of properly. + */ + if_clone_detach(V_edsc_cloner); +} +VNET_SYSUNINIT(vnet_edsc_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, + vnet_edsc_uninit, NULL); + /* * This function provides handlers for module events, namely load and unload. */ @@ -316,25 +348,8 @@ edsc_modevent(module_t mod, int type, vo switch (type) { case MOD_LOAD: - /* - * Connect to the network interface cloning framework. - * The last argument is the number of units to be created - * from the outset. It's also the minimum number of units - * allowed. We don't want any units created as soon as the - * driver is loaded. - */ - edsc_cloner = if_clone_simple(edscname, edsc_clone_create, - edsc_clone_destroy, 0); - break; - case MOD_UNLOAD: - /* - * Disconnect from the cloning framework. - * Existing interfaces will be disposed of properly. - */ - if_clone_detach(edsc_cloner); break; - default: /* * There are other event types, but we don't handle them.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410052127.s95LRQlY024235>