Skip to contentSkip to conversation

vxlan: fix rcu related warnings

PATCH Superseded Stephen Hemminger 4 participants 9 messages Jul 30, 2013 – Aug 5, 2013

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

PATCH 1/1 vxlan: fix rcu related warnings

Vxlan remote list is protected by RCU but since first_remote returns a bare pointer, sparse complains.
Split out the rcu and non-rcu access to the list.

Ok to replace list_for_or_null with just list_entry_rcu because remotes list must be non-empty.

drivers/net/vxlan.c +11 -5
@@ -176,9 +176,14 @@ static inline struct hlist_head *vs_head
 /* First remote destination for a forwarding entry.
  * Guaranteed to be non-NULL because remotes are never deleted.
  */
-static inline struct vxlan_rdst *first_remote(struct vxlan_fdb *fdb)
+static inline struct vxlan_rdst __rcu *first_remote_rcu(struct vxlan_fdb *fdb)
 {
-	return list_first_or_null_rcu(&fdb->remotes, struct vxlan_rdst, list);
+	return list_entry_rcu(fdb->remotes.next, struct vxlan_rdst, list);
+}
+
+static inline struct vxlan_rdst *first_remote_rtnl(struct vxlan_fdb *fdb)
+{
+	return list_first_entry(&fdb->remotes, struct vxlan_rdst, list);
 }
 
 /* Find VXLAN socket based on network namespace and UDP port */
