From nobody Tue Nov 10 04:45:35 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jNvGq5brjz6xfDK; Tue, 10 Nov 2026 04:45:39 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from omta004.cacentral1.a.cloudfilter.net (omta002.cacentral1.a.cloudfilter.net [3.97.99.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jNvGp5MVGz4nw6; Tue, 10 Nov 2026 04:45:38 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=permerror reason="p tag has invalid value: quarantine rua=mailto:p[ostmaster@cschubert.com" header.from=cschubert.com (policy=permerror); spf=pass (mx1.freebsd.org: domain of cy.schubert@cschubert.com designates 3.97.99.33 as permitted sender) smtp.mailfrom=cy.schubert@cschubert.com Received: from shw-obgw-4001b.ext.cloudfilter.net ([10.228.9.171]) by cmsmtp with ESMTPS id Qbi6xORbySrfpQdjlxDV6r; Tue, 10 Nov 2026 04:45:37 +0000 Received: from spqr.komquats.com ([70.66.136.217]) by cmsmtp with ESMTPSA id QdjkxYw2lWVmrQdjlxQW1G; Tue, 10 Nov 2026 04:45:37 +0000 X-Auth-User: cschuber X-Authority-Analysis: v=2.4 cv=f9NFxeyM c=1 sm=1 tr=0 ts=6af2a171 a=h7br+8Ma+Xn9xscxy5znUg==:117 a=h7br+8Ma+Xn9xscxy5znUg==:17 a=b8+xJRgcbepLoiPQPEzLjyvsYN4=:19 a=kj9zAlcOel0A:10 a=zJRp6_cAMcgA:10 a=6I5d2MoRAAAA:8 a=EkcXrb_YAAAA:8 a=YxBL1-UpAAAA:8 a=ppCKCMrKaSK9qQlrSTYA:9 a=CjuIK1q_8ugA:10 a=LK5xJRSDVpKd5WXXoEvA:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy.cwsent.com [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTP id A9A15387; Mon, 09 Nov 2026 21:45:35 -0700 (MST) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (Postfix) with ESMTP id 9AA5D320; Mon, 09 Nov 2026 21:45:35 -0700 (MST) Date: Mon, 9 Nov 2026 21:45:35 -0700 From: Cy Schubert To: Zhenlei Huang Cc: Cy Schubert , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Subject: Re: git: 86861520613f - main - ipfilter: Remove erroneous ntohs() Message-ID: <20261109214535.7e9dd514@slippy.cwsent.com> In-Reply-To: <80FDAF52-6DB4-4707-9C94-C1A5092604A3@FreeBSD.org> References: <6af255c9.9db2.513e412b@gitrepo.freebsd.org> <80FDAF52-6DB4-4707-9C94-C1A5092604A3@FreeBSD.org> Organization: KOMQUATS X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; amd64-portbld-freebsd16.0) List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4xfGVG2n8Grvnhp5P7/qYXpgQHJ6VYOW6tP06opUqghRL6O9NJHL40wCMd8L9sDzI8ZHveRcX7pSOFirq1HpWa56inRhiLS9VpN/CdOIPVw2dVUoVbIjKW IFYVP0W0Y7WF6XCG0AESQXDuSA0FygoNjjh1XbA9BK2nDD183t41DMypcUNaVTkZ6jgyLEDeb6v0QupDif3slv8rzotWRfqPQQK4lCGQlV4Dw6E0hGAy99tz VsnZP56mO32j1h4KHdq49VKrLtxJCv4xMEozi1kIaJOydD2eXmOYiPreWKz/CQvjCziN8UAWr3/b9/64eeCgmt80GLOZpp0m1PyxvPJG8sv6uZOh7VN/UySB SNf4iZvT X-Rspamd-Queue-Id: 4jNvGp5MVGz4nw6 X-Spamd-Bar: / X-Spamd-Result: default: False [-0.40 / 15.00]; R_SPF_ALLOW(-0.20)[+ip4:3.97.99.32/31]; RCVD_IN_DNSWL_LOW(-0.10)[3.97.99.33:from]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_EQ_ADDR_SOME(0.00)[]; TO_DN_SOME(0.00)[]; ASN(0.00)[asn:16509, ipnet:3.96.0.0/15, country:US]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_ORG_HEADER(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; R_DKIM_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DMARC_BAD_POLICY(0.00)[cschubert.com : p tag has invalid value: quarantine rua=mailto:p[ostmaster@cschubert.com]; RCVD_TLS_LAST(0.00)[]; MLMMJ_DEST(0.00)[dev-commits-src-all@freebsd.org,dev-commits-src-main@freebsd.org]; RCVD_COUNT_THREE(0.00)[4]; RCPT_COUNT_FIVE(0.00)[5] On Tue, 10 Nov 2026 09:22:00 +0800 Zhenlei Huang wrote: > > On Nov 10, 2026, at 7:22 AM, Cy Schubert wrote: > > > > The branch main has been updated by cy: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=86861520613f99c85b5fbdf92b5c955a13ed6624 > > > > commit 86861520613f99c85b5fbdf92b5c955a13ed6624 > > Author: Cy Schubert > > AuthorDate: 2026-11-09 23:13:21 +0000 > > Commit: Cy Schubert > > CommitDate: 2026-11-09 23:22:44 +0000 > > > > ipfilter: Remove erroneous ntohs() > > > > The original commit was wrong. ipf_nat_builddivertmp() builds the UDP > > template with the length in host byte order > > But ipf_nat_builddivertmp() build the ip header with network byte order, > ``` > ip->ip_len = htons(len); > ``` > > I'd prefer consistent byte orders ( all in network byte order if possible ) to make the maintenance easier. Reviewing it tonight, you're right, it does need some work. I can see why it was done this way but still it will need to be visited. > > > > > M_DUP() copies that value unchanged. The old code was therefore correct. > > It added fin_plen in host order and then did a single htons(). > > > > The original patch was discussed with Co-Pilot, which pointed out the > > original bug. claude-opus-5-5 discovered the ntohs() error that > > co-pilot suggested. > > > > Interestingly this code had been running here for a couple of months. > > > > Reported by: llm-postcr > > Fixes: 72cc9e3766f4 > > --- > > sys/netpfil/ipfilter/netinet/ip_nat.c | 1 - > > 1 file changed, 1 deletion(-) > > > > diff --git a/sys/netpfil/ipfilter/netinet/ip_nat.c b/sys/netpfil/ipfilter/netinet/ip_nat.c > > index c8125c10e3f0..4b4890587f53 100644 > > --- a/sys/netpfil/ipfilter/netinet/ip_nat.c > > +++ b/sys/netpfil/ipfilter/netinet/ip_nat.c > > @@ -5156,7 +5156,6 @@ ipf_nat_out(fr_info_t *fin, nat_t *nat, int natadd, u_32_t nflags) > > > > if (ip->ip_p == IPPROTO_UDP) { > > uh = (udphdr_t *)(ip + 1); > > - uh->uh_ulen = ntohs(uh->uh_ulen); > > uh->uh_ulen += fin->fin_plen; > > uh->uh_ulen = htons(uh->uh_ulen); > > } > > > > Best regards, > Zhenlei -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org e**(i*pi)+1=0