From owner-p4-projects@FreeBSD.ORG Mon Oct 16 20:14:00 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9CCF316A4E6; Mon, 16 Oct 2006 20:13:59 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6947516A4C2 for ; Mon, 16 Oct 2006 20:13:59 +0000 (UTC) (envelope-from piso@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8F1BF43D4C for ; Mon, 16 Oct 2006 20:13:51 +0000 (GMT) (envelope-from piso@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k9GKDpQ0066309 for ; Mon, 16 Oct 2006 20:13:51 GMT (envelope-from piso@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k9GKDpAs066306 for perforce@freebsd.org; Mon, 16 Oct 2006 20:13:51 GMT (envelope-from piso@freebsd.org) Date: Mon, 16 Oct 2006 20:13:51 GMT Message-Id: <200610162013.k9GKDpAs066306@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 107997 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: Mon, 16 Oct 2006 20:14:00 -0000 http://perforce.freebsd.org/chv.cgi?CH=107997 Change 107997 by piso@piso_newluxor on 2006/10/16 20:13:08 Move the helper function m_megapullup from ng_nat.c & ipfw2.c to alias.c and alias.h. Affected files ... .. //depot/projects/soc2005/libalias/sys/netgraph/ng_nat.c#3 edit .. //depot/projects/soc2005/libalias/sys/netinet/ip_fw2.c#19 edit .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#16 edit .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.h#6 edit Differences ... ==== //depot/projects/soc2005/libalias/sys/netgraph/ng_nat.c#3 (text+ko) ==== @@ -56,8 +56,6 @@ static ng_rcvdata_t ng_nat_rcvdata; static ng_disconnect_t ng_nat_disconnect; -static struct mbuf * m_megapullup(struct mbuf *, int); - /* List of commands and how to convert arguments to/from ASCII. */ static const struct ng_cmdlist ng_nat_cmdlist[] = { { @@ -327,36 +325,3 @@ return (0); } -/* - * m_megapullup() function is a big hack. - * - * It allocates an mbuf with cluster and copies the whole - * chain into cluster, so that it is all contigous and the - * whole packet can be accessed via char pointer. - * - * This is required, because libalias doesn't have idea - * about mbufs. - */ -static struct mbuf * -m_megapullup(struct mbuf *m, int len) -{ - struct mbuf *mcl; - caddr_t cp; - - if (len > MCLBYTES) - goto bad; - - 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); - mcl->m_len = mcl->m_pkthdr.len; - m_freem(m); - - return (mcl); -bad: - m_freem(m); - return (NULL); -} ==== //depot/projects/soc2005/libalias/sys/netinet/ip_fw2.c#19 (text+ko) ==== @@ -2046,42 +2046,6 @@ return match; } -/* - * m_megapullup() function (from ng_nat.c) is a big hack. - * - * It allocates an mbuf with cluster and copies the whole - * chain into cluster, so that it is all contigous and the - * whole packet can be accessed via char pointer. - * This is required, because libalias doesn't have idea - * about mbufs. - * - * On success, m_megapullup returns an mbuf with cluster - * containing the input packet, on failure NULL. - * In both cases, the input packet is consumed. - */ -static struct mbuf * -m_megapullup(struct mbuf *m, int len) { - struct mbuf *mcl; - caddr_t cp; - - if (len > MCLBYTES) - goto bad; - - 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); - mcl->m_len = mcl->m_pkthdr.len; - m_freem(m); - - return (mcl); -bad: - m_freem(m); - return (NULL); -} - static void flush_nat_ptrs(const int i) { struct ip_fw *rule; ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#16 (text+ko) ==== @@ -113,6 +113,8 @@ #ifdef _KERNEL #include +#include +#include #else #include #include @@ -1574,3 +1576,41 @@ } #endif + +#ifdef _KERNEL +/* + * m_megapullup() function is a big hack (only used in ng_nat and ipfw+nat). + * + * It allocates an mbuf with cluster and copies the whole + * chain into cluster, so that it is all contigous and the + * whole packet can be accessed via char pointer. + * This is required, because libalias doesn't have idea + * about mbufs. + * + * 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 > MCLBYTES) + goto bad; + + 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); + mcl->m_len = mcl->m_pkthdr.len; + m_freem(m); + + return (mcl); +bad: + m_freem(m); + return (NULL); +} +#endif ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.h#6 (text+ko) ==== @@ -189,6 +189,9 @@ int LibAliasUnLoadAllModule(void); int LibAliasRefreshModules(void); +/* Mbuf helper function. */ +struct mbuf *m_megapullup(struct mbuf *, int); + /* * Mode flags and other constants. */