Skip to contentSkip to conversation

net: Clean up af_ops->{get_link_af_size,fill_link_af}().

PATCH In review Kuniyuki Iwashima 2 participants 5 messages Aug 15, 2024 – Aug 16, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover net: Clean up af_ops->{get_link_af_size,fill_link_af}().

Since commit 5fa85a09390c ("net: core: rcu-ify rtnl af_ops"), af_ops->{get_link_af_size,fill_link_af}() are called under RCU.

Patch 1 makes the context clear and patch 2 removes unnecessary rcu_read_lock().

Kuniyuki Iwashima (2):
ipv4: Use RCU helper in inet_get_link_af_size() and

    inet_fill_link_af().

net: bridge: Remove rcu_read_lock() in br_get_link_af_size_filtered().

 net/bridge/br_netlink.c | 2 --
 net/ipv4/devinet.c      | 6 ++----
 2 files changed, 2 insertions(+), 6 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/2 ipv4: Use RCU helper in inet_get_link_af_size() and inet_fill_link_af().

Since commit 5fa85a09390c ("net: core: rcu-ify rtnl af_ops"), af_ops->{get_link_af_size,fill_link_af}() are called under RCU.

Instead of using rcu_dereference_rtnl(), let's make the context clear by using RCU helpers.

---
 net/ipv4/devinet.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
net/ipv4/devinet.c +2 -4
index 61be85154dd1..a4f9822213bf 100644
@@ -1950,9 +1950,7 @@ static void rtmsg_ifa(int event, struct in_ifaddr *ifa, struct nlmsghdr *nlh,
 static size_t inet_get_link_af_size(const struct net_device *dev,
 				    u32 ext_filter_mask)
 {
-	struct in_device *in_dev = rcu_dereference_rtnl(dev->ip_ptr);
-
-	if (!in_dev)
+	if (!rcu_access_pointer(dev->ip_ptr))
 		return 0;
 
 	return nla_total_size(IPV4_DEVCONF_MAX * 4); /* IFLA_INET_CONF */
@@ -1961,7 +1959,7 @@ static size_t inet_get_link_af_size(const struct net_device *dev,
 static int inet_fill_link_af(struct sk_buff *skb, const struct net_device *dev,
 			     u32 ext_filter_mask)
 {
-	struct in_device *in_dev = rcu_dereference_rtnl(dev->ip_ptr);
+	struct in_device *in_dev = rcu_dereference(dev->ip_ptr);
 	struct nlattr *nla;
 	int i;
 
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/2 net: bridge: Remove rcu_read_lock() in br_get_link_af_size_filtered().

In reply to Kuniyuki Iwashima

Since commit 5fa85a09390c ("net: core: rcu-ify rtnl af_ops"), af_ops->get_link_af_size() is called under RCU.

Let's remove unnecessary rcu_read_lock() in br_get_link_af_size_filtered().

---
 net/bridge/br_netlink.c | 2 --
 1 file changed, 2 deletions(-)
net/bridge/br_netlink.c +0 -2
index f17dbac7d828..c386a8ec370f 100644
@@ -101,7 +101,6 @@ static size_t br_get_link_af_size_filtered(const struct net_device *dev,
 	size_t vinfo_sz = 0;
 	int num_vlan_infos;
 
-	rcu_read_lock();
 	if (netif_is_bridge_port(dev)) {
 		p = br_port_get_check_rcu(dev);
 		if (p)
@@ -111,7 +110,6 @@ static size_t br_get_link_af_size_filtered(const struct net_device *dev,
 		vg = br_vlan_group_rcu(br);
 	}
 	num_vlan_infos = br_get_num_vlan_infos(vg, filter_mask);
-	rcu_read_unlock();
 
 	if (p && (p->flags & BR_VLAN_TUNNEL))
 		vinfo_sz += br_get_vlan_tunnel_info_size(vg);
Signature · 1 line
2.30.2
maintainer
#3 lore raw
In reply to Kuniyuki Iwashima
Quoted 5 lines · On Thu, 15 Aug 2024 14:11:35 -0700 Kuniyuki Iwashima wrote:

Since commit 5fa85a09390c ("net: core: rcu-ify rtnl af_ops"), af_ops->{get_link_af_size,fill_link_af}() are called under RCU.

Patch 1 makes the context clear and patch 2 removes unnecessary rcu_read_lock().

Tests violently disagree.

https://netdev.bots.linux.dev/contest.html?branch=net-next-2024-08-16--00-00&pw-n=0&pass=0

Signature · 1 line
pw-bot: cr
#4 lore raw

From: Jakub Kicinski <[email protected]>
Date: Thu, 15 Aug 2024 18:36:51 -0700

Quoted 10 lines · On Thu, 15 Aug 2024 14:11:35 -0700 Kuniyuki Iwashima wrote:
Quoted 5 lines

Since commit 5fa85a09390c ("net: core: rcu-ify rtnl af_ops"), af_ops->{get_link_af_size,fill_link_af}() are called under RCU.

Patch 1 makes the context clear and patch 2 removes unnecessary rcu_read_lock().

Tests violently disagree.

https://netdev.bots.linux.dev/contest.html?branch=net-next-2024-08-16--00-00&pw-n=0&pass=0

Sorry, I missed the birdge one is called under RTNL. I'll drop patch 2.