summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorbmilekic <bmilekic@FreeBSD.org>2002-12-19 22:58:27 +0000
committerbmilekic <bmilekic@FreeBSD.org>2002-12-19 22:58:27 +0000
commit514c635ee6d3ff47b542ec91a037e7a241c1357c (patch)
treefb78678839efbdec9c58873ff5e7df1cf42aa7f5 /sys/net
parent13bc2a4ca63803cb5287e5acd86ed9b2e3238689 (diff)
downloadFreeBSD-src-514c635ee6d3ff47b542ec91a037e7a241c1357c.zip
FreeBSD-src-514c635ee6d3ff47b542ec91a037e7a241c1357c.tar.gz
o Untangle the confusion with the malloc flags {M_WAITOK, M_NOWAIT} and
the mbuf allocator flags {M_TRYWAIT, M_DONTWAIT}. o Fix a bpf_compat issue where malloc() was defined to just call bpf_alloc() and pass the 'canwait' flag(s) along. It's been changed to call bpf_alloc() but pass the corresponding M_TRYWAIT or M_DONTWAIT flag (and only one of those two). Submitted by: Hiten Pandya <hiten@unixdaemons.com> (hiten->commit_count++)
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/bpf_compat.h8
-rw-r--r--sys/net/bridge.c4
-rw-r--r--sys/net/if_ethersubr.c4
-rw-r--r--sys/net/radix.c1
-rw-r--r--sys/net/radix.h2
-rw-r--r--sys/net/raw_cb.c2
6 files changed, 10 insertions, 11 deletions
diff --git a/sys/net/bpf_compat.h b/sys/net/bpf_compat.h
index cac9aff..212ac5f 100644
--- a/sys/net/bpf_compat.h
+++ b/sys/net/bpf_compat.h
@@ -40,14 +40,14 @@
/*
* Some hacks for compatibility across SunOS and 4.4BSD. We emulate malloc
* and free with mbuf clusters. We store a pointer to the mbuf in the first
- * word of the mbuf and return 8 bytes passed the start of data (for double
+ * word of the mbuf and return 8 bytes past the start of data (for double
* word alignment). We cannot just use offsets because clusters are not at
* a fixed offset from the associated mbuf. Sorry for this kludge.
*/
-#define malloc(size, type, canwait) bpf_alloc(size, canwait)
+#define malloc(size, type, canwait) \
+bpf_alloc(size, (canwait & M_NOWAIT) ? M_DONTWAIT : M_TRYWAIT)
+
#define free(cp, type) m_free(*(struct mbuf **)(cp - 8))
-#define M_WAITOK M_TRYWAIT
-#define M_NOWAIT M_DONTWAIT
/* This mapping works for our purposes. */
#define ERESTART EINTR
diff --git a/sys/net/bridge.c b/sys/net/bridge.c
index b5fa0e9..295c208 100644
--- a/sys/net/bridge.c
+++ b/sys/net/bridge.c
@@ -239,7 +239,7 @@ add_cluster(u_int16_t cluster_id, struct arpcom *ac)
goto found;
/* Not found, need to reallocate */
- c = malloc((1+n_clusters) * sizeof (*c), M_IFADDR, M_DONTWAIT | M_ZERO);
+ c = malloc((1+n_clusters) * sizeof (*c), M_IFADDR, M_NOWAIT | M_ZERO);
if (c == NULL) {/* malloc failure */
printf("-- bridge: cannot add new cluster\n");
return NULL;
@@ -793,7 +793,7 @@ static struct mbuf *
bdg_forward(struct mbuf *m0, struct ifnet *dst)
{
#define EH_RESTORE(_m) do { \
- M_PREPEND((_m), ETHER_HDR_LEN, M_NOWAIT); \
+ M_PREPEND((_m), ETHER_HDR_LEN, M_DONTWAIT); \
if ((_m) == NULL) { \
bdg_dropped++; \
return NULL; \
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 4273f0e..c40c4d6 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -470,7 +470,7 @@ ether_ipfw_chk(struct mbuf **m0, struct ifnet *dst,
* Restore Ethernet header, as needed, in case the
* mbuf chain was replaced by ipfw.
*/
- M_PREPEND(m, ETHER_HDR_LEN, M_NOWAIT);
+ M_PREPEND(m, ETHER_HDR_LEN, M_DONTWAIT);
if (m == NULL) {
*m0 = m;
return 0;
@@ -894,7 +894,7 @@ discard:
* Put back the ethernet header so netgraph has a
* consistent view of inbound packets.
*/
- M_PREPEND(m, sizeof (struct ether_header), M_NOWAIT);
+ M_PREPEND(m, sizeof (struct ether_header), M_DONTWAIT);
(*ng_ether_input_orphan_p)(ifp, m);
return;
}
diff --git a/sys/net/radix.c b/sys/net/radix.c
index 86da493..e1742f3 100644
--- a/sys/net/radix.c
+++ b/sys/net/radix.c
@@ -42,7 +42,6 @@
#ifdef _KERNEL
#include <sys/systm.h>
#include <sys/malloc.h>
-#define M_DONTWAIT M_NOWAIT
#include <sys/domain.h>
#else
#include <stdlib.h>
diff --git a/sys/net/radix.h b/sys/net/radix.h
index 5d51745..3a65585 100644
--- a/sys/net/radix.h
+++ b/sys/net/radix.h
@@ -150,7 +150,7 @@ struct radix_node_head {
#define Bcmp(a, b, n) bcmp(((caddr_t)(a)), ((caddr_t)(b)), (unsigned)(n))
#define Bcopy(a, b, n) bcopy(((caddr_t)(a)), ((caddr_t)(b)), (unsigned)(n))
#define Bzero(p, n) bzero((caddr_t)(p), (unsigned)(n));
-#define R_Malloc(p, t, n) (p = (t) malloc((unsigned long)(n), M_RTABLE, M_DONTWAIT))
+#define R_Malloc(p, t, n) (p = (t) malloc((unsigned long)(n), M_RTABLE, M_NOWAIT))
#define Free(p) free((caddr_t)p, M_RTABLE);
#endif /* _KERNEL */
diff --git a/sys/net/raw_cb.c b/sys/net/raw_cb.c
index 7e45500..6f3f8b5 100644
--- a/sys/net/raw_cb.c
+++ b/sys/net/raw_cb.c
@@ -139,7 +139,7 @@ raw_bind(so, nam)
if (ifnet == 0)
return (EADDRNOTAVAIL);
rp = sotorawcb(so);
- nam = m_copym(nam, 0, M_COPYALL, M_WAITOK);
+ nam = m_copym(nam, 0, M_COPYALL, M_TRYWAIT);
rp->rcb_laddr = mtod(nam, struct sockaddr *);
return (0);
}
OpenPOWER on IntegriCloud