netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] vxlan: remove vxlan_group_used in vxlan_open
@ 2013-12-05  9:01 Gao feng
  2013-12-05  9:01 ` [PATCH 2/2] vxlan: leave multicast group when vxlan device down Gao feng
  2013-12-10  0:32 ` [PATCH 1/2] vxlan: remove vxlan_group_used in vxlan_open David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Gao feng @ 2013-12-05  9:01 UTC (permalink / raw)
  To: stephen; +Cc: netdev, Gao feng

In vxlan_open, vxlan_group_used always returns true,
because the state of the vxlan deivces which we want
to open has alreay been running. and it has already
in vxlan_list.

Since ip_mc_join_group takes care of the reference
problem. we can remove vxlan_group_used here, let
ip_mc_join_group resolve the reference problem.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
 drivers/net/vxlan.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 0358c07..8c40254 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1943,8 +1943,7 @@ static int vxlan_open(struct net_device *dev)
 	if (!vs)
 		return -ENOTCONN;
 
-	if (vxlan_addr_multicast(&vxlan->default_dst.remote_ip) &&
-	    vxlan_group_used(vn, &vxlan->default_dst.remote_ip)) {
+	if (vxlan_addr_multicast(&vxlan->default_dst.remote_ip)) {
 		vxlan_sock_hold(vs);
 		dev_hold(dev);
 		queue_work(vxlan_wq, &vxlan->igmp_join);
-- 
1.8.3.1

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

* [PATCH 2/2] vxlan: leave multicast group when vxlan device down
  2013-12-05  9:01 [PATCH 1/2] vxlan: remove vxlan_group_used in vxlan_open Gao feng
@ 2013-12-05  9:01 ` Gao feng
  2013-12-10  0:32 ` [PATCH 1/2] vxlan: remove vxlan_group_used in vxlan_open David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: Gao feng @ 2013-12-05  9:01 UTC (permalink / raw)
  To: stephen; +Cc: netdev, Gao feng

vxlan_group_used only allows device to leave multicast group
when the remote_ip of this vxlan device is difference from
other vxlan devices' remote_ip. this will cause device not
leave multicast group untile the vn_sock of this vxlan deivce
being released.

The check in vxlan_group_used is not quite precise. since even
the remote_ip is same, but these vxlan devices may use different
lower devices, and they may use different vn_socks.

Only when some vxlan devices use the same vn_sock,same lower
device and same remote_ip, the mc_list of the vn_sock should
not be changed.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
 drivers/net/vxlan.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 8c40254..d28a3f4 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -916,17 +916,32 @@ static bool vxlan_snoop(struct net_device *dev,
 }
 
 /* See if multicast group is already in use by other ID */
-static bool vxlan_group_used(struct vxlan_net *vn, union vxlan_addr *remote_ip)
+static bool vxlan_group_used(struct vxlan_net *vn, struct vxlan_dev *dev)
 {
 	struct vxlan_dev *vxlan;
 
+	/* The vxlan_sock is only used by dev, leaving group has
+	 * no effect on other vxlan devices.
+	 */
+	if (atomic_read(&dev->vn_sock->refcnt) == 1)
+		return false;
+
 	list_for_each_entry(vxlan, &vn->vxlan_list, next) {
-		if (!netif_running(vxlan->dev))
+		if (!netif_running(vxlan->dev) || vxlan == dev)
 			continue;
 
-		if (vxlan_addr_equal(&vxlan->default_dst.remote_ip,
-				     remote_ip))
-			return true;
+		if (vxlan->vn_sock != dev->vn_sock)
+			continue;
+
+		if (!vxlan_addr_equal(&vxlan->default_dst.remote_ip,
+				      &dev->default_dst.remote_ip))
+			continue;
+
+		if (vxlan->default_dst.remote_ifindex !=
+		    dev->default_dst.remote_ifindex)
+			continue;
+
+		return true;
 	}
 
 	return false;
@@ -1982,7 +1997,7 @@ static int vxlan_stop(struct net_device *dev)
 	struct vxlan_sock *vs = vxlan->vn_sock;
 
 	if (vs && vxlan_addr_multicast(&vxlan->default_dst.remote_ip) &&
-	    ! vxlan_group_used(vn, &vxlan->default_dst.remote_ip)) {
+	    !vxlan_group_used(vn, vxlan)) {
 		vxlan_sock_hold(vs);
 		dev_hold(dev);
 		queue_work(vxlan_wq, &vxlan->igmp_leave);
-- 
1.8.3.1

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

* Re: [PATCH 1/2] vxlan: remove vxlan_group_used in vxlan_open
  2013-12-05  9:01 [PATCH 1/2] vxlan: remove vxlan_group_used in vxlan_open Gao feng
  2013-12-05  9:01 ` [PATCH 2/2] vxlan: leave multicast group when vxlan device down Gao feng
@ 2013-12-10  0:32 ` David Miller
  2013-12-10  6:26   ` Gao feng
  1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2013-12-10  0:32 UTC (permalink / raw)
  To: gaofeng; +Cc: stephen, netdev

From: Gao feng <gaofeng@cn.fujitsu.com>
Date: Thu, 5 Dec 2013 17:01:35 +0800

> In vxlan_open, vxlan_group_used always returns true,
> because the state of the vxlan deivces which we want
> to open has alreay been running. and it has already
> in vxlan_list.
> 
> Since ip_mc_join_group takes care of the reference
> problem. we can remove vxlan_group_used here, let
> ip_mc_join_group resolve the reference problem.
> 
> Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>

"already" is misspelled in this commit message.

Please describe what "the reference problem" actually is.

> @@ -1943,8 +1943,7 @@ static int vxlan_open(struct net_device *dev)
>  	if (!vs)
>  		return -ENOTCONN;
>  
> -	if (vxlan_addr_multicast(&vxlan->default_dst.remote_ip) &&
> -	    vxlan_group_used(vn, &vxlan->default_dst.remote_ip)) {
> +	if (vxlan_addr_multicast(&vxlan->default_dst.remote_ip)) {

This makes "vn" unused, please remove it.

The compiler even warns about this, are you watching the build
after making changes for messages like that?

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

* Re: [PATCH 1/2] vxlan: remove vxlan_group_used in vxlan_open
  2013-12-10  0:32 ` [PATCH 1/2] vxlan: remove vxlan_group_used in vxlan_open David Miller
@ 2013-12-10  6:26   ` Gao feng
  0 siblings, 0 replies; 4+ messages in thread
From: Gao feng @ 2013-12-10  6:26 UTC (permalink / raw)
  To: David Miller; +Cc: stephen, netdev

On 12/10/2013 08:32 AM, David Miller wrote:
> From: Gao feng <gaofeng@cn.fujitsu.com>
> Date: Thu, 5 Dec 2013 17:01:35 +0800
> 
>> In vxlan_open, vxlan_group_used always returns true,
>> because the state of the vxlan deivces which we want
>> to open has alreay been running. and it has already
>> in vxlan_list.
>>
>> Since ip_mc_join_group takes care of the reference
>> problem. we can remove vxlan_group_used here, let
>> ip_mc_join_group resolve the reference problem.
>>
>> Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
> 
> "already" is misspelled in this commit message.
> 
> Please describe what "the reference problem" actually is.
> 

There is no reference bug here. just means we needn't to take
care of the reference of ip_mc_list, vxlan_group_used has no use here.

>> @@ -1943,8 +1943,7 @@ static int vxlan_open(struct net_device *dev)
>>  	if (!vs)
>>  		return -ENOTCONN;
>>  
>> -	if (vxlan_addr_multicast(&vxlan->default_dst.remote_ip) &&
>> -	    vxlan_group_used(vn, &vxlan->default_dst.remote_ip)) {
>> +	if (vxlan_addr_multicast(&vxlan->default_dst.remote_ip)) {
> 
> This makes "vn" unused, please remove it.
> 
> The compiler even warns about this, are you watching the build
> after making changes for messages like that?

Sorry for this. I will take care of this.

Thanks!

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

end of thread, other threads:[~2013-12-10  6:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-05  9:01 [PATCH 1/2] vxlan: remove vxlan_group_used in vxlan_open Gao feng
2013-12-05  9:01 ` [PATCH 2/2] vxlan: leave multicast group when vxlan device down Gao feng
2013-12-10  0:32 ` [PATCH 1/2] vxlan: remove vxlan_group_used in vxlan_open David Miller
2013-12-10  6:26   ` Gao feng

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