From owner-p4-projects@FreeBSD.ORG Thu Jun 5 13:12:29 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 637D11065675; Thu, 5 Jun 2008 13:12:29 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2530C1065679 for ; Thu, 5 Jun 2008 13:12:29 +0000 (UTC) (envelope-from piso@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 10A288FC24 for ; Thu, 5 Jun 2008 13:12:29 +0000 (UTC) (envelope-from piso@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m55DCS8T017898 for ; Thu, 5 Jun 2008 13:12:28 GMT (envelope-from piso@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m55DCSq2017896 for perforce@freebsd.org; Thu, 5 Jun 2008 13:12:28 GMT (envelope-from piso@freebsd.org) Date: Thu, 5 Jun 2008 13:12:28 GMT Message-Id: <200806051312.m55DCSq2017896@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to piso@freebsd.org using -f From: Paolo Pisati To: Perforce Change Reviews Cc: Subject: PERFORCE change 142958 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jun 2008 13:12:29 -0000 http://perforce.freebsd.org/chv.cgi?CH=142958 Change 142958 by piso@piso_ferret on 2008/06/05 13:11:51 Revert modifications made to m_megapullup(). Affected files ... .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#81 edit Differences ... ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#81 (text+ko) ==== @@ -1698,49 +1698,29 @@ * m_megapullup() - this function is a big hack. * Thankfully, it's only used in ng_nat and ipfw+nat. * - * It allocates an mbuf with cluster and copies the specified part of the chain - * into cluster, so that it is all contiguous and can be accessed via a plain - * (char *) pointer. This is required, because libalias doesn't know how to - * handle mbuf chains. + * It allocates an mbuf with cluster and copies the whole chain into cluster, + * so that it is all contiguous and the whole packet can be accessed via a + * plain (char *) pointer. This is required, because libalias doesn't know + * how to handle mbuf chains. * - * On success, m_megapullup returns an mbuf (possibly with cluster) containing - * the input packet, on failure NULL. The input packet is always consumed. + * On success, m_megapullup returns an mbuf with cluster containing the input + * packet, on failure NULL. In both cases, the input packet is consumed. */ struct mbuf * m_megapullup(struct mbuf *m, int len) { struct mbuf *mcl; + caddr_t cp; - if (len > m->m_pkthdr.len) + if (len > MCLBYTES) goto bad; - /* Do not reallocate packet if it is sequentional, - * writable and has some extra space for expansion. - * XXX: Constant 100bytes is completely empirical. */ -#define RESERVE 100 - if (m->m_next == NULL && M_WRITABLE(m) && M_TRAILINGSPACE(m) >= RESERVE) - return (m); - - if (len <= MCLBYTES - RESERVE) { - mcl = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); - } else if (len < MJUM16BYTES) { - int size; - if (len <= MJUMPAGESIZE - RESERVE) { - size = MJUMPAGESIZE; - } else if (len <= MJUM9BYTES - RESERVE) { - size = MJUM9BYTES; - } else { - size = MJUM16BYTES; - }; - mcl = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, size); - } else { - goto bad; - } - if (mcl == NULL) + if ((mcl = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR)) == NULL) goto bad; + cp = mtod(mcl, caddr_t); + m_copydata(m, 0, len, cp); m_move_pkthdr(mcl, m); - m_copydata(m, 0, len, mtod(mcl, caddr_t)); - mcl->m_len = mcl->m_pkthdr.len = len; + mcl->m_len = mcl->m_pkthdr.len; m_freem(m); return (mcl);