Commit 2698acd6 authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski
Browse files

net: do not acquire rtnl in fib_seq_sum()



After we made sure no fib_seq_read() handlers needs RTNL anymore,
we can remove RTNL from fib_seq_sum().

Note that after RTNL was dropped, fib_seq_sum() result was possibly
outdated anyway.

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


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 055202b1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ enum fib_event_type {
struct fib_notifier_ops {
	int family;
	struct list_head list;
	unsigned int (*fib_seq_read)(struct net *net);
	unsigned int (*fib_seq_read)(const struct net *net);
	int (*fib_dump)(struct net *net, struct notifier_block *nb,
			struct netlink_ext_ack *extack);
	struct module *owner;
+0 −2
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ static unsigned int fib_seq_sum(struct net *net)
	struct fib_notifier_ops *ops;
	unsigned int fib_seq = 0;

	rtnl_lock();
	rcu_read_lock();
	list_for_each_entry_rcu(ops, &fn_net->fib_notifier_ops, list) {
		if (!try_module_get(ops->owner))
@@ -52,7 +51,6 @@ static unsigned int fib_seq_sum(struct net *net)
		module_put(ops->owner);
	}
	rcu_read_unlock();
	rtnl_unlock();

	return fib_seq;
}
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ int call_fib4_notifiers(struct net *net, enum fib_event_type event_type,
	return call_fib_notifiers(net, event_type, info);
}

static unsigned int fib4_seq_read(struct net *net)
static unsigned int fib4_seq_read(const struct net *net)
{
	/* Paired with WRITE_ONCE() in call_fib4_notifiers() */
	return READ_ONCE(net->ipv4.fib_seq) + fib4_rules_seq_read(net);
+1 −1
Original line number Diff line number Diff line
@@ -3035,7 +3035,7 @@ static const struct net_protocol pim_protocol = {
};
#endif

static unsigned int ipmr_seq_read(struct net *net)
static unsigned int ipmr_seq_read(const struct net *net)
{
	return READ_ONCE(net->ipv4.ipmr_seq) + ipmr_rules_seq_read(net);
}
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ int call_fib6_notifiers(struct net *net, enum fib_event_type event_type,
	return call_fib_notifiers(net, event_type, info);
}

static unsigned int fib6_seq_read(struct net *net)
static unsigned int fib6_seq_read(const struct net *net)
{
	return fib6_tables_seq_read(net) + fib6_rules_seq_read(net);
}
Loading