Switch IF_AFDATA lock to rmlock
This commit is contained in:
parent
aca894e07b
commit
9883e41b4b
@ -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>
|
||||
@ -773,8 +774,11 @@ if_attachdomain1(struct ifnet *ifp)
|
||||
* Since dp->dom_ifattach calls malloc() with M_WAITOK, we
|
||||
* cannot lock ifp->if_afdata initialization, entirely.
|
||||
*/
|
||||
#if 0
|
||||
if (IF_AFDATA_TRYLOCK(ifp) == 0)
|
||||
return;
|
||||
#endif
|
||||
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",
|
||||
|
@ -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>
|
||||
@ -142,6 +143,7 @@ llentry_alloc(struct ifnet *ifp, struct lltable *lt,
|
||||
struct sockaddr_storage *dst)
|
||||
{
|
||||
struct llentry *la;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
IF_AFDATA_RLOCK(ifp);
|
||||
la = lla_lookup(lt, LLE_EXCLUSIVE, (struct sockaddr *)dst);
|
||||
|
@ -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,22 @@ EVENTHANDLER_DECLARE(group_change_event, group_change_event_handler_t);
|
||||
#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, &tracker)
|
||||
#define IF_AFDATA_WUNLOCK(ifp) rm_wunlock(&(ifp)->if_afdata_lock)
|
||||
#define IF_AFDATA_RUNLOCK(ifp) rm_runlock(&(ifp)->if_afdata_lock, &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_TRACKER struct rm_priotracker tracker
|
||||
|
||||
#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)
|
||||
|
||||
/*
|
||||
* 72 was chosen below because it is the size of a TCP/IP
|
||||
|
@ -681,6 +681,7 @@ fib6_storelladdr(struct ifnet *ifp, struct in6_addr *dst, int mm_flags,
|
||||
{
|
||||
struct llentry *ln;
|
||||
struct sockaddr_in6 dst_sa;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
if (mm_flags & M_MCAST) {
|
||||
ETHER_MAP_IPV6_MULTICAST(&dst, desten);
|
||||
|
@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/systm.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/rmlock.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/syslog.h>
|
||||
@ -354,6 +355,7 @@ arpresolve_fast(struct ifnet *ifp, struct in_addr dst, u_int mflags,
|
||||
struct llentry *la;
|
||||
struct sockaddr_in sin;
|
||||
const struct sockaddr *sa_dst;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
if (mflags & M_BCAST) {
|
||||
memcpy(dst_addr, ifp->if_broadcastaddr, ifp->if_addrlen);
|
||||
@ -437,6 +439,7 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
|
||||
const struct sockaddr *dst, u_char *desten, struct llentry **lle)
|
||||
{
|
||||
struct llentry *la = NULL;
|
||||
IF_AFDATA_TRACKER;
|
||||
int is_gw;
|
||||
|
||||
*lle = NULL;
|
||||
@ -479,6 +482,7 @@ arpresolve_slow(struct ifnet *ifp, int is_gw, struct mbuf *m,
|
||||
struct mbuf *curr = NULL;
|
||||
struct mbuf *next = NULL;
|
||||
int create, error;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
create = 0;
|
||||
*lle = NULL;
|
||||
@ -699,6 +703,7 @@ in_arpinput(struct mbuf *m)
|
||||
sin.sin_len = sizeof(struct sockaddr_in);
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_addr.s_addr = 0;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
if (ifp->if_bridge)
|
||||
bridged = 1;
|
||||
|
@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/systm.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/rmlock.h>
|
||||
#include <sys/priv.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/jail.h>
|
||||
|
@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/systm.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/rmlock.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sockopt.h>
|
||||
#include <sys/sysctl.h>
|
||||
@ -456,6 +457,7 @@ toe_nd6_resolve(struct ifnet *ifp, struct sockaddr *sa, uint8_t *lladdr)
|
||||
struct llentry *lle;
|
||||
struct sockaddr_in6 *sin6 = (void *)sa;
|
||||
int rc, flags = 0;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
restart:
|
||||
IF_AFDATA_RLOCK(ifp);
|
||||
|
@ -74,6 +74,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>
|
||||
@ -2504,6 +2505,7 @@ icmp6_redirect_output(struct mbuf *m0, struct rtentry *rt)
|
||||
struct sockaddr_in6 src_sa;
|
||||
struct route_info ri;
|
||||
struct nhop6_basic nh6;
|
||||
IF_AFDATA_TRACKER;
|
||||
int e;
|
||||
|
||||
icmp6_errcount(ND_REDIRECT, 0);
|
||||
|
@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/errno.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/rmlock.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/sockio.h>
|
||||
|
@ -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>
|
||||
@ -997,6 +998,7 @@ nd6_is_addr_neighbor(struct sockaddr_in6 *addr, struct ifnet *ifp)
|
||||
{
|
||||
struct llentry *lle;
|
||||
int rc = 0;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
IF_AFDATA_UNLOCK_ASSERT(ifp);
|
||||
if (nd6_is_new_addr_neighbor(addr, ifp))
|
||||
@ -1166,6 +1168,7 @@ nd6_nud_hint(struct rtentry *rt, struct in6_addr *dst6, int force)
|
||||
{
|
||||
struct llentry *ln;
|
||||
struct ifnet *ifp;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
if ((dst6 == NULL) || (rt == NULL))
|
||||
return;
|
||||
@ -1253,6 +1256,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
|
||||
struct nd_defrouter *dr;
|
||||
struct nd_prefix *pr;
|
||||
int i = 0, error = 0;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
if (ifp->if_afdata[AF_INET6] == NULL)
|
||||
return (EPFNOSUPPORT);
|
||||
@ -1578,6 +1582,7 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr,
|
||||
struct sockaddr_in6 sin6;
|
||||
struct mbuf *chain = NULL;
|
||||
int static_route = 0;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
IF_AFDATA_UNLOCK_ASSERT(ifp);
|
||||
|
||||
@ -1867,6 +1872,7 @@ nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m,
|
||||
{
|
||||
struct llentry *ln = NULL;
|
||||
int error = 0;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
/* discard the packet if IPv6 operation is disabled on the interface */
|
||||
if ((ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED)) {
|
||||
@ -1963,6 +1969,7 @@ nd6_output_lle(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m,
|
||||
int error = 0;
|
||||
int has_lle = 0;
|
||||
int ip6len;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
#ifdef INVARIANTS
|
||||
if (lle != NULL) {
|
||||
@ -2304,6 +2311,7 @@ nd6_storelladdr(struct ifnet *ifp, struct mbuf *m,
|
||||
const struct sockaddr *dst, u_char *desten, struct llentry **lle)
|
||||
{
|
||||
struct llentry *ln;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
*lle = NULL;
|
||||
IF_AFDATA_UNLOCK_ASSERT(ifp);
|
||||
|
@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/malloc.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>
|
||||
@ -609,6 +610,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
|
||||
struct mbuf *chain = NULL;
|
||||
struct m_tag *mtag;
|
||||
struct sockaddr_in6 sin6;
|
||||
IF_AFDATA_TRACKER;
|
||||
char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
|
||||
|
||||
if (ip6->ip6_hlim != 255) {
|
||||
|
@ -626,6 +626,7 @@ defrouter_select(void)
|
||||
{
|
||||
struct nd_defrouter *dr, *selected_dr = NULL, *installed_dr = NULL;
|
||||
struct llentry *ln = NULL;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
/*
|
||||
* Let's handle easy case (3) first:
|
||||
@ -1299,6 +1300,7 @@ find_pfxlist_reachable_router(struct nd_prefix *pr)
|
||||
struct nd_pfxrouter *pfxrtr;
|
||||
struct llentry *ln;
|
||||
int canreach;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
LIST_FOREACH(pfxrtr, &pr->ndpr_advrtrs, pfr_entry) {
|
||||
IF_AFDATA_RLOCK(pfxrtr->router->ifp);
|
||||
|
@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/param.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/rmlock.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/systm.h>
|
||||
@ -208,6 +209,7 @@ static int
|
||||
scope6_get(struct ifnet *ifp, struct scope6_id *idlist)
|
||||
{
|
||||
struct scope6_id *sid;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
/* We only need to lock the interface's afdata for SID() to work. */
|
||||
IF_AFDATA_RLOCK(ifp);
|
||||
@ -410,6 +412,7 @@ in6_setscope(struct in6_addr *in6, struct ifnet *ifp, u_int32_t *ret_id)
|
||||
int scope;
|
||||
u_int32_t zoneid = 0;
|
||||
struct scope6_id *sid;
|
||||
IF_AFDATA_TRACKER;
|
||||
|
||||
/*
|
||||
* special case: the loopback address can only belong to a loopback
|
||||
|
Loading…
x
Reference in New Issue
Block a user