diff --git a/src/libs/compat/freebsd_network/compat/net/if_var.h b/src/libs/compat/freebsd_network/compat/net/if_var.h index eb34267296..067b84b8a0 100644 --- a/src/libs/compat/freebsd_network/compat/net/if_var.h +++ b/src/libs/compat/freebsd_network/compat/net/if_var.h @@ -239,6 +239,16 @@ typedef void if_init_f_t(void *); #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) + +/* + * 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 */ #define IF_ADDR_LOCK_ASSERT(if) mtx_assert(&(if)->if_addr_mtx, MA_OWNED) /* diff --git a/src/libs/compat/freebsd_network/if.c b/src/libs/compat/freebsd_network/if.c index b2f88a0166..f8204024ce 100644 --- a/src/libs/compat/freebsd_network/if.c +++ b/src/libs/compat/freebsd_network/if.c @@ -413,3 +413,36 @@ ether_ioctl(struct ifnet *ifp, u_long command, caddr_t data) 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); +}