| 7d99a7c6 | 29-Oct-2025 |
Kuniyuki Iwashima <kuniyu@google.com> |
mpls: Drop RTNL for RTM_NEWROUTE, RTM_DELROUTE, and RTM_GETROUTE.
RTM_NEWROUTE looks up dev under RCU (ip_route_output(), ipv6_stub->ipv6_dst_lookup_flow(), netdev_get_by_index()), and each neighbou
mpls: Drop RTNL for RTM_NEWROUTE, RTM_DELROUTE, and RTM_GETROUTE.
RTM_NEWROUTE looks up dev under RCU (ip_route_output(), ipv6_stub->ipv6_dst_lookup_flow(), netdev_get_by_index()), and each neighbour holds the refcnt of its dev.
Also, net->mpls.platform_label is protected by a dedicated per-netns mutex.
Now, no MPLS code depends on RTNL.
Let's drop RTNL for RTM_NEWROUTE, RTM_DELROUTE, and RTM_GETROUTE.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Link: https://patch.msgid.link/20251029173344.2934622-14-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
show more ...
|
| e833eb25 | 29-Oct-2025 |
Kuniyuki Iwashima <kuniyu@google.com> |
mpls: Protect net->mpls.platform_label with a per-netns mutex.
MPLS (re)uses RTNL to protect net->mpls.platform_label, but the lock does not need to be RTNL at all.
Let's protect net->mpls.platform
mpls: Protect net->mpls.platform_label with a per-netns mutex.
MPLS (re)uses RTNL to protect net->mpls.platform_label, but the lock does not need to be RTNL at all.
Let's protect net->mpls.platform_label with a dedicated per-netns mutex.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Link: https://patch.msgid.link/20251029173344.2934622-13-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
show more ...
|
| fb2b77b9 | 29-Oct-2025 |
Kuniyuki Iwashima <kuniyu@google.com> |
mpls: Convert RTM_GETNETCONF to RCU.
mpls_netconf_get_devconf() calls __dev_get_by_index(), and this only depends on RTNL.
Let's convert mpls_netconf_get_devconf() to RCU and use dev_get_by_index_r
mpls: Convert RTM_GETNETCONF to RCU.
mpls_netconf_get_devconf() calls __dev_get_by_index(), and this only depends on RTNL.
Let's convert mpls_netconf_get_devconf() to RCU and use dev_get_by_index_rcu().
Note that nlmsg_new() is moved ahead to use GFP_KERNEL.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Link: https://patch.msgid.link/20251029173344.2934622-12-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
show more ...
|
| dde1b38e | 29-Oct-2025 |
Kuniyuki Iwashima <kuniyu@google.com> |
mpls: Convert mpls_dump_routes() to RCU.
mpls_dump_routes() sets fib_dump_filter.rtnl_held to true and calls __dev_get_by_index() in mpls_valid_fib_dump_req().
This is the only RTNL dependant in mp
mpls: Convert mpls_dump_routes() to RCU.
mpls_dump_routes() sets fib_dump_filter.rtnl_held to true and calls __dev_get_by_index() in mpls_valid_fib_dump_req().
This is the only RTNL dependant in mpls_dump_routes().
Also, synchronize_rcu() in resize_platform_label_table() guarantees that net->mpls.platform_label is alive under RCU.
Let's convert mpls_dump_routes() to RCU and use dev_get_by_index_rcu().
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Link: https://patch.msgid.link/20251029173344.2934622-11-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
show more ...
|
| 3a496293 | 29-Oct-2025 |
Kuniyuki Iwashima <kuniyu@google.com> |
mpls: Use mpls_route_input() where appropriate.
In many places, we uses rtnl_dereference() twice for net->mpls.platform_label and net->mpls.platform_label[index].
Let's replace the code with mpls_r
mpls: Use mpls_route_input() where appropriate.
In many places, we uses rtnl_dereference() twice for net->mpls.platform_label and net->mpls.platform_label[index].
Let's replace the code with mpls_route_input().
We do not use mpls_route_input() in mpls_dump_routes() since we will rely on RCU there.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Link: https://patch.msgid.link/20251029173344.2934622-10-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
show more ...
|
| 73e40539 | 29-Oct-2025 |
Kuniyuki Iwashima <kuniyu@google.com> |
mpls: Add mpls_route_input().
mpls_route_input_rcu() is called from mpls_forward() and mpls_getroute().
The former is under RCU, and the latter is under RTNL, so mpls_route_input_rcu() uses rcu_der
mpls: Add mpls_route_input().
mpls_route_input_rcu() is called from mpls_forward() and mpls_getroute().
The former is under RCU, and the latter is under RTNL, so mpls_route_input_rcu() uses rcu_dereference_rtnl().
Let's use rcu_dereference() in mpls_route_input_rcu() and add an RTNL variant for mpls_getroute().
Later, we will remove rtnl_dereference() there.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Link: https://patch.msgid.link/20251029173344.2934622-9-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
show more ...
|
| 1fb462de | 29-Oct-2025 |
Kuniyuki Iwashima <kuniyu@google.com> |
mpls: Pass net to mpls_dev_get().
We will replace RTNL with a per-netns mutex to protect dev->mpls_ptr.
Then, we will use rcu_dereference_protected() with the lockdep_is_held() annotation, which re
mpls: Pass net to mpls_dev_get().
We will replace RTNL with a per-netns mutex to protect dev->mpls_ptr.
Then, we will use rcu_dereference_protected() with the lockdep_is_held() annotation, which requires net to access the per-netns mutex.
However, dev_net(dev) is not safe without RTNL.
Let's pass net to mpls_dev_get().
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Link: https://patch.msgid.link/20251029173344.2934622-8-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
show more ...
|
| ab061f33 | 29-Oct-2025 |
Kuniyuki Iwashima <kuniyu@google.com> |
mpls: Add mpls_dev_rcu().
mpls_dev_get() uses rcu_dereference_rtnl() to fetch dev->mpls_ptr.
We will replace RTNL with a dedicated mutex to protect the field.
Then, we will use rcu_dereference_pro
mpls: Add mpls_dev_rcu().
mpls_dev_get() uses rcu_dereference_rtnl() to fetch dev->mpls_ptr.
We will replace RTNL with a dedicated mutex to protect the field.
Then, we will use rcu_dereference_protected() for clarity.
Let's add mpls_dev_rcu() for the RCU reader.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Link: https://patch.msgid.link/20251029173344.2934622-7-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
show more ...
|
| bc7ebc56 | 29-Oct-2025 |
Kuniyuki Iwashima <kuniyu@google.com> |
mpls: Use in6_dev_rcu() and dev_net_rcu() in mpls_forward() and mpls_xmit().
mpls_forward() and mpls_xmit() are called under RCU.
Let's use in6_dev_rcu() and dev_net_rcu() there to annotate as such
mpls: Use in6_dev_rcu() and dev_net_rcu() in mpls_forward() and mpls_xmit().
mpls_forward() and mpls_xmit() are called under RCU.
Let's use in6_dev_rcu() and dev_net_rcu() there to annotate as such.
Now we pass net to mpls_stats_inc_outucastpkts() not to read dev_net_rcu() twice.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Link: https://patch.msgid.link/20251029173344.2934622-6-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
show more ...
|
| 451c538e | 29-Oct-2025 |
Kuniyuki Iwashima <kuniyu@google.com> |
mpls: Unify return paths in mpls_dev_notify().
We will protect net->mpls.platform_label by a dedicated mutex.
Then, we need to wrap functions called from mpls_dev_notify() with the mutex.
As a pre
mpls: Unify return paths in mpls_dev_notify().
We will protect net->mpls.platform_label by a dedicated mutex.
Then, we need to wrap functions called from mpls_dev_notify() with the mutex.
As a prep, let's unify the return paths.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Link: https://patch.msgid.link/20251029173344.2934622-4-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
show more ...
|
| f0914b84 | 29-Oct-2025 |
Kuniyuki Iwashima <kuniyu@google.com> |
mpls: Hold dev refcnt for mpls_nh.
MPLS uses RTNL
1) to guarantee the lifetime of struct mpls_nh.nh_dev 2) to protect net->mpls.platform_label
, but neither actually requires RTNL.
If we do n
mpls: Hold dev refcnt for mpls_nh.
MPLS uses RTNL
1) to guarantee the lifetime of struct mpls_nh.nh_dev 2) to protect net->mpls.platform_label
, but neither actually requires RTNL.
If we do not call dev_put() in find_outdev() and call it just before freeing struct mpls_route, we can drop RTNL for 1).
Let's hold the refcnt of mpls_nh.nh_dev and track it with netdevice_tracker.
Two notable changes:
If mpls_nh_build_multi() fails to set up a neighbour, we need to call netdev_put() for successfully created neighbours in mpls_rt_free_rcu(), so the number of neighbours (rt->rt_nhn) is now updated in each iteration.
When a dev is unregistered, mpls_ifdown() clones mpls_route and replaces it with the clone, so the clone requires extra netdev_hold().
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Link: https://patch.msgid.link/20251029173344.2934622-3-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
show more ...
|
| 69a1ecfe | 14-Apr-2025 |
Breno Leitao <leitao@debian.org> |
mpls: Use nlmsg_payload in mpls_valid_getroute_req
Leverage the new nlmsg_payload() helper to avoid checking for message size and then reading the nlmsg data.
Signed-off-by: Breno Leitao <leitao@de
mpls: Use nlmsg_payload in mpls_valid_getroute_req
Leverage the new nlmsg_payload() helper to avoid checking for message size and then reading the nlmsg data.
Signed-off-by: Breno Leitao <leitao@debian.org> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://patch.msgid.link/20250414-nlmsg-v2-8-3d90cb42c6af@debian.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
show more ...
|