Date: Fri, 27 Mar 2015 15:06:31 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r280762 - projects/ifnet/sys/net Message-ID: <201503271506.t2RF6V5k005544@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Fri Mar 27 15:06:31 2015 New Revision: 280762 URL: https://svnweb.freebsd.org/changeset/base/280762 Log: Rename if_addr_lock to if_lock, since it already protects not only address lists, and is going to protect even more. Modified: projects/ifnet/sys/net/if.c projects/ifnet/sys/net/if_var.h Modified: projects/ifnet/sys/net/if.c ============================================================================== --- projects/ifnet/sys/net/if.c Fri Mar 27 14:40:58 2015 (r280761) +++ projects/ifnet/sys/net/if.c Fri Mar 27 15:06:31 2015 (r280762) @@ -579,7 +579,7 @@ if_attach(struct if_attach_args *ifat) if (ifdrv->ifdrv_maxqlen > 0) ifp->if_snd = if_snd_alloc(ifdrv->ifdrv_maxqlen); - IF_ADDR_LOCK_INIT(ifp); + rw_init(&ifp->if_lock, "if_lock"); IF_AFDATA_LOCK_INIT(ifp); TASK_INIT(&ifp->if_linktask, 0, do_link_state_change, ifp); TAILQ_INIT(&ifp->if_addrhead); @@ -661,7 +661,7 @@ if_free_internal(struct ifnet *ifp) if (ifp->if_description != NULL) free(ifp->if_description, M_IFDESCR); IF_AFDATA_DESTROY(ifp); - IF_ADDR_LOCK_DESTROY(ifp); + rw_destroy(&ifp->if_lock); if (ifp->if_snd) if_snd_free(ifp->if_snd); Modified: projects/ifnet/sys/net/if_var.h ============================================================================== --- projects/ifnet/sys/net/if_var.h Fri Mar 27 14:40:58 2015 (r280761) +++ projects/ifnet/sys/net/if_var.h Fri Mar 27 15:06:31 2015 (r280762) @@ -90,12 +90,14 @@ struct ifnet { struct ifdriver *if_drv; /* driver static definition */ struct iftype *if_type; /* if type static def (optional)*/ struct iftsomax *if_tsomax; /* TSO limits */ + + struct rwlock if_lock; /* lock to protect the ifnet */ /* General book keeping of interface lists. */ TAILQ_ENTRY(ifnet) if_link; /* all struct ifnets are chained */ LIST_ENTRY(ifnet) if_clones; /* interfaces of a cloner */ TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per if */ - /* protected by if_addr_lock */ + /* protected by if_lock */ void *if_llsoftc; /* link layer softc */ void *if_l2com; /* pointer to protocol bits */ int if_dunit; /* unit or IF_DUNIT_NONE */ @@ -124,7 +126,6 @@ struct ifnet { struct task if_linktask; /* task for link change events */ /* Addresses of different protocol families assigned to this if. */ - struct rwlock if_addr_lock; /* lock to protect address lists */ /* * if_addrhead is the list of all addresses associated to * an interface. @@ -168,16 +169,24 @@ struct ifnet { }; /* - * Locks for address lists on the network interface. + * Modyfing interface requires synchronisation. + */ +#define IF_WLOCK(ifp) rw_wlock(&(ifp)->if_lock) +#define IF_WUNLOCK(if) rw_wunlock(&(ifp)->if_lock) +#define IF_RLOCK(ifp) rw_rlock(&(ifp)->if_lock) +#define IF_RUNLOCK(ifp) rw_runlock(&(ifp)->if_lock) +#define IF_LOCK_ASSERT(ifp) rw_assert(&(ifp)->if_lock, RA_LOCKED) +#define IF_WLOCK_ASSERT(ifp) rw_assert(&(ifp)->if_lock, RA_WLOCKED) +/* + * Originally only address lists were locked, so we keep these macros + * for compatibility, until they are cleaned up from kernel. */ -#define IF_ADDR_LOCK_INIT(if) rw_init(&(if)->if_addr_lock, "if_addr_lock") -#define IF_ADDR_LOCK_DESTROY(if) rw_destroy(&(if)->if_addr_lock) -#define IF_ADDR_WLOCK(if) rw_wlock(&(if)->if_addr_lock) -#define IF_ADDR_WUNLOCK(if) rw_wunlock(&(if)->if_addr_lock) -#define IF_ADDR_RLOCK(if) rw_rlock(&(if)->if_addr_lock) -#define IF_ADDR_RUNLOCK(if) rw_runlock(&(if)->if_addr_lock) -#define IF_ADDR_LOCK_ASSERT(if) rw_assert(&(if)->if_addr_lock, RA_LOCKED) -#define IF_ADDR_WLOCK_ASSERT(if) rw_assert(&(if)->if_addr_lock, RA_WLOCKED) +#define IF_ADDR_WLOCK(ifp) IF_WLOCK(ifp) +#define IF_ADDR_WUNLOCK(ifp) IF_WUNLOCK(ifp) +#define IF_ADDR_RLOCK(ifp) IF_RLOCK(ifp) +#define IF_ADDR_RUNLOCK(ifp) IF_RUNLOCK(ifp) +#define IF_ADDR_LOCK_ASSERT(ifp) IF_LOCK_ASSERT(ifp) +#define IF_ADDR_WLOCK_ASSERT(ifp) IF_WLOCK_ASSERT(ifp) #ifdef _KERNEL #ifdef _SYS_EVENTHANDLER_H_
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201503271506.t2RF6V5k005544>