From nobody Fri Aug 11 12:13:29 2023 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 4RMjPP5xlpz4q10X; Fri, 11 Aug 2023 12:13:29 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RMjPP5Hkrz3gFh; Fri, 11 Aug 2023 12:13:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691756009; 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=hhBIkpzhJ592mYWj+rQIKdGSxO2d5A9QrntPsmfgPWw=; b=wQaamx+qnpxa4WW7G+uevBYf4+2IRuFHD7wZNqyZSdp3pr+Qoc53qyKf+W6u7aXYRr8sNf 0zPC673AS0fXl/WOhgMkuYMJr5sAOXTH4TBfRbbC1Cy/oWZMiSMOW/4Lv3jGMwSyDhjbWy sFr+lM9C/WZeoeH4OIUB2ctCuXHBiCqqzaTQzjQTOaG9OaJJh2ys9G1h6PqsR93SXbyAwl JaGP72o0P2bQu5mOmhxiCQF4MBMDpvG4inxGJKNa0mDQv66M1jXyWTrH3MtbLAVt6xuc4Y 2+ZzBVimLxSIfXrhCc0ylh+7q+BU5MxC1OUPW7Pw9B3z88TkdreqmpU2fXrixg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691756009; 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=hhBIkpzhJ592mYWj+rQIKdGSxO2d5A9QrntPsmfgPWw=; b=PZK0R5bX6UEO4bmApfMwT8NXnUCAAk/FWkLqMLqH2RpBrGg8kDoQGkT/XbWqVfFYa5IOQN Kt0IeNeysbEBNOKDQRZYzGoaZIkGmY7Uf4GrjITv1f2suH9ZtB29NzBEnrjZhZFhGEsNF0 vZlxceJyq6KRP/zXxdoy8jGQCIFaiKmssWFRIld07ySXzIpm9DzP7HE3lmGwYf0a1HyvG4 /BsjCR8/TN6oViBeb087Y3GSxIRLwXpJg2HM8McbD6ZOE1hL/vjlGdljKlKEBiBafJp95k niIh9JtYqLZEhnQwjtwALc8NwacdIZ2QM6WE9LxWoZZS0mK+mtRpJ5WcCfTnsA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691756009; a=rsa-sha256; cv=none; b=VNOpG3pLYXeE6viIk70h4YAquI8YHU16h+nPjsZlDOYY21/auuEIDYScs4E7DtBMRWF5Bt a/JGFIt9hYd1TPL2yrN1I9jfwHrDJNRQVQjrlaIdoiuiYMRwYjSCjVPkYDyHqIgfUZmraG PTN+Sj1YZAiIlP+ICH/P0FCIKcyGm8kmpMhgaKg3MGSNtWNQICTj0Aa8CbtDOi84kQDLxM mpwfKnmqGwiH+b2XUySc1wbfNFU8uqis4lglg9xjv2v85VHqF1NXqs70Ws+Y/aP/+DwIjl nZFO+BCATilcMziL7MvhpFxrsGrJQ7Cj1q3waPX39XOvwveA3nSDmNP6q0DlLw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4RMjPP4LMQzfLB; Fri, 11 Aug 2023 12:13:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37BCDTO6008407; Fri, 11 Aug 2023 12:13:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37BCDTZw008404; Fri, 11 Aug 2023 12:13:29 GMT (envelope-from git) Date: Fri, 11 Aug 2023 12:13:29 GMT Message-Id: <202308111213.37BCDTZw008404@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 836dc3507e0d - stable/13 - pf: use sctp_calculate_cksum() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 836dc3507e0da06a60762eca8f98c80530eb7173 Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=836dc3507e0da06a60762eca8f98c80530eb7173 commit 836dc3507e0da06a60762eca8f98c80530eb7173 Author: Kristof Provost AuthorDate: 2023-07-07 08:04:51 +0000 Commit: Kristof Provost CommitDate: 2023-08-11 12:13:09 +0000 pf: use sctp_calculate_cksum() This function is always available, even if the SCTP or SCTP_SUPPORT options are not set. That lets us remove an ifdef, and also means we improve pf's SCTP handling when the options are not set. MFC after: 3 weeks Sponsored by: Orange Business Services Differential Revision: https://reviews.freebsd.org/D40911 (cherry picked from commit 61e22e9b2905f405170c249a2239f324229b60d1) --- sys/netpfil/pf/pf.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index c9c0995cc4e7..57c9bb3bf3b1 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -104,9 +104,8 @@ __FBSDID("$FreeBSD$"); #include #endif /* INET6 */ -#if defined(SCTP) || defined(SCTP_SUPPORT) +#include #include -#endif #include #include @@ -412,6 +411,21 @@ VNET_DEFINE(struct intr_event *, pf_swi_ie); VNET_DEFINE(uint32_t, pf_hashseed); #define V_pf_hashseed VNET(pf_hashseed) +static void +pf_sctp_checksum(struct mbuf *m, int off) +{ + uint32_t sum = 0; + + /* Zero out the checksum, to enable recalculation. */ + m_copyback(m, off + offsetof(struct sctphdr, checksum), + sizeof(sum), (caddr_t)&sum); + + sum = sctp_calculate_cksum(m, off); + + m_copyback(m, off + offsetof(struct sctphdr, checksum), + sizeof(sum), (caddr_t)&sum); +} + int pf_addr_cmp(struct pf_addr *a, struct pf_addr *b, sa_family_t af) { @@ -5977,12 +5991,10 @@ pf_route(struct mbuf **m, struct pf_krule *r, int dir, struct ifnet *oifp, in_delayed_cksum(m0); m0->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } -#if defined(SCTP) || defined(SCTP_SUPPORT) if (m0->m_pkthdr.csum_flags & CSUM_SCTP & ~ifp->if_hwassist) { - sctp_delayed_cksum(m0, (uint32_t)(ip->ip_hl << 2)); + pf_sctp_checksum(m0, (uint32_t)(ip->ip_hl << 2)); m0->m_pkthdr.csum_flags &= ~CSUM_SCTP; } -#endif /* * If small enough for interface, or the interface will take