From owner-svn-src-user@FreeBSD.ORG Thu Dec 24 19:06:13 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 93CC41065676; Thu, 24 Dec 2009 19:06:13 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6A2748FC18; Thu, 24 Dec 2009 19:06:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBOJ6DMR038722; Thu, 24 Dec 2009 19:06:13 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBOJ6Dp9038720; Thu, 24 Dec 2009 19:06:13 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200912241906.nBOJ6Dp9038720@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 24 Dec 2009 19:06:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200959 - user/luigi/ipfw3-head/sys/netinet/ipfw X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Dec 2009 19:06:13 -0000 Author: luigi Date: Thu Dec 24 19:06:13 2009 New Revision: 200959 URL: http://svn.freebsd.org/changeset/base/200959 Log: better form of endiannes adaptation Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c Thu Dec 24 18:50:59 2009 (r200958) +++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw2.c Thu Dec 24 19:06:13 2009 (r200959) @@ -606,11 +606,12 @@ send_reject(struct ip_fw_args *args, int #endif if (code != ICMP_REJECT_RST) { /* Send an ICMP unreach */ /* We need the IP header in host order for icmp_error(). */ - if (args->eh != NULL) { #ifndef HAVE_NET_IPLEN + if (args->eh != NULL) +#endif /* !HAVE_NET_IPLEN */ + { ip->ip_len = ntohs(ip->ip_len); ip->ip_off = ntohs(ip->ip_off); -#endif /* !HAVE_NET_IPLEN */ } icmp_error(args->m, ICMP_UNREACH, code, 0L, 0); } else if (args->f_id.proto == IPPROTO_TCP) { @@ -1097,14 +1098,14 @@ do { \ src_ip = ip->ip_src; dst_ip = ip->ip_dst; #ifndef HAVE_NET_IPLEN - if (args->eh != NULL) { /* layer 2 packets are as on the wire */ - offset = ntohs(ip->ip_off) & IP_OFFMASK; - ip_len = ntohs(ip->ip_len); - } else -#endif /* !HAVE_NET_IPLEN */ - { + if (args->eh == NULL) { /* on l3 these are in host format */ offset = ip->ip_off & IP_OFFMASK; ip_len = ip->ip_len; + } else +#endif /* !HAVE_NET_IPLEN */ + { /* otherwise they are in net format */ + offset = ntohs(ip->ip_off) & IP_OFFMASK; + ip_len = ntohs(ip->ip_len); } pktlen = ip_len < pktlen ? ip_len : pktlen; @@ -2166,10 +2167,13 @@ do { \ ip = mtod(m, struct ip *); hlen = ip->ip_hl << 2; #ifndef HAVE_NET_IPLEN - /* revert len & off for layer2 pkts */ + /* revert len. & off to net format if needed */ if (args->eh != NULL) - ip->ip_len = htons(ip->ip_len); #endif /* !HAVE_NET_IPLEN */ + { + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); + } ip->ip_sum = 0; if (hlen == sizeof(struct ip)) ip->ip_sum = in_cksum_hdr(ip);