inet6: Backport complete patchset for inet6_destroy_sock() call modification
Subsystems (3)
cover inet6: Backport complete patchset for inet6_destroy_sock() call modification
4.14 LTS has backported commit ca43ccf41224 ("dccp/tcp: Avoid negative sk_forward_alloc by ipv6_pinfo.pktoptions.") and commit 62ec33b44e0f ("net:
Remove WARN_ON_ONCE(sk->sk_forward_alloc) from sk_stream_kill_queues()."), but these are incomplete. There are some patches that have not been backported including key pre-patches commit d38afeec26ed ("tcp/udp:
Call inet6_destroy_sock() in IPv6 sk->sk_destruct().") and commit b5fc29233d28 ("inet6: Remove inet6_destroy_sock() in sk->sk_prot->destroy()."). Without them, there are some memory leak bugs.
Backport complete patchset for inet6_destroy_sock() call modification.
Kuniyuki Iwashima (5):
udp: Call inet6_destroy_sock() in setsockopt(IPV6_ADDRFORM). tcp/udp: Call inet6_destroy_sock() in IPv6 sk->sk_destruct().
inet6: Remove inet6_destroy_sock() in sk->sk_prot->destroy().
dccp: Call inet6_destroy_sock() via sk->sk_destruct().
sctp: Call inet6_destroy_sock() via sk->sk_destruct().
include/net/ipv6.h | 2 ++ include/net/udp.h | 2 +- include/net/udplite.h | 8 -------- net/dccp/dccp.h | 1 + net/dccp/ipv6.c | 15 ++++++++------- net/dccp/proto.c | 8 +++++++- net/ipv4/udp.c | 9 ++++++--- net/ipv4/udplite.c | 8 ++++++++ net/ipv6/af_inet6.c | 15 ++++++++++++++- net/ipv6/ipv6_sockglue.c | 20 ++++++++------------ net/ipv6/ping.c | 6 ------ net/ipv6/raw.c | 2 -- net/ipv6/tcp_ipv6.c | 8 +------- net/ipv6/udp.c | 17 ++++++++++++++--- net/ipv6/udp_impl.h | 1 + net/ipv6/udplite.c | 9 ++++++++- net/l2tp/l2tp_ip6.c | 2 -- net/sctp/socket.c | 29 +++++++++++++++++++++-------- 18 files changed, 100 insertions(+), 62 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/5 udp: Call inet6_destroy_sock() in setsockopt(IPV6_ADDRFORM).
From: Kuniyuki Iwashima <[email protected]>
commit 21985f43376cee092702d6cb963ff97a9d2ede68 upstream.
Commit 4b340ae20d0e ("IPv6: Complete IPV6_DONTFRAG support") forgot to add a change to free inet6_sk(sk)->rxpmtu while converting an IPv6 socket into IPv4 with IPV6_ADDRFORM. After conversion, sk_prot is changed to udp_prot and ->destroy() never cleans it up, resulting in a memory leak.
This is due to the discrepancy between inet6_destroy_sock() and IPV6_ADDRFORM, so let's call inet6_destroy_sock() from IPV6_ADDRFORM to remove the difference.
However, this is not enough for now because rxpmtu can be changed without lock_sock() after commit 03485f2adcde ("udpv6: Add lockless sendmsg() support"). We will fix this case in the following patch.
Note we will rename inet6_destroy_sock() to inet6_cleanup_sock() and remove unnecessary inet6_destroy_sock() calls in sk_prot->destroy() in the future.
--- include/net/ipv6.h | 1 + net/ipv6/af_inet6.c | 6 ++++++ net/ipv6/ipv6_sockglue.c | 20 ++++++++------------ 3 files changed, 15 insertions(+), 12 deletions(-)
include/net/ipv6.h +1 -0
@@ -942,6 +942,7 @@ void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, __be16 port,void ipv6_local_error (struct sock *sk,int err,struct flowi6 *fl6,u32 info);void ipv6_local_rxpmtu (struct sock *sk,struct flowi6 *fl6,u32 mtu); +void inet6_cleanup_sock (struct sock *sk);int inet6_release (struct socket *sock);int inet6_bind (struct socket *sock,struct sockaddr *uaddr,int addr_len); int inet6_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_len,
net/ipv6/af_inet6.c +6 -0
@@ -480,6 +480,12 @@ void inet6_destroy_sock(struct sock *sk) }EXPORT_SYMBOL_GPL (inet6_destroy_sock); +void inet6_cleanup_sock (struct sock *sk) +{ +inet6_destroy_sock (sk); +} +EXPORT_SYMBOL_GPL (inet6_cleanup_sock); +/* * This does both peername and sockname. */
net/ipv6/ipv6_sockglue.c +8 -12
@@ -178,9 +178,6 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,if (optlen <sizeof (int )) goto e_inval;if (val ==PF_INET ) { -struct ipv6_txoptions *opt; -struct sk_buff *pktopt; -if (sk->sk_type ==SOCK_RAW )break ;
@@ -211,7 +208,6 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,break ; } -fl6_free_socklist (sk);__ipv6_sock_mc_close (sk);__ipv6_sock_ac_close (sk);
@@ -246,14 +242,14 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, sk->sk_socket->ops = &inet_dgram_ops; sk->sk_family =PF_INET ; } - opt =xchg ((__force struct ipv6_txoptions **)&np->opt, -NULL ); -if (opt) { -atomic_sub (opt->tot_len, &sk->sk_omem_alloc); -txopt_put (opt); - } - pktopt =xchg (&np->pktoptions,NULL ); -kfree_skb (pktopt); + +/* Disable all options not to allocate memory anymore, +* but there is still a race. See the lockless path +* in udpv6_sendmsg() and ipv6_local_rxpmtu(). +*/ + np->rxopt.all =0 ; + +inet6_cleanup_sock (sk);/* * ... and add it to the refcnt debug socks count
Signature · 1 line
2.25.1
PATCH 2/5 tcp/udp: Call inet6_destroy_sock() in IPv6 sk->sk_destruct().
In reply to Ziyang XuanFrom: Kuniyuki Iwashima <[email protected]>
commit d38afeec26ed4739c640bf286c270559aab2ba5f upstream.
Originally, inet6_sk(sk)->XXX were changed under lock_sock(), so we were able to clean them up by calling inet6_destroy_sock() during the IPv6 -> IPv4 conversion by IPV6_ADDRFORM. However, commit 03485f2adcde ("udpv6:
Add lockless sendmsg() support") added a lockless memory allocation path, which could cause a memory leak:
setsockopt(IPV6_ADDRFORM) sendmsg() +-----------------------+ +-------+ - do_ipv6_setsockopt(sk, ...) - udpv6_sendmsg(sk, ...)
- sockopt_lock_sock(sk) ^._ called via udpv6_prot
- lock_sock(sk) before WRITE_ONCE()
- WRITE_ONCE(sk->sk_prot, &tcp_prot)
- inet6_destroy_sock() - if (!corkreq)
- sockopt_release_sock(sk) - ip6_make_skb(sk, ...)
- release_sock(sk) ^._ lockless fast path for
the non-corking case
- __ip6_append_data(sk, ...)
- ipv6_local_rxpmtu(sk, ...)
- xchg(&np->rxpmtu, skb) ^._ rxpmtu is never freed.
- goto out_no_dst;
- lock_sock(sk)
For now, rxpmtu is only the case, but not to miss the future change and a similar bug fixed in commit e27326009a3d ("net: ping6: Fix memleak in ipv6_renew_options()."), let's set a new function to IPv6 sk->sk_destruct() and call inet6_cleanup_sock() there. Since the conversion does not change sk->sk_destruct(), we can guarantee that we can clean up IPv6 resources finally.
We can now remove all inet6_destroy_sock() calls from IPv6 protocol specific ->destroy() functions, but such changes are invasive to backport. So they can be posted as a follow-up later for net-next.
--- include/net/ipv6.h | 1 + include/net/udp.h | 2 +- include/net/udplite.h | 8 -------- net/ipv4/udp.c | 9 ++++++--- net/ipv4/udplite.c | 8 ++++++++ net/ipv6/af_inet6.c | 8 +++++++- net/ipv6/udp.c | 15 ++++++++++++++- net/ipv6/udp_impl.h | 1 + net/ipv6/udplite.c | 9 ++++++++- 9 files changed, 46 insertions(+), 15 deletions(-)
include/net/ipv6.h +1 -0
@@ -943,6 +943,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi6 *fl6, u32 info);void ipv6_local_rxpmtu (struct sock *sk,struct flowi6 *fl6,u32 mtu);void inet6_cleanup_sock (struct sock *sk); +void inet6_sock_destruct (struct sock *sk);int inet6_release (struct socket *sock);int inet6_bind (struct socket *sock,struct sockaddr *uaddr,int addr_len); int inet6_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_len,
include/net/udp.h +1 -1
@@ -251,7 +251,7 @@ static inline int udp_rqueue_get(struct sock *sk) }/* net/ipv4/udp.c */ -void udp_destruct_sock (struct sock *sk); +void udp_destruct_common (struct sock *sk);void skb_consume_udp (struct sock *sk,struct sk_buff *skb,int len);int __udp_enqueue_schedule_skb (struct sock *sk,struct sk_buff *skb);void udp_skb_destructor (struct sock *sk,struct sk_buff *skb);
include/net/udplite.h +0 -8
@@ -24,14 +24,6 @@ static __inline__ int udplite_getfrag(void *from, char *to, int offset,return copy_from_iter_full (to, len, &msg->msg_iter) ?0 : -EFAULT ; } -/* Designate sk as UDP-Lite socket */ -static inline int udplite_sk_init (struct sock *sk) -{ -udp_init_sock (sk); -udp_sk (sk)->pcflag =UDPLITE_BIT ; -return 0 ; -} -/* * Checksumming routines */
net/ipv4/udp.c +6 -3
@@ -1380,7 +1380,7 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) }EXPORT_SYMBOL_GPL (__udp_enqueue_schedule_skb); -void udp_destruct_sock (struct sock *sk) +void udp_destruct_common (struct sock *sk) {/* reclaim completely the forward allocated memory */ struct udp_sock *up =udp_sk (sk);
@@ -1393,10 +1393,14 @@ void udp_destruct_sock(struct sock *sk)kfree_skb (skb); }udp_rmem_release (sk, total,0 , true); +} +EXPORT_SYMBOL_GPL (udp_destruct_common); +static void udp_destruct_sock (struct sock *sk) +{ +udp_destruct_common (sk);inet_sock_destruct (sk); } -EXPORT_SYMBOL_GPL (udp_destruct_sock);int udp_init_sock (struct sock *sk) {
@@ -1404,7 +1408,6 @@ int udp_init_sock(struct sock *sk) sk->sk_destruct = udp_destruct_sock;return 0 ; } -EXPORT_SYMBOL_GPL (udp_init_sock);void skb_consume_udp (struct sock *sk,struct sk_buff *skb,int len) {
net/ipv4/udplite.c +8 -0
@@ -19,6 +19,14 @@struct udp_table udplite_table__read_mostly ;EXPORT_SYMBOL (udplite_table); +/* Designate sk as UDP-Lite socket */ +static int udplite_sk_init (struct sock *sk) +{ +udp_init_sock (sk); +udp_sk (sk)->pcflag =UDPLITE_BIT ; +return 0 ; +} +static int udplite_rcv (struct sk_buff *skb) {return __udp4_lib_rcv (skb, &udplite_table,IPPROTO_UDPLITE );
net/ipv6/af_inet6.c +7 -1
@@ -107,6 +107,12 @@ static __inline__ struct ipv6_pinfo *inet6_sk_generic(struct sock *sk)return (struct ipv6_pinfo *)(((u8 *)sk) + offset); } +void inet6_sock_destruct (struct sock *sk) +{ +inet6_cleanup_sock (sk); +inet_sock_destruct (sk); +} +static int inet6_create (struct net *net,struct socket *sock,int protocol,int kern) {
@@ -199,7 +205,7 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol, inet->hdrincl =1 ; } - sk->sk_destruct = inet_sock_destruct; + sk->sk_destruct = inet6_sock_destruct; sk->sk_family =PF_INET6 ; sk->sk_protocol = protocol;
net/ipv6/udp.c +14 -1
@@ -66,6 +66,19 @@ static bool udp6_lib_exact_dif_match(struct net *net, struct sk_buff *skb)return false; } +static void udpv6_destruct_sock (struct sock *sk) +{ +udp_destruct_common (sk); +inet6_sock_destruct (sk); +} + +int udpv6_init_sock (struct sock *sk) +{ +skb_queue_head_init (&udp_sk (sk)->reader_queue); + sk->sk_destruct = udpv6_destruct_sock; +return 0 ; +} + static u32 udp6_ehashfn(const struct net *net, const struct in6_addr *laddr, const u16 lport,
@@ -1552,7 +1565,7 @@ struct proto udpv6_prot = { .connect = ip6_datagram_connect, .disconnect = udp_disconnect, .ioctl = udp_ioctl, - .init = udp_init_sock, + .init = udpv6_init_sock, .destroy = udpv6_destroy_sock, .setsockopt = udpv6_setsockopt, .getsockopt = udpv6_getsockopt,
net/ipv6/udp_impl.h +1 -0
@@ -12,6 +12,7 @@ int __udp6_lib_rcv(struct sk_buff *, struct udp_table *, int);void __udp6_lib_err (struct sk_buff *,struct inet6_skb_parm *,u8 ,u8 ,int ,__be32 ,struct udp_table *); +int udpv6_init_sock (struct sock *sk);int udp_v6_get_port (struct sock *sk,unsigned short snum); int udpv6_getsockopt(struct sock *sk, int level, int optname,
net/ipv6/udplite.c +8 -1
@@ -14,6 +14,13 @@#include <linux/export.h> #include "udp_impl.h" +static int udplitev6_sk_init (struct sock *sk) +{ +udpv6_init_sock (sk); +udp_sk (sk)->pcflag =UDPLITE_BIT ; +return 0 ; +} +static int udplitev6_rcv (struct sk_buff *skb) {return __udp6_lib_rcv (skb, &udplite_table,IPPROTO_UDPLITE );
@@ -39,7 +46,7 @@ struct proto udplitev6_prot = { .connect = ip6_datagram_connect, .disconnect = udp_disconnect, .ioctl = udp_ioctl, - .init = udplite_sk_init, + .init = udplitev6_sk_init, .destroy = udpv6_destroy_sock, .setsockopt = udpv6_setsockopt, .getsockopt = udpv6_getsockopt,
Signature · 1 line
2.25.1
PATCH 3/5 inet6: Remove inet6_destroy_sock() in sk->sk_prot->destroy().
In reply to Ziyang XuanFrom: Kuniyuki Iwashima <[email protected]>
commit b5fc29233d28be7a3322848ebe73ac327559cdb9 upstream.
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.
--- net/ipv6/ping.c | 6 ------ net/ipv6/raw.c | 2 -- net/ipv6/tcp_ipv6.c | 8 +------- net/ipv6/udp.c | 2 -- net/l2tp/l2tp_ip6.c | 2 -- 5 files changed, 1 insertion(+), 19 deletions(-)
net/ipv6/ping.c +0 -6
@@ -26,11 +26,6 @@#include <net/transp_v6.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)
@@ -178,7 +173,6 @@ struct proto pingv6_prot = { .owner = THIS_MODULE, .init = ping_init_sock, .close = ping_close, - .destroy = ping_v6_destroy, .connect = ip6_datagram_connect_v6_only, .disconnect = __udp_disconnect, .setsockopt = ipv6_setsockopt,
net/ipv6/raw.c +0 -2
@@ -1258,8 +1258,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)
net/ipv6/tcp_ipv6.c +1 -7
@@ -1754,12 +1754,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,
@@ -1953,7 +1947,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,
net/ipv6/udp.c +0 -2
@@ -1459,8 +1459,6 @@ void udpv6_destroy_sock(struct sock *sk)if (encap_destroy)encap_destroy (sk); } - -inet6_destroy_sock (sk); }/*
net/l2tp/l2tp_ip6.c +0 -2
@@ -277,8 +277,6 @@ static void l2tp_ip6_destroy_sock(struct sock *sk)l2tp_tunnel_closeall (tunnel);sock_put (sk); } - -inet6_destroy_sock (sk); }static int l2tp_ip6_bind (struct sock *sk,struct sockaddr *uaddr,int addr_len)
Signature · 1 line
2.25.1
PATCH 4/5 dccp: Call inet6_destroy_sock() via sk->sk_destruct().
In reply to Ziyang XuanFrom: Kuniyuki Iwashima <[email protected]>
commit 1651951ebea54970e0bda60c638fc2eee7a6218f upstream.
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.
DCCP sets its own sk->sk_destruct() in the dccp_init_sock(), and DCCPv6 socket shares it by calling the same init function via dccp_v6_init_sock().
To call inet6_sock_destruct() from DCCPv6 sk->sk_destruct(), we export it and set dccp_v6_sk_destruct() in the init function.
--- net/dccp/dccp.h | 1 + net/dccp/ipv6.c | 15 ++++++++------- net/dccp/proto.c | 8 +++++++- net/ipv6/af_inet6.c | 1 + 4 files changed, 17 insertions(+), 8 deletions(-)
net/dccp/dccp.h +1 -0
@@ -291,6 +291,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);
net/dccp/ipv6.c +8 -7
@@ -1000,6 +1000,12 @@ static const struct inet_connection_sock_af_ops dccp_ipv6_mapped = {#endif }; +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. */
@@ -1012,17 +1018,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 ), };
@@ -1045,7 +1046,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),
net/dccp/proto.c +7 -1
@@ -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); }
net/ipv6/af_inet6.c +1 -0
@@ -112,6 +112,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)
Signature · 1 line
2.25.1
PATCH 5/5 sctp: Call inet6_destroy_sock() via sk->sk_destruct().
In reply to Ziyang XuanFrom: Kuniyuki Iwashima <[email protected]>
commit 6431b0f6ff1633ae598667e4cdd93830074a03e8 upstream.
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.
SCTP sets its own sk->sk_destruct() in the sctp_init_sock(), and SCTPv6 socket reuses it as the init function.
To call inet6_sock_destruct() from SCTPv6 sk->sk_destruct(), we set sctp_v6_destruct_sock() in a new init function.
--- net/sctp/socket.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-)
net/sctp/socket.c +21 -8
@@ -4497,13 +4497,17 @@ static void sctp_destroy_sock(struct sock *sk) }/* Triggered when there are no references on the socket anymore */ -static void sctp_destruct_sock (struct sock *sk) +static void sctp_destruct_common (struct sock *sk) {struct sctp_sock *sp =sctp_sk (sk);/* Free up the HMAC transform. */ crypto_free_shash (sp->hmac); +} +static void sctp_destruct_sock (struct sock *sk) +{ +sctp_destruct_common (sk);inet_sock_destruct (sk); }
@@ -8134,7 +8138,7 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk, newsk->sk_reuse = sk->sk_reuse; newsk->sk_shutdown = sk->sk_shutdown; - newsk->sk_destruct = sctp_destruct_sock; + newsk->sk_destruct = sk->sk_destruct; newsk->sk_family = sk->sk_family; newsk->sk_protocol =IPPROTO_SCTP ; newsk->sk_backlog_rcv = sk->sk_prot->backlog_rcv;
@@ -8351,11 +8355,20 @@ struct proto sctp_prot = {#if IS_ENABLED (CONFIG_IPV6 ) -#include <net/transp_v6.h> -static void sctp_v6_destroy_sock (struct sock *sk) +static void sctp_v6_destruct_sock (struct sock *sk) +{ +sctp_destruct_common (sk); +inet6_sock_destruct (sk); +} + +static int sctp_v6_init_sock (struct sock *sk) { -sctp_destroy_sock (sk); -inet6_destroy_sock (sk); +int ret =sctp_init_sock (sk); + +if (!ret) + sk->sk_destruct = sctp_v6_destruct_sock; + +return ret; } struct proto sctpv6_prot = {
@@ -8365,8 +8378,8 @@ struct proto sctpv6_prot = { .disconnect = sctp_disconnect, .accept = sctp_accept, .ioctl = sctp_ioctl, - .init = sctp_init_sock, - .destroy = sctp_v6_destroy_sock, + .init = sctp_v6_init_sock, + .destroy = sctp_destroy_sock, .shutdown = sctp_shutdown, .setsockopt = sctp_setsockopt, .getsockopt = sctp_getsockopt,
Signature · 1 line
2.25.1