summaryrefslogtreecommitdiffstats
path: root/sys/net/route.h
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2003-11-08 23:36:32 +0000
committersam <sam@FreeBSD.org>2003-11-08 23:36:32 +0000
commitc997776d7c832608d60560c380ff43549d2dbe3a (patch)
tree216d7a328008c2857f9b286342d5087eea1cc6a5 /sys/net/route.h
parent1cd9ce158fbe3f8fd872eff74a1cfd939dea5515 (diff)
downloadFreeBSD-src-c997776d7c832608d60560c380ff43549d2dbe3a.zip
FreeBSD-src-c997776d7c832608d60560c380ff43549d2dbe3a.tar.gz
replace explicit changes to rt_refcnt by RT_ADDREF and RT_REMREF
macros that expand to include assertions when the system is built with INVARIANTS Supported by: FreeBSD Foundation
Diffstat (limited to 'sys/net/route.h')
-rw-r--r--sys/net/route.h37
1 files changed, 25 insertions, 12 deletions
diff --git a/sys/net/route.h b/sys/net/route.h
index 2c60780..54f706d 100644
--- a/sys/net/route.h
+++ b/sys/net/route.h
@@ -266,19 +266,32 @@ struct rt_addrinfo {
#define RT_LOCK_DESTROY(_rt) mtx_destroy(&(_rt)->rt_mtx)
#define RT_LOCK_ASSERT(_rt) mtx_assert(&(_rt)->rt_mtx, MA_OWNED)
-#define RTFREE_LOCKED(_rt) do { \
- if ((_rt)->rt_refcnt <= 1) \
- rtfree(_rt); \
- else { \
- (_rt)->rt_refcnt--; \
- RT_UNLOCK(_rt); \
- } \
- /* guard against invalid refs */ \
- _rt = 0; \
+#define RT_ADDREF(_rt) do { \
+ RT_LOCK_ASSERT(_rt); \
+ KASSERT((_rt)->rt_refcnt >= 0, \
+ ("negative refcnt %ld", (_rt)->rt_refcnt)); \
+ (_rt)->rt_refcnt++; \
+} while (0);
+#define RT_REMREF(_rt) do { \
+ RT_LOCK_ASSERT(_rt); \
+ KASSERT((_rt)->rt_refcnt > 0, \
+ ("bogus refcnt %ld", (_rt)->rt_refcnt)); \
+ (_rt)->rt_refcnt--; \
+} while (0);
+
+#define RTFREE_LOCKED(_rt) do { \
+ if ((_rt)->rt_refcnt <= 1) \
+ rtfree(_rt); \
+ else { \
+ RT_REMREF(_rt); \
+ RT_UNLOCK(_rt); \
+ } \
+ /* guard against invalid refs */ \
+ _rt = 0; \
} while (0)
-#define RTFREE(_rt) do { \
- RT_LOCK(_rt); \
- RTFREE_LOCKED(_rt); \
+#define RTFREE(_rt) do { \
+ RT_LOCK(_rt); \
+ RTFREE_LOCKED(_rt); \
} while (0)
extern struct radix_node_head *rt_tables[AF_MAX+1];
OpenPOWER on IntegriCloud