From: Martin Willi <martin@strongswan.org>
To: Steffen Klassert <steffen.klassert@secunet.com>,
Benedict Wong <benedictwong@google.com>,
Eyal Birger <eyal.birger@gmail.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org
Subject: [PATCH ipsec v2] xfrm: Preserve xfrm interface secpath for packets forwarded
Date: Wed, 12 Apr 2023 10:56:15 +0200 [thread overview]
Message-ID: <20230412085615.124791-1-martin@strongswan.org> (raw)
The commit referenced below clears the secpath on packets received via
xfrm interfaces to support nested IPsec tunnels. This breaks Netfilter
policy matching using xt_policy in the FORWARD chain, as the secpath
is missing during forwarding. INPUT matching is not affected, as it is
done before secpath reset.
A work-around could use XFRM input interface matching for such rules,
but this does not work if the XFRM interface is part of a VRF; the
Netfilter input interface is replaced by the VRF interface, making a
sufficient match for IPsec-protected packets difficult.
So instead, limit the secpath reset to packets that are not using a
XFRM forward policy. This should allow nested tunnels, but keeps the
secpath intact on packets that are passed to Netfilter chains with
potential IPsec policy matches.
Fixes: b0355dbbf13c ("Fix XFRM-I support for nested ESP tunnels")
Suggested-by: Eyal Birger <eyal.birger@gmail.com>
Signed-off-by: Martin Willi <martin@strongswan.org>
---
v1 -> v2: Use policy dir instead of flowi outif to check for forwarding
net/xfrm/xfrm_policy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 5c61ec04b839..669c3c0880a6 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -3745,7 +3745,7 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,
goto reject;
}
- if (if_id)
+ if (if_id && dir != XFRM_POLICY_FWD)
secpath_reset(skb);
xfrm_pols_put(pols, npols);
--
2.34.1
next reply other threads:[~2023-04-12 8:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-12 8:56 Martin Willi [this message]
2023-04-13 18:04 ` [PATCH ipsec v2] xfrm: Preserve xfrm interface secpath for packets forwarded Benedict Wong
2023-04-17 22:01 ` Benedict Wong
2023-04-19 6:06 ` Steffen Klassert
2023-04-25 7:45 ` Martin Willi
2023-04-25 7:47 ` Steffen Klassert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230412085615.124791-1-martin@strongswan.org \
--to=martin@strongswan.org \
--cc=benedictwong@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eyal.birger@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=steffen.klassert@secunet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).