summaryrefslogtreecommitdiffstats
path: root/sys/netinet/in_pcb.h
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2003-11-08 22:48:27 +0000
committersam <sam@FreeBSD.org>2003-11-08 22:48:27 +0000
commite0d3008a3fb80872d82c1b1ed81635db1b62364e (patch)
tree1b3ca6ddac383b208b3f4558c3f648888b667ad5 /sys/netinet/in_pcb.h
parent2514456ec973900c0a4e4be0673a733a603d3081 (diff)
downloadFreeBSD-src-e0d3008a3fb80872d82c1b1ed81635db1b62364e.zip
FreeBSD-src-e0d3008a3fb80872d82c1b1ed81635db1b62364e.tar.gz
add locking assertions that turn into noops if INET6 is configured;
this is necessary because the ipv6 code shares the in_pcb code with ipv4 but (presently) lacks proper locking Supported by: FreeBSD Foundation
Diffstat (limited to 'sys/netinet/in_pcb.h')
-rw-r--r--sys/netinet/in_pcb.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h
index 429bf79..19786b59 100644
--- a/sys/netinet/in_pcb.h
+++ b/sys/netinet/in_pcb.h
@@ -246,11 +246,21 @@ struct inpcbinfo { /* XXX documentation, prefixes */
struct mtx ipi_mtx;
};
+/*
+ * NB: We cannot enable assertions when IPv6 is configured as
+ * this code is shared by both IPv4 and IPv6 and IPv6 is
+ * not properly locked.
+ */
#define INP_LOCK_INIT(inp, d) \
mtx_init(&(inp)->inp_mtx, (d), NULL, MTX_DEF | MTX_RECURSE | MTX_DUPOK)
#define INP_LOCK_DESTROY(inp) mtx_destroy(&(inp)->inp_mtx)
#define INP_LOCK(inp) mtx_lock(&(inp)->inp_mtx)
#define INP_UNLOCK(inp) mtx_unlock(&(inp)->inp_mtx)
+#ifndef INET6
+#define INP_LOCK_ASSERT(inp) mtx_assert(&(inp)->inp_mtx, MA_OWNED)
+#else
+#define INP_LOCK_ASSERT(inp)
+#endif
#define INP_INFO_LOCK_INIT(ipi, d) \
mtx_init(&(ipi)->ipi_mtx, (d), NULL, MTX_DEF | MTX_RECURSE)
@@ -258,6 +268,13 @@ struct inpcbinfo { /* XXX documentation, prefixes */
#define INP_INFO_WLOCK(ipi) mtx_lock(&(ipi)->ipi_mtx)
#define INP_INFO_RUNLOCK(ipi) mtx_unlock(&(ipi)->ipi_mtx)
#define INP_INFO_WUNLOCK(ipi) mtx_unlock(&(ipi)->ipi_mtx)
+#ifndef INET6
+#define INP_INFO_RLOCK_ASSERT(ipi) mtx_assert(&(ipi)->ipi_mtx, MA_OWNED)
+#define INP_INFO_WLOCK_ASSERT(ipi) mtx_assert(&(ipi)->ipi_mtx, MA_OWNED)
+#else
+#define INP_INFO_RLOCK_ASSERT(ipi)
+#define INP_INFO_WLOCK_ASSERT(ipi)
+#endif
#define INP_PCBHASH(faddr, lport, fport, mask) \
(((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask))
OpenPOWER on IntegriCloud