summaryrefslogtreecommitdiffstats
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
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++)
-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
-rw-r--r--sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c2
-rw-r--r--sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c4
-rw-r--r--sys/netgraph/ng_bridge.c2
-rw-r--r--sys/netgraph/ng_l2tp.c10
-rw-r--r--sys/netgraph/ng_one2many.c2
-rw-r--r--sys/netgraph/ng_ppp.c4
-rw-r--r--sys/netgraph/ng_pptpgre.c2
-rw-r--r--sys/netgraph/ng_source.c2
-rw-r--r--sys/netgraph/ng_tee.c2
-rw-r--r--sys/netinet/ip_encap.c2
-rw-r--r--sys/netinet/ip_fw.c4
-rw-r--r--sys/netinet6/esp_core.c2
-rw-r--r--sys/netinet6/ip6_fw.c4
-rw-r--r--sys/netinet6/ip6_input.c2
-rw-r--r--sys/netinet6/ipcomp_output.c4
-rw-r--r--sys/netipsec/keysock.c2
-rw-r--r--sys/netkey/keysock.c2
-rw-r--r--sys/netsmb/smb_trantcp.c2
24 files changed, 37 insertions, 38 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);
}
diff --git a/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c b/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
index 69fcbf0..8fa8a08 100644
--- a/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
+++ b/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
@@ -1271,7 +1271,7 @@ ng_btsocket_hci_raw_send(struct socket *so, int flags, struct mbuf *m,
sa = (struct sockaddr *) &pcb->addr;
}
- MGET(nam, M_WAITOK, MT_SONAME);
+ MGET(nam, M_TRYWAIT, MT_SONAME);
if (nam == NULL) {
error = ENOBUFS;
goto drop;
diff --git a/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c b/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
index 8360038..dec7a3c 100644
--- a/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
+++ b/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
@@ -1464,7 +1464,7 @@ ng_btsocket_l2cap_data_input(struct mbuf *m, hook_p hook)
* it is a broadcast traffic after all
*/
- copy = m_dup(m, M_NOWAIT);
+ copy = m_dup(m, M_DONTWAIT);
if (copy != NULL) {
sbappendrecord(&pcb->so->so_rcv, copy);
sorwakeup(pcb->so);
@@ -2384,7 +2384,7 @@ ng_btsocket_l2cap_send2(ng_btsocket_l2cap_pcb_p pcb)
if (pcb->so->so_snd.sb_cc == 0)
return (EINVAL); /* XXX */
- m = m_dup(pcb->so->so_snd.sb_mb, M_NOWAIT);
+ m = m_dup(pcb->so->so_snd.sb_mb, M_DONTWAIT);
if (m == NULL)
return (ENOBUFS);
diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c
index 1e1ff1c..f552a50 100644
--- a/sys/netgraph/ng_bridge.c
+++ b/sys/netgraph/ng_bridge.c
@@ -713,7 +713,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item)
* It's usable link but not the reserved (first) one.
* Copy mbuf and meta info for sending.
*/
- m2 = m_dup(m, M_NOWAIT); /* XXX m_copypacket() */
+ m2 = m_dup(m, M_DONTWAIT); /* XXX m_copypacket() */
if (m2 == NULL) {
link->stats.memoryFailures++;
NG_FREE_ITEM(item);
diff --git a/sys/netgraph/ng_l2tp.c b/sys/netgraph/ng_l2tp.c
index e467cb5..ebc6a41 100644
--- a/sys/netgraph/ng_l2tp.c
+++ b/sys/netgraph/ng_l2tp.c
@@ -55,6 +55,7 @@
#include <sys/mbuf.h>
#include <sys/malloc.h>
#include <sys/errno.h>
+#include <sys/libkern.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
@@ -295,9 +296,8 @@ NETGRAPH_INIT(l2tp, &ng_l2tp_typestruct);
#define L2TP_SEQ_CHECK(x) do { } while (0)
#endif
-/* mem*() macros */
+/* memmove macro */
#define memmove(d, s, l) ovbcopy(s, d, l)
-#define memset(d, z, l) bzero(d, l) /* XXX */
/* Whether to use m_copypacket() or m_dup() */
#define L2TP_COPY_MBUF m_copypacket
@@ -955,7 +955,7 @@ ng_l2tp_recv_ctrl(node_p node, item_p item)
}
/* Copy packet */
- if ((m = L2TP_COPY_MBUF(seq->xwin[i], M_NOWAIT)) == NULL) {
+ if ((m = L2TP_COPY_MBUF(seq->xwin[i], M_DONTWAIT)) == NULL) {
priv->stats.memoryFailures++;
return (ENOBUFS);
}
@@ -1219,7 +1219,7 @@ ng_l2tp_seq_recv_nr(priv_p priv, u_int16_t nr)
*/
while ((i = L2TP_SEQ_DIFF(seq->ns, seq->rack)) < seq->cwnd
&& seq->xwin[i] != NULL) {
- if ((m = L2TP_COPY_MBUF(seq->xwin[i], M_NOWAIT)) == NULL)
+ if ((m = L2TP_COPY_MBUF(seq->xwin[i], M_DONTWAIT)) == NULL)
priv->stats.memoryFailures++;
else
ng_l2tp_xmit_ctrl(priv, m, seq->ns);
@@ -1361,7 +1361,7 @@ ng_l2tp_seq_rack_timeout(void *arg)
seq->acks = 0;
/* Retransmit oldest unack'd packet */
- if ((m = L2TP_COPY_MBUF(seq->xwin[0], M_NOWAIT)) == NULL)
+ if ((m = L2TP_COPY_MBUF(seq->xwin[0], M_DONTWAIT)) == NULL)
priv->stats.memoryFailures++;
else
ng_l2tp_xmit_ctrl(priv, m, seq->rack);
diff --git a/sys/netgraph/ng_one2many.c b/sys/netgraph/ng_one2many.c
index 5332049..927bb77 100644
--- a/sys/netgraph/ng_one2many.c
+++ b/sys/netgraph/ng_one2many.c
@@ -427,7 +427,7 @@ ng_one2many_rcvdata(hook_p hook, item_p item)
struct ng_one2many_link *mdst;
mdst = &priv->many[priv->activeMany[i]];
- m2 = m_dup(m, M_NOWAIT); /* XXX m_copypacket() */
+ m2 = m_dup(m, M_DONTWAIT); /* XXX m_copypacket() */
if (m2 == NULL) {
mdst->stats.memoryFailures++;
NG_FREE_ITEM(item);
diff --git a/sys/netgraph/ng_ppp.c b/sys/netgraph/ng_ppp.c
index 16373e3..6ffb082 100644
--- a/sys/netgraph/ng_ppp.c
+++ b/sys/netgraph/ng_ppp.c
@@ -1595,7 +1595,7 @@ deliver:
/* Split off next fragment as "m2" */
m2 = m;
if (!lastFragment) {
- struct mbuf *n = m_split(m, len, M_NOWAIT);
+ struct mbuf *n = m_split(m, len, M_DONTWAIT);
if (n == NULL) {
NG_FREE_M(m);
@@ -1916,7 +1916,7 @@ ng_ppp_addproto(struct mbuf *m, int proto, int compOK)
static struct mbuf *
ng_ppp_prepend(struct mbuf *m, const void *buf, int len)
{
- M_PREPEND(m, len, M_NOWAIT);
+ M_PREPEND(m, len, M_DONTWAIT);
if (m == NULL || (m->m_len < len && (m = m_pullup(m, len)) == NULL))
return (NULL);
bcopy(buf, mtod(m, u_char *), len);
diff --git a/sys/netgraph/ng_pptpgre.c b/sys/netgraph/ng_pptpgre.c
index f87e415..50811da 100644
--- a/sys/netgraph/ng_pptpgre.c
+++ b/sys/netgraph/ng_pptpgre.c
@@ -532,7 +532,7 @@ ng_pptpgre_xmit(node_p node, item_p item)
m->m_len = m->m_pkthdr.len = grelen;
m->m_pkthdr.rcvif = NULL;
} else {
- M_PREPEND(m, grelen, M_NOWAIT);
+ M_PREPEND(m, grelen, M_DONTWAIT);
if (m == NULL || (m->m_len < grelen
&& (m = m_pullup(m, grelen)) == NULL)) {
priv->stats.memoryFailures++;
diff --git a/sys/netgraph/ng_source.c b/sys/netgraph/ng_source.c
index 4932b3f..b2e976c 100644
--- a/sys/netgraph/ng_source.c
+++ b/sys/netgraph/ng_source.c
@@ -638,7 +638,7 @@ ng_source_send (sc_p sc, int tosend, int *sent_p)
break;
/* duplicate the packet */
- m2 = m_copypacket(m, M_NOWAIT);
+ m2 = m_copypacket(m, M_DONTWAIT);
if (m2 == NULL) {
s = splnet();
IF_PREPEND(&sc->snd_queue, m);
diff --git a/sys/netgraph/ng_tee.c b/sys/netgraph/ng_tee.c
index 877ef16..fbe80ba 100644
--- a/sys/netgraph/ng_tee.c
+++ b/sys/netgraph/ng_tee.c
@@ -334,7 +334,7 @@ ngt_rcvdata(hook_p hook, item_p item)
meta_p meta2;
/* Copy packet (failure will not stop the original)*/
- m2 = m_dup(m, M_NOWAIT);
+ m2 = m_dup(m, M_DONTWAIT);
if (m2) {
/* Copy meta info */
diff --git a/sys/netinet/ip_encap.c b/sys/netinet/ip_encap.c
index a547c66..478cdfa 100644
--- a/sys/netinet/ip_encap.c
+++ b/sys/netinet/ip_encap.c
@@ -487,7 +487,7 @@ encap_fillarg(m, ep)
{
struct m_tag *tag;
- tag = m_tag_get(PACKET_TAG_ENCAP, sizeof (void*), M_NOWAIT);
+ tag = m_tag_get(PACKET_TAG_ENCAP, sizeof (void*), M_DONTWAIT);
if (tag) {
*(void**)(tag+1) = ep->arg;
m_tag_prepend(m, tag);
diff --git a/sys/netinet/ip_fw.c b/sys/netinet/ip_fw.c
index d7ccad7..8a41f99 100644
--- a/sys/netinet/ip_fw.c
+++ b/sys/netinet/ip_fw.c
@@ -882,7 +882,7 @@ add_dyn_rule(struct ipfw_flow_id *id, u_int8_t dyn_type, struct ip_fw *rule)
}
i = hash_packet(id);
- r = malloc(sizeof *r, M_IPFW, M_DONTWAIT | M_ZERO);
+ r = malloc(sizeof *r, M_IPFW, M_NOWAIT | M_ZERO);
if (r == NULL) {
printf ("sorry cannot allocate state\n");
return NULL ;
@@ -1695,7 +1695,7 @@ add_entry(struct ip_fw_head *head, struct ip_fw *rule)
u_short nbr = 0;
int s;
- ftmp = malloc(sizeof *ftmp, M_IPFW, M_DONTWAIT | M_ZERO);
+ ftmp = malloc(sizeof *ftmp, M_IPFW, M_NOWAIT | M_ZERO);
if (!ftmp)
return (ENOSPC);
bcopy(rule, ftmp, sizeof(*ftmp));
diff --git a/sys/netinet6/esp_core.c b/sys/netinet6/esp_core.c
index 54ca346..db09b94 100644
--- a/sys/netinet6/esp_core.c
+++ b/sys/netinet6/esp_core.c
@@ -219,7 +219,7 @@ esp_schedule(algo, sav)
sav->schedlen = (*algo->schedlen)(algo);
if (sav->schedlen < 0)
return EINVAL;
- sav->sched = malloc(sav->schedlen, M_SECA, M_DONTWAIT);
+ sav->sched = malloc(sav->schedlen, M_SECA, M_NOWAIT);
if (!sav->sched) {
sav->schedlen = 0;
return ENOBUFS;
diff --git a/sys/netinet6/ip6_fw.c b/sys/netinet6/ip6_fw.c
index da968e2..c3e6d88 100644
--- a/sys/netinet6/ip6_fw.c
+++ b/sys/netinet6/ip6_fw.c
@@ -845,8 +845,8 @@ add_entry6(struct ip6_fw_head *chainptr, struct ip6_fw *frwl)
u_short nbr = 0;
int s;
- fwc = malloc(sizeof *fwc, M_IP6FW, M_DONTWAIT);
- ftmp = malloc(sizeof *ftmp, M_IP6FW, M_DONTWAIT);
+ fwc = malloc(sizeof *fwc, M_IP6FW, M_NOWAIT);
+ ftmp = malloc(sizeof *ftmp, M_IP6FW, M_NOWAIT);
if (!fwc || !ftmp) {
dprintf(("%s malloc said no\n", err_prefix));
if (fwc) free(fwc, M_IP6FW);
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index 82c1036..e76727f 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -1623,7 +1623,7 @@ ip6_addaux(m)
if (!tag) {
tag = m_tag_get(PACKET_TAG_IPV6_INPUT,
sizeof (struct ip6aux),
- M_NOWAIT);
+ M_DONTWAIT);
if (tag)
m_tag_prepend(m, tag);
}
diff --git a/sys/netinet6/ipcomp_output.c b/sys/netinet6/ipcomp_output.c
index 009b01e..71e5755 100644
--- a/sys/netinet6/ipcomp_output.c
+++ b/sys/netinet6/ipcomp_output.c
@@ -171,12 +171,12 @@ ipcomp_output(m, nexthdrp, md, isr, af)
* compromise two m_copym(). we will be going through every byte of
* the payload during compression process anyways.
*/
- mcopy = m_copym(m, 0, M_COPYALL, M_NOWAIT);
+ mcopy = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
if (mcopy == NULL) {
error = ENOBUFS;
return 0;
}
- md0 = m_copym(md, 0, M_COPYALL, M_NOWAIT);
+ md0 = m_copym(md, 0, M_COPYALL, M_DONTWAIT);
if (md0 == NULL) {
m_freem(mcopy);
error = ENOBUFS;
diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c
index 39f57e5..d61c15b 100644
--- a/sys/netipsec/keysock.c
+++ b/sys/netipsec/keysock.c
@@ -152,7 +152,7 @@ key_sendup0(rp, m, promisc)
if (promisc) {
struct sadb_msg *pmsg;
- M_PREPEND(m, sizeof(struct sadb_msg), M_NOWAIT);
+ M_PREPEND(m, sizeof(struct sadb_msg), M_DONTWAIT);
if (m && m->m_len < sizeof(struct sadb_msg))
m = m_pullup(m, sizeof(struct sadb_msg));
if (!m) {
diff --git a/sys/netkey/keysock.c b/sys/netkey/keysock.c
index 1bf62de..60b43c4 100644
--- a/sys/netkey/keysock.c
+++ b/sys/netkey/keysock.c
@@ -147,7 +147,7 @@ key_sendup0(rp, m, promisc)
if (promisc) {
struct sadb_msg *pmsg;
- M_PREPEND(m, sizeof(struct sadb_msg), M_NOWAIT);
+ M_PREPEND(m, sizeof(struct sadb_msg), M_DONTWAIT);
if (m && m->m_len < sizeof(struct sadb_msg))
m = m_pullup(m, sizeof(struct sadb_msg));
if (!m) {
diff --git a/sys/netsmb/smb_trantcp.c b/sys/netsmb/smb_trantcp.c
index 37085b5..cf0adcb 100644
--- a/sys/netsmb/smb_trantcp.c
+++ b/sys/netsmb/smb_trantcp.c
@@ -648,7 +648,7 @@ smb_nbst_send(struct smb_vc *vcp, struct mbuf *m0, struct thread *td)
error = ENOTCONN;
goto abort;
}
- M_PREPEND(m0, 4, M_WAITOK);
+ M_PREPEND(m0, 4, M_TRYWAIT);
if (m0 == NULL)
return ENOBUFS;
nb_sethdr(m0, NB_SSN_MESSAGE, m_fixhdr(m0) - 4);
OpenPOWER on IntegriCloud