Make LLTABLE list lock private for if_llatbl.c
Rename lock and macros to reflect that it protects V_lltables list.
This commit is contained in:
parent
9ba323071d
commit
199511bcdd
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=307062
@ -66,8 +66,13 @@ static VNET_DEFINE(SLIST_HEAD(, lltable), lltables) =
|
||||
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, struct sysctl_req *wr)
|
||||
{
|
||||
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 sysctl_req *wr)
|
||||
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 sysctl_req *wr)
|
||||
}
|
||||
}
|
||||
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 sockaddr *addr, struct sockaddr *mask,
|
||||
{
|
||||
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, struct rt_addrinfo *info)
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user