From nobody Thu Oct 10 12:37:23 2024 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 4XPTmM6WxZz5Z01L; Thu, 10 Oct 2024 12:37:23 +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 4XPTmM3Hqmz4H49; Thu, 10 Oct 2024 12:37:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728563843; 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=sH6AsV/btiO940+kVjQmCc+CZge32s8Jeeh92MbUtgA=; b=MZ9BloFIlol+TD5r2T9Bp3XfYRHQqvolJOgr/UfDmFvuZQlxOhRvidoaDaEhiyNqVnSI9E /F7dsHIiq9y305CdDvbfvJ4+N89k8uSPjJNurkXalM8K5MjIA04bTe3Req2LRnqqWIB1oQ fl8YSi/e1HYPhLKefQNDzpy99kmvtbv3OdcKRfLHds7sUxvJFReX55avRFqex1n9olHgIg fBNQ11IcT7EYgeMENVH4qhjTwCi4pVBqmMYYvCppULAzo4sSG4Iovtd3fEFHfTQioLhbcc I7a0+MQiLJ2SgzXUDX86puZiRPETvLJJfGd7Z1jXgYhe/eNpnrUaVtmw6v1eiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728563843; 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=sH6AsV/btiO940+kVjQmCc+CZge32s8Jeeh92MbUtgA=; b=OWiu2jM0A7C4NNjYsUZLh1yLX3x0eNjuFOXuHlz8mN2DTLWUJlrhMkj/cJkHz2CT3n/tkZ +M70HkjNrP/ZsejtsTHCc6Cd3x11nUY9BHbKwaobm0jFu31ZjRUi+p3yW/4mC/TfLOOqnw I/RFyGNnDyIFMX0zZO5To3NswZsrYTTkjsKW0MTjrDiqhSV0fcv7PQBKASEe4YzPVULRy9 ezRc4tTndDR8gdOwrcaqA2sLG7IjXR1/UnOn92sTyl9rvIuyHe8mPKtxsEtULAt8FhuixO ZuxCo7cFT6xoGZFQ+5anzQUlsEz1Nuedyhoj0ktoFmUNrdcCdvwL+icwf6jiVQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728563843; a=rsa-sha256; cv=none; b=aKXEIy8VzMuvaSyAiUhgCz2tKYkFZM0VzIGoBDEQSWelM8IyS8fWBc86Aq6GPbxAE6ULso 2f21VmxALLPTkEV4DkniGozBv/DiJglfZwtQCW3GkKIU79im/rdtIpgfSiQOtlF59xvbY6 L5oDj0MUD0euUfQh/ZAIfbdBdHX3/Z+uEtp6/8MvE0NBjR0bXvI3vPN4/6yfOZZluptVZY sak1i9KloWqAH9O/A+I1CM09Rk7zDnPCxU+sbB2XYvQCGSykQLZ2dT8wX9Elvn+ayHSkCX vePMlh6FzGu4a5Ikv+lvKex7yOgTGgz3l9+wJylzZWgsbhxubvLlZNEy7TgAHQ== 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 4XPTmM2KNkzy2P; Thu, 10 Oct 2024 12:37:23 +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 49ACbNSO006500; Thu, 10 Oct 2024 12:37:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49ACbNLR006497; Thu, 10 Oct 2024 12:37:23 GMT (envelope-from git) Date: Thu, 10 Oct 2024 12:37:23 GMT Message-Id: <202410101237.49ACbNLR006497@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: abc8996e7fa6 - main - pf: deduplicate IPv4 and IPv6 code that handles fragments 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: abc8996e7fa6c3755306021bffbf58c707e33d18 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=abc8996e7fa6c3755306021bffbf58c707e33d18 commit abc8996e7fa6c3755306021bffbf58c707e33d18 Author: Kristof Provost AuthorDate: 2024-10-02 06:47:52 +0000 Commit: Kristof Provost CommitDate: 2024-10-10 12:10:40 +0000 pf: deduplicate IPv4 and IPv6 code that handles fragments Deduplicate IPv4 and IPv6 code that handles fragments that have not been reassembled by normalization. ok henning claudio Obtained from: OpenBSD, bluhm , ddd2494207 Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D46934 --- sys/netpfil/pf/pf.c | 45 ++++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index cd90cc1c85c4..653365d42059 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -8697,21 +8697,8 @@ pf_setup_pdesc(sa_family_t af, int dir, struct pf_pdesc *pd, struct mbuf **m0, if (h->ip_hl > 5) /* has options */ pd->badopts++; - if (h->ip_off & htons(IP_MF | IP_OFFMASK)) { - /* - * handle fragments that aren't reassembled by - * normalization - */ + if (h->ip_off & htons(IP_MF | IP_OFFMASK)) pd->virtual_proto = PF_VPROTO_FRAGMENT; - if (kif == NULL || r == NULL) /* pflog */ - *action = PF_DROP; - else - *action = pf_test_rule(r, s, kif, m, *off, - pd, a, ruleset, inp, *hdrlen); - if (*action != PF_PASS) - REASON_SET(reason, PFRES_FRAG); - return (-1); - } break; } @@ -8798,21 +8785,8 @@ pf_setup_pdesc(sa_family_t af, int dir, struct pf_pdesc *pd, struct mbuf **m0, return (-1); } - if (fragoff != 0) { - /* - * handle fragments that aren't reassembled by - * normalization - */ + if (fragoff != 0) pd->virtual_proto = PF_VPROTO_FRAGMENT; - if (kif == NULL || r == NULL) /* pflog */ - *action = PF_DROP; - else - *action = pf_test_rule(r, s, kif, m, *off, - pd, a, ruleset, NULL /* XXX TODO */, *hdrlen); - if (*action != PF_PASS) - REASON_SET(reason, PFRES_FRAG); - return (-1); - } break; } @@ -8821,7 +8795,20 @@ pf_setup_pdesc(sa_family_t af, int dir, struct pf_pdesc *pd, struct mbuf **m0, panic("pf_setup_pdesc called with illegal af %u", af); } - switch (pd->proto) { + switch (pd->virtual_proto) { + case PF_VPROTO_FRAGMENT: + /* + * handle fragments that aren't reassembled by + * normalization + */ + if (kif == NULL || r == NULL) /* pflog */ + *action = PF_DROP; + else + *action = pf_test_rule(r, s, kif, m, *off, pd, a, + ruleset, inp, *hdrlen); + if (*action != PF_PASS) + REASON_SET(reason, PFRES_FRAG); + return (-1); case IPPROTO_TCP: { struct tcphdr *th = &pd->hdr.tcp;