inet6: Remove inet6_destroy_sock() in sk->sk_prot->destroy().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Wed, 19 Oct 2022 22:35:59 +0000 (15:35 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Oct 2022 08:40:38 +0000 (09:40 +0100)
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>
net/ipv6/ping.c
net/ipv6/raw.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c
net/l2tp/l2tp_ip6.c
net/mptcp/protocol.c

index 86c26e4..808983b 100644 (file)
 #include <linux/bpf-cgroup.h>
 #include <net/ping.h>
 
-static void ping_v6_destroy(struct sock *sk)
-{
-       inet6_destroy_sock(sk);
-}
-
 /* Compatibility glue so we can support IPv6 when it's compiled as a module */
 static int dummy_ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len,
                                 int *addr_len)
@@ -205,7 +200,6 @@ struct proto pingv6_prot = {
        .owner =        THIS_MODULE,
        .init =         ping_init_sock,
        .close =        ping_close,
-       .destroy =      ping_v6_destroy,
        .pre_connect =  ping_v6_pre_connect,
        .connect =      ip6_datagram_connect_v6_only,
        .disconnect =   __udp_disconnect,
index 722de9d..a06a9f8 100644 (file)
@@ -1173,8 +1173,6 @@ static void raw6_destroy(struct sock *sk)
        lock_sock(sk);
        ip6_flush_pending_frames(sk);
        release_sock(sk);
-
-       inet6_destroy_sock(sk);
 }
 
 static int rawv6_init_sk(struct sock *sk)
index 2a3f929..f676be1 100644 (file)
@@ -1966,12 +1966,6 @@ static int tcp_v6_init_sock(struct sock *sk)
        return 0;
 }
 
-static void tcp_v6_destroy_sock(struct sock *sk)
-{
-       tcp_v4_destroy_sock(sk);
-       inet6_destroy_sock(sk);
-}
-
 #ifdef CONFIG_PROC_FS
 /* Proc filesystem TCPv6 sock list dumping. */
 static void get_openreq6(struct seq_file *seq,
@@ -2164,7 +2158,7 @@ struct proto tcpv6_prot = {
        .accept                 = inet_csk_accept,
        .ioctl                  = tcp_ioctl,
        .init                   = tcp_v6_init_sock,
-       .destroy                = tcp_v6_destroy_sock,
+       .destroy                = tcp_v4_destroy_sock,
        .shutdown               = tcp_shutdown,
        .setsockopt             = tcp_setsockopt,
        .getsockopt             = tcp_getsockopt,
index 129ec5a..2260406 100644 (file)
@@ -1661,8 +1661,6 @@ void udpv6_destroy_sock(struct sock *sk)
                        udp_encap_disable();
                }
        }
-
-       inet6_destroy_sock(sk);
 }
 
 /*
index 9dbd801..2478aa6 100644 (file)
@@ -257,8 +257,6 @@ static void l2tp_ip6_destroy_sock(struct sock *sk)
 
        if (tunnel)
                l2tp_tunnel_delete(tunnel);
-
-       inet6_destroy_sock(sk);
 }
 
 static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
index f599ad4..2e16c89 100644 (file)
@@ -3898,12 +3898,6 @@ static const struct proto_ops mptcp_v6_stream_ops = {
 
 static struct proto mptcp_v6_prot;
 
-static void mptcp_v6_destroy(struct sock *sk)
-{
-       mptcp_destroy(sk);
-       inet6_destroy_sock(sk);
-}
-
 static struct inet_protosw mptcp_v6_protosw = {
        .type           = SOCK_STREAM,
        .protocol       = IPPROTO_MPTCP,
@@ -3919,7 +3913,6 @@ int __init mptcp_proto_v6_init(void)
        mptcp_v6_prot = mptcp_prot;
        strcpy(mptcp_v6_prot.name, "MPTCPv6");
        mptcp_v6_prot.slab = NULL;
-       mptcp_v6_prot.destroy = mptcp_v6_destroy;
        mptcp_v6_prot.obj_size = sizeof(struct mptcp6_sock);
 
        err = proto_register(&mptcp_v6_prot, 1);