aboutsummaryrefslogtreecommitdiffstats
path: root/net/l2tp
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2015-05-08 22:10:31 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-11 10:50:18 -0400
commit26abe14379f8e2fa3fd1bcf97c9a7ad9364886fe (patch)
treee2161c09531299ce4bfbeb1506c420b9f8db7fc2 /net/l2tp
parent11aa9c28b4209242a9de0a661a7b3405adb568a0 (diff)
net: Modify sk_alloc to not reference count the netns of kernel sockets.
Now that sk_alloc knows when a kernel socket is being allocated modify it to not reference count the network namespace of kernel sockets. Keep track of if a socket needs reference counting by adding a flag to struct sock called sk_net_refcnt. Update all of the callers of sock_create_kern to stop using sk_change_net and sk_release_kernel as those hacks are no longer needed, to avoid reference counting a kernel socket. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/l2tp')
-rw-r--r--net/l2tp/l2tp_core.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index ae513a2fe7f3..f6b090df3930 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -1334,9 +1334,10 @@ static void l2tp_tunnel_del_work(struct work_struct *work)
1334 if (sock) 1334 if (sock)
1335 inet_shutdown(sock, 2); 1335 inet_shutdown(sock, 2);
1336 } else { 1336 } else {
1337 if (sock) 1337 if (sock) {
1338 kernel_sock_shutdown(sock, SHUT_RDWR); 1338 kernel_sock_shutdown(sock, SHUT_RDWR);
1339 sk_release_kernel(sk); 1339 sock_release(sock);
1340 }
1340 } 1341 }
1341 1342
1342 l2tp_tunnel_sock_put(sk); 1343 l2tp_tunnel_sock_put(sk);
@@ -1399,13 +1400,11 @@ static int l2tp_tunnel_sock_create(struct net *net,
1399 if (cfg->local_ip6 && cfg->peer_ip6) { 1400 if (cfg->local_ip6 && cfg->peer_ip6) {
1400 struct sockaddr_l2tpip6 ip6_addr = {0}; 1401 struct sockaddr_l2tpip6 ip6_addr = {0};
1401 1402
1402 err = sock_create_kern(&init_net, AF_INET6, SOCK_DGRAM, 1403 err = sock_create_kern(net, AF_INET6, SOCK_DGRAM,
1403 IPPROTO_L2TP, &sock); 1404 IPPROTO_L2TP, &sock);
1404 if (err < 0) 1405 if (err < 0)
1405 goto out; 1406 goto out;
1406 1407
1407 sk_change_net(sock->sk, net);
1408
1409 ip6_addr.l2tp_family = AF_INET6; 1408 ip6_addr.l2tp_family = AF_INET6;
1410 memcpy(&ip6_addr.l2tp_addr, cfg->local_ip6, 1409 memcpy(&ip6_addr.l2tp_addr, cfg->local_ip6,
1411 sizeof(ip6_addr.l2tp_addr)); 1410 sizeof(ip6_addr.l2tp_addr));
@@ -1429,13 +1428,11 @@ static int l2tp_tunnel_sock_create(struct net *net,
1429 { 1428 {
1430 struct sockaddr_l2tpip ip_addr = {0}; 1429 struct sockaddr_l2tpip ip_addr = {0};
1431 1430
1432 err = sock_create_kern(&init_net, AF_INET, SOCK_DGRAM, 1431 err = sock_create_kern(net, AF_INET, SOCK_DGRAM,
1433 IPPROTO_L2TP, &sock); 1432 IPPROTO_L2TP, &sock);
1434 if (err < 0) 1433 if (err < 0)
1435 goto out; 1434 goto out;
1436 1435
1437 sk_change_net(sock->sk, net);
1438
1439 ip_addr.l2tp_family = AF_INET; 1436 ip_addr.l2tp_family = AF_INET;
1440 ip_addr.l2tp_addr = cfg->local_ip; 1437 ip_addr.l2tp_addr = cfg->local_ip;
1441 ip_addr.l2tp_conn_id = tunnel_id; 1438 ip_addr.l2tp_conn_id = tunnel_id;
@@ -1462,7 +1459,7 @@ out:
1462 *sockp = sock; 1459 *sockp = sock;
1463 if ((err < 0) && sock) { 1460 if ((err < 0) && sock) {
1464 kernel_sock_shutdown(sock, SHUT_RDWR); 1461 kernel_sock_shutdown(sock, SHUT_RDWR);
1465 sk_release_kernel(sock->sk); 1462 sock_release(sock);
1466 *sockp = NULL; 1463 *sockp = NULL;
1467 } 1464 }
1468 1465