From: Antony Antony <antony.antony@secunet.com>
To: Eyal Birger <eyal.birger@gmail.com>
Cc: <steffen.klassert@secunet.com>, <herbert@gondor.apana.org.au>,
<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
<dsahern@kernel.org>, <pabeni@redhat.com>,
<netdev@vger.kernel.org>, <devel@linux-ipsec.org>,
Antony Antony <antony@phenome.org>
Subject: Re: [devel-ipsec] [PATCH ipsec, v2 0/2] xfrm: respect ip proto rules criteria in xfrm dst lookups
Date: Mon, 2 Sep 2024 22:39:38 +0200 [thread overview]
Message-ID: <ZtYiig0I3zKimOVB@moon.secunet.de> (raw)
In-Reply-To: <20240902110719.502566-1-eyal.birger@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1775 bytes --]
On Mon, Sep 02, 2024 at 04:07:17AM -0700, Eyal Birger via Devel wrote:
> This series fixes the route lookup when done for xfrm to regard
> L4 criteria specified in ip rules.
Thanks Eyal for explaining the purpose of this series on the call.
How about something like this for the beginning of the commit message:
'This series fixes the route lookup for the outer packet after
encapsulation, including the L4 criteria specified in IP rules.'
It's just a cosmetic suggestion, so may be improve it if you're planning to
send a new version of the patch series for other reasons.
We ran into this issue before and used workaround, mark instead of L4 in the
"ip rule" for the outer packet.
> The first patch is a minor refactor to allow passing more parameters
> to dst lookup functions.
> The second patch actually passes L4 information to these lookup functions.
>
> Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
Tested-by: Antony Antony <antony.antony@secunet.com>
And I have a further suggestion to improve this fix make it more generic.
I was doing the following rule as a work around for ESP-in-UDP tunnels.
ip rule add from all to 192.1.2.23 fwmark 0x1 lookup 50
With your fix I can change it to a L4 rule when using ESP-in-UDP
ip rule add from 192.1.2.45 to 192.1.2.23 ipproto udp dport 4500 lookup 50
However, when not using ESP, without UDP, and rule with "ipproto esp" does
work.
ip rule add from 192.1.2.45 to 192.1.2.23 ipproto esp lookup 50
So, I have come up with a fix/hack on top of your fix.
@@ -327,6 +327,8 @@ static inline struct dst_entry *xfrm_dst_lookup(struct xfrm_state *x,
+ } else {
+ params.ipproto = IPPROTO_ESP;
With this fix "ipproto esp" rules also works.
see the attached full patch.
regards,
-antony
[-- Attachment #2: 0001-xfrm-use-IPPROTO_ESP-for-route-lookup-without-encaps.patch --]
[-- Type: text/x-diff, Size: 1003 bytes --]
From 54cfdfaab12270784623c60d91baf499765e50f5 Mon Sep 17 00:00:00 2001
From: Antony Antony <antony.antony@secunet.com>
Date: Mon, 2 Sep 2024 22:08:15 +0200
Subject: [PATCH ipsec] xfrm: use IPPROTO_ESP for route lookup without encapsulation
When there is no UDP or TCP encapsulation, use IPPROTO_ESP for route
lookup. This ensures that "ip rule" entries like the following match
correctly:
ip rule add from 192.1.2.45 to 192.1.2.23 ipproto esp lookup 50
Signed-off-by: Antony Antony <antony.antony@secunet.com>
---
net/xfrm/xfrm_policy.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 64bfd1390df0..9b0b1b448dce 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -327,6 +327,8 @@ static inline struct dst_entry *xfrm_dst_lookup(struct xfrm_state *x,
params.uli.ports.dport = x->encap->encap_dport;
break;
}
+ } else {
+ params.ipproto = IPPROTO_ESP;
}
dst = __xfrm_dst_lookup(family, ¶ms);
--
2.43.0
prev parent reply other threads:[~2024-09-02 20:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 11:07 [PATCH ipsec,v2 0/2] xfrm: respect ip proto rules criteria in xfrm dst lookups Eyal Birger
2024-09-02 11:07 ` [PATCH ipsec,v2 1/2] xfrm: extract dst lookup parameters into a struct Eyal Birger
2024-09-02 11:07 ` [PATCH ipsec,v2 2/2] xfrm: respect ip protocols rules criteria when performing dst lookups Eyal Birger
2024-09-02 13:52 ` [devel-ipsec] [PATCH ipsec, v2 0/2] xfrm: respect ip proto rules criteria in xfrm " Antony Antony
2024-09-02 20:39 ` Antony Antony [this message]
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=ZtYiig0I3zKimOVB@moon.secunet.de \
--to=antony.antony@secunet.com \
--cc=antony@phenome.org \
--cc=davem@davemloft.net \
--cc=devel@linux-ipsec.org \
--cc=dsahern@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.