net: fib_rules: Convert RTM_NEWRULE to per-netns RTNL.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Fri, 7 Feb 2025 07:25:00 +0000 (16:25 +0900)
committerJakub Kicinski <kuba@kernel.org>
Tue, 11 Feb 2025 03:08:52 +0000 (19:08 -0800)
commit98d3a6f681caad8e89e365be00a11d55176bc328
treefee47dc0898243fdaadd9c759efd6584c575158a
parenta0596c2c63fc9d9ad16d701044293e11d8f97953
net: fib_rules: Convert RTM_NEWRULE to per-netns RTNL.

fib_nl_newrule() is the doit() handler for RTM_NEWRULE but also called
from vrf_newlink().

In the latter case, RTNL is already held and the 4th arg is true.

Let's hold per-netns RTNL in fib_newrule() if rtnl_held is false.

Note that we call fib_rule_get() before releasing per-netns RTNL to call
notify_rule_change() without RTNL and prevent freeing the new rule.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Tested-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20250207072502.87775-7-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/fib_rules.c