From owner-p4-projects@FreeBSD.ORG Thu Feb 1 00:18:16 2007 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 5BFAA16A405; Thu, 1 Feb 2007 00:18:16 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3106816A402 for ; Thu, 1 Feb 2007 00:18:16 +0000 (UTC) (envelope-from piso@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 234B913C46B for ; Thu, 1 Feb 2007 00:18:16 +0000 (UTC) (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 l110IG0J067343 for ; Thu, 1 Feb 2007 00:18:16 GMT (envelope-from piso@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l110IFf9067340 for perforce@freebsd.org; Thu, 1 Feb 2007 00:18:15 GMT (envelope-from piso@freebsd.org) Date: Thu, 1 Feb 2007 00:18:15 GMT Message-Id: <200702010018.l110IFf9067340@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 113800 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, 01 Feb 2007 00:18:16 -0000 http://perforce.freebsd.org/chv.cgi?CH=113800 Change 113800 by piso@piso_newluxor on 2007/02/01 00:17:50 Pass down the mbuf and pullup enough data for UdpAlias[In|Out](). Affected files ... .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#48 edit Differences ... ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#48 (text+ko) ==== @@ -143,6 +143,26 @@ #include "alias_mod.h" #endif +#ifdef _KERNEL + +#define PULLUP_IPHDR(pip, ptr) do { \ + struct mbuf *m; \ + m = m_pullup((ptr), sizeof(struct ip)); \ + (pip) = mtod(m, struct ip *); \ +} while (0) + +#define PULLUP_UDPHDR(pip, ptr) do { \ + struct mbuf *m; \ + pip = ptr; \ + m = m_pullup((ptr), (pip->ip_hl << 2) + sizeof(struct udphdr)); \ + (pip) = mtod(m, struct ip *); \ +} while (0) + +#else +#define PULLUP_IPHDR(pip, ptr) pip = ptr +#define PULLUP_UDPHDR(pip, ptr) pip = ptr +#endif + static __inline int twowords(void *p) { @@ -753,18 +773,15 @@ struct ip *pip; struct udphdr *ud; struct alias_link *lnk; -#ifdef _KERNEL - // XXX - m_pullup() - pip = ptr; -#else - pip = ptr; -#endif LIBALIAS_LOCK_ASSERT(la); /* Return if proxy-only mode is enabled */ if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY) return (PKT_ALIAS_OK); + PULLUP_UDPHDR(pip, ptr); + if (pip == NULL) + return (PKT_ALIAS_IGNORED); ud = (struct udphdr *)ip_next(pip); lnk = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst, @@ -791,9 +808,10 @@ alias_port = ud->uh_dport; ud->uh_dport = GetOriginalPort(lnk); - /* Walk out chain. */ + /* XXX broken - Walk out chain. */ error = find_handler(IN, UDP, la, pip, &ad); - + // XXX m_pullup() + /* If UDP checksum is not zero, then adjust since destination port */ /* is being unaliased and destination address is being altered. */ if (ud->uh_sum != 0) { @@ -826,18 +844,15 @@ struct udphdr *ud; struct alias_link *lnk; int error; -#ifdef _KERNEL - // XXX m_pullup() - pip = ptr; -#else - pip = ptr; -#endif LIBALIAS_LOCK_ASSERT(la); /* Return if proxy-only mode is enabled */ if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY) return (PKT_ALIAS_OK); + PULLUP_UDPHDR(pip, ptr); + if (pip == NULL) + return (PKT_ALIAS_IGNORED); ud = (struct udphdr *)ip_next(pip); lnk = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst, @@ -859,8 +874,9 @@ alias_address = GetAliasAddress(lnk); alias_port = GetAliasPort(lnk); - /* Walk out chain. */ + /* XXX broken - Walk out chain. */ error = find_handler(OUT, UDP, la, pip, &ad); + // XXX m_pullup() /* If UDP checksum is not zero, adjust since source port is */ /* being aliased and source address is being altered */ @@ -1290,16 +1306,6 @@ return (res); } -#ifdef _KERNEL -#define PULLUP_IPHDR(pip, ptr) do { \ - struct mbuf *m; \ - m = m_pullup((ptr), sizeof(struct ip)); \ - (pip) = mtod(m, struct ip *); \ -} while (0) -#else -#define PULLUP_IPHDR(pip, ptr) pip = ptr -#endif - static int LibAliasInLocked(struct libalias *la, void *ptr, int maxpacketsize) { @@ -1332,7 +1338,7 @@ iresult = IcmpAliasIn(la, pip); break; case IPPROTO_UDP: - iresult = UdpAliasIn(la, pip); + iresult = UdpAliasIn(la, ptr); break; case IPPROTO_TCP: iresult = TcpAliasIn(la, pip); @@ -1483,7 +1489,7 @@ iresult = IcmpAliasOut(la, pip, create); break; case IPPROTO_UDP: - iresult = UdpAliasOut(la, pip, create); + iresult = UdpAliasOut(la, ptr, create); break; case IPPROTO_TCP: iresult = TcpAliasOut(la, pip, maxpacketsize, create);