Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Jul 2001 00:13:14 +0900 (JST)
From:      Hajimu UMEMOTO <ume@mahoroba.org>
To:        net@FreeBSD.org, current@FreeBSD.org
Subject:   Use of M_WAITOK in if_addmulti().
Message-ID:  <20010716.001314.59549708.ume@mahoroba.org>
In-Reply-To: <20010715120317.A99869@fump.kawo2.rwth-aachen.de>
References:  <20010715120317.A99869@fump.kawo2.rwth-aachen.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

Current if_addmulti() calls MALLOC() with M_WAITOK.  However,
if_addmulti() can be called from in[6]_addmulti() with splnet().  It
may lead kernel panic.  So, I wish to change to use M_NOWAIT.
Any comment?

Index: sys/net/if.c
diff -u sys/net/if.c.orig sys/net/if.c
--- sys/net/if.c.orig	Wed Jul  4 20:28:47 2001
+++ sys/net/if.c	Sun Jul 15 23:47:15 2001
@@ -1412,8 +1412,8 @@
 		llsa = 0;
 	}
 
-	MALLOC(ifma, struct ifmultiaddr *, sizeof *ifma, M_IFMADDR, M_WAITOK);
-	MALLOC(dupsa, struct sockaddr *, sa->sa_len, M_IFMADDR, M_WAITOK);
+	MALLOC(ifma, struct ifmultiaddr *, sizeof *ifma, M_IFMADDR, M_NOWAIT);
+	MALLOC(dupsa, struct sockaddr *, sa->sa_len, M_IFMADDR, M_NOWAIT);
 	bcopy(sa, dupsa, sa->sa_len);
 
 	ifma->ifma_addr = dupsa;
@@ -1441,9 +1441,9 @@
 			ifma->ifma_refcount++;
 		} else {
 			MALLOC(ifma, struct ifmultiaddr *, sizeof *ifma,
-			       M_IFMADDR, M_WAITOK);
+			       M_IFMADDR, M_NOWAIT);
 			MALLOC(dupsa, struct sockaddr *, llsa->sa_len,
-			       M_IFMADDR, M_WAITOK);
+			       M_IFMADDR, M_NOWAIT);
 			bcopy(llsa, dupsa, llsa->sa_len);
 			ifma->ifma_addr = dupsa;
 			ifma->ifma_ifp = ifp;

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume@mahoroba.org  ume@bisd.hitachi.co.jp  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010716.001314.59549708.ume>