@@ -296,7 +301,8 @@ static void vxlan_fdb_notify(struct vxla
 	if (skb == NULL)
 		goto errout;
 
-	err = vxlan_fdb_info(skb, vxlan, fdb, 0, 0, type, 0, first_remote(fdb));
+	err = vxlan_fdb_info(skb, vxlan, fdb, 0, 0, type, 0,
+			     first_remote_rtnl(fdb));
 	if (err < 0) {
 		/* -EMSGSIZE implies BUG in vxlan_nlmsg_size() */
 		WARN_ON(err == -EMSGSIZE);
@@ -739,7 +745,7 @@ static bool vxlan_snoop(struct net_devic
 
 	f = vxlan_find_mac(vxlan, src_mac);
 	if (likely(f)) {
-		struct vxlan_rdst *rdst = first_remote(f);
+		struct vxlan_rdst *rdst = first_remote_rcu(f);
 
 		if (likely(rdst->remote_ip == src_ip))
 			return false;
@@ -987,7 +993,7 @@ static int arp_reduce(struct net_device
 		}
 
 		f = vxlan_find_mac(vxlan, n->ha);
-		if (f && first_remote(f)->remote_ip == htonl(INADDR_ANY)) {
+		if (f && first_remote_rcu(f)->remote_ip == htonl(INADDR_ANY)) {
 			/* bridge-local neighbor */
 			neigh_release(n);
 			goto out;
#1 lore raw
Quoted 7 lines · Stephen Hemminger

Vxlan remote list is protected by RCU but since first_remote returns a bare pointer, sparse complains.
Split out the rcu and non-rcu access to the list.

Ok to replace list_for_or_null with just list_entry_rcu because remotes list must be non-empty.

I am still getting following sparse waning.

CHECK drivers/net/vxlan.c
drivers/net/vxlan.c:181:16: warning: incorrect type in return expression (different address spaces)
drivers/net/vxlan.c:181:16: expected struct vxlan_rdst [noderef] <asn:4>*
drivers/net/vxlan.c:181:16: got struct vxlan_rdst *<noident>
drivers/net/vxlan.c:748:59: warning: incorrect type in initializer (different address spaces)
drivers/net/vxlan.c:748:59: expected struct vxlan_rdst *rdst
drivers/net/vxlan.c:748:59: got struct vxlan_rdst [noderef] <asn:4>*
drivers/net/vxlan.c:181:16: warning: incorrect type in return expression (different address spaces)
drivers/net/vxlan.c:181:16: expected struct vxlan_rdst [noderef] <asn:4>*
drivers/net/vxlan.c:181:16: got struct vxlan_rdst *<noident>
drivers/net/vxlan.c:996:42: warning: dereference of noderef expression

#2 lore raw
Quoted 21 lines · On Tue, 30 Jul 2013 15:17:21 -0700 Pravin Shelar <[email protected]> wrote:
Quoted 7 lines · Stephen Hemminger

Vxlan remote list is protected by RCU but since first_remote returns a bare pointer, sparse complains.
Split out the rcu and non-rcu access to the list.

Ok to replace list_for_or_null with just list_entry_rcu because remotes list must be non-empty.

I am still getting following sparse waning.

CHECK drivers/net/vxlan.c
drivers/net/vxlan.c:181:16: warning: incorrect type in return expression (different address spaces)
drivers/net/vxlan.c:181:16: expected struct vxlan_rdst [noderef] <asn:4>*
drivers/net/vxlan.c:181:16: got struct vxlan_rdst *<noident>
drivers/net/vxlan.c:748:59: warning: incorrect type in initializer (different address spaces)
drivers/net/vxlan.c:748:59: expected struct vxlan_rdst *rdst
drivers/net/vxlan.c:748:59: got struct vxlan_rdst [noderef] <asn:4>*
drivers/net/vxlan.c:181:16: warning: incorrect type in return

Quoted 8 lines

expression (different address spaces)
drivers/net/vxlan.c:181:16: expected struct vxlan_rdst [noderef] <asn:4>*
drivers/net/vxlan.c:181:16: got struct vxlan_rdst *<noident>
drivers/net/vxlan.c:996:42: warning: dereference of noderef expression --
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Which version of sparse? I don't see this with latest version.

#3 lore raw
Quoted 1 line · Stephen Hemminger

Which version of sparse? I don't see this with latest version.

Make sure you have CONFIG_SPARSE_RCU_POINTER=y

#4 lore raw
Quoted 7 lines · On Tue, 30 Jul 2013 16:04:59 -0700 Eric Dumazet <[email protected]> wrote:
Quoted 1 line · Stephen Hemminger

Which version of sparse? I don't see this with latest version.

Make sure you have CONFIG_SPARSE_RCU_POINTER=y

I have it enabled. And am using latest version from git.

#5 lore raw
Quoted 5 lines · Stephen Hemminger
Quoted 2 lines · On Tue, 30 Jul 2013 16:04:59 -0700 Eric Dumazet <[email protected]> wrote:

On Tue, 2013-07-30 at 16:02 -0700, Stephen Hemminger wrote:

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Which version of sparse? I don't see this with latest version.

Make sure you have CONFIG_SPARSE_RCU_POINTER=y

I have it enabled. And am using latest version from git.

Attached patch fixes warnings for me.

From 805650bc435b99cbcc02829039a0c3a877416fd9 Mon Sep 17 00:00:00 2001
From: Pravin B Shelar <[email protected]>
Date: Wed, 31 Jul 2013 10:52:59 -0700
Subject: [PATCH net-next] vxlan: fix rcu warn.

---
 drivers/net/vxlan.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/vxlan.c +1 -1
index 31718c6..e4d1513 100644
@@ -176,7 +176,7 @@ static inline struct hlist_head *vs_head(struct net *net, __be16 port)
 /* First remote destination for a forwarding entry.
  * Guaranteed to be non-NULL because remotes are never deleted.
  */
-static inline struct vxlan_rdst __rcu *first_remote_rcu(struct vxlan_fdb *fdb)
+static inline struct vxlan_rdst *first_remote_rcu(struct vxlan_fdb *fdb)
 {
 	return list_entry_rcu(fdb->remotes.next, struct vxlan_rdst, list);
 }
Signature · 1 line
1.7.1
#6 lore raw

PATCH v3 1/1 vxlan: fix rcu related warning

Vxlan remote list is protected by RCU and guaranteed to be non-empty. Split out the rcu and non-rcu access to the list to fix warning

---
v3 - remove one __rcu

drivers/net/vxlan.c +11 -5
@@ -177,9 +177,14 @@ static inline struct hlist_head *vs_head
 /* First remote destination for a forwarding entry.
  * Guaranteed to be non-NULL because remotes are never deleted.
  */
-static inline struct vxlan_rdst *first_remote(struct vxlan_fdb *fdb)
+static inline struct vxlan_rdst *first_remote_rcu(struct vxlan_fdb *fdb)
 {
-	return list_first_or_null_rcu(&fdb->remotes, struct vxlan_rdst, list);
+	return list_entry_rcu(fdb->remotes.next, struct vxlan_rdst, list);
+}
+
+static inline struct vxlan_rdst *first_remote_rtnl(struct vxlan_fdb *fdb)
+{
+	return list_first_entry(&fdb->remotes, struct vxlan_rdst, list);
 }
 
 /* Find VXLAN socket based on network namespace and UDP port */
@@ -297,7 +302,8 @@ static void vxlan_fdb_notify(struct vxla
 	if (skb == NULL)
 		goto errout;
 
-	err = vxlan_fdb_info(skb, vxlan, fdb, 0, 0, type, 0, first_remote(fdb));
+	err = vxlan_fdb_info(skb, vxlan, fdb, 0, 0, type, 0,
+			     first_remote_rtnl(fdb));
 	if (err < 0) {
 		/* -EMSGSIZE implies BUG in vxlan_nlmsg_size() */
 		WARN_ON(err == -EMSGSIZE);
@@ -740,7 +746,7 @@ static bool vxlan_snoop(struct net_devic
 
 	f = vxlan_find_mac(vxlan, src_mac);
 	if (likely(f)) {
-		struct vxlan_rdst *rdst = first_remote(f);
+		struct vxlan_rdst *rdst = first_remote_rcu(f);
 
 		if (likely(rdst->remote_ip == src_ip))
 			return false;
@@ -1005,7 +1011,7 @@ static int arp_reduce(struct net_device
 		}
 
 		f = vxlan_find_mac(vxlan, n->ha);
-		if (f && first_remote(f)->remote_ip == htonl(INADDR_ANY)) {
+		if (f && first_remote_rcu(f)->remote_ip == htonl(INADDR_ANY)) {
 			/* bridge-local neighbor */
 			neigh_release(n);
 			goto out;
maintainer
#7 lore raw

Re: [PATCH net-next v3] vxlan: fix rcu related warning

From: Stephen Hemminger <[email protected]>
Date: Sun, 4 Aug 2013 17:17:39 -0700

Quoted 4 lines

Vxlan remote list is protected by RCU and guaranteed to be non-empty. Split out the rcu and non-rcu access to the list to fix warning

Also applied, thanks.

#8 lore raw
In reply to Stephen Hemminger
Quoted 34 lines · Stephen Hemminger
Quoted 21 lines · On Tue, 30 Jul 2013 15:17:21 -0700 Pravin Shelar <[email protected]> wrote:
Quoted 7 lines · Stephen Hemminger

Vxlan remote list is protected by RCU but since first_remote returns a bare pointer, sparse complains.
Split out the rcu and non-rcu access to the list.

Ok to replace list_for_or_null with just list_entry_rcu because remotes list must be non-empty.

I am still getting following sparse waning.

CHECK drivers/net/vxlan.c
drivers/net/vxlan.c:181:16: warning: incorrect type in return expression (different address spaces)
drivers/net/vxlan.c:181:16: expected struct vxlan_rdst [noderef] <asn:4>*
drivers/net/vxlan.c:181:16: got struct vxlan_rdst *<noident>
drivers/net/vxlan.c:748:59: warning: incorrect type in initializer (different address spaces)
drivers/net/vxlan.c:748:59: expected struct vxlan_rdst *rdst
drivers/net/vxlan.c:748:59: got struct vxlan_rdst [noderef] <asn:4>*
drivers/net/vxlan.c:181:16: warning: incorrect type in return

Quoted 8 lines

expression (different address spaces)
drivers/net/vxlan.c:181:16: expected struct vxlan_rdst [noderef] <asn:4>*
drivers/net/vxlan.c:181:16: got struct vxlan_rdst *<noident>
drivers/net/vxlan.c:996:42: warning: dereference of noderef expression --
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 2 lines

Which version of sparse? I don't see this with latest version.

I am using sparse from latest git repo.

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html