From nobody Mon Dec 30 20:44:53 2024 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 4YMSlT3Jq5z5j0RJ; Mon, 30 Dec 2024 20:44:53 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YMSlT1DYyz4J4K; Mon, 30 Dec 2024 20:44:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735591493; 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=f3CiL1GLp/dfr+8FLINsaRCR6IZhwHqnwH+25+7WxEw=; b=MJMNieGzZ/yhABQ+eJB3jwX64QjjyU+fmfZoJNRmV7rX834Xngn0fLyFHAwPgeqlUL4ESt TywGT0UjuSLrHKq3OOAxKDRfYxKYFlbN7USUq/th6Y8LFKU2rS2gPYdH/kVaQ5cQKEt//a IsI5wDr8S86NutZWWQHumOAndliWGGPi+8OYoLN0D6TF96fV/ZduiCx/RetIXFU4N95/1i xZk9PUmKNpR+ggJLuX85Hk7fIaB1FW5WViQDFThE2/qTj4bojII595Lqk5GAxPO+fZdmUq wWwp3B9agkNL8074luHQw83c94KM/VAuEVVSSBb/TYyKHn/XFpJe/P+L4v3JhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735591493; 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=f3CiL1GLp/dfr+8FLINsaRCR6IZhwHqnwH+25+7WxEw=; b=QxJbeOEBU0g+Y3f435dfrCzCFonJwCcYRKf3Y1PZgs6NwZVv+EqJHXZELMauuVgSDfDiGe DCIkscSYskvthUqVwfBRd/1PyORLF9cFT/tD6yDiX8ig4lqnJkdNC7FQprRmfOVp4YaVP/ sFm6wOiCS7EmQ1F9rcm8Cf/KF01PdRwwgEwxp/fmAgJb2SFrG0kSud7+hIqktRXJDpglNQ 2pNjRVogeZF5PKMH/mYdEUSJu7HP/0TY01HYc4b7Z30eKKX7o1OQvBmlW0mDjSp5tXdCHH i2+t+MfbBICnN9Z5JS5AqCPHpDtGdvsKZ3ViJnhH3lAUlNfu3lCSlUA93N9GzA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1735591493; a=rsa-sha256; cv=none; b=jv1a4ykUf+Za5o31lFoe5Ur6ds8jZvP0bjXt4wxKgltMk7TGVZAW1t/6+5ALmeWJ168vO3 1HZAZQiqwCwU22AncV8B6UPMQR2vo6Lw9vAn9f73J+4MQeV1kviwfEGsfS5HWAo1j0bh8U T8wPepTzgPP9pjtrDd4JxvYrhCnXc+9hID7DtN+j/79rCr4MMtxBCVbIpsHs5RMXDR4OnN oytR0sngZfzZw8yfLZGhDrI2LZj5idspAzybCYpFluhA/8YiUL5eeNX6TA0E7Uy06yExP/ qEwIWquvzrP4bQMOuNcG9LBDgp9ayHsn3ZtcChJigjIcRO2zppgy3Emll0FMvQ== 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 4YMSlT0r3Sz18Nm; Mon, 30 Dec 2024 20:44:53 +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 4BUKir7E020092; Mon, 30 Dec 2024 20:44:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BUKiroP020089; Mon, 30 Dec 2024 20:44:53 GMT (envelope-from git) Date: Mon, 30 Dec 2024 20:44:53 GMT Message-Id: <202412302044.4BUKiroP020089@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: 54ead732cf08 - main - pf: deduplicate IPPROTO_ICMPV6 and IPPROTO_ICMP handling 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/main X-Git-Reftype: branch X-Git-Commit: 54ead732cf08ee0a8ac915e9f9ad9a5709d3bc97 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=54ead732cf08ee0a8ac915e9f9ad9a5709d3bc97 commit 54ead732cf08ee0a8ac915e9f9ad9a5709d3bc97 Author: Kristof Provost AuthorDate: 2024-12-28 16:02:05 +0000 Commit: Kristof Provost CommitDate: 2024-12-30 20:42:13 +0000 pf: deduplicate IPPROTO_ICMPV6 and IPPROTO_ICMP handling These blocks were nearly identical, so handle them with the same code. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index cd557a9614d1..761839715011 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -10306,28 +10306,16 @@ pf_test(sa_family_t af, int dir, int pflags, struct ifnet *ifp, struct mbuf **m0 break; } - case IPPROTO_ICMP: { - if (af != AF_INET) { + case IPPROTO_ICMP: + case IPPROTO_ICMPV6: { + if (pd.virtual_proto == IPPROTO_ICMP && af != AF_INET) { action = PF_DROP; REASON_SET(&reason, PFRES_NORM); DPFPRINTF(PF_DEBUG_MISC, ("dropping IPv6 packet with ICMPv4 payload")); goto done; } - action = pf_test_state_icmp(&s, &pd, &reason); - if (action == PF_PASS || action == PF_AFRT) { - if (V_pfsync_update_state_ptr != NULL) - V_pfsync_update_state_ptr(s); - r = s->rule; - a = s->anchor; - } else if (s == NULL) - action = pf_test_rule(&r, &s, &pd, - &a, &ruleset, inp); - break; - } - - case IPPROTO_ICMPV6: { - if (af != AF_INET6) { + if (pd.virtual_proto == IPPROTO_ICMPV6 && af != AF_INET6) { action = PF_DROP; REASON_SET(&reason, PFRES_NORM); DPFPRINTF(PF_DEBUG_MISC,