From owner-p4-projects@FreeBSD.ORG Tue May 27 14:48:34 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A2E51106567D; Tue, 27 May 2008 14:48:34 +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 4BEC41065679 for ; Tue, 27 May 2008 14:48:34 +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 3B7EA8FC1F for ; Tue, 27 May 2008 14:48:34 +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 m4REmYGb093499 for ; Tue, 27 May 2008 14:48:34 GMT (envelope-from piso@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m4REmY7U093497 for perforce@freebsd.org; Tue, 27 May 2008 14:48:34 GMT (envelope-from piso@freebsd.org) Date: Tue, 27 May 2008 14:48:34 GMT Message-Id: <200805271448.m4REmY7U093497@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 142390 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: Tue, 27 May 2008 14:48:34 -0000 http://perforce.freebsd.org/chv.cgi?CH=142390 Change 142390 by piso@piso_ferret on 2008/05/27 14:48:33 Reenable modules: -push the megapullup hack down one level, around modules call. -pass the pkt_t abstraction to modules, this way in kernel land they have access to the mbuf. Next step: convert, one by one, all the modules so they can natively handle mbufs. Affected files ... .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#79 edit .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.c#32 edit .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.h#27 edit Differences ... ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#79 (text+ko) ==== @@ -752,7 +752,10 @@ ud->uh_dport = GetOriginalPort(lnk); /* Walk out chain. */ - error = find_handler(IN, UDP, la, pip, &ad); + error = find_handler(IN, UDP, la, ptr, &ad); + PULLUP_IPHDR(pip, ptr); + PULLUP_UDPHDR(pip, ptr); + ud = (struct udphdr *)ip_next(pip); /* If UDP checksum is not zero, then adjust since destination port */ /* is being unaliased and destination address is being altered. */ @@ -815,7 +818,10 @@ alias_port = GetAliasPort(lnk); /* Walk out chain. */ - error = find_handler(OUT, UDP, la, pip, &ad); + error = find_handler(OUT, UDP, la, ptr, &ad); + PULLUP_IPHDR(pip, ptr); + PULLUP_UDPHDR(pip, ptr); + ud = (struct udphdr *)ip_next(pip); /* If UDP checksum is not zero, adjust since source port is */ /* being aliased and source address is being altered */ @@ -883,7 +889,10 @@ }; /* Walk out chain. */ - error = find_handler(IN, TCP, la, pip, &ad); + error = find_handler(IN, TCP, la, ptr, &ad); + PULLUP_IPHDR(pip, ptr); + PULLUP_TCPHDR(pip, ptr); + tc = (struct tcphdr *)ip_next(pip); alias_address = GetAliasAddress(lnk); original_address = GetOriginalAddress(lnk); @@ -909,7 +918,10 @@ }; /* Walk out chain. */ - error = find_handler(la, pip, &ad); + error = find_handler(la, ptr, &ad); + PULLUP_IPHDR(pip, ptr); + PULLUP_TCPHDR(pip, ptr); + tc = (struct tcphdr *)ip_next(pip); if (error == EHDNOF) printf("Protocol handler not found\n"); #endif @@ -1049,7 +1061,10 @@ TcpMonitorOut(tc->th_flags, lnk); /* Walk out chain. */ - error = find_handler(OUT, TCP, la, pip, &ad); + error = find_handler(OUT, TCP, la, ptr, &ad); + PULLUP_IPHDR(pip, ptr); + PULLUP_TCPHDR(pip, ptr); + tc = (struct tcphdr *)ip_next(pip); /* Adjust TCP checksum since source port is being aliased */ /* and source address is being altered */ @@ -1298,7 +1313,9 @@ }; /* Walk out chain. */ - error = find_handler(IN, IP, la, pip, &ad); + error = find_handler(IN, IP, la, ptr, &ad); + PULLUP_IPHDR(pip, ptr); + if (error == 0) iresult = PKT_ALIAS_OK; else @@ -1443,7 +1460,8 @@ .maxpktsize = 0 }; /* Walk out chain. */ - error = find_handler(OUT, IP, la, pip, &ad); + error = find_handler(OUT, IP, la, ptr, &ad); + PULLUP_IPHDR(pip, ptr); error = 0; if (error == 0) iresult = PKT_ALIAS_OK; ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.c#32 (text+ko) ==== @@ -30,6 +30,8 @@ #ifdef _KERNEL #include #include +#include +#include #include #include #else @@ -44,9 +46,11 @@ #include #ifdef _KERNEL +#include #include #include #else +#include "alias.h" #include "alias_local.h" #include "alias_mod.h" #endif @@ -218,11 +222,13 @@ return (error); } +// XXX pullup again after calling this function... int -find_handler(int8_t dir, int8_t proto, struct libalias *la, __unused struct ip *pip, +find_handler(int8_t dir, int8_t proto, struct libalias *la, pkt_t pkt, struct alias_data *ad) { struct proto_handler *p; + struct ip *pip; int error; LIBALIAS_RLOCK(); @@ -230,7 +236,17 @@ LIST_FOREACH(p, &handler_chain, entries) { if ((p->dir & dir) && (p->proto & proto)) if (p->fingerprint(la, ad) == 0) { - //error = p->protohandler(la, pip, ad); +#ifdef _KERNEL + *pkt = m_megapullup(*pkt, (*pkt)->m_pkthdr.len); + if (*pkt == NULL) { + error = EPERM; + break; + } + pip = mtod(*pkt, struct ip *); +#else + pip = (struct ip *)pkt; +#endif + error = p->protohandler(la, pip, ad); break; } } ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.h#27 (text+ko) ==== @@ -34,6 +34,12 @@ #ifndef _ALIAS_MOD_H_ #define _ALIAS_MOD_H_ +#ifdef _KERNEL +#include +#else +#include "alias.h" +#endif + #ifdef _KERNEL MALLOC_DECLARE(M_ALIAS); @@ -114,7 +120,7 @@ int LibAliasDetachHandlers(struct proto_handler *); int detach_handler(struct proto_handler *); int find_handler(int8_t, int8_t, struct libalias *, - struct ip *, struct alias_data *); + pkt_t, struct alias_data *); struct proto_handler *first_handler(void); /* Functions used with dll module. */