Re: Use of M_WAITOK in if_addmulti().
> On Sun, 15 Jul 2001 16:50:36 -0400 (EDT), > Garrett Wollman <[EMAIL PROTECTED]> said: >> 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. > This is not a problem (or should not be). It is permissible to sleep > while some interrupts are blocked; it is just not (in 4-stable) > permissible to sleep in interrupt context. The PR that I sent a few > days ago was an example of one such circumstance. Is it really the > case that in6_addmulti() can be invoked in interrupt context, Yes, it is. in6_update_ifa() can be called under an interrupt context, as you pointed out, and it calls in6_joingroup(), which then calls in6_addmulti(). > and if > so, why? When a new unicast address is configured, the configuring node must be join the solicited-node multicast group corresponding to the unicast address. Since the autoconfiguration procedure runs under an interrupt context, the joining routine also runs under the context. JINMEI, Tatuya Communication Platform Lab. Corporate R&D Center, Toshiba Corp. [EMAIL PROTECTED] To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message
Use of M_WAITOK in if_addmulti().
< said: > 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. This is not a problem (or should not be). It is permissible to sleep while some interrupts are blocked; it is just not (in 4-stable) permissible to sleep in interrupt context. The PR that I sent a few days ago was an example of one such circumstance. Is it really the case that in6_addmulti() can be invoked in interrupt context, and if so, why? -GAWollman To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message
Re: Use of M_WAITOK in if_addmulti().
* Hajimu UMEMOTO <[EMAIL PROTECTED]> [010715 12:31] wrote: > > ume> Index: sys/net/if.c > ume> diff -u sys/net/if.c.orig sys/net/if.c > ume> --- sys/net/if.c.origMon Jul 16 01:39:34 2001 > ume> +++ sys/net/if.c Mon Jul 16 01:51:49 2001 > > Oops, it was wrong version. One trick is to pass a "waitok" parameter, the INET6 code would call it with it set to zero, however most other consumers would call it with it set to one meaning they can block. -- -Alfred Perlstein [[EMAIL PROTECTED]] Ok, who wrote this damn function called '??'? And why do my programs keep crashing in it? To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message
Re: Use of M_WAITOK in if_addmulti().
ume> Index: sys/net/if.c ume> diff -u sys/net/if.c.orig sys/net/if.c ume> --- sys/net/if.c.orig Mon Jul 16 01:39:34 2001 ume> +++ sys/net/if.c Mon Jul 16 01:51:49 2001 Oops, it was wrong version. Index: sys/net/if.c diff -u sys/net/if.c.orig sys/net/if.c --- sys/net/if.c.orig Mon Jul 16 01:39:34 2001 +++ sys/net/if.cMon Jul 16 01:51:49 2001 @@ -1412,8 +1412,14 @@ 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); + if (ifma == NULL) + return (ENOBUFS); + MALLOC(dupsa, struct sockaddr *, sa->sa_len, M_IFMADDR, M_NOWAIT); + if (dupsa == NULL) { + FREE(ifma, M_IFMADDR); + return (ENOBUFS); + } bcopy(sa, dupsa, sa->sa_len); ifma->ifma_addr = dupsa; @@ -1441,9 +1447,15 @@ ifma->ifma_refcount++; } else { MALLOC(ifma, struct ifmultiaddr *, sizeof *ifma, - M_IFMADDR, M_WAITOK); + M_IFMADDR, M_NOWAIT); + if (ifma == NULL) + return (ENOBUFS); MALLOC(dupsa, struct sockaddr *, llsa->sa_len, - M_IFMADDR, M_WAITOK); + M_IFMADDR, M_NOWAIT); + if (dupsa == NULL) { + FREE(ifma, M_IFMADDR); + return (ENOBUFS); + } bcopy(llsa, dupsa, llsa->sa_len); ifma->ifma_addr = dupsa; ifma->ifma_ifp = ifp; -- Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan [EMAIL PROTECTED] [EMAIL PROTECTED] ume@{,jp.}FreeBSD.org http://www.imasy.org/~ume/ To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message
Re: Use of M_WAITOK in if_addmulti().
> On Sun, 15 Jul 2001 09:19:27 -0700 > Julian Elischer <[EMAIL PROTECTED]> said: julian> NOWAIT MAY return. julian> you have not handled the case for when it returns with a NULL allocation julian> so if it returns NULL you continue, and page-fault immediatly. Oops, thank you. How about this? Index: sys/net/if.c diff -u sys/net/if.c.orig sys/net/if.c --- sys/net/if.c.orig Mon Jul 16 01:39:34 2001 +++ sys/net/if.cMon Jul 16 01:51:49 2001 @@ -1412,8 +1412,14 @@ 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); + if (iama == NULL) + return (ENOBUFS); + MALLOC(dupsa, struct sockaddr *, sa->sa_len, M_IFMADDR, M_NOWAIT); + if (dupsa == NULL) { + FREE(ifma, M_IFMADDR); + return (ENOBUFS); + } bcopy(sa, dupsa, sa->sa_len); ifma->ifma_addr = dupsa; @@ -1441,9 +1447,15 @@ ifma->ifma_refcount++; } else { MALLOC(ifma, struct ifmultiaddr *, sizeof *ifma, - M_IFMADDR, M_WAITOK); + M_IFMADDR, M_NOWAIT); + if (iama == NULL) + return (ENOBUFS); MALLOC(dupsa, struct sockaddr *, llsa->sa_len, - M_IFMADDR, M_WAITOK); + M_IFMADDR, M_NOWAIT); + if (dupsa == NULL) { + FREE(ifma, M_IFMADDR); + return (ENOBUFS); + } bcopy(llsa, dupsa, llsa->sa_len); ifma->ifma_addr = dupsa; ifma->ifma_ifp = ifp; -- Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan [EMAIL PROTECTED] [EMAIL PROTECTED] ume@{,jp.}FreeBSD.org http://www.imasy.org/~ume/ To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message
Re: Use of M_WAITOK in if_addmulti().
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.cSun 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 > [EMAIL PROTECTED] [EMAIL PROTECTED] ume@{,jp.}FreeBSD.org > http://www.imasy.org/~ume/ > > To Unsubscribe: send mail to [EMAIL PROTECTED] > with "unsubscribe freebsd-current" in the body of the message WAIT -- ++ __ _ __ | __--_|\ Julian Elischer | \ U \/ / hard at work in | / \ [EMAIL PROTECTED] +-->x USA\ a very strange | ( OZ)\___ ___ | country ! +- X_.---._/presently in San Francisco \_/ \\ v To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message
Use of M_WAITOK in if_addmulti().
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.cSun 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 [EMAIL PROTECTED] [EMAIL PROTECTED] ume@{,jp.}FreeBSD.org http://www.imasy.org/~ume/ To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message