From nobody Sat Jun 04 12:23:46 2022 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 50B521BD5C2D; Sat, 4 Jun 2022 12:23:47 +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 4LFf770bH2z4nFY; Sat, 4 Jun 2022 12:23:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654345427; 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=f7rb5fUKJilzcb3+vw5imMB1Q44quUlb18nWttG5Rcs=; b=ecIQUNzB8FMeqcZxz0KwZWiWcmPVljixc4x3U8UNevlI2ynmA02w65/aiEcpriTqRqegga HqE+0ojf7ON1CmJj2T/XAZ0Ct53lrIAJHr184BVGh4M/70waNJxnAgHwGvxLZT95HD0gTw EUlEXtRhd4l6y5EWADB19Ae0zGZlZNuhtrp17mLXg14nfVRTzFi5sygSFOQkS/dSdhJA7Q W78j092yzwSw8aGrJU46r6CnYs8igArFFQBgf6BfSr/0eGvMURcr55/by2TSzuKULQN1jQ 8xO8iw3MErfFc5g5/7JR8zofGadREiprzNE+r/zUyhzliZaym/X0ny3yNfB6YQ== 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 BC9441D94A; Sat, 4 Jun 2022 12:23:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 254CNkkP025129; Sat, 4 Jun 2022 12:23:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 254CNkeS025128; Sat, 4 Jun 2022 12:23:46 GMT (envelope-from git) Date: Sat, 4 Jun 2022 12:23:46 GMT Message-Id: <202206041223.254CNkeS025128@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: 81ef217ad428 - main - pf: Improve route-to handling of pfsync'd states 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: 81ef217ad428c29be669aac2166d194db31817a7 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654345427; 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=f7rb5fUKJilzcb3+vw5imMB1Q44quUlb18nWttG5Rcs=; b=PpSOrs/VP1uBcIui8D20d9INhX9BHIDbZPBmWoVyZ3yro+H+wfGIjlqframwWOS739MJri MCT4i1Xixl2CE4PPkvTd+5o4HlwW7J4OrXgRkDDmysNLWo6wDNiLHpCED0ururCwooLFFU iMS6nXWQDdwMKvUhtC2qzMnDlRAMsvfP8Rf0b6aLyjspED76NVEUr33VcdGz+tIjJYbc2A GJ1e5Nfpny9AueHUt4+Vipkko6AuNxkygPMmDod7OJdIrQeWaERH1/d5LWTQmDRZEtsQmo 6s2sJfKV6r7TrETf57Pii/UqToVtcBpUi7Tp6XRsJsjKt4nkQw6KlhYElZUgvg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1654345427; a=rsa-sha256; cv=none; b=TQu6mg+RkTfqP330rTKSMx3QQ51QiZEgPgZ/XXq2BU+ACathCnyvRDw8difqNtPD2bxKk/ ALazRmBZGqIeUUvhgPBhui4uhjv9vAKQ4o9eQ+GE3gLmNzZZDZoKYtD33pZ2ssB75xqFER IDNmtaOfklLUc78ftnAiLQL4okTBcq0Y1GUTT2ajEgOSYo1+bh4SkUMCoKyXGJqs31ACF9 cIjUPFtp7F1ynCVjxDlsrD1ZWo2D/bXJPBrUNDgH569I7E4oaMaL9uhxPq2wZkjrmQGUQJ eDLNDI2Vxu/tjIokksIRTq+Yu0lKuxhnsPQxVa6bBO98PswqDCKTUBMoTaeoQg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=81ef217ad428c29be669aac2166d194db31817a7 commit 81ef217ad428c29be669aac2166d194db31817a7 Author: Kristof Provost AuthorDate: 2022-06-04 10:38:40 +0000 Commit: Kristof Provost CommitDate: 2022-06-04 12:23:17 +0000 pf: Improve route-to handling of pfsync'd states When a state if pfsync’d to a different host it doesn’t get all of the expected pointers, including the pointer to the struct pfi_kif / struct ifnet rt_kif pointer. (I.e. the interface to route out on). That in turn means that pf_route() ends up dropping the packet. Use the rule's struct pfi_kif pointer so we can still route out of the expected interface. MFC after: 2 weeks Sponsored by: Orange Business Services --- sys/netpfil/pf/pf.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 56dab43a2810..8e3cd98879a6 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -6344,6 +6344,10 @@ pf_route(struct mbuf **m, struct pf_krule *r, int dir, struct ifnet *oifp, r->rpool.cur->kif->pfik_ifp : NULL; } else { ifp = s->rt_kif ? s->rt_kif->pfik_ifp : NULL; + /* If pfsync'd */ + if (ifp == NULL) + ifp = r->rpool.cur->kif ? + r->rpool.cur->kif->pfik_ifp : NULL; PF_STATE_UNLOCK(s); } if (ifp == oifp) { @@ -6400,6 +6404,9 @@ pf_route(struct mbuf **m, struct pf_krule *r, int dir, struct ifnet *oifp, ifp = s->rt_kif ? s->rt_kif->pfik_ifp : NULL; PF_STATE_UNLOCK(s); } + /* If pfsync'd */ + if (ifp == NULL) + ifp = r->rpool.cur->kif ? r->rpool.cur->kif->pfik_ifp : NULL; if (ifp == NULL) goto bad; @@ -6539,6 +6546,10 @@ pf_route6(struct mbuf **m, struct pf_krule *r, int dir, struct ifnet *oifp, r->rpool.cur->kif->pfik_ifp : NULL; } else { ifp = s->rt_kif ? s->rt_kif->pfik_ifp : NULL; + /* If pfsync'd */ + if (ifp == NULL) + ifp = r->rpool.cur->kif ? + r->rpool.cur->kif->pfik_ifp : NULL; PF_STATE_UNLOCK(s); } if (ifp == oifp) { @@ -6598,6 +6609,9 @@ pf_route6(struct mbuf **m, struct pf_krule *r, int dir, struct ifnet *oifp, if (s) PF_STATE_UNLOCK(s); + /* If pfsync'd */ + if (ifp == NULL) + ifp = r->rpool.cur->kif ? r->rpool.cur->kif->pfik_ifp : NULL; if (ifp == NULL) goto bad;