diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2015-09-13 10:02:37 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2015-09-13 10:02:37 +0000 |
commit | 0d77d16dd0356614a7a93f47cbfaed7b01e62803 (patch) | |
tree | ae47be6a42c69966b944e43e1ae5542be6cd0258 /sys | |
parent | afbe16433e9ef1083c6999205ac03072d1b3946b (diff) |
replace hand rolled reference counting with refcnts.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if_vlan.c | 25 | ||||
-rw-r--r-- | sys/net/if_vlan_var.h | 6 |
2 files changed, 9 insertions, 22 deletions
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 4c2fc9552fc..8287de18fc0 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan.c,v 1.141 2015/09/13 09:46:45 dlg Exp $ */ +/* $OpenBSD: if_vlan.c,v 1.142 2015/09/13 10:02:36 dlg Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology @@ -57,8 +57,6 @@ #include <sys/socket.h> #include <sys/sockio.h> #include <sys/systm.h> -#include <sys/atomic.h> -#include <sys/proc.h> #include <sys/rwlock.h> #include <net/if.h> @@ -159,7 +157,7 @@ vlan_clone_create(struct if_clone *ifc, int unit) else ifv->ifv_type = ETHERTYPE_VLAN; - ifv->ifv_refs = 1; + refcnt_init(&ifv->ifv_refcnt); ifp->if_start = vlan_start; ifp->if_ioctl = vlan_ioctl; @@ -177,7 +175,7 @@ vlan_ref(void *null, void *v) { struct ifvlan *ifv = v; - atomic_inc_int(&ifv->ifv_refs); + refcnt_take(&ifv->ifv_refcnt); } void @@ -185,31 +183,18 @@ vlan_unref(void *null, void *v) { struct ifvlan *ifv = v; - if (atomic_dec_int_nv(&ifv->ifv_refs) == 0) - wakeup(&ifv->ifv_refs); + refcnt_rele_wake(&ifv->ifv_refcnt); } int vlan_clone_destroy(struct ifnet *ifp) { struct ifvlan *ifv = ifp->if_softc; - struct sleep_state sls; - u_int refs; vlan_unconfig(ifp, NULL); ether_ifdetach(ifp); if_detach(ifp); - - refs = atomic_dec_int_nv(&ifv->ifv_refs); - while (refs) { - sleep_setup(&sls, &ifv->ifv_refs, PWAIT, "vlandel"); - - membar_consumer(); - refs = ifv->ifv_refs; - - sleep_finish(&sls, refs); - } - + refcnt_finalize(&ifv->ifv_refcnt, "vlanrefs"); free(ifv, M_DEVBUF, sizeof(*ifv)); return (0); diff --git a/sys/net/if_vlan_var.h b/sys/net/if_vlan_var.h index 659009eaf18..8b271e8a7d6 100644 --- a/sys/net/if_vlan_var.h +++ b/sys/net/if_vlan_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan_var.h,v 1.29 2015/09/13 09:46:45 dlg Exp $ */ +/* $OpenBSD: if_vlan_var.h,v 1.30 2015/09/13 10:02:36 dlg Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology @@ -62,6 +62,8 @@ struct vlanreq { }; #ifdef _KERNEL +#include <sys/refcnt.h> + #define mc_enm mc_u.mcu_enm struct vlan_mc_entry { @@ -85,7 +87,7 @@ struct ifvlan { LIST_HEAD(__vlan_mchead, vlan_mc_entry) vlan_mc_listhead; struct srpl_entry ifv_list; int ifv_flags; - u_int ifv_refs; + struct refcnt ifv_refcnt; void *lh_cookie; void *dh_cookie; struct ifih *ifv_ifih; |