From nobody Fri Mar 21 01:39:27 2025 X-Original-To: dev-commits-src-main@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 4ZJlVS3YCBz5rdK1; Fri, 21 Mar 2025 01:39:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZJlVR5lQPz46sH; Fri, 21 Mar 2025 01:39:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1742521167; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=M0Q6IisXk+h2uPbW+iy0m/jReIbh95HF6u65EDzIxTY=; b=DbsN2Akgir3kYKJfJOK9E9oTajUDjiUSkEZg13ynipARE53J1xEnIhL065DW9m/gORUPvw zvM5U7tegf+cqqk18gA4pdgxXplHqFPmCg73BFIf6Us4a2AvUPiyzaYyL2ZvtiOEDVF+4L RSaB7yHllv1ViL2R+IjJ/Aa2HwoSCSZjIOP27J/+DpwLZT7zaXn5gbfTjbRYLCCAXeC01Z QzDBsnRvdUWptbQaOyR5C881XD36zncKLRTG/TEbf8ycSPIIYfLdwEYCF6vr0Dw3q8gTBR mLqlrcwVAk73v4Ai9e9pAFkNKcle0OUc2dE2LCGbxAMQab4SKxc3Sjl9wp9thQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1742521167; a=rsa-sha256; cv=none; b=XvLpY5J13qcxO+eCtfHBFXx6Tvo38a3J+Fr51KVVSuGmkTi2JQyYCbum3iti1ztoci0sVh LLDUVHxGs2oLm/VJz7tBt3CkiaSQ9W7NeTn8VvV2hqp634R6P79LQiBnUnFZot+hWQ/Ogn FrLQ21GnhkA3r+CcyRk3lecx2mGtGAUgZtLDDqJ/cqc6mREhrRLFNgGD8GPfdD2y/PDCmZ 0RNZike2WWwF8ss3U42JVOspVjYsW3c4Sustv5QV1biDh0Y6EuznULULEUIw5KybICt7Fd +Xs02XEIATMp6ntr8MiwmtbdtsvLRYpTZ8NnMW8Q4im0HJiCiRjrT/EMVvamMw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1742521167; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=M0Q6IisXk+h2uPbW+iy0m/jReIbh95HF6u65EDzIxTY=; b=oNdIs71fd+ga9BCsUqgMeADecZAmt6o3fVmPck9LCFveSLLTBaP1N4/ESiLHQkSMa/ZhXz /NW9doIlkOOo1layapQa0MBxX7XHZrNZuRC0mRkOR1K6t9KckiBtSMv8QK9P5H2ijO4c+I KEx20cYuwSt3xQOhH/c3hmC9JyORzM7NyD+ut9+XF1fuOgKaKoMY3QcexCuz+HtuBpYq1s U+XG7JtNjq86KO0fjw5xbSy97iDx+9TjvC0ZR+ejinbwEAwm6hdl7gszVTlNgnJAPquDdf d3M72uuCToT1BQLhSr4/EYsSKAU4e7MsKYrmqTnsktEziALeKTPKGwi8cLRx/Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ZJlVR5KKMz1SYG; Fri, 21 Mar 2025 01:39:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 52L1dRG1001046; Fri, 21 Mar 2025 01:39:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 52L1dRBR001043; Fri, 21 Mar 2025 01:39:27 GMT (envelope-from git) Date: Fri, 21 Mar 2025 01:39:27 GMT Message-Id: <202503210139.52L1dRBR001043@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 4cdcdf0e5f18 - main - pf: Expand ancient NTOHL/NTOHS/HTONS/HTONL macros. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4cdcdf0e5f1833e2ca7ce3bbf099b32c67064523 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=4cdcdf0e5f1833e2ca7ce3bbf099b32c67064523 commit 4cdcdf0e5f1833e2ca7ce3bbf099b32c67064523 Author: Kristof Provost AuthorDate: 2025-03-04 08:44:41 +0000 Commit: Kristof Provost CommitDate: 2025-03-21 01:29:04 +0000 pf: Expand ancient NTOHL/NTOHS/HTONS/HTONL macros. ok guenther@, henning@ Obtained from: OpenBSD, mpi , faf7e06f4d Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf.c | 15 ++++++--------- sys/netpfil/pf/pf_lb.c | 8 ++++---- sys/netpfil/pf/pf_osfp.c | 4 ++-- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index bfff339a66f5..2c06c0253d4b 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -2266,7 +2266,7 @@ pf_icmp_mapping(struct pf_pdesc *pd, u_int8_t type, *icmp_dir = PF_IN; *virtual_type = type; *virtual_id = 0; - HTONS(*virtual_type); + *virtual_type = htons(*virtual_type); return (1); /* These types match to another state */ /* @@ -2333,7 +2333,7 @@ pf_icmp_mapping(struct pf_pdesc *pd, u_int8_t type, *icmp_dir = PF_IN; *virtual_type = type; *virtual_id = 0; - HTONS(*virtual_type); + *virtual_type = htons(*virtual_type); return (1); /* These types match to another state */ /* * All remaining ICMP6 types get their own states, @@ -2350,7 +2350,7 @@ pf_icmp_mapping(struct pf_pdesc *pd, u_int8_t type, default: unhandled_af(pd->af); } - HTONS(*virtual_type); + *virtual_type = htons(*virtual_type); return (0); /* These types match to their own state */ } @@ -4101,7 +4101,7 @@ pf_build_tcp(const struct pf_krule *r, sa_family_t af, opt = (char *)(th + 1); opt[0] = TCPOPT_MAXSEG; opt[1] = 4; - HTONS(mss); + mss = htons(mss); memcpy((opt + 2), &mss, 2); } @@ -4527,10 +4527,7 @@ pf_match(u_int8_t op, u_int32_t a1, u_int32_t a2, u_int32_t p) int pf_match_port(u_int8_t op, u_int16_t a1, u_int16_t a2, u_int16_t p) { - NTOHS(a1); - NTOHS(a2); - NTOHS(p); - return (pf_match(op, a1, a2, p)); + return (pf_match(op, ntohs(a1), ntohs(a2), ntohs(p))); } static int @@ -5034,7 +5031,7 @@ pf_get_mss(struct pf_pdesc *pd) break; case TCPOPT_MAXSEG: memcpy(&mss, (opt + 2), 2); - NTOHS(mss); + mss = ntohs(mss); /* FALLTHROUGH */ default: optlen = opt[1]; diff --git a/sys/netpfil/pf/pf_lb.c b/sys/netpfil/pf/pf_lb.c index ea9fbc46af63..f0cad4bb43c2 100644 --- a/sys/netpfil/pf/pf_lb.c +++ b/sys/netpfil/pf/pf_lb.c @@ -1065,19 +1065,19 @@ pf_get_transaddr_af(struct pf_krule *r, struct pf_pdesc *pd) } if (pd->proto == IPPROTO_ICMPV6 && pd->naf == AF_INET) { - NTOHS(pd->ndport); + pd->ndport = ntohs(pd->ndport); if (pd->ndport == ICMP6_ECHO_REQUEST) pd->ndport = ICMP_ECHO; else if (pd->ndport == ICMP6_ECHO_REPLY) pd->ndport = ICMP_ECHOREPLY; - HTONS(pd->ndport); + pd->ndport = htons(pd->ndport); } else if (pd->proto == IPPROTO_ICMP && pd->naf == AF_INET6) { - NTOHS(pd->ndport); + pd->nsport = ntohs(pd->nsport); if (pd->ndport == ICMP_ECHO) pd->ndport = ICMP6_ECHO_REQUEST; else if (pd->ndport == ICMP_ECHOREPLY) pd->ndport = ICMP6_ECHO_REPLY; - HTONS(pd->ndport); + pd->nsport = htons(pd->nsport); } /* get the destination address and port */ diff --git a/sys/netpfil/pf/pf_osfp.c b/sys/netpfil/pf/pf_osfp.c index de60619bdc18..3e00cc7c80a2 100644 --- a/sys/netpfil/pf/pf_osfp.c +++ b/sys/netpfil/pf/pf_osfp.c @@ -157,13 +157,13 @@ pf_osfp_fingerprint_hdr(const struct ip *ip, const struct ip6_hdr *ip6, const st sizeof(fp.fp_mss)); fp.fp_tcpopts = (fp.fp_tcpopts << PF_OSFP_TCPOPT_BITS) | PF_OSFP_TCPOPT_MSS; - NTOHS(fp.fp_mss); + fp.fp_mss = ntohs(fp.fp_mss); break; case TCPOPT_WINDOW: if (optlen >= TCPOLEN_WINDOW) memcpy(&fp.fp_wscale, &optp[2], sizeof(fp.fp_wscale)); - NTOHS(fp.fp_wscale); + fp.fp_wscale = ntohs(fp.fp_wscale); fp.fp_tcpopts = (fp.fp_tcpopts << PF_OSFP_TCPOPT_BITS) | PF_OSFP_TCPOPT_WSCALE;