svn commit: r287531 - in projects/routing/sys: net netinet netinet6
Alexander V. Chernikov
melifaro at FreeBSD.org
Mon Sep 7 07:22:39 UTC 2015
Author: melifaro
Date: Mon Sep 7 07:22:35 2015
New Revision: 287531
URL: https://svnweb.freebsd.org/changeset/base/287531
Log:
Convert AFDATA lock to rmlock.
Modified:
projects/routing/sys/net/if.c
projects/routing/sys/net/if_llatbl.c
projects/routing/sys/net/if_var.h
projects/routing/sys/netinet/if_ether.c
projects/routing/sys/netinet/toecore.c
projects/routing/sys/netinet6/icmp6.c
projects/routing/sys/netinet6/in6_fib.c
projects/routing/sys/netinet6/nd6.c
projects/routing/sys/netinet6/nd6_nbr.c
projects/routing/sys/netinet6/nd6_rtr.c
projects/routing/sys/netinet6/scope6.c
Modified: projects/routing/sys/net/if.c
==============================================================================
--- projects/routing/sys/net/if.c Mon Sep 7 07:03:40 2015 (r287530)
+++ projects/routing/sys/net/if.c Mon Sep 7 07:22:35 2015 (r287531)
@@ -52,6 +52,7 @@
#include <sys/refcount.h>
#include <sys/module.h>
#include <sys/rwlock.h>
+#include <sys/rmlock.h>
#include <sys/sockio.h>
#include <sys/syslog.h>
#include <sys/sysctl.h>
@@ -790,8 +791,7 @@ if_attachdomain1(struct ifnet *ifp)
* Since dp->dom_ifattach calls malloc() with M_WAITOK, we
* cannot lock ifp->if_afdata initialization, entirely.
*/
- if (IF_AFDATA_TRYLOCK(ifp) == 0)
- return;
+ IF_AFDATA_LOCK(ifp);
if (ifp->if_afdata_initialized >= domain_init_status) {
IF_AFDATA_UNLOCK(ifp);
log(LOG_WARNING, "%s called more than once on %s\n",
@@ -1453,6 +1453,20 @@ if_data_copy(struct ifnet *ifp, struct i
ifd->ifi_noproto = ifp->if_get_counter(ifp, IFCOUNTER_NOPROTO);
}
+void
+if_afdata_wlock(struct ifnet *ifp)
+{
+
+ IF_AFDATA_WLOCK(ifp);
+}
+
+void
+if_afdata_wunlock(struct ifnet *ifp)
+{
+
+ IF_AFDATA_WUNLOCK(ifp);
+}
+
/*
* Wrapper functions for struct ifnet address list locking macros. These are
* used by kernel modules to avoid encoding programming interface or binary
Modified: projects/routing/sys/net/if_llatbl.c
==============================================================================
--- projects/routing/sys/net/if_llatbl.c Mon Sep 7 07:03:40 2015 (r287530)
+++ projects/routing/sys/net/if_llatbl.c Mon Sep 7 07:22:35 2015 (r287531)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/rwlock.h>
+#include <sys/rmlock.h>
#ifdef DDB
#include <ddb/ddb.h>
@@ -85,6 +86,7 @@ static int
lltable_dump_af(struct lltable *llt, struct sysctl_req *wr)
{
int error;
+ struct rm_priotracker if_afdata_tracker;
LLTABLE_LOCK_ASSERT();
@@ -320,6 +322,7 @@ llentry_alloc(struct ifnet *ifp, struct
struct sockaddr_storage *dst)
{
struct llentry *la, *la_tmp;
+ struct rm_priotracker if_afdata_tracker;
IF_AFDATA_RLOCK(ifp);
la = lla_lookup(lt, LLE_EXCLUSIVE, (struct sockaddr *)dst);
Modified: projects/routing/sys/net/if_var.h
==============================================================================
--- projects/routing/sys/net/if_var.h Mon Sep 7 07:03:40 2015 (r287530)
+++ projects/routing/sys/net/if_var.h Mon Sep 7 07:22:35 2015 (r287531)
@@ -192,7 +192,7 @@ struct ifnet {
int if_amcount; /* number of all-multicast requests */
struct ifaddr *if_addr; /* pointer to link-level address */
const u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */
- struct rwlock if_afdata_lock;
+ struct rmlock if_afdata_lock;
void *if_afdata[AF_MAX];
int if_afdata_initialized;
@@ -340,21 +340,24 @@ EVENTHANDLER_DECLARE(group_change_event,
#endif /* _SYS_EVENTHANDLER_H_ */
#define IF_AFDATA_LOCK_INIT(ifp) \
- rw_init(&(ifp)->if_afdata_lock, "if_afdata")
+ rm_init(&(ifp)->if_afdata_lock, "if_afdata")
-#define IF_AFDATA_WLOCK(ifp) rw_wlock(&(ifp)->if_afdata_lock)
-#define IF_AFDATA_RLOCK(ifp) rw_rlock(&(ifp)->if_afdata_lock)
-#define IF_AFDATA_WUNLOCK(ifp) rw_wunlock(&(ifp)->if_afdata_lock)
-#define IF_AFDATA_RUNLOCK(ifp) rw_runlock(&(ifp)->if_afdata_lock)
+#define IF_AFDATA_WLOCK(ifp) rm_wlock(&(ifp)->if_afdata_lock)
+#define IF_AFDATA_RLOCK(ifp) rm_rlock(&(ifp)->if_afdata_lock, &if_afdata_tracker)
+#define IF_AFDATA_WUNLOCK(ifp) rm_wunlock(&(ifp)->if_afdata_lock)
+#define IF_AFDATA_RUNLOCK(ifp) rm_runlock(&(ifp)->if_afdata_lock, &if_afdata_tracker)
#define IF_AFDATA_LOCK(ifp) IF_AFDATA_WLOCK(ifp)
#define IF_AFDATA_UNLOCK(ifp) IF_AFDATA_WUNLOCK(ifp)
-#define IF_AFDATA_TRYLOCK(ifp) rw_try_wlock(&(ifp)->if_afdata_lock)
-#define IF_AFDATA_DESTROY(ifp) rw_destroy(&(ifp)->if_afdata_lock)
+#define IF_AFDATA_TRYLOCK(ifp) rm_try_wlock(&(ifp)->if_afdata_lock)
+#define IF_AFDATA_DESTROY(ifp) rm_destroy(&(ifp)->if_afdata_lock)
-#define IF_AFDATA_LOCK_ASSERT(ifp) rw_assert(&(ifp)->if_afdata_lock, RA_LOCKED)
-#define IF_AFDATA_RLOCK_ASSERT(ifp) rw_assert(&(ifp)->if_afdata_lock, RA_RLOCKED)
-#define IF_AFDATA_WLOCK_ASSERT(ifp) rw_assert(&(ifp)->if_afdata_lock, RA_WLOCKED)
-#define IF_AFDATA_UNLOCK_ASSERT(ifp) rw_assert(&(ifp)->if_afdata_lock, RA_UNLOCKED)
+#define IF_AFDATA_LOCK_ASSERT(ifp) rm_assert(&(ifp)->if_afdata_lock, RA_LOCKED)
+#define IF_AFDATA_RLOCK_ASSERT(ifp) rm_assert(&(ifp)->if_afdata_lock, RA_RLOCKED)
+#define IF_AFDATA_WLOCK_ASSERT(ifp) rm_assert(&(ifp)->if_afdata_lock, RA_WLOCKED)
+#define IF_AFDATA_UNLOCK_ASSERT(ifp) rm_assert(&(ifp)->if_afdata_lock, RA_UNLOCKED)
+
+void if_afdata_wlock(struct ifnet *);
+void if_afdata_wunlock(struct ifnet *);
/*
* 72 was chosen below because it is the size of a TCP/IP
Modified: projects/routing/sys/netinet/if_ether.c
==============================================================================
--- projects/routing/sys/netinet/if_ether.c Mon Sep 7 07:03:40 2015 (r287530)
+++ projects/routing/sys/netinet/if_ether.c Mon Sep 7 07:22:35 2015 (r287531)
@@ -375,6 +375,7 @@ arpresolve_fast(struct ifnet *ifp, struc
int error;
struct llentry *la;
struct sockaddr_in sin;
+ struct rm_priotracker if_afdata_tracker;
if (mflags & M_BCAST) {
memcpy(dst_addr, ifp->if_broadcastaddr, ifp->if_addrlen);
@@ -431,6 +432,7 @@ arpresolve_full(struct ifnet *ifp, int i
struct mbuf *curr = NULL;
struct mbuf *next = NULL;
int error, renew;
+ struct rm_priotracker if_afdata_tracker;
if (pflags != NULL)
*pflags = 0;
@@ -556,6 +558,7 @@ arpresolve(struct ifnet *ifp, int is_gw,
const struct sockaddr *dst, u_char *desten, uint32_t *pflags)
{
struct llentry *la = 0;
+ struct rm_priotracker if_afdata_tracker;
if (pflags != NULL)
*pflags = 0;
@@ -707,6 +710,7 @@ in_arpinput(struct mbuf *m)
struct nhop4_extended nh_ext;
struct sockaddr_in sin;
struct sockaddr *dst;
+ struct rm_priotracker if_afdata_tracker;
sin.sin_len = sizeof(struct sockaddr_in);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = 0;
Modified: projects/routing/sys/netinet/toecore.c
==============================================================================
--- projects/routing/sys/netinet/toecore.c Mon Sep 7 07:03:40 2015 (r287530)
+++ projects/routing/sys/netinet/toecore.c Mon Sep 7 07:22:35 2015 (r287531)
@@ -36,6 +36,8 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/rmlock.h>
#include <sys/types.h>
#include <sys/sockopt.h>
#include <sys/sysctl.h>
@@ -459,6 +461,7 @@ toe_nd6_resolve(struct ifnet *ifp, struc
struct llentry *lle, *lle_tmp;
struct sockaddr_in6 *sin6 = (void *)sa;
int rc, flags = 0;
+ struct rm_priotracker if_afdata_tracker;
restart:
IF_AFDATA_RLOCK(ifp);
Modified: projects/routing/sys/netinet6/icmp6.c
==============================================================================
--- projects/routing/sys/netinet6/icmp6.c Mon Sep 7 07:03:40 2015 (r287530)
+++ projects/routing/sys/netinet6/icmp6.c Mon Sep 7 07:22:35 2015 (r287531)
@@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/lock.h>
+#include <sys/rmlock.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/proc.h>
@@ -2505,6 +2506,7 @@ icmp6_redirect_output(struct mbuf *m0, s
struct route_info ri;
struct nhop6_basic nh6;
int e;
+ struct rm_priotracker if_afdata_tracker;
icmp6_errcount(ND_REDIRECT, 0);
Modified: projects/routing/sys/netinet6/in6_fib.c
==============================================================================
--- projects/routing/sys/netinet6/in6_fib.c Mon Sep 7 07:03:40 2015 (r287530)
+++ projects/routing/sys/netinet6/in6_fib.c Mon Sep 7 07:22:35 2015 (r287531)
@@ -129,6 +129,7 @@ fib6_storelladdr(struct ifnet *ifp, stru
{
struct llentry *ln;
struct sockaddr_in6 dst_sa;
+ struct rm_priotracker if_afdata_tracker;
if (mm_flags & M_MCAST) {
ETHER_MAP_IPV6_MULTICAST(&dst, desten);
Modified: projects/routing/sys/netinet6/nd6.c
==============================================================================
--- projects/routing/sys/netinet6/nd6.c Mon Sep 7 07:03:40 2015 (r287530)
+++ projects/routing/sys/netinet6/nd6.c Mon Sep 7 07:22:35 2015 (r287531)
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <sys/syslog.h>
#include <sys/lock.h>
#include <sys/rwlock.h>
+#include <sys/rmlock.h>
#include <sys/queue.h>
#include <sys/sdt.h>
#include <sys/sysctl.h>
@@ -1101,6 +1102,7 @@ nd6_is_addr_neighbor(struct sockaddr_in6
{
struct llentry *lle;
int rc = 0;
+ struct rm_priotracker if_afdata_tracker;
IF_AFDATA_UNLOCK_ASSERT(ifp);
if (nd6_is_new_addr_neighbor(addr, ifp))
@@ -1266,6 +1268,7 @@ nd6_nud_hint(struct rtentry *rt, struct
{
struct llentry *ln;
struct ifnet *ifp;
+ struct rm_priotracker if_afdata_tracker;
if ((dst6 == NULL) || (rt == NULL))
return;
@@ -1353,6 +1356,7 @@ nd6_ioctl(u_long cmd, caddr_t data, stru
struct nd_defrouter *dr;
struct nd_prefix *pr;
int i = 0, error = 0;
+ struct rm_priotracker if_afdata_tracker;
if (ifp->if_afdata[AF_INET6] == NULL)
return (EPFNOSUPPORT);
@@ -1678,6 +1682,7 @@ nd6_cache_lladdr(struct ifnet *ifp, stru
struct sockaddr_in6 sin6;
struct mbuf *chain = NULL;
int static_route = 0;
+ struct rm_priotracker if_afdata_tracker;
IF_AFDATA_UNLOCK_ASSERT(ifp);
@@ -2016,6 +2021,7 @@ nd6_output(struct ifnet *ifp, struct ifn
struct sockaddr_in6 *dst, struct rtentry *rt0)
{
struct llentry *ln = NULL;
+ struct rm_priotracker if_afdata_tracker;
/* discard the packet if IPv6 operation is disabled on the interface */
if ((ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED)) {
@@ -2071,6 +2077,7 @@ nd6_output_lle(struct ifnet *ifp, struct
struct sockaddr_in6 *dst)
{
struct llentry *lle = NULL, *lle_tmp;
+ struct rm_priotracker if_afdata_tracker;
KASSERT(m != NULL, ("NULL mbuf, nothing to send"));
/* discard the packet if IPv6 operation is disabled on the interface */
@@ -2359,6 +2366,7 @@ nd6_storelladdr(struct ifnet *ifp, struc
const struct sockaddr *dst, u_char *desten, uint32_t *pflags)
{
struct llentry *ln;
+ struct rm_priotracker if_afdata_tracker;
if (pflags != NULL)
*pflags = 0;
Modified: projects/routing/sys/netinet6/nd6_nbr.c
==============================================================================
--- projects/routing/sys/netinet6/nd6_nbr.c Mon Sep 7 07:03:40 2015 (r287530)
+++ projects/routing/sys/netinet6/nd6_nbr.c Mon Sep 7 07:22:35 2015 (r287531)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/libkern.h>
#include <sys/lock.h>
#include <sys/rwlock.h>
+#include <sys/rmlock.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/sockio.h>
@@ -626,6 +627,7 @@ nd6_na_input(struct mbuf *m, int off, in
union nd_opts ndopts;
struct mbuf *chain = NULL;
struct sockaddr_in6 sin6;
+ struct rm_priotracker if_afdata_tracker;
char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
if (ip6->ip6_hlim != 255) {
Modified: projects/routing/sys/netinet6/nd6_rtr.c
==============================================================================
--- projects/routing/sys/netinet6/nd6_rtr.c Mon Sep 7 07:03:40 2015 (r287530)
+++ projects/routing/sys/netinet6/nd6_rtr.c Mon Sep 7 07:22:35 2015 (r287531)
@@ -634,6 +634,7 @@ defrouter_select(void)
{
struct nd_defrouter *dr, *selected_dr = NULL, *installed_dr = NULL;
struct llentry *ln = NULL;
+ struct rm_priotracker if_afdata_tracker;
/*
* Let's handle easy case (3) first:
@@ -1307,6 +1308,7 @@ find_pfxlist_reachable_router(struct nd_
struct nd_pfxrouter *pfxrtr;
struct llentry *ln;
int canreach;
+ struct rm_priotracker if_afdata_tracker;
LIST_FOREACH(pfxrtr, &pr->ndpr_advrtrs, pfr_entry) {
IF_AFDATA_RLOCK(pfxrtr->router->ifp);
Modified: projects/routing/sys/netinet6/scope6.c
==============================================================================
--- projects/routing/sys/netinet6/scope6.c Mon Sep 7 07:03:40 2015 (r287530)
+++ projects/routing/sys/netinet6/scope6.c Mon Sep 7 07:22:35 2015 (r287531)
@@ -33,6 +33,8 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/rmlock.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
@@ -148,11 +150,11 @@ scope6_set(struct ifnet *ifp, struct sco
int error = 0;
struct scope6_id *sid = NULL;
- IF_AFDATA_WLOCK(ifp);
+ if_afdata_wlock(ifp);
sid = SID(ifp);
if (!sid) { /* paranoid? */
- IF_AFDATA_WUNLOCK(ifp);
+ if_afdata_wunlock(ifp);
return (EINVAL);
}
@@ -175,7 +177,7 @@ scope6_set(struct ifnet *ifp, struct sco
*/
if (i == IPV6_ADDR_SCOPE_INTFACELOCAL &&
idlist->s6id_list[i] != ifp->if_index) {
- IF_AFDATA_WUNLOCK(ifp);
+ if_afdata_wunlock(ifp);
return (EINVAL);
}
@@ -187,7 +189,7 @@ scope6_set(struct ifnet *ifp, struct sco
* IDs, but we check the consistency for
* safety in later use.
*/
- IF_AFDATA_WUNLOCK(ifp);
+ if_afdata_wunlock(ifp);
return (EINVAL);
}
@@ -199,7 +201,7 @@ scope6_set(struct ifnet *ifp, struct sco
sid->s6id_list[i] = idlist->s6id_list[i];
}
}
- IF_AFDATA_WUNLOCK(ifp);
+ if_afdata_wunlock(ifp);
return (error);
}
@@ -208,6 +210,7 @@ static int
scope6_get(struct ifnet *ifp, struct scope6_id *idlist)
{
struct scope6_id *sid;
+ struct rm_priotracker if_afdata_tracker;
/* We only need to lock the interface's afdata for SID() to work. */
IF_AFDATA_RLOCK(ifp);
@@ -410,6 +413,7 @@ in6_setscope(struct in6_addr *in6, struc
int scope;
u_int32_t zoneid = 0;
struct scope6_id *sid;
+ struct rm_priotracker if_afdata_tracker;
/*
* special case: the loopback address can only belong to a loopback
More information about the svn-src-projects
mailing list