From: Ido Schimmel <idosch@nvidia.com>
To: "Girlich, Franz" <franz.girlich@secunet.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: IPv6: wrong routing from local socket with multiple routing tables
Date: Tue, 20 Oct 2026 18:03:42 +0300 [thread overview]
Message-ID: <20261020150342.GA3175861@shredder> (raw)
In-Reply-To: <84e3ec2178897680e510842e4282d691984bf20f.camel@secunet.com>
On Mon, Oct 19, 2026 at 11:35:43AM +0000, Girlich, Franz wrote:
> Hi!
>
> IPv6 routing from a local socket breaks when using multiple routing
> tables and changing them while the socket is in use. When a different
> routing table is changed, i.e., one not "used" by the local socket, so
> that the best path for the socket changes, packets from the socket
> still use the old path.
>
> The behavior fixes itself, when the routing rules are touched, the
> table currently in use is touched, or the socket is re-opened.
>
> I was able to reproduce this bug with multiple kernel versions,
> including current master 7.3.0-rc7 and 6.12.113 LTS:
Thanks for the report. AFAICT, this is not a regression (never worked).
[...]
>
> I used deepseek-v4.1-flash to attempt a fix for this issue. The fix
> does work for the reproduction above, but I am not confident that it is
> regression free. So I am attaching it for reference only.
>
> ----------------------------
> diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
> index 9ff761962..516176599 100644
> --- a/net/ipv6/ip6_fib.c
> +++ b/net/ipv6/ip6_fib.c
> @@ -2059,6 +2059,8 @@ static void fib6_del_route(struct fib6_table
> *table, struct fib6_node *fn,
> if (!info->skip_notify)
> inet6_rt_del_notify(rt, info, del_reason);
>
> + fib6_new_sernum(net);
> +
> fib6_info_release(rt);
> }
This looks correct.
>
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index a5e955e56..b21ef70f1 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1430,8 +1430,7 @@ static struct rt6_info *ip6_rt_pcpu_alloc(const
> struct fib6_result *res)
> ip6_rt_copy_init(pcpu_rt, res);
> pcpu_rt->rt6i_flags |= RTF_PCPU;
>
> - if (f6i->nh)
> - pcpu_rt->sernum = rt_genid_ipv6(dev_net(dev));
> + pcpu_rt->sernum = rt_genid_ipv6(dev_net(dev));
>
> return pcpu_rt;
> }
But this one is problematic. It's similar to IPv4, but invalidating the
cache in IPv4 is cheaper since there are fewer entries to recreate. An
IPv4 nexthop can be shared by many IPv4 routes, whereas in IPv6 each
route is using a different nexthop (unless you're using nexthop object).
It also doesn't solve the problem when the socket is caching a dst entry
that is not per-CPU (such as an exception).
I need to think about a different solution for this, but it will take me
some time given other commitments.
prev parent reply other threads:[~2026-10-20 15:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 11:35 IPv6: wrong routing from local socket with multiple routing tables Girlich, Franz
2026-10-20 15:03 ` Ido Schimmel [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=20261020150342.GA3175861@shredder \
--to=idosch@nvidia.com \
--cc=franz.girlich@secunet.com \
--cc=netdev@vger.kernel.org \
/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