From a3335c93b9a924f9255eabefe20044ffee3ea74d Mon Sep 17 00:00:00 2001 From: rwatson Date: Tue, 2 Aug 2005 17:43:35 +0000 Subject: Add if_addr_mtx to struct ifnet, a mutex to protect ifnet-related address lists. Add accessor macros. This changes the size of struct ifnet, but ideally, all ifnet consumers are now using if_alloc() to allocate these structures rather than embedding them into device driver softc's, so this won't modify the network device driver ABI. MFC after: 1 week --- sys/net/if_var.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'sys') diff --git a/sys/net/if_var.h b/sys/net/if_var.h index c79cb89..6c4991a 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -179,6 +179,7 @@ struct ifnet { struct mtx if_afdata_mtx; struct task if_starttask; /* task for IFF_NEEDSGIANT */ struct task if_linktask; /* task for link change events */ + struct mtx if_addr_mtx; /* mutex to protect address lists */ }; typedef void if_init_f_t(void *); @@ -217,6 +218,16 @@ typedef void if_init_f_t(void *); #define if_list if_link /* + * Locks for address lists on the network interface. + */ +#define IF_ADDR_LOCK_INIT(if) mtx_init(&(if)->if_addr_mtx, \ + "if_addr_mtx", NULL, MTX_DEF) +#define IF_ADDR_LOCK_DESTROY(if) mtx_destroy(&(if)->if_addr_mtx) +#define IF_ADDR_LOCK(if) mtx_lock(&(if)->if_addr_mtx) +#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) + +/* * Output queues (ifp->if_snd) and slow device input queues (*ifp->if_slowq) * are queues of messages stored on ifqueue structures * (defined above). Entries are added to and deleted from these structures -- cgit v1.1