Skip to content

Commit b5fc292

Browse files
q2vendavem330
authored andcommitted
inet6: Remove inet6_destroy_sock() in sk->sk_prot->destroy().
After commit d38afee ("tcp/udp: Call inet6_destroy_sock() in IPv6 sk->sk_destruct()."), we call inet6_destroy_sock() in sk->sk_destruct() by setting inet6_sock_destruct() to it to make sure we do not leak inet6-specific resources. Now we can remove unnecessary inet6_destroy_sock() calls in sk->sk_prot->destroy(). DCCP and SCTP have their own sk->sk_destruct() function, so we change them separately in the following patches. Signed-off-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Matthieu Baerts <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 225480f commit b5fc292

File tree

6 files changed

+1
-26
lines changed

6 files changed

+1
-26
lines changed

net/ipv6/ping.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323
#include <linux/bpf-cgroup.h>
2424
#include <net/ping.h>
2525

26-
static void ping_v6_destroy(struct sock *sk)
27-
{
28-
inet6_destroy_sock(sk);
29-
}
30-
3126
/* Compatibility glue so we can support IPv6 when it's compiled as a module */
3227
static int dummy_ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len,
3328
int *addr_len)
@@ -205,7 +200,6 @@ struct proto pingv6_prot = {
205200
.owner = THIS_MODULE,
206201
.init = ping_init_sock,
207202
.close = ping_close,
208-
.destroy = ping_v6_destroy,
209203
.pre_connect = ping_v6_pre_connect,
210204
.connect = ip6_datagram_connect_v6_only,
211205
.disconnect = __udp_disconnect,

net/ipv6/raw.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,8 +1173,6 @@ static void raw6_destroy(struct sock *sk)
11731173
lock_sock(sk);
11741174
ip6_flush_pending_frames(sk);
11751175
release_sock(sk);
1176-
1177-
inet6_destroy_sock(sk);
11781176
}
11791177

11801178
static int rawv6_init_sk(struct sock *sk)

net/ipv6/tcp_ipv6.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,12 +1966,6 @@ static int tcp_v6_init_sock(struct sock *sk)
19661966
return 0;
19671967
}
19681968

1969-
static void tcp_v6_destroy_sock(struct sock *sk)
1970-
{
1971-
tcp_v4_destroy_sock(sk);
1972-
inet6_destroy_sock(sk);
1973-
}
1974-
19751969
#ifdef CONFIG_PROC_FS
19761970
/* Proc filesystem TCPv6 sock list dumping. */
19771971
static void get_openreq6(struct seq_file *seq,
@@ -2164,7 +2158,7 @@ struct proto tcpv6_prot = {
21642158
.accept = inet_csk_accept,
21652159
.ioctl = tcp_ioctl,
21662160
.init = tcp_v6_init_sock,
2167-
.destroy = tcp_v6_destroy_sock,
2161+
.destroy = tcp_v4_destroy_sock,
21682162
.shutdown = tcp_shutdown,
21692163
.setsockopt = tcp_setsockopt,
21702164
.getsockopt = tcp_getsockopt,

net/ipv6/udp.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,8 +1661,6 @@ void udpv6_destroy_sock(struct sock *sk)
16611661
udp_encap_disable();
16621662
}
16631663
}
1664-
1665-
inet6_destroy_sock(sk);
16661664
}
16671665

16681666
/*

net/l2tp/l2tp_ip6.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,6 @@ static void l2tp_ip6_destroy_sock(struct sock *sk)
257257

258258
if (tunnel)
259259
l2tp_tunnel_delete(tunnel);
260-
261-
inet6_destroy_sock(sk);
262260
}
263261

264262
static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)

net/mptcp/protocol.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3898,12 +3898,6 @@ static const struct proto_ops mptcp_v6_stream_ops = {
38983898

38993899
static struct proto mptcp_v6_prot;
39003900

3901-
static void mptcp_v6_destroy(struct sock *sk)
3902-
{
3903-
mptcp_destroy(sk);
3904-
inet6_destroy_sock(sk);
3905-
}
3906-
39073901
static struct inet_protosw mptcp_v6_protosw = {
39083902
.type = SOCK_STREAM,
39093903
.protocol = IPPROTO_MPTCP,
@@ -3919,7 +3913,6 @@ int __init mptcp_proto_v6_init(void)
39193913
mptcp_v6_prot = mptcp_prot;
39203914
strcpy(mptcp_v6_prot.name, "MPTCPv6");
39213915
mptcp_v6_prot.slab = NULL;
3922-
mptcp_v6_prot.destroy = mptcp_v6_destroy;
39233916
mptcp_v6_prot.obj_size = sizeof(struct mptcp6_sock);
39243917

39253918
err = proto_register(&mptcp_v6_prot, 1);

0 commit comments

Comments
 (0)