Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

inet6: Remove inet6_destroy_sock() in sk->sk_prot->destroy().

After commit d38afeec26ed ("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 <kuniyu@amazon.com>
Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Kuniyuki Iwashima and committed by
David S. Miller
b5fc2923 225480f0

+1 -26
-6
net/ipv6/ping.c
··· 23 23 #include <linux/bpf-cgroup.h> 24 24 #include <net/ping.h> 25 25 26 - static void ping_v6_destroy(struct sock *sk) 27 - { 28 - inet6_destroy_sock(sk); 29 - } 30 - 31 26 /* Compatibility glue so we can support IPv6 when it's compiled as a module */ 32 27 static int dummy_ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len, 33 28 int *addr_len) ··· 200 205 .owner = THIS_MODULE, 201 206 .init = ping_init_sock, 202 207 .close = ping_close, 203 - .destroy = ping_v6_destroy, 204 208 .pre_connect = ping_v6_pre_connect, 205 209 .connect = ip6_datagram_connect_v6_only, 206 210 .disconnect = __udp_disconnect,
-2
net/ipv6/raw.c
··· 1173 1173 lock_sock(sk); 1174 1174 ip6_flush_pending_frames(sk); 1175 1175 release_sock(sk); 1176 - 1177 - inet6_destroy_sock(sk); 1178 1176 } 1179 1177 1180 1178 static int rawv6_init_sk(struct sock *sk)
+1 -7
net/ipv6/tcp_ipv6.c
··· 1966 1966 return 0; 1967 1967 } 1968 1968 1969 - static void tcp_v6_destroy_sock(struct sock *sk) 1970 - { 1971 - tcp_v4_destroy_sock(sk); 1972 - inet6_destroy_sock(sk); 1973 - } 1974 - 1975 1969 #ifdef CONFIG_PROC_FS 1976 1970 /* Proc filesystem TCPv6 sock list dumping. */ 1977 1971 static void get_openreq6(struct seq_file *seq, ··· 2158 2164 .accept = inet_csk_accept, 2159 2165 .ioctl = tcp_ioctl, 2160 2166 .init = tcp_v6_init_sock, 2161 - .destroy = tcp_v6_destroy_sock, 2167 + .destroy = tcp_v4_destroy_sock, 2162 2168 .shutdown = tcp_shutdown, 2163 2169 .setsockopt = tcp_setsockopt, 2164 2170 .getsockopt = tcp_getsockopt,
-2
net/ipv6/udp.c
··· 1661 1661 udp_encap_disable(); 1662 1662 } 1663 1663 } 1664 - 1665 - inet6_destroy_sock(sk); 1666 1664 } 1667 1665 1668 1666 /*
-2
net/l2tp/l2tp_ip6.c
··· 257 257 258 258 if (tunnel) 259 259 l2tp_tunnel_delete(tunnel); 260 - 261 - inet6_destroy_sock(sk); 262 260 } 263 261 264 262 static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
-7
net/mptcp/protocol.c
··· 3898 3898 3899 3899 static struct proto mptcp_v6_prot; 3900 3900 3901 - static void mptcp_v6_destroy(struct sock *sk) 3902 - { 3903 - mptcp_destroy(sk); 3904 - inet6_destroy_sock(sk); 3905 - } 3906 - 3907 3901 static struct inet_protosw mptcp_v6_protosw = { 3908 3902 .type = SOCK_STREAM, 3909 3903 .protocol = IPPROTO_MPTCP, ··· 3913 3919 mptcp_v6_prot = mptcp_prot; 3914 3920 strcpy(mptcp_v6_prot.name, "MPTCPv6"); 3915 3921 mptcp_v6_prot.slab = NULL; 3916 - mptcp_v6_prot.destroy = mptcp_v6_destroy; 3917 3922 mptcp_v6_prot.obj_size = sizeof(struct mptcp6_sock); 3918 3923 3919 3924 err = proto_register(&mptcp_v6_prot, 1);