From nobody Fri Jul 21 10:32:35 2023 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 4R6m8g6p4qz4pFxd; Fri, 21 Jul 2023 10:32:35 +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 4R6m8g6MFMz3q5n; Fri, 21 Jul 2023 10:32:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689935555; 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=tKUVnNtxXcYDT5KvQGkJuS2uMtZcj6elxDI3RKO3E/0=; b=uEAx1DNWRsRnLcHxx7Bl/E38seT0tahrfW5dBVzYlLhFEfqlYE9r51wHFXmsSUpOuFeR63 KxZXjWYxH9OMZ7NyMS3VEd5JKKw9O3YiThYmFAD4Ohl+O8cnEHtmjue+fhWwIYLFKjGbCs B1d6JEF6GKJ16Ku1ESZKmZE1nfz+IIPFQH5hgpxEVO3oIryUl5UchD/B5EOXN2S26Xchil kD0prUFa/0adFmq2TxXTg/op8HpDdu7+XvHTuQ0YJ7vqLDedGBnOBGoczUZpF9QTUIsnBl GKe4WxuOOJTs+8hxrrUXHprx2AkHXnggPFRcTbIGorbP6AYKckXWmA1SvUaC1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689935555; 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=tKUVnNtxXcYDT5KvQGkJuS2uMtZcj6elxDI3RKO3E/0=; b=iPoIgiyE6YUXyiG3rcVfc8V4CWKvcVt+8AWH/ND5QDWvv8qqe0v7Ancyb6a43U9vUVursJ DH6U6SG+OnJ59SVA5dGXXu3lCNFvoHa58aHNf8F4CESHyAQKpvtdUTjJ9FofjpFduAxZjB Ac70ZOEyV6bk05ggKoocTwt3GHkM3i0LhSYqUqJ2RQnm4R+mBwa6OMW5cFCSzAmyiNzsO2 SbmrZ/mTLjFIsBUg+GpXw+CrDrU2NT4uqmbm3hDDIZip9JdT2zOlLwZE21vfxwv0dLqXTR kCX6VHJIE2rt3seLtvmPLub+LX+642KlD1L2NW3ejrcBy7qHMUbZ0fPtDWGLVA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689935555; a=rsa-sha256; cv=none; b=W/ijRDLF6G9/AfZumrhwgHkBen7ENi651kSt3E469xt6GkSt+sTyccd7saE8ZIvDblFLNi bw62jAYqskRA0tCCoOog3iH5xM7ESPMHkoD3aWN87i4V6qGFcQic/o8SWzpu4ltgd2Zrr5 SQthcdkkwajWbuD2G8nAAKgx66r3FvosfGEVxGb/i/POddul7DK/YcFt93Jy/lLxU4b+mJ IY4PRylDyuOCra3io9L8l0mEHQD7JwfLN0UkHEXw6RrE4cc+SweQihjxUKRYPVKP5u6BT1 wJvAj9gTONoabX0eeJXM3mZQ6MSuCHtmK8PkwcI0hIJtBRj8oO6aHUPEz5/FOA== 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 4R6m8g5RnZz18X1; Fri, 21 Jul 2023 10:32:35 +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 36LAWZXf010470; Fri, 21 Jul 2023 10:32:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36LAWZ2l010469; Fri, 21 Jul 2023 10:32:35 GMT (envelope-from git) Date: Fri, 21 Jul 2023 10:32:35 GMT Message-Id: <202307211032.36LAWZ2l010469@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: 61e22e9b2905 - main - pf: use sctp_calculate_cksum() 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: 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: 61e22e9b2905f405170c249a2239f324229b60d1 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=61e22e9b2905f405170c249a2239f324229b60d1 commit 61e22e9b2905f405170c249a2239f324229b60d1 Author: Kristof Provost AuthorDate: 2023-07-07 08:04:51 +0000 Commit: Kristof Provost CommitDate: 2023-07-21 10:32:17 +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 --- 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 2a1813d6aadd..490a4130f025 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -112,9 +112,8 @@ __FBSDID("$FreeBSD$"); #include #endif /* INET6 */ -#if defined(SCTP) || defined(SCTP_SUPPORT) +#include #include -#endif #include #include @@ -438,6 +437,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) { @@ -6569,12 +6583,10 @@ pf_route(struct mbuf **m, struct pf_krule *r, 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