Commit 04d63e62 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'inet6_destroy_sock-calls-remove'

Kuniyuki Iwashima says:

====================
inet6: Remove inet6_destroy_sock() calls.

This is a follow-up series for commit d38afeec ("tcp/udp: Call
inet6_destroy_sock() in IPv6 sk->sk_destruct().").

This series cleans up unnecessary inet6_destory_sock() calls in
sk->sk_prot->destroy() and call it from sk->sk_destruct() to make
sure we do not leak memory related to IPv6 specific-resources.

Changes:
  v2:
    * patch 1
      * Fix build failure for CONFIG_MPTCP_IPV6=y

  v1: https://lore.kernel.org/netdev/20221018190956.1308-1-kuniyu@amazon.com/


====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 225480f0 b45a337f
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -58,8 +58,6 @@ ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp, __u16 srcp,

#define LOOPBACK4_IPV6 cpu_to_be32(0x7f000006)

void inet6_destroy_sock(struct sock *sk);

#define IPV6_SEQ_DGRAM_HEADER					       \
	"  sl  "						       \
	"local_address                         "		       \
+1 −0
Original line number Diff line number Diff line
@@ -278,6 +278,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
			 const struct dccp_hdr *dh, const unsigned int len);

void dccp_destruct_common(struct sock *sk);
int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized);
void dccp_destroy_sock(struct sock *sk);

+8 −7
Original line number Diff line number Diff line
@@ -1021,6 +1021,12 @@ static const struct inet_connection_sock_af_ops dccp_ipv6_mapped = {
	.sockaddr_len	   = sizeof(struct sockaddr_in6),
};

static void dccp_v6_sk_destruct(struct sock *sk)
{
	dccp_destruct_common(sk);
	inet6_sock_destruct(sk);
}

/* NOTE: A lot of things set to zero explicitly by call to
 *       sk_alloc() so need not be done here.
 */
@@ -1033,17 +1039,12 @@ static int dccp_v6_init_sock(struct sock *sk)
		if (unlikely(!dccp_v6_ctl_sock_initialized))
			dccp_v6_ctl_sock_initialized = 1;
		inet_csk(sk)->icsk_af_ops = &dccp_ipv6_af_ops;
		sk->sk_destruct = dccp_v6_sk_destruct;
	}

	return err;
}

static void dccp_v6_destroy_sock(struct sock *sk)
{
	dccp_destroy_sock(sk);
	inet6_destroy_sock(sk);
}

static struct timewait_sock_ops dccp6_timewait_sock_ops = {
	.twsk_obj_size	= sizeof(struct dccp6_timewait_sock),
};
@@ -1066,7 +1067,7 @@ static struct proto dccp_v6_prot = {
	.accept		   = inet_csk_accept,
	.get_port	   = inet_csk_get_port,
	.shutdown	   = dccp_shutdown,
	.destroy	   = dccp_v6_destroy_sock,
	.destroy	   = dccp_destroy_sock,
	.orphan_count	   = &dccp_orphan_count,
	.max_header	   = MAX_DCCP_HEADER,
	.obj_size	   = sizeof(struct dccp6_sock),
+7 −1
Original line number Diff line number Diff line
@@ -171,12 +171,18 @@ const char *dccp_packet_name(const int type)

EXPORT_SYMBOL_GPL(dccp_packet_name);

static void dccp_sk_destruct(struct sock *sk)
void dccp_destruct_common(struct sock *sk)
{
	struct dccp_sock *dp = dccp_sk(sk);

	ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
	dp->dccps_hc_tx_ccid = NULL;
}
EXPORT_SYMBOL_GPL(dccp_destruct_common);

static void dccp_sk_destruct(struct sock *sk)
{
	dccp_destruct_common(sk);
	inet_sock_destruct(sk);
}

+2 −7
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ void inet6_sock_destruct(struct sock *sk)
	inet6_cleanup_sock(sk);
	inet_sock_destruct(sk);
}
EXPORT_SYMBOL_GPL(inet6_sock_destruct);

static int inet6_create(struct net *net, struct socket *sock, int protocol,
			int kern)
@@ -489,7 +490,7 @@ int inet6_release(struct socket *sock)
}
EXPORT_SYMBOL(inet6_release);

void inet6_destroy_sock(struct sock *sk)
void inet6_cleanup_sock(struct sock *sk)
{
	struct ipv6_pinfo *np = inet6_sk(sk);
	struct sk_buff *skb;
@@ -514,12 +515,6 @@ void inet6_destroy_sock(struct sock *sk)
		txopt_put(opt);
	}
}
EXPORT_SYMBOL_GPL(inet6_destroy_sock);

void inet6_cleanup_sock(struct sock *sk)
{
	inet6_destroy_sock(sk);
}
EXPORT_SYMBOL_GPL(inet6_cleanup_sock);

/*
Loading