Patchwork [PATCHv2,net-next] vxlan: put UDP socket in correct namespace

login
register
mail settings
Submitter stephen hemminger
Date Oct. 2, 2012, 4:49 a.m.
Message ID <20121001214921.78d9ed72@nehalam.linuxnetplumber.net>
Download mbox | patch
Permalink /patch/188383/
State Accepted
Delegated to: David Miller
Headers show

Comments

stephen hemminger - Oct. 2, 2012, 4:49 a.m.
Move vxlan UDP socket to correct network namespace

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
v2 need to change sock_release to sk_release_kernel

--
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
Eric W. Biederman - Oct. 2, 2012, 3:18 p.m.
Stephen Hemminger <shemminger@vyatta.com> writes:

> Move vxlan UDP socket to correct network namespace
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

Looks good from here.

Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>

> ---
> v2 need to change sock_release to sk_release_kernel
>
> --- a/drivers/net/vxlan.c	2012-10-01 17:18:30.776513263 -0700
> +++ b/drivers/net/vxlan.c	2012-10-01 21:47:40.435979178 -0700
> @@ -1136,6 +1136,9 @@ static __net_init int vxlan_init_net(str
>  		pr_debug("UDP socket create failed\n");
>  		return rc;
>  	}
> +	/* Put in proper namespace */
> +	sk = vn->sock->sk;
> +	sk_change_net(sk, net);
>  
>  	vxlan_addr.sin_port = htons(vxlan_port);
>  
> @@ -1144,13 +1147,12 @@ static __net_init int vxlan_init_net(str
>  	if (rc < 0) {
>  		pr_debug("bind for UDP socket %pI4:%u (%d)\n",
>  			 &vxlan_addr.sin_addr, ntohs(vxlan_addr.sin_port), rc);
> -		sock_release(vn->sock);
> +		sk_release_kernel(sk);
>  		vn->sock = NULL;
>  		return rc;
>  	}
>  
>  	/* Disable multicast loopback */
> -	sk = vn->sock->sk;
>  	inet_sk(sk)->mc_loop = 0;
>  
>  	/* Mark socket as an encapsulation socket. */
> @@ -1169,7 +1171,7 @@ static __net_exit void vxlan_exit_net(st
>  	struct vxlan_net *vn = net_generic(net, vxlan_net_id);
>  
>  	if (vn->sock) {
> -		sock_release(vn->sock);
> +		sk_release_kernel(vn->sock->sk);
>  		vn->sock = NULL;
>  	}
>  }
> --
> 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
--
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
David Miller - Oct. 2, 2012, 6:39 p.m.
From: ebiederm@xmission.com (Eric W. Biederman)
Date: Tue, 02 Oct 2012 08:18:13 -0700

> Stephen Hemminger <shemminger@vyatta.com> writes:
> 
>> Move vxlan UDP socket to correct network namespace
>>
>> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> 
> Looks good from here.
> 
> Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>

Applied, thanks.
--
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

Patch

--- a/drivers/net/vxlan.c	2012-10-01 17:18:30.776513263 -0700
+++ b/drivers/net/vxlan.c	2012-10-01 21:47:40.435979178 -0700
@@ -1136,6 +1136,9 @@  static __net_init int vxlan_init_net(str
 		pr_debug("UDP socket create failed\n");
 		return rc;
 	}
+	/* Put in proper namespace */
+	sk = vn->sock->sk;
+	sk_change_net(sk, net);
 
 	vxlan_addr.sin_port = htons(vxlan_port);
 
@@ -1144,13 +1147,12 @@  static __net_init int vxlan_init_net(str
 	if (rc < 0) {
 		pr_debug("bind for UDP socket %pI4:%u (%d)\n",
 			 &vxlan_addr.sin_addr, ntohs(vxlan_addr.sin_port), rc);
-		sock_release(vn->sock);
+		sk_release_kernel(sk);
 		vn->sock = NULL;
 		return rc;
 	}
 
 	/* Disable multicast loopback */
-	sk = vn->sock->sk;
 	inet_sk(sk)->mc_loop = 0;
 
 	/* Mark socket as an encapsulation socket. */
@@ -1169,7 +1171,7 @@  static __net_exit void vxlan_exit_net(st
 	struct vxlan_net *vn = net_generic(net, vxlan_net_id);
 
 	if (vn->sock) {
-		sock_release(vn->sock);
+		sk_release_kernel(vn->sock->sk);
 		vn->sock = NULL;
 	}
 }