netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] vxlan: fix rcu related warnings
@ 2013-07-30 20:18 Stephen Hemminger
  2013-07-30 22:17 ` Pravin Shelar
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2013-07-30 20:18 UTC (permalink / raw)
  To: David Miller, Thomas Richter, Pravin B Shelar, Mike Rapoport; +Cc: netdev

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.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

--- a/drivers/net/vxlan.c	2013-07-24 12:42:42.919769763 -0700
+++ b/drivers/net/vxlan.c	2013-07-30 13:15:21.436571647 -0700
@@ -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;

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-08-05  1:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-30 20:18 [PATCH net-next] vxlan: fix rcu related warnings Stephen Hemminger
2013-07-30 22:17 ` Pravin Shelar
2013-07-30 23:02   ` Stephen Hemminger
2013-07-30 23:04     ` Eric Dumazet
2013-07-31  0:35       ` Stephen Hemminger
2013-07-31 17:57         ` Pravin Shelar
2013-08-05  0:17           ` [PATCH net-next v3] vxlan: fix rcu related warning Stephen Hemminger
2013-08-05  1:47             ` David Miller
2013-07-30 23:20     ` [PATCH net-next] vxlan: fix rcu related warnings Pravin Shelar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).