From owner-freebsd-net Sun Jul 15 9:24:31 2001 Delivered-To: freebsd-net@freebsd.org Received: from InterJet.elischer.org (c421509-a.pinol1.sfba.home.com [24.7.86.9]) by hub.freebsd.org (Postfix) with ESMTP id D292E37B409; Sun, 15 Jul 2001 09:24:14 -0700 (PDT) (envelope-from julian@elischer.org) Received: from elischer.org (InterJet.elischer.org [192.168.1.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id LAA79651; Sun, 15 Jul 2001 11:18:48 -0700 (PDT) Message-ID: <3B51C28F.7A56D8D8@elischer.org> Date: Sun, 15 Jul 2001 09:19:27 -0700 From: Julian Elischer X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 5.0-CURRENT i386) X-Accept-Language: en, hu MIME-Version: 1.0 To: Hajimu UMEMOTO Cc: net@FreeBSD.org, current@FreeBSD.org Subject: Re: Use of M_WAITOK in if_addmulti(). References: <20010715120317.A99869@fump.kawo2.rwth-aachen.de> <20010716.001314.59549708.ume@mahoroba.org> Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Hajimu UMEMOTO wrote: NOWAIT MAY return. you have not handled the case for when it returns with a NULL allocation so if it returns NULL you continue, and page-fault immediatly. > > 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-current" in the body of the message WAIT____ -- +------------------------------------+ ______ _ __ | __--_|\ Julian Elischer | \ U \/ / hard at work in | / \ julian@elischer.org +------>x USA \ a very strange | ( OZ ) \___ ___ | country ! +- X_.---._/ presently in San Francisco \_/ \\ v To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message