Date: Thu, 1 Feb 2007 00:18:15 GMT From: Paolo Pisati <piso@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 113800 for review Message-ID: <200702010018.l110IFf9067340@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200702010018.l110IFf9067340>