From owner-svn-src-all@freebsd.org Tue Oct 31 10:31:48 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A7AB8E5490C; Tue, 31 Oct 2017 10:31:48 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 76F076DB4F; Tue, 31 Oct 2017 10:31:48 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9VAVlRC007908; Tue, 31 Oct 2017 10:31:47 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9VAVlui007907; Tue, 31 Oct 2017 10:31:47 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201710311031.v9VAVlui007907@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Tue, 31 Oct 2017 10:31:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r325229 - stable/11/sys/netpfil/ipfw X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sys/netpfil/ipfw X-SVN-Commit-Revision: 325229 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Oct 2017 10:31:48 -0000 Author: ae Date: Tue Oct 31 10:31:47 2017 New Revision: 325229 URL: https://svnweb.freebsd.org/changeset/base/325229 Log: MFC r324947: Add IPv6 support for O_TCPDATALEN opcode. PR: 222746 Modified: stable/11/sys/netpfil/ipfw/ip_fw2.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netpfil/ipfw/ip_fw2.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw2.c Tue Oct 31 10:15:03 2017 (r325228) +++ stable/11/sys/netpfil/ipfw/ip_fw2.c Tue Oct 31 10:31:47 2017 (r325229) @@ -963,7 +963,7 @@ ipfw_chk(struct ip_fw_args *args) uint8_t proto; uint16_t src_port = 0, dst_port = 0; /* NOTE: host format */ struct in_addr src_ip, dst_ip; /* NOTE: network format */ - uint16_t iplen=0; + int iplen = 0; int pktlen; uint16_t etype = 0; /* Host order stored ether type */ @@ -1205,6 +1205,7 @@ do { \ args->f_id.src_ip = 0; args->f_id.dst_ip = 0; args->f_id.flow_id6 = ntohl(ip6->ip6_flow); + iplen = ntohs(ip6->ip6_plen) + sizeof(*ip6); } else if (pktlen >= sizeof(struct ip) && (args->eh == NULL || etype == ETHERTYPE_IP) && ip->ip_v == 4) { is_ipv4 = 1; @@ -1219,7 +1220,6 @@ do { \ dst_ip = ip->ip_dst; offset = ntohs(ip->ip_off) & IP_OFFMASK; iplen = ntohs(ip->ip_len); - pktlen = iplen < pktlen ? iplen : pktlen; if (offset == 0) { switch (proto) { @@ -1258,6 +1258,7 @@ do { \ args->f_id.dst_ip = ntohl(dst_ip.s_addr); } #undef PULLUP_TO + pktlen = iplen < pktlen ? iplen: pktlen; if (proto) { /* we may have port numbers, store them */ args->f_id.proto = proto; args->f_id.src_port = src_port = ntohs(src_port); @@ -1771,10 +1772,25 @@ do { \ uint16_t x; uint16_t *p; int i; +#ifdef INET6 + if (is_ipv6) { + struct ip6_hdr *ip6; + ip6 = (struct ip6_hdr *)ip; + if (ip6->ip6_plen == 0) { + /* + * Jumbo payload is not + * supported by this + * opcode. + */ + break; + } + x = iplen - hlen; + } else +#endif /* INET6 */ + x = iplen - (ip->ip_hl << 2); tcp = TCP(ulp); - x = iplen - - ((ip->ip_hl + tcp->th_off) << 2); + x -= tcp->th_off << 2; if (cmdlen == 1) { match = (cmd->arg1 == x); break;