diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-06-21 19:30:33 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-06-21 19:30:33 +0000 |
commit | 1f7e54e8c51edb13935d195e0c1f2ec68c672794 (patch) | |
tree | 2cfffa4418c1fa90f1e9d094aa882742d0ababb9 /sys/net/if_var.h | |
parent | 2fc79768f33d575d200ae1482dc23207f9d93703 (diff) | |
download | FreeBSD-src-1f7e54e8c51edb13935d195e0c1f2ec68c672794.zip FreeBSD-src-1f7e54e8c51edb13935d195e0c1f2ec68c672794.tar.gz |
Clean up common ifaddr management:
- Unify reference count and lock initialization in a single function,
ifa_init().
- Move tear-down from a macro (IFAFREE) to a function ifa_free().
- Move reference count bump from a macro (IFAREF) to a function ifa_ref().
- Instead of using a u_int protected by a mutex to refcount(9) for
reference count management.
The ifa_mtx is now used for exactly one ioctl, and possibly should be
removed.
MFC after: 3 weeks
Diffstat (limited to 'sys/net/if_var.h')
-rw-r--r-- | sys/net/if_var.h | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 556aace..cbd274a 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -706,11 +706,14 @@ struct ifaddr { /* for compatibility with other BSDs */ #define ifa_list ifa_link -#define IFA_LOCK_INIT(ifa) \ - mtx_init(&(ifa)->ifa_mtx, "ifaddr", NULL, MTX_DEF) +#ifdef _KERNEL #define IFA_LOCK(ifa) mtx_lock(&(ifa)->ifa_mtx) #define IFA_UNLOCK(ifa) mtx_unlock(&(ifa)->ifa_mtx) -#define IFA_DESTROY(ifa) mtx_destroy(&(ifa)->ifa_mtx) + +void ifa_free(struct ifaddr *ifa); +void ifa_init(struct ifaddr *ifa); +void ifa_ref(struct ifaddr *ifa); +#endif /* * The prefix structure contains information about one prefix @@ -741,24 +744,6 @@ struct ifmultiaddr { }; #ifdef _KERNEL -#define IFAFREE(ifa) \ - do { \ - IFA_LOCK(ifa); \ - KASSERT((ifa)->ifa_refcnt > 0, \ - ("ifa %p !(ifa_refcnt > 0)", ifa)); \ - if (--(ifa)->ifa_refcnt == 0) { \ - IFA_DESTROY(ifa); \ - free(ifa, M_IFADDR); \ - } else \ - IFA_UNLOCK(ifa); \ - } while (0) - -#define IFAREF(ifa) \ - do { \ - IFA_LOCK(ifa); \ - ++(ifa)->ifa_refcnt; \ - IFA_UNLOCK(ifa); \ - } while (0) extern struct rwlock ifnet_lock; #define IFNET_LOCK_INIT() \ |