Commit e53ee454 authored by David S. Miller's avatar David S. Miller

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 5d77dca8 ba2489b0
...@@ -1020,7 +1020,6 @@ struct proto { ...@@ -1020,7 +1020,6 @@ struct proto {
void (*unhash)(struct sock *sk); void (*unhash)(struct sock *sk);
void (*rehash)(struct sock *sk); void (*rehash)(struct sock *sk);
int (*get_port)(struct sock *sk, unsigned short snum); int (*get_port)(struct sock *sk, unsigned short snum);
void (*clear_sk)(struct sock *sk, int size);
/* Keeping track of sockets in use */ /* Keeping track of sockets in use */
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
...@@ -1242,8 +1241,6 @@ static inline int __sk_prot_rehash(struct sock *sk) ...@@ -1242,8 +1241,6 @@ static inline int __sk_prot_rehash(struct sock *sk)
return sk->sk_prot->hash(sk); return sk->sk_prot->hash(sk);
} }
void sk_prot_clear_portaddr_nulls(struct sock *sk, int size);
/* About 10 seconds */ /* About 10 seconds */
#define SOCK_DESTROY_TIME (10*HZ) #define SOCK_DESTROY_TIME (10*HZ)
......
...@@ -1315,24 +1315,6 @@ static void sock_copy(struct sock *nsk, const struct sock *osk) ...@@ -1315,24 +1315,6 @@ static void sock_copy(struct sock *nsk, const struct sock *osk)
#endif #endif
} }
void sk_prot_clear_portaddr_nulls(struct sock *sk, int size)
{
unsigned long nulls1, nulls2;
nulls1 = offsetof(struct sock, __sk_common.skc_node.next);
nulls2 = offsetof(struct sock, __sk_common.skc_portaddr_node.next);
if (nulls1 > nulls2)
swap(nulls1, nulls2);
if (nulls1 != 0)
memset((char *)sk, 0, nulls1);
memset((char *)sk + nulls1 + sizeof(void *), 0,
nulls2 - nulls1 - sizeof(void *));
memset((char *)sk + nulls2 + sizeof(void *), 0,
size - nulls2 - sizeof(void *));
}
EXPORT_SYMBOL(sk_prot_clear_portaddr_nulls);
static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority, static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,
int family) int family)
{ {
...@@ -1344,12 +1326,8 @@ static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority, ...@@ -1344,12 +1326,8 @@ static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,
sk = kmem_cache_alloc(slab, priority & ~__GFP_ZERO); sk = kmem_cache_alloc(slab, priority & ~__GFP_ZERO);
if (!sk) if (!sk)
return sk; return sk;
if (priority & __GFP_ZERO) { if (priority & __GFP_ZERO)
if (prot->clear_sk) sk_prot_clear_nulls(sk, prot->obj_size);
prot->clear_sk(sk, prot->obj_size);
else
sk_prot_clear_nulls(sk, prot->obj_size);
}
} else } else
sk = kmalloc(prot->obj_size, priority); sk = kmalloc(prot->obj_size, priority);
......
...@@ -2237,7 +2237,6 @@ struct proto udp_prot = { ...@@ -2237,7 +2237,6 @@ struct proto udp_prot = {
.compat_setsockopt = compat_udp_setsockopt, .compat_setsockopt = compat_udp_setsockopt,
.compat_getsockopt = compat_udp_getsockopt, .compat_getsockopt = compat_udp_getsockopt,
#endif #endif
.clear_sk = sk_prot_clear_portaddr_nulls,
.diag_destroy = udp_abort, .diag_destroy = udp_abort,
}; };
EXPORT_SYMBOL(udp_prot); EXPORT_SYMBOL(udp_prot);
......
...@@ -61,7 +61,6 @@ struct proto udplite_prot = { ...@@ -61,7 +61,6 @@ struct proto udplite_prot = {
.compat_setsockopt = compat_udp_setsockopt, .compat_setsockopt = compat_udp_setsockopt,
.compat_getsockopt = compat_udp_getsockopt, .compat_getsockopt = compat_udp_getsockopt,
#endif #endif
.clear_sk = sk_prot_clear_portaddr_nulls,
}; };
EXPORT_SYMBOL(udplite_prot); EXPORT_SYMBOL(udplite_prot);
......
...@@ -1862,17 +1862,6 @@ void tcp6_proc_exit(struct net *net) ...@@ -1862,17 +1862,6 @@ void tcp6_proc_exit(struct net *net)
} }
#endif #endif
static void tcp_v6_clear_sk(struct sock *sk, int size)
{
struct inet_sock *inet = inet_sk(sk);
/* we do not want to clear pinet6 field, because of RCU lookups */
sk_prot_clear_nulls(sk, offsetof(struct inet_sock, pinet6));
size -= offsetof(struct inet_sock, pinet6) + sizeof(inet->pinet6);
memset(&inet->pinet6 + 1, 0, size);
}
struct proto tcpv6_prot = { struct proto tcpv6_prot = {
.name = "TCPv6", .name = "TCPv6",
.owner = THIS_MODULE, .owner = THIS_MODULE,
...@@ -1914,7 +1903,6 @@ struct proto tcpv6_prot = { ...@@ -1914,7 +1903,6 @@ struct proto tcpv6_prot = {
.compat_setsockopt = compat_tcp_setsockopt, .compat_setsockopt = compat_tcp_setsockopt,
.compat_getsockopt = compat_tcp_getsockopt, .compat_getsockopt = compat_tcp_getsockopt,
#endif #endif
.clear_sk = tcp_v6_clear_sk,
.diag_destroy = tcp_abort, .diag_destroy = tcp_abort,
}; };
......
...@@ -1424,17 +1424,6 @@ void udp6_proc_exit(struct net *net) ...@@ -1424,17 +1424,6 @@ void udp6_proc_exit(struct net *net)
} }
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
void udp_v6_clear_sk(struct sock *sk, int size)
{
struct inet_sock *inet = inet_sk(sk);
/* we do not want to clear pinet6 field, because of RCU lookups */
sk_prot_clear_portaddr_nulls(sk, offsetof(struct inet_sock, pinet6));
size -= offsetof(struct inet_sock, pinet6) + sizeof(inet->pinet6);
memset(&inet->pinet6 + 1, 0, size);
}
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
struct proto udpv6_prot = { struct proto udpv6_prot = {
...@@ -1466,7 +1455,6 @@ struct proto udpv6_prot = { ...@@ -1466,7 +1455,6 @@ struct proto udpv6_prot = {
.compat_setsockopt = compat_udpv6_setsockopt, .compat_setsockopt = compat_udpv6_setsockopt,
.compat_getsockopt = compat_udpv6_getsockopt, .compat_getsockopt = compat_udpv6_getsockopt,
#endif #endif
.clear_sk = udp_v6_clear_sk,
.diag_destroy = udp_abort, .diag_destroy = udp_abort,
}; };
......
...@@ -29,8 +29,6 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, ...@@ -29,8 +29,6 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);
void udpv6_destroy_sock(struct sock *sk); void udpv6_destroy_sock(struct sock *sk);
void udp_v6_clear_sk(struct sock *sk, int size);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
int udp6_seq_show(struct seq_file *seq, void *v); int udp6_seq_show(struct seq_file *seq, void *v);
#endif #endif
......
...@@ -56,7 +56,6 @@ struct proto udplitev6_prot = { ...@@ -56,7 +56,6 @@ struct proto udplitev6_prot = {
.compat_setsockopt = compat_udpv6_setsockopt, .compat_setsockopt = compat_udpv6_setsockopt,
.compat_getsockopt = compat_udpv6_getsockopt, .compat_getsockopt = compat_udpv6_getsockopt,
#endif #endif
.clear_sk = udp_v6_clear_sk,
}; };
static struct inet_protosw udplite6_protosw = { static struct inet_protosw udplite6_protosw = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment