From nobody Sat Jun 18 13:08:08 2022 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 141E485CDFB; Sat, 18 Jun 2022 13:08:09 +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 4LQGRr5Jzbz3M7R; Sat, 18 Jun 2022 13:08:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655557688; 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=mQGclShJ+gImiDH2nsh5qGsEFDFtV6FBn9juS3SeQyQ=; b=rUuwNdIYAIv5B27yXT3m4B0QeSbGdRMZTMXNRHRTmUQXI4OQlev9HdKuzl3mKXrpnBMJpZ bGdk4i5DZ/awFklYCLY/9Gk3HwVuCvyHKCX7VJ3RbAfOig0oBRUjmu+d5Gkh5ATaMlIG1+ wpf9qfWFnpjaWy4tKkCsW0zjkeb1Wv3Tf8aQJaPcBqYg/EI79jbu9M432FujZ+l50oFY5S GsYbPrq0T1RVSvYnOFKVvkJpejrF3/57gHF0lAovuV68S/5cGSx+5/ey1gez8QUwWL6A+K LO3IENxy2ELf5womhA+WMV/vzhbWOHm0NOj7OPUeHYP0W0an22Pr6bgNd+pV+A== 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 8765015194; Sat, 18 Jun 2022 13:08:08 +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 25ID88xH039587; Sat, 18 Jun 2022 13:08:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25ID88x9039586; Sat, 18 Jun 2022 13:08:08 GMT (envelope-from git) Date: Sat, 18 Jun 2022 13:08:08 GMT Message-Id: <202206181308.25ID88x9039586@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: c5203f7d418d - stable/13 - pf: Improve route-to handling of pfsync'd states 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: c5203f7d418db97cc5419a7e1bafa56fdeb26563 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655557688; 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=mQGclShJ+gImiDH2nsh5qGsEFDFtV6FBn9juS3SeQyQ=; b=vquMaEqADduEOOPAB2K0uOh60jxxtJIAfgXlZ2zKD/8rCbV7TdATgX/GXfunX2LiV16ifB eVYrYcU06igNl4BN3Cu9TUQUR181v4bkjdaxbmmsZqMCk3jEQZwRur0vn5pKL98nbK6Ory 3SEFWBdFpBJL1At1rS5KRgUyX9PX1rfQKdNnrRMUc/1BQZ0nUw/IySqzdd5nO3DBZrrsfV q7ED/0PxBJIg/QmScRqFdIoeLK9JQuDUXV8ogZPr6q+ko/tqkfRMQbXIOlvZ9d/ZIjGtjg lWfO7LV+vNmPJ6pEtjMSIuzuttdjF6YUtTPn9O4NGZr85jZjDv7qCVZ5pCWe9Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655557688; a=rsa-sha256; cv=none; b=IMAiPvBO/2K4fIQsiM5qVO6nmvBM7eK4eGayz4PYIXdypNR/ZLvIhwzQTKJmsxQlHTDF/W e/6eJ5HQqsbhw8n18M9Pzwge1KjY31/8CJg/5YEMwC3GBq5rigLAzsqypQM6X89goD+EzR 0X2Ns+oplKXLm+t4JyRr/RaY43IjSU173byGEEtme6WjubBHTLdQfLf9WV7FBzUeldT2iF 43VGx9K52SQ4h0AKQWDBLbLmbXx5xPFyxl+w3WM94Xhcmku8Nu7WJkb6eDB48A9vA66cqi /tc5FlF28BGct2OqfBv/Zk4hSbH0M7il8lPJjmtJ7VYbeKKobyLoou495FZ9NA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=c5203f7d418db97cc5419a7e1bafa56fdeb26563 commit c5203f7d418db97cc5419a7e1bafa56fdeb26563 Author: Kristof Provost AuthorDate: 2022-06-04 10:38:40 +0000 Commit: Kristof Provost CommitDate: 2022-06-18 07:29:18 +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 (cherry picked from commit 81ef217ad428c29be669aac2166d194db31817a7) --- 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 3f7370e1cf12..0c5266fbbcb9 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -5885,6 +5885,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) { @@ -5940,6 +5944,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; @@ -6070,6 +6077,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) { @@ -6128,6 +6139,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;