* [PATCH net] ipv4: fib: treat an unbuildable encapsulation as a nexthop mismatch
@ 2026-09-18 15:28 Gabriel Goller
2026-09-20 9:08 ` Ido Schimmel
0 siblings, 1 reply; 2+ messages in thread
From: Gabriel Goller @ 2026-09-18 15:28 UTC (permalink / raw)
To: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Roopa Prabhu
Cc: netdev, linux-kernel
fib_encap_match() builds the requested lwtunnel state and compares it
against the nexthop of a candidate route. When lwtunnel_build_state()
failed it left result at 0, which is interpreted as "the nexthop
matches", so fib_nh_match() continues to compare only oif and gateway.
So if there comes along a RTM_DELROUTE which carries an encapsulation
the kernel rejects, it could delete a different route with a different
encapsulation.
Fixes: 571e722676fe ("ipv4: support for fib route lwtunnel encap attributes")
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
net/ipv4/fib_semantics.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 50e96f86ca59..951e48ae87da 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -911,17 +911,17 @@ static int fib_encap_match(struct net *net, u16 encap_type,
struct netlink_ext_ack *extack)
{
struct lwtunnel_state *lwtstate;
- int ret, result = 0;
+ int result;
if (encap_type == LWTUNNEL_ENCAP_NONE)
return 0;
- ret = lwtunnel_build_state(net, encap_type, encap, AF_INET,
- cfg, &lwtstate, extack);
- if (!ret) {
- result = lwtunnel_cmp_encap(lwtstate, nh->fib_nh_lws);
- lwtstate_free(lwtstate);
- }
+ if (lwtunnel_build_state(net, encap_type, encap, AF_INET, cfg,
+ &lwtstate, extack))
+ return 1;
+
+ result = lwtunnel_cmp_encap(lwtstate, nh->fib_nh_lws);
+ lwtstate_free(lwtstate);
return result;
}
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH net] ipv4: fib: treat an unbuildable encapsulation as a nexthop mismatch
2026-09-18 15:28 [PATCH net] ipv4: fib: treat an unbuildable encapsulation as a nexthop mismatch Gabriel Goller
@ 2026-09-20 9:08 ` Ido Schimmel
0 siblings, 0 replies; 2+ messages in thread
From: Ido Schimmel @ 2026-09-20 9:08 UTC (permalink / raw)
To: Gabriel Goller
Cc: David Ahern, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Roopa Prabhu, netdev, linux-kernel
On Fri, Sep 18, 2026 at 05:28:33PM +0200, Gabriel Goller wrote:
> fib_encap_match() builds the requested lwtunnel state and compares it
> against the nexthop of a candidate route. When lwtunnel_build_state()
> failed it left result at 0, which is interpreted as "the nexthop
> matches", so fib_nh_match() continues to compare only oif and gateway.
>
> So if there comes along a RTM_DELROUTE which carries an encapsulation
> the kernel rejects, it could delete a different route with a different
> encapsulation.
Did you hit this in practice? Can you share details?
Note that the modern alternative is to install nexthop objects with
encapsulation and then associate these objects with routes.
>
> Fixes: 571e722676fe ("ipv4: support for fib route lwtunnel encap attributes")
> Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
> ---
> net/ipv4/fib_semantics.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
> index 50e96f86ca59..951e48ae87da 100644
> --- a/net/ipv4/fib_semantics.c
> +++ b/net/ipv4/fib_semantics.c
> @@ -911,17 +911,17 @@ static int fib_encap_match(struct net *net, u16 encap_type,
> struct netlink_ext_ack *extack)
> {
> struct lwtunnel_state *lwtstate;
> - int ret, result = 0;
> + int result;
>
> if (encap_type == LWTUNNEL_ENCAP_NONE)
> return 0;
This is also "unbuildable", but will match.
lwtunnel_build_state() returns an error in this case, so you can just
remove this check.
>
> - ret = lwtunnel_build_state(net, encap_type, encap, AF_INET,
> - cfg, &lwtstate, extack);
> - if (!ret) {
> - result = lwtunnel_cmp_encap(lwtstate, nh->fib_nh_lws);
> - lwtstate_free(lwtstate);
> - }
> + if (lwtunnel_build_state(net, encap_type, encap, AF_INET, cfg,
> + &lwtstate, extack))
> + return 1;
> +
> + result = lwtunnel_cmp_encap(lwtstate, nh->fib_nh_lws);
> + lwtstate_free(lwtstate);
>
> return result;
> }
> --
> 2.47.3
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-20 9:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-18 15:28 [PATCH net] ipv4: fib: treat an unbuildable encapsulation as a nexthop mismatch Gabriel Goller
2026-09-20 9:08 ` Ido Schimmel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®