DragonFly submit List (threaded) for 2003-07
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Fixing Mbuf/Malloc flag usage
Backport patch was mbuf/malloc flag usage clearup.
Brief Summary:
The mbuf M_DONTWAIT/M_TRYWAIT flags end up being
used as M_WAITOK/M_NOWAIT. This patch clears this
mess.
Cheers.
-- Hiten (hmp@xxxxxxxxxxx)
Index: net/bridge.c
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/net/bridge.c,v
retrieving revision 1.2
diff -u -r1.2 bridge.c
--- net/bridge.c 17 Jun 2003 04:28:47 -0000 1.2
+++ net/bridge.c 20 Jul 2003 02:16:33 -0000
@@ -243,7 +243,7 @@
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;
Index: net/radix.c
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/net/radix.c,v
retrieving revision 1.2
diff -u -r1.2 radix.c
--- net/radix.c 17 Jun 2003 04:28:48 -0000 1.2
+++ net/radix.c 20 Jul 2003 02:16:33 -0000
@@ -43,7 +43,6 @@
#ifdef _KERNEL
#include <sys/systm.h>
#include <sys/malloc.h>
-#define M_DONTWAIT M_NOWAIT
#include <sys/domain.h>
#else
#include <stdlib.h>
Index: net/radix.h
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/net/radix.h,v
retrieving revision 1.2
diff -u -r1.2 radix.h
--- net/radix.h 17 Jun 2003 04:28:48 -0000 1.2
+++ net/radix.h 20 Jul 2003 02:16:33 -0000
@@ -151,7 +151,7 @@
#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 */
Index: net/raw_cb.c
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/net/raw_cb.c,v
retrieving revision 1.2
diff -u -r1.2 raw_cb.c
--- net/raw_cb.c 17 Jun 2003 04:28:48 -0000 1.2
+++ net/raw_cb.c 20 Jul 2003 02:16:33 -0000
@@ -139,7 +139,7 @@
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);
}
Index: netgraph/ng_l2tp.c
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/netgraph/ng_l2tp.c,v
retrieving revision 1.2
diff -u -r1.2 ng_l2tp.c
--- netgraph/ng_l2tp.c 17 Jun 2003 04:28:50 -0000 1.2
+++ netgraph/ng_l2tp.c 20 Jul 2003 02:16:33 -0000
@@ -56,6 +56,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 @@
#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
@@ -937,7 +937,7 @@
}
/* 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);
}
@@ -1204,7 +1204,7 @@
*/
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);
@@ -1350,7 +1350,7 @@
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);
Index: netgraph/ng_ppp.c
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/netgraph/ng_ppp.c,v
retrieving revision 1.2
diff -u -r1.2 ng_ppp.c
--- netgraph/ng_ppp.c 17 Jun 2003 04:28:51 -0000 1.2
+++ netgraph/ng_ppp.c 20 Jul 2003 02:16:33 -0000
@@ -1546,7 +1546,7 @@
/* 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_DATA(m, meta);
@@ -1864,7 +1864,7 @@
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);
Index: netgraph/ng_pptpgre.c
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/netgraph/ng_pptpgre.c,v
retrieving revision 1.2
diff -u -r1.2 ng_pptpgre.c
--- netgraph/ng_pptpgre.c 17 Jun 2003 04:28:51 -0000 1.2
+++ netgraph/ng_pptpgre.c 20 Jul 2003 02:16:33 -0000
@@ -538,7 +538,7 @@
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++;
Index: netinet/ip_encap.c
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/netinet/ip_encap.c,v
retrieving revision 1.2
diff -u -r1.2 ip_encap.c
--- netinet/ip_encap.c 17 Jun 2003 04:28:51 -0000 1.2
+++ netinet/ip_encap.c 20 Jul 2003 02:16:50 -0000
@@ -492,7 +492,7 @@
{
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);
Index: netinet/ip_fw.c
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/netinet/ip_fw.c,v
retrieving revision 1.2
diff -u -r1.2 ip_fw.c
--- netinet/ip_fw.c 17 Jun 2003 04:28:51 -0000 1.2
+++ netinet/ip_fw.c 20 Jul 2003 02:16:50 -0000
@@ -854,7 +854,7 @@
}
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 ;
@@ -1628,7 +1628,7 @@
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));
Index: netinet6/esp_core.c
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/netinet6/esp_core.c,v
retrieving revision 1.2
diff -u -r1.2 esp_core.c
--- netinet6/esp_core.c 17 Jun 2003 04:28:51 -0000 1.2
+++ netinet6/esp_core.c 20 Jul 2003 02:16:50 -0000
@@ -220,7 +220,7 @@
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;
Index: netinet6/ip6_fw.c
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/netinet6/ip6_fw.c,v
retrieving revision 1.2
diff -u -r1.2 ip6_fw.c
--- netinet6/ip6_fw.c 17 Jun 2003 04:28:52 -0000 1.2
+++ netinet6/ip6_fw.c 20 Jul 2003 02:16:50 -0000
@@ -844,8 +844,8 @@
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);
Index: netinet6/ip6_input.c
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.4
diff -u -r1.4 ip6_input.c
--- netinet6/ip6_input.c 25 Jun 2003 03:56:04 -0000 1.4
+++ netinet6/ip6_input.c 20 Jul 2003 02:16:50 -0000
@@ -1609,7 +1609,7 @@
if (!tag) {
tag = m_tag_get(PACKET_TAG_IPV6_INPUT,
sizeof (struct ip6aux),
- M_NOWAIT);
+ M_DONTWAIT);
if (tag)
m_tag_prepend(m, tag);
}
Index: netinet6/ipcomp_output.c
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/netinet6/ipcomp_output.c,v
retrieving revision 1.2
diff -u -r1.2 ipcomp_output.c
--- netinet6/ipcomp_output.c 17 Jun 2003 04:28:52 -0000 1.2
+++ netinet6/ipcomp_output.c 20 Jul 2003 02:16:50 -0000
@@ -172,12 +172,12 @@
* 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;
Index: netipsec/keysock.c
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/netipsec/keysock.c,v
retrieving revision 1.2
diff -u -r1.2 keysock.c
--- netipsec/keysock.c 17 Jun 2003 04:28:53 -0000 1.2
+++ netipsec/keysock.c 20 Jul 2003 02:17:39 -0000
@@ -155,7 +155,7 @@
if (promisc) {
struct sadb_msg *pmsg;
- M_PREPEND(m, sizeof(struct sadb_msg), M_DONTWAIT);
+ M_PREPEND(m, sizeof(struct sadb_msg), M_NOWAIT);
if (m && m->m_len < sizeof(struct sadb_msg))
m = m_pullup(m, sizeof(struct sadb_msg));
if (!m) {
Index: netkey/keysock.c
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/netkey/keysock.c,v
retrieving revision 1.2
diff -u -r1.2 keysock.c
--- netkey/keysock.c 17 Jun 2003 04:28:53 -0000 1.2
+++ netkey/keysock.c 20 Jul 2003 02:17:39 -0000
@@ -150,7 +150,7 @@
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) {
Index: netsmb/smb_trantcp.c
===================================================================
RCS file: /home/hmp/perforce/df-cvs/src/sys/netsmb/smb_trantcp.c,v
retrieving revision 1.4
diff -u -r1.4 smb_trantcp.c
--- netsmb/smb_trantcp.c 19 Jul 2003 21:14:45 -0000 1.4
+++ netsmb/smb_trantcp.c 20 Jul 2003 02:17:39 -0000
@@ -568,7 +568,7 @@
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);
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]