Commit 29c8e323 authored by Kuniyuki Iwashima's avatar Kuniyuki Iwashima Committed by Jakub Kicinski
Browse files

nexthop: Convert RTM_DELNEXTHOP to per-netns RTNL.



In rtm_del_nexthop(), only nexthop_find_by_id() and remove_nexthop()
require RTNL as they touch net->nexthop.rb_root.

Let's move RTNL down as rtnl_net_lock() before nexthop_find_by_id().

Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20250319230743.65267-8-kuniyu@amazon.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent f5fabaff
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -3314,13 +3314,17 @@ static int rtm_del_nexthop(struct sk_buff *skb, struct nlmsghdr *nlh,
	if (err)
		return err;

	nh = nexthop_find_by_id(net, id);
	if (!nh)
		return -ENOENT;
	rtnl_net_lock(net);

	nh = nexthop_find_by_id(net, id);
	if (nh)
		remove_nexthop(net, nh, &nlinfo);
	else
		err = -ENOENT;

	return 0;
	rtnl_net_unlock(net);

	return err;
}

/* rtnl */
@@ -4074,7 +4078,8 @@ static struct pernet_operations nexthop_net_ops = {
static const struct rtnl_msg_handler nexthop_rtnl_msg_handlers[] __initconst = {
	{.msgtype = RTM_NEWNEXTHOP, .doit = rtm_new_nexthop,
	 .flags = RTNL_FLAG_DOIT_PERNET},
	{.msgtype = RTM_DELNEXTHOP, .doit = rtm_del_nexthop},
	{.msgtype = RTM_DELNEXTHOP, .doit = rtm_del_nexthop,
	 .flags = RTNL_FLAG_DOIT_PERNET},
	{.msgtype = RTM_GETNEXTHOP, .doit = rtm_get_nexthop,
	 .dumpit = rtm_dump_nexthop},
	{.msgtype = RTM_GETNEXTHOPBUCKET, .doit = rtm_get_nexthop_bucket,