From owner-svn-src-projects@FreeBSD.ORG Fri Mar 27 15:06:32 2015 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B6DA02B9; Fri, 27 Mar 2015 15:06:32 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A224F11C; Fri, 27 Mar 2015 15:06:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2RF6Wb1005546; Fri, 27 Mar 2015 15:06:32 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2RF6V5k005544; Fri, 27 Mar 2015 15:06:31 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201503271506.t2RF6V5k005544@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Fri, 27 Mar 2015 15:06:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r280762 - projects/ifnet/sys/net X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Mar 2015 15:06:32 -0000 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_