1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-20 11:11:24 +00:00

Define four wrapper functions for interface address locking,

if_addr_rlock() and if_addr_runlock() for regular address lists, and
if_maddr_rlock() and if_maddr_runlock() for multicast address lists.

We will use these in various kernel modules to avoid encoding specific
type and locking strategy information into modules that currently use
IF_ADDR_LOCK() and IF_ADDR_UNLOCK() directly.

MFC after:	6 weeks
This commit is contained in:
Robert Watson 2009-06-26 00:36:47 +00:00
parent 534027673b
commit f9ef96ca71
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=195020
2 changed files with 44 additions and 0 deletions

View File

@ -1418,6 +1418,40 @@ if_rtdel(struct radix_node *rn, void *arg)
return (0);
}
/*
* Wrapper functions for struct ifnet address list locking macros. These are
* used by kernel modules to avoid encoding programming interface or binary
* interface assumptions that may be violated when kernel-internal locking
* approaches change.
*/
void
if_addr_rlock(struct ifnet *ifp)
{
IF_ADDR_LOCK(ifp);
}
void
if_addr_runlock(struct ifnet *ifp)
{
IF_ADDR_UNLOCK(ifp);
}
void
if_maddr_rlock(struct ifnet *ifp)
{
IF_ADDR_LOCK(ifp);
}
void
if_maddr_runlock(struct ifnet *ifp)
{
IF_ADDR_UNLOCK(ifp);
}
/*
* Reference count functions for ifaddrs.
*/

View File

@ -252,6 +252,16 @@ typedef void if_init_f_t(void *);
#define IF_ADDR_UNLOCK(if) mtx_unlock(&(if)->if_addr_mtx)
#define IF_ADDR_LOCK_ASSERT(if) mtx_assert(&(if)->if_addr_mtx, MA_OWNED)
/*
* Function variations on locking macros intended to be used by loadable
* kernel modules in order to divorce them from the internals of address list
* locking.
*/
void if_addr_rlock(struct ifnet *ifp); /* if_addrhead */
void if_addr_runlock(struct ifnet *ifp); /* if_addrhead */
void if_maddr_rlock(struct ifnet *ifp); /* if_multiaddrs */
void if_maddr_runlock(struct ifnet *ifp); /* if_multiaddrs */
/*
* Output queues (ifp->if_snd) and slow device input queues (*ifp->if_slowq)
* are queues of messages stored on ifqueue structures