From owner-svn-src-all@freebsd.org Tue Oct 11 17:41:14 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 577FCC0DB93; Tue, 11 Oct 2016 17:41:14 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 347DC61D; Tue, 11 Oct 2016 17:41:14 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BHfDmM041808; Tue, 11 Oct 2016 17:41:13 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BHfDsr041806; Tue, 11 Oct 2016 17:41:13 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201610111741.u9BHfDsr041806@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Tue, 11 Oct 2016 17:41:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307062 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 17:41:14 -0000 Author: ae Date: Tue Oct 11 17:41:13 2016 New Revision: 307062 URL: https://svnweb.freebsd.org/changeset/base/307062 Log: Make LLTABLE list lock private for if_llatbl.c Rename lock and macros to reflect that it protects V_lltables list. Modified: head/sys/net/if_llatbl.c head/sys/net/if_llatbl.h Modified: head/sys/net/if_llatbl.c ============================================================================== --- head/sys/net/if_llatbl.c Tue Oct 11 17:12:26 2016 (r307061) +++ head/sys/net/if_llatbl.c Tue Oct 11 17:41:13 2016 (r307062) @@ -66,8 +66,13 @@ static VNET_DEFINE(SLIST_HEAD(, lltable) SLIST_HEAD_INITIALIZER(lltables); #define V_lltables VNET(lltables) -struct rwlock lltable_rwlock; -RW_SYSINIT(lltable_rwlock, &lltable_rwlock, "lltable_rwlock"); +static struct rwlock lltable_list_lock; +RW_SYSINIT(lltable_list_lock, &lltable_list_lock, "lltable_list_lock"); +#define LLTABLE_LIST_RLOCK() rw_rlock(&lltable_list_lock) +#define LLTABLE_LIST_RUNLOCK() rw_runlock(&lltable_list_lock) +#define LLTABLE_LIST_WLOCK() rw_wlock(&lltable_list_lock) +#define LLTABLE_LIST_WUNLOCK() rw_wunlock(&lltable_list_lock) +#define LLTABLE_LIST_LOCK_ASSERT() rw_assert(&lltable_list_lock, RA_LOCKED) static void lltable_unlink(struct lltable *llt); static void llentries_unlink(struct lltable *llt, struct llentries *head); @@ -85,7 +90,7 @@ lltable_dump_af(struct lltable *llt, str { int error; - LLTABLE_LOCK_ASSERT(); + LLTABLE_LIST_LOCK_ASSERT(); if (llt->llt_ifp->if_flags & IFF_LOOPBACK) return (0); @@ -108,7 +113,7 @@ lltable_sysctl_dumparp(int af, struct sy struct lltable *llt; int error = 0; - LLTABLE_RLOCK(); + LLTABLE_LIST_RLOCK(); SLIST_FOREACH(llt, &V_lltables, llt_link) { if (llt->llt_af == af) { error = lltable_dump_af(llt, wr); @@ -117,7 +122,7 @@ lltable_sysctl_dumparp(int af, struct sy } } done: - LLTABLE_RUNLOCK(); + LLTABLE_LIST_RUNLOCK(); return (error); } @@ -531,7 +536,7 @@ lltable_drain(int af) struct llentry *lle; register int i; - LLTABLE_RLOCK(); + LLTABLE_LIST_RLOCK(); SLIST_FOREACH(llt, &V_lltables, llt_link) { if (llt->llt_af != af) continue; @@ -547,7 +552,7 @@ lltable_drain(int af) } } } - LLTABLE_RUNLOCK(); + LLTABLE_LIST_RUNLOCK(); } #endif @@ -591,14 +596,14 @@ lltable_prefix_free(int af, struct socka { struct lltable *llt; - LLTABLE_RLOCK(); + LLTABLE_LIST_RLOCK(); SLIST_FOREACH(llt, &V_lltables, llt_link) { if (llt->llt_af != af) continue; llt->llt_prefix_free(llt, addr, mask, flags); } - LLTABLE_RUNLOCK(); + LLTABLE_LIST_RUNLOCK(); } struct lltable * @@ -632,18 +637,18 @@ void lltable_link(struct lltable *llt) { - LLTABLE_WLOCK(); + LLTABLE_LIST_WLOCK(); SLIST_INSERT_HEAD(&V_lltables, llt, llt_link); - LLTABLE_WUNLOCK(); + LLTABLE_LIST_WUNLOCK(); } static void lltable_unlink(struct lltable *llt) { - LLTABLE_WLOCK(); + LLTABLE_LIST_WLOCK(); SLIST_REMOVE(&V_lltables, llt, lltable, llt_link); - LLTABLE_WUNLOCK(); + LLTABLE_LIST_WUNLOCK(); } @@ -739,13 +744,13 @@ lla_rt_output(struct rt_msghdr *rtm, str } /* XXX linked list may be too expensive */ - LLTABLE_RLOCK(); + LLTABLE_LIST_RLOCK(); SLIST_FOREACH(llt, &V_lltables, llt_link) { if (llt->llt_af == dst->sa_family && llt->llt_ifp == ifp) break; } - LLTABLE_RUNLOCK(); + LLTABLE_LIST_RUNLOCK(); KASSERT(llt != NULL, ("Yep, ugly hacks are bad\n")); error = 0; Modified: head/sys/net/if_llatbl.h ============================================================================== --- head/sys/net/if_llatbl.h Tue Oct 11 17:12:26 2016 (r307061) +++ head/sys/net/if_llatbl.h Tue Oct 11 17:41:13 2016 (r307062) @@ -37,17 +37,9 @@ struct ifnet; struct sysctl_req; struct rt_msghdr; struct rt_addrinfo; - struct llentry; LIST_HEAD(llentries, llentry); -extern struct rwlock lltable_rwlock; -#define LLTABLE_RLOCK() rw_rlock(&lltable_rwlock) -#define LLTABLE_RUNLOCK() rw_runlock(&lltable_rwlock) -#define LLTABLE_WLOCK() rw_wlock(&lltable_rwlock) -#define LLTABLE_WUNLOCK() rw_wunlock(&lltable_rwlock) -#define LLTABLE_LOCK_ASSERT() rw_assert(&lltable_rwlock, RA_LOCKED) - #define LLE_MAX_LINKHDR 24 /* Full IB header */ /* * Code referencing llentry must at least hold