DragonFly BSD
DragonFly submit List (threaded) for 2004-03
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Fix panic with IPFW


From: Craig Dooley <craig@xxxxxxxxxx>
Date: Tue, 9 Mar 2004 08:38:41 -0500

IPFW was causing a panic whenever I loaded rules because it was using
M_DONTWAIT. Change this to M_WAITOK since all the code in ipfw mallocs 
with M_NOWAIT except when it's under spl protection. Reverse this behavior 
and use M_WAITOK except when under spl.

-Craig
-- 
------------------------------------------------------------------------
Craig Dooley                                            craig@xxxxxxxxxx
------------------------------------------------------------------------
Index: net/ipfw/ip_fw.c
===================================================================
RCS file: /home/dcvs/src/sys/net/ipfw/ip_fw.c,v
retrieving revision 1.6
diff -u -r1.6 ip_fw.c
--- net/ipfw/ip_fw.c	6 Jan 2004 03:17:26 -0000	1.6
+++ net/ipfw/ip_fw.c	9 Mar 2004 13:29:30 -0000
@@ -850,14 +850,14 @@
 	    if (ipfw_dyn_v != NULL)
 		free(ipfw_dyn_v, M_IPFW);
 	    ipfw_dyn_v = malloc(curr_dyn_buckets * sizeof r,
-                   M_IPFW, M_DONTWAIT | M_ZERO);
+                   M_IPFW, M_WAITOK | M_ZERO);
 	    if (ipfw_dyn_v == NULL)
 		return NULL; /* failed ! */
 	}
     }
     i = hash_packet(id);
 
-    r = malloc(sizeof *r, M_IPFW, M_NOWAIT | M_ZERO);
+    r = malloc(sizeof *r, M_IPFW, M_WAITOK | M_ZERO);
     if (r == NULL) {
 	printf ("sorry cannot allocate state\n");
 	return NULL ;
@@ -1631,7 +1631,7 @@
 	u_short nbr = 0;
 	int s;
 
-	ftmp = malloc(sizeof *ftmp, M_IPFW, M_NOWAIT | M_ZERO);
+	ftmp = malloc(sizeof *ftmp, M_IPFW, M_WAITOK | M_ZERO);
 	if (!ftmp)
 		return (ENOSPC);
 	bcopy(rule, ftmp, sizeof(*ftmp));
@@ -1953,7 +1953,7 @@
 		 * bother filling up the buffer, just jump to the
 		 * sooptcopyout.
 		 */
-		buf = malloc(size, M_TEMP, M_WAITOK);
+		buf = malloc(size, M_TEMP, M_NOWAIT);
 		if (buf == 0) {
 		    splx(s);
 		    error = ENOBUFS;
Index: net/ipfw/ip_fw2.c
===================================================================
RCS file: /home/dcvs/src/sys/net/ipfw/ip_fw2.c,v
retrieving revision 1.7
diff -u -r1.7 ip_fw2.c
--- net/ipfw/ip_fw2.c	14 Feb 2004 21:12:38 -0000	1.7
+++ net/ipfw/ip_fw2.c	9 Mar 2004 13:30:02 -0000
@@ -847,7 +847,7 @@
 		free(ipfw_dyn_v, M_IPFW);
 	for (;;) {
 		ipfw_dyn_v = malloc(curr_dyn_buckets * sizeof(ipfw_dyn_rule *),
-		       M_IPFW, M_NOWAIT | M_ZERO);
+		       M_IPFW, M_WAITOK | M_ZERO);
 		if (ipfw_dyn_v != NULL || curr_dyn_buckets <= 2)
 			break;
 		curr_dyn_buckets /= 2;
@@ -878,7 +878,7 @@
 	}
 	i = hash_packet(id);
 
-	r = malloc(sizeof *r, M_IPFW, M_NOWAIT | M_ZERO);
+	r = malloc(sizeof *r, M_IPFW, M_WAITOK | M_ZERO);
 	if (r == NULL) {
 		printf ("sorry cannot allocate state\n");
 		return NULL;
@@ -1984,7 +1984,7 @@
 	if (*head == NULL && input_rule->rulenum != IPFW_DEFAULT_RULE)
 		return (EINVAL);
 
-	rule = malloc(l, M_IPFW, M_NOWAIT | M_ZERO);
+	rule = malloc(l, M_IPFW, M_WAITOK | M_ZERO);
 	if (rule == NULL)
 		return (ENOSPC);
 
@@ -2494,7 +2494,7 @@
 		 * how much room is needed, do not bother filling up the
 		 * buffer, just jump to the sooptcopyout.
 		 */
-		buf = malloc(size, M_TEMP, M_WAITOK);
+		buf = malloc(size, M_TEMP, M_NOWAIT);
 		if (buf == 0) {
 			splx(s);
 			error = ENOBUFS;

Attachment: pgp00004.pgp
Description: PGP signature



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]