summaryrefslogtreecommitdiffstats
path: root/sys/netipx
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-01-09 05:00:41 +0000
committerrwatson <rwatson@FreeBSD.org>2005-01-09 05:00:41 +0000
commita6ab698ab0edb8e7baa3a6a732e387823f1c3dcd (patch)
tree4fd6402fc00deda5073cdd5d8a3074dacec8f007 /sys/netipx
parentdbe7c51df6abf448367f1b6dd6785e0cc8b5815b (diff)
downloadFreeBSD-src-a6ab698ab0edb8e7baa3a6a732e387823f1c3dcd.zip
FreeBSD-src-a6ab698ab0edb8e7baa3a6a732e387823f1c3dcd.tar.gz
Introduce a global mutex, ipxpcb_list_mtx, to protect the global
IPX PCB lists. Add macros to initialize, destroy, lock, unlock, and assert the mutex. Initialize the mutex when IPX is started. Add per-IPX PCB mutexes, ipxp_mtx in struct ipxpcb, to protect per-PCB IPX/SPX state. Add macros to initialize, destroy, lock, unlock, and assert the mutex. Initialize the mutex when a new PCB is allocated; destroy it when the PCB is free'd. MFC after: 2 weeks
Diffstat (limited to 'sys/netipx')
-rw-r--r--sys/netipx/ipx_input.c3
-rw-r--r--sys/netipx/ipx_pcb.c2
-rw-r--r--sys/netipx/ipx_pcb.h20
3 files changed, 24 insertions, 1 deletions
diff --git a/sys/netipx/ipx_input.c b/sys/netipx/ipx_input.c
index 596b275..0e8f75e 100644
--- a/sys/netipx/ipx_input.c
+++ b/sys/netipx/ipx_input.c
@@ -88,6 +88,7 @@ struct sockaddr_ipx ipx_netmask, ipx_hostmask;
/*
* IPX protocol control block (pcb) lists.
*/
+struct mtx ipxpcb_list_mtx;
struct ipxpcbhead ipxpcb_list;
struct ipxpcbhead ipxrawpcb_list;
@@ -114,6 +115,8 @@ ipx_init()
LIST_INIT(&ipxpcb_list);
LIST_INIT(&ipxrawpcb_list);
+ IPX_LIST_LOCK_INIT();
+
ipx_netmask.sipx_len = 6;
ipx_netmask.sipx_addr.x_net = ipx_broadnet;
diff --git a/sys/netipx/ipx_pcb.c b/sys/netipx/ipx_pcb.c
index 1649b2e..322e569 100644
--- a/sys/netipx/ipx_pcb.c
+++ b/sys/netipx/ipx_pcb.c
@@ -66,6 +66,7 @@ ipx_pcballoc(so, head, td)
MALLOC(ipxp, struct ipxpcb *, sizeof *ipxp, M_PCB, M_NOWAIT | M_ZERO);
if (ipxp == NULL)
return (ENOBUFS);
+ IPX_LOCK_INIT(ipxp);
ipxp->ipxp_socket = so;
if (ipxcksum)
ipxp->ipxp_flags |= IPXP_CHECKSUM;
@@ -277,6 +278,7 @@ ipx_pcbdetach(ipxp)
if (ipxp->ipxp_route.ro_rt != NULL)
RTFREE(ipxp->ipxp_route.ro_rt);
LIST_REMOVE(ipxp, ipxp_list);
+ IPX_LOCK_DESTROY(ipxp);
FREE(ipxp, M_PCB);
}
diff --git a/sys/netipx/ipx_pcb.h b/sys/netipx/ipx_pcb.h
index 8164844..f65e133 100644
--- a/sys/netipx/ipx_pcb.h
+++ b/sys/netipx/ipx_pcb.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2004, Robert N. M. Watson
+ * Copyright (c) 2004-2005 Robert N. M. Watson
* Copyright (c) 1995, Mike Mitchell
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
@@ -54,6 +54,7 @@ struct ipxpcb {
short ipxp_flags;
u_char ipxp_dpt; /* default packet type for ipx_output */
u_char ipxp_rpt; /* last received packet type by ipx_input() */
+ struct mtx ipxp_mtx;
};
/*
@@ -63,6 +64,10 @@ LIST_HEAD(ipxpcbhead, ipxpcb);
extern struct ipxpcbhead ipxpcb_list;
extern struct ipxpcbhead ipxrawpcb_list;
+#ifdef _KERNEL
+extern struct mtx ipxpcb_list_mtx;
+#endif
+
/* possible flags */
#define IPXP_IN_ABORT 0x1 /* calling abort through socket */
@@ -97,6 +102,19 @@ struct ipxpcb *
ipx_pcblookup(struct ipx_addr *faddr, int lport, int wildp);
void ipx_setpeeraddr(struct ipxpcb *ipxp, struct sockaddr **nam);
void ipx_setsockaddr(struct ipxpcb *ipxp, struct sockaddr **nam);
+
+#define IPX_LIST_LOCK_INIT() mtx_init(&ipxpcb_list_mtx, "ipx_list_mtx", \
+ NULL, MTX_DEF | MTX_RECURSE)
+#define IPX_LIST_LOCK() mtx_lock(&ipxpcb_list_mtx)
+#define IPX_LIST_UNLOCK() mtx_unlock(&ipxpcb_list_mtx)
+#define IPX_LIST_LOCK_ASSERT() mtx_assert(&ipxpcb_list_mtx, MA_OWNED)
+
+#define IPX_LOCK_INIT(ipx) mtx_init(&(ipx)->ipxp_mtx, "ipx_mtx", NULL, \
+ MTX_DEF)
+#define IPX_LOCK_DESTROY(ipx) mtx_destroy(&(ipx)->ipxp_mtx)
+#define IPX_LOCK(ipx) mtx_lock(&(ipx)->ipxp_mtx)
+#define IPX_UNLOCK(ipx) mtx_unlock(&(ipx)->ipxp_mtx)
+#define IPX_LOCK_ASSERT(ipx) mtx_assert(&(ipx)->ipxp_mtx, MA_OWNED)
#endif /* _KERNEL */
#endif /* !_NETIPX_IPX_PCB_H_ */
OpenPOWER on IntegriCloud