Date: Tue, 17 Oct 2006 19:58:08 GMT From: Paolo Pisati <piso@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 108037 for review Message-ID: <200610171958.k9HJw8UJ077600@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=108037 Change 108037 by piso@piso_newluxor on 2006/10/17 19:57:22 Turn (where possible) mallocs from NOWAIT to WAITOK. Affected files ... .. //depot/projects/soc2005/libalias/sys/netinet/ip_fw2.c#24 edit Differences ... ==== //depot/projects/soc2005/libalias/sys/netinet/ip_fw2.c#24 (text+ko) ==== @@ -2149,20 +2149,12 @@ for(cnt = 0, off = 0; cnt < ptr->redir_cnt; cnt++) { ser_r = (struct cfg_redir *)&buf[off]; - r = malloc(sof_redir, M_IPFW, M_NOWAIT | M_ZERO); - if (r == NULL) { - panic_err = "malloc(sof_redir, ...) failed"; - goto bad; - } + r = malloc(sof_redir, M_IPFW, M_WAITOK | M_ZERO); memcpy(r, ser_r, sof_redir); LIST_INIT(&r->spool_chain); off += sof_redir; r->alink = malloc(sof_alinkp*r->pport_cnt, - M_IPFW, M_NOWAIT | M_ZERO); - if (r->alink == NULL) { - panic_err = "malloc(sof_alinkp*r->pport_cnt, ...) failed"; - goto bad; - } + M_IPFW, M_WAITOK | M_ZERO); switch (r->mode) { case REDIR_ADDR: r->alink[0] = LibAliasRedirectAddr(ptr->lib, @@ -2205,11 +2197,7 @@ } else /* LSNAT handling. */ for (i = 0; i < r->spool_cnt; i++) { ser_s = (struct cfg_spool *)&buf[off]; - s = malloc(sof_redir, M_IPFW, M_NOWAIT | M_ZERO); - if (s == NULL) { - panic_err = "malloc(sof_redir, ...) failed"; - goto bad; - } + s = malloc(sof_redir, M_IPFW, M_WAITOK | M_ZERO); memcpy(s, ser_s, sof_spool); LibAliasAddServer(ptr->lib, r->alink[0], s->addr, @@ -4550,9 +4538,7 @@ struct cfg_nat *ptr, *ser_n; char *buf; - buf = malloc(NAT_BUF_LEN, M_IPFW, M_NOWAIT | M_ZERO); - if (buf == NULL) - return (ENOSPC); + buf = malloc(NAT_BUF_LEN, M_IPFW, M_WAITOK | M_ZERO); error = sooptcopyin(sopt, buf, NAT_BUF_LEN, sizeof(struct cfg_nat)); ser_n = (struct cfg_nat *)buf; @@ -4645,9 +4631,8 @@ int sof_spool = sizeof(struct cfg_spool); int nat_cnt = 0, off = sizeof(nat_cnt); - data = malloc(NAT_BUF_LEN, M_IPFW, M_NOWAIT | M_ZERO); - if (data == NULL) - return (ENOSPC); + data = malloc(NAT_BUF_LEN, M_IPFW, M_WAITOK | M_ZERO); + IPFW_RLOCK(&layer3_chain); /* Serialize all the data. */ LIST_FOREACH(n, &layer3_chain.nat, _next) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610171958.k9HJw8UJ077600>