aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2016-08-24 02:25:37 -0400
committerDavid S. Miller <davem@davemloft.net>2016-08-24 02:25:37 -0400
commite53ee45435465aa8fb87eb2e01503d55159b3c6a (patch)
tree1eb76062dddfc69baabb51a4aba9e69c02908052
parent5d77dca82839ef016a93ad7acd7058b14d967752 (diff)
parentba2489b0e0113f68a25fe7a563842c2b591829d7 (diff)
Merge branch 'remove-clear_sk'
Eric Dumazet says: ==================== net: remove clear_sk() method Since IPv6 socket lookups no longer dereference pinet6 pointer and UDP lost SLAB_DESTROY_BY_RCU special rules, we no longer need special clear_sk() methods. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/sock.h3
-rw-r--r--net/core/sock.c26
-rw-r--r--net/ipv4/udp.c1
-rw-r--r--net/ipv4/udplite.c1
-rw-r--r--net/ipv6/tcp_ipv6.c12
-rw-r--r--net/ipv6/udp.c12
-rw-r--r--net/ipv6/udp_impl.h2
-rw-r--r--net/ipv6/udplite.c1
8 files changed, 2 insertions, 56 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 2aab9b63bf16..c797c57f4d9f 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1020,7 +1020,6 @@ struct proto {
1020 void (*unhash)(struct sock *sk); 1020 void (*unhash)(struct sock *sk);
1021 void (*rehash)(struct sock *sk); 1021 void (*rehash)(struct sock *sk);
1022 int (*get_port)(struct sock *sk, unsigned short snum); 1022 int (*get_port)(struct sock *sk, unsigned short snum);
1023 void (*clear_sk)(struct sock *sk, int size);
1024 1023
1025 /* Keeping track of sockets in use */ 1024 /* Keeping track of sockets in use */
1026#ifdef CONFIG_PROC_FS 1025#ifdef CONFIG_PROC_FS
@@ -1242,8 +1241,6 @@ static inline int __sk_prot_rehash(struct sock *sk)
1242 return sk->sk_prot->hash(sk); 1241 return sk->sk_prot->hash(sk);
1243} 1242}
1244 1243
1245void sk_prot_clear_portaddr_nulls(struct sock *sk, int size);
1246
1247/* About 10 seconds */ 1244/* About 10 seconds */
1248#define SOCK_DESTROY_TIME (10*HZ) 1245#define SOCK_DESTROY_TIME (10*HZ)
1249 1246
diff --git a/net/core/sock.c b/net/core/sock.c
index 25dab8b60223..51a730485649 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1315,24 +1315,6 @@ static void sock_copy(struct sock *nsk, const struct sock *osk)
1315#endif 1315#endif
1316} 1316}
1317 1317
1318void sk_prot_clear_portaddr_nulls(struct sock *sk, int size)
1319{
1320 unsigned long nulls1, nulls2;
1321
1322 nulls1 = offsetof(struct sock, __sk_common.skc_node.next);
1323 nulls2 = offsetof(struct sock, __sk_common.skc_portaddr_node.next);
1324 if (nulls1 > nulls2)
1325 swap(nulls1, nulls2);
1326
1327 if (nulls1 != 0)
1328 memset((char *)sk, 0, nulls1);
1329 memset((char *)sk + nulls1 + sizeof(void *), 0,
1330 nulls2 - nulls1 - sizeof(void *));
1331 memset((char *)sk + nulls2 + sizeof(void *), 0,
1332 size - nulls2 - sizeof(void *));
1333}
1334EXPORT_SYMBOL(sk_prot_clear_portaddr_nulls);
1335
1336static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority, 1318static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,
1337 int family) 1319 int family)
1338{ 1320{
@@ -1344,12 +1326,8 @@ static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,
1344 sk = kmem_cache_alloc(slab, priority & ~__GFP_ZERO); 1326 sk = kmem_cache_alloc(slab, priority & ~__GFP_ZERO);
1345 if (!sk) 1327 if (!sk)
1346 return sk; 1328 return sk;
1347 if (priority & __GFP_ZERO) { 1329 if (priority & __GFP_ZERO)
1348 if (prot->clear_sk) 1330 sk_prot_clear_nulls(sk, prot->obj_size);
1349 prot->clear_sk(sk, prot->obj_size);
1350 else
1351 sk_prot_clear_nulls(sk, prot->obj_size);
1352 }
1353 } else 1331 } else
1354 sk = kmalloc(prot->obj_size, priority); 1332 sk = kmalloc(prot->obj_size, priority);
1355 1333
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index e9ffc27b23d0..f0ebb0bd1e11 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2237,7 +2237,6 @@ struct proto udp_prot = {
2237 .compat_setsockopt = compat_udp_setsockopt, 2237 .compat_setsockopt = compat_udp_setsockopt,
2238 .compat_getsockopt = compat_udp_getsockopt, 2238 .compat_getsockopt = compat_udp_getsockopt,
2239#endif 2239#endif
2240 .clear_sk = sk_prot_clear_portaddr_nulls,
2241 .diag_destroy = udp_abort, 2240 .diag_destroy = udp_abort,
2242}; 2241};
2243EXPORT_SYMBOL(udp_prot); 2242EXPORT_SYMBOL(udp_prot);
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c
index 3b3efbda48e1..67fc9d96e67d 100644
--- a/net/ipv4/udplite.c
+++ b/net/ipv4/udplite.c
@@ -61,7 +61,6 @@ struct proto udplite_prot = {
61 .compat_setsockopt = compat_udp_setsockopt, 61 .compat_setsockopt = compat_udp_setsockopt,
62 .compat_getsockopt = compat_udp_getsockopt, 62 .compat_getsockopt = compat_udp_getsockopt,
63#endif 63#endif
64 .clear_sk = sk_prot_clear_portaddr_nulls,
65}; 64};
66EXPORT_SYMBOL(udplite_prot); 65EXPORT_SYMBOL(udplite_prot);
67 66
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 33df8b8575cc..e0f46439e391 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1862,17 +1862,6 @@ void tcp6_proc_exit(struct net *net)
1862} 1862}
1863#endif 1863#endif
1864 1864
1865static void tcp_v6_clear_sk(struct sock *sk, int size)
1866{
1867 struct inet_sock *inet = inet_sk(sk);
1868
1869 /* we do not want to clear pinet6 field, because of RCU lookups */
1870 sk_prot_clear_nulls(sk, offsetof(struct inet_sock, pinet6));
1871
1872 size -= offsetof(struct inet_sock, pinet6) + sizeof(inet->pinet6);
1873 memset(&inet->pinet6 + 1, 0, size);
1874}
1875
1876struct proto tcpv6_prot = { 1865struct proto tcpv6_prot = {
1877 .name = "TCPv6", 1866 .name = "TCPv6",
1878 .owner = THIS_MODULE, 1867 .owner = THIS_MODULE,
@@ -1914,7 +1903,6 @@ struct proto tcpv6_prot = {
1914 .compat_setsockopt = compat_tcp_setsockopt, 1903 .compat_setsockopt = compat_tcp_setsockopt,
1915 .compat_getsockopt = compat_tcp_getsockopt, 1904 .compat_getsockopt = compat_tcp_getsockopt,
1916#endif 1905#endif
1917 .clear_sk = tcp_v6_clear_sk,
1918 .diag_destroy = tcp_abort, 1906 .diag_destroy = tcp_abort,
1919}; 1907};
1920 1908
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 16512cf06e73..9efe740ff6dd 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1424,17 +1424,6 @@ void udp6_proc_exit(struct net *net)
1424} 1424}
1425#endif /* CONFIG_PROC_FS */ 1425#endif /* CONFIG_PROC_FS */
1426 1426
1427void udp_v6_clear_sk(struct sock *sk, int size)
1428{
1429 struct inet_sock *inet = inet_sk(sk);
1430
1431 /* we do not want to clear pinet6 field, because of RCU lookups */
1432 sk_prot_clear_portaddr_nulls(sk, offsetof(struct inet_sock, pinet6));
1433
1434 size -= offsetof(struct inet_sock, pinet6) + sizeof(inet->pinet6);
1435 memset(&inet->pinet6 + 1, 0, size);
1436}
1437
1438/* ------------------------------------------------------------------------ */ 1427/* ------------------------------------------------------------------------ */
1439 1428
1440struct proto udpv6_prot = { 1429struct proto udpv6_prot = {
@@ -1466,7 +1455,6 @@ struct proto udpv6_prot = {
1466 .compat_setsockopt = compat_udpv6_setsockopt, 1455 .compat_setsockopt = compat_udpv6_setsockopt,
1467 .compat_getsockopt = compat_udpv6_getsockopt, 1456 .compat_getsockopt = compat_udpv6_getsockopt,
1468#endif 1457#endif
1469 .clear_sk = udp_v6_clear_sk,
1470 .diag_destroy = udp_abort, 1458 .diag_destroy = udp_abort,
1471}; 1459};
1472 1460
diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h
index 0682c031ccdc..f6eb1ab34f4b 100644
--- a/net/ipv6/udp_impl.h
+++ b/net/ipv6/udp_impl.h
@@ -29,8 +29,6 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
29int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); 29int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);
30void udpv6_destroy_sock(struct sock *sk); 30void udpv6_destroy_sock(struct sock *sk);
31 31
32void udp_v6_clear_sk(struct sock *sk, int size);
33
34#ifdef CONFIG_PROC_FS 32#ifdef CONFIG_PROC_FS
35int udp6_seq_show(struct seq_file *seq, void *v); 33int udp6_seq_show(struct seq_file *seq, void *v);
36#endif 34#endif
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c
index 9cf097e206e9..5cf0099b86f7 100644
--- a/net/ipv6/udplite.c
+++ b/net/ipv6/udplite.c
@@ -56,7 +56,6 @@ struct proto udplitev6_prot = {
56 .compat_setsockopt = compat_udpv6_setsockopt, 56 .compat_setsockopt = compat_udpv6_setsockopt,
57 .compat_getsockopt = compat_udpv6_getsockopt, 57 .compat_getsockopt = compat_udpv6_getsockopt,
58#endif 58#endif
59 .clear_sk = udp_v6_clear_sk,
60}; 59};
61 60
62static struct inet_protosw udplite6_protosw = { 61static struct inet_protosw udplite6_protosw = {