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

* Re: [PATCH net-next] vxlan: fix rcu related warnings
  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
  0 siblings, 1 reply; 9+ messages in thread
From: Pravin Shelar @ 2013-07-30 22:17 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: David Miller, Thomas Richter, Mike Rapoport, netdev

On Tue, Jul 30, 2013 at 1:18 PM, Stephen Hemminger
<stephen@networkplumber.org> wrote:
> 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

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

* Re: [PATCH net-next] vxlan: fix rcu related warnings
  2013-07-30 22:17 ` Pravin Shelar
@ 2013-07-30 23:02   ` Stephen Hemminger
  2013-07-30 23:04     ` Eric Dumazet
  2013-07-30 23:20     ` [PATCH net-next] vxlan: fix rcu related warnings Pravin Shelar
  0 siblings, 2 replies; 9+ messages in thread
From: Stephen Hemminger @ 2013-07-30 23:02 UTC (permalink / raw)
  To: Pravin Shelar; +Cc: David Miller, Thomas Richter, Mike Rapoport, netdev

On Tue, 30 Jul 2013 15:17:21 -0700
Pravin Shelar <pshelar@nicira.com> wrote:

> On Tue, Jul 30, 2013 at 1:18 PM, Stephen Hemminger
> <stephen@networkplumber.org> wrote:
> > 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
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

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

* Re: [PATCH net-next] vxlan: fix rcu related warnings
  2013-07-30 23:02   ` Stephen Hemminger
@ 2013-07-30 23:04     ` Eric Dumazet
  2013-07-31  0:35       ` Stephen Hemminger
  2013-07-30 23:20     ` [PATCH net-next] vxlan: fix rcu related warnings Pravin Shelar
  1 sibling, 1 reply; 9+ messages in thread
From: Eric Dumazet @ 2013-07-30 23:04 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Pravin Shelar, David Miller, Thomas Richter, Mike Rapoport, netdev

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

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

Make sure you have CONFIG_SPARSE_RCU_POINTER=y

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

* Re: [PATCH net-next] vxlan: fix rcu related warnings
  2013-07-30 23:02   ` Stephen Hemminger
  2013-07-30 23:04     ` Eric Dumazet
@ 2013-07-30 23:20     ` Pravin Shelar
  1 sibling, 0 replies; 9+ messages in thread
From: Pravin Shelar @ 2013-07-30 23:20 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: David Miller, Thomas Richter, Mike Rapoport, netdev

On Tue, Jul 30, 2013 at 4:02 PM, Stephen Hemminger
<stephen@networkplumber.org> wrote:
> On Tue, 30 Jul 2013 15:17:21 -0700
> Pravin Shelar <pshelar@nicira.com> wrote:
>
>> On Tue, Jul 30, 2013 at 1:18 PM, Stephen Hemminger
>> <stephen@networkplumber.org> wrote:
>> > 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
>> --
>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
> Which version of sparse? I don't see this with latest version.
>
I am using sparse from latest git repo.

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

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

* Re: [PATCH net-next] vxlan: fix rcu related warnings
  2013-07-30 23:04     ` Eric Dumazet
@ 2013-07-31  0:35       ` Stephen Hemminger
  2013-07-31 17:57         ` Pravin Shelar
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2013-07-31  0:35 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Pravin Shelar, David Miller, Thomas Richter, Mike Rapoport, netdev

On Tue, 30 Jul 2013 16:04:59 -0700
Eric Dumazet <eric.dumazet@gmail.com> wrote:

> On Tue, 2013-07-30 at 16:02 -0700, Stephen Hemminger wrote:
> 
> > 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.

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

* Re: [PATCH net-next] vxlan: fix rcu related warnings
  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
  0 siblings, 1 reply; 9+ messages in thread
From: Pravin Shelar @ 2013-07-31 17:57 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Eric Dumazet, David Miller, Thomas Richter, Mike Rapoport, netdev

[-- Attachment #1: Type: text/plain, Size: 466 bytes --]

On Tue, Jul 30, 2013 at 5:35 PM, Stephen Hemminger
<stephen@networkplumber.org> wrote:
> On Tue, 30 Jul 2013 16:04:59 -0700
> Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
>> On Tue, 2013-07-30 at 16:02 -0700, Stephen Hemminger wrote:
>>
>> > 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.

[-- Attachment #2: 0002-vxlan-fix-rcu-warn.patch --]
[-- Type: application/octet-stream, Size: 877 bytes --]

From 805650bc435b99cbcc02829039a0c3a877416fd9 Mon Sep 17 00:00:00 2001
From: Pravin B Shelar <pshelar@nicira.com>
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(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 31718c6..e4d1513 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -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);
 }
-- 
1.7.1


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

* [PATCH net-next v3] vxlan: fix rcu related warning
  2013-07-31 17:57         ` Pravin Shelar
@ 2013-08-05  0:17           ` Stephen Hemminger
  2013-08-05  1:47             ` David Miller
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2013-08-05  0:17 UTC (permalink / raw)
  To: Pravin Shelar
  Cc: Eric Dumazet, David Miller, Thomas Richter, Mike Rapoport, netdev

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

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

---
v3 - remove one __rcu

--- a/drivers/net/vxlan.c	2013-08-04 11:04:01.922478082 -0700
+++ b/drivers/net/vxlan.c	2013-08-04 16:54:33.214598043 -0700
@@ -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;

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

* Re: [PATCH net-next v3] vxlan: fix rcu related warning
  2013-08-05  0:17           ` [PATCH net-next v3] vxlan: fix rcu related warning Stephen Hemminger
@ 2013-08-05  1:47             ` David Miller
  0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2013-08-05  1:47 UTC (permalink / raw)
  To: stephen; +Cc: pshelar, eric.dumazet, tmricht, mike.rapoport, netdev

From: Stephen Hemminger <stephen@networkplumber.org>
Date: Sun, 4 Aug 2013 17:17:39 -0700

> 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
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Also applied, thanks.

^ 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).