]> git.ipfire.org Git - thirdparty/linux.git/commit
mpls: Hold dev refcnt for mpls_nh.
authorKuniyuki Iwashima <kuniyu@google.com>
Wed, 29 Oct 2025 17:32:54 +0000 (17:32 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 4 Nov 2025 01:40:44 +0000 (17:40 -0800)
commitf0914b8436c589b7ab32c614d8d7868eb4ebd5bf
tree10765eabfe4c19ae51bf412179b4ac14306d7757
parent2214ca1ff6df1c1faab4fb95f0296b6d9bf6e1ee
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>
net/mpls/af_mpls.c
net/mpls/internal.h