summaryrefslogtreecommitdiffstats
path: root/sys/net/if_vlan.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2012-10-16 13:37:54 +0000
committerglebius <glebius@FreeBSD.org>2012-10-16 13:37:54 +0000
commit05f24a6b77a43334f14f31cd33a4f3e34a418ea2 (patch)
tree0f54a9446bfe2083d3c0a3f744318b2be8a0db05 /sys/net/if_vlan.c
parent745884b065065ffc8847d3ea463bf751ffcaf863 (diff)
downloadFreeBSD-src-05f24a6b77a43334f14f31cd33a4f3e34a418ea2.zip
FreeBSD-src-05f24a6b77a43334f14f31cd33a4f3e34a418ea2.tar.gz
Make the "struct if_clone" opaque to users of the cloning API. Users
now use function calls: if_clone_simple() if_clone_advanced() to initialize a cloner, instead of macros that initialize if_clone structure. Discussed with: brooks, bz, 1 year ago
Diffstat (limited to 'sys/net/if_vlan.c')
-rw-r--r--sys/net/if_vlan.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index 3bc3b67..379a59b 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -66,7 +66,6 @@ __FBSDID("$FreeBSD$");
#include <net/if_vlan_var.h>
#include <net/vnet.h>
-#define VLANNAME "vlan"
#define VLAN_DEF_HWIDTH 4
#define VLAN_IFFLAGS (IFF_BROADCAST | IFF_MULTICAST)
@@ -139,7 +138,8 @@ static int soft_pad = 0;
SYSCTL_INT(_net_link_vlan, OID_AUTO, soft_pad, CTLFLAG_RW, &soft_pad, 0,
"pad short frames before tagging");
-static MALLOC_DEFINE(M_VLAN, VLANNAME, "802.1Q Virtual LAN Interface");
+static const char vlanname[] = "vlan";
+static MALLOC_DEFINE(M_VLAN, vlanname, "802.1Q Virtual LAN Interface");
static eventhandler_tag ifdetach_tag;
static eventhandler_tag iflladdr_tag;
@@ -162,7 +162,7 @@ static struct sx ifv_lock;
#define VLAN_LOCK_ASSERT() sx_assert(&ifv_lock, SA_LOCKED)
#define VLAN_LOCK() sx_xlock(&ifv_lock)
#define VLAN_UNLOCK() sx_xunlock(&ifv_lock)
-#define TRUNK_LOCK_INIT(trunk) rw_init(&(trunk)->rw, VLANNAME)
+#define TRUNK_LOCK_INIT(trunk) rw_init(&(trunk)->rw, vlanname)
#define TRUNK_LOCK_DESTROY(trunk) rw_destroy(&(trunk)->rw)
#define TRUNK_LOCK(trunk) rw_wlock(&(trunk)->rw)
#define TRUNK_UNLOCK(trunk) rw_wunlock(&(trunk)->rw)
@@ -207,11 +207,10 @@ static int vlan_clone_destroy(struct if_clone *, struct ifnet *);
static void vlan_ifdetach(void *arg, struct ifnet *ifp);
static void vlan_iflladdr(void *arg, struct ifnet *ifp);
-static struct if_clone vlan_cloner = IFC_CLONE_INITIALIZER(VLANNAME, NULL,
- IF_MAXUNIT, NULL, vlan_clone_match, vlan_clone_create, vlan_clone_destroy);
+static struct if_clone *vlan_cloner;
#ifdef VIMAGE
-static VNET_DEFINE(struct if_clone, vlan_cloner);
+static VNET_DEFINE(struct if_clone *, vlan_cloner);
#define V_vlan_cloner VNET(vlan_cloner)
#endif
@@ -723,7 +722,8 @@ vlan_modevent(module_t mod, int type, void *data)
vlan_tag_p = vlan_tag;
vlan_devat_p = vlan_devat;
#ifndef VIMAGE
- if_clone_attach(&vlan_cloner);
+ vlan_cloner = if_clone_advanced(vlanname, 0, vlan_clone_match,
+ vlan_clone_create, vlan_clone_destroy);
#endif
if (bootverbose)
printf("vlan: initialized, using "
@@ -737,7 +737,7 @@ vlan_modevent(module_t mod, int type, void *data)
break;
case MOD_UNLOAD:
#ifndef VIMAGE
- if_clone_detach(&vlan_cloner);
+ if_clone_detach(vlan_cloner);
#endif
EVENTHANDLER_DEREGISTER(ifnet_departure_event, ifdetach_tag);
EVENTHANDLER_DEREGISTER(iflladdr_event, iflladdr_tag);
@@ -773,8 +773,9 @@ static void
vnet_vlan_init(const void *unused __unused)
{
+ vlan_cloner = if_clone_advanced(vlanname, 0, vlan_clone_match,
+ vlan_clone_create, vlan_clone_destroy);
V_vlan_cloner = vlan_cloner;
- if_clone_attach(&V_vlan_cloner);
}
VNET_SYSINIT(vnet_vlan_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY,
vnet_vlan_init, NULL);
@@ -783,7 +784,7 @@ static void
vnet_vlan_uninit(const void *unused __unused)
{
- if_clone_detach(&V_vlan_cloner);
+ if_clone_detach(V_vlan_cloner);
}
VNET_SYSUNINIT(vnet_vlan_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_FIRST,
vnet_vlan_uninit, NULL);
@@ -835,7 +836,7 @@ vlan_clone_match(struct if_clone *ifc, const char *name)
if (vlan_clone_match_ethervid(ifc, name, NULL) != NULL)
return (1);
- if (strncmp(VLANNAME, name, strlen(VLANNAME)) != 0)
+ if (strncmp(vlanname, name, strlen(vlanname)) != 0)
return (0);
for (cp = name + 4; *cp != '\0'; cp++) {
if (*cp < '0' || *cp > '9')
@@ -943,7 +944,7 @@ vlan_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
* we don't conform to the default naming convention for interfaces.
*/
strlcpy(ifp->if_xname, name, IFNAMSIZ);
- ifp->if_dname = ifc->ifc_name;
+ ifp->if_dname = vlanname;
ifp->if_dunit = unit;
/* NB: flags are not set here */
ifp->if_linkmib = &ifv->ifv_mib;
OpenPOWER on IntegriCloud