diff options
author | David Ahern <dsa@cumulusnetworks.com> | 2016-08-23 21:06:33 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-08-23 23:12:27 -0700 |
commit | 5d77dca82839ef016a93ad7acd7058b14d967752 (patch) | |
tree | 6ce7ab03eddb29ebcca23e80de5018401b4b00e9 /net/ipv4/udp.c | |
parent | 5128b18522e143e634712ceef6a007333b8c7439 (diff) | |
download | linux-5d77dca82839ef016a93ad7acd7058b14d967752.tar.gz linux-5d77dca82839ef016a93ad7acd7058b14d967752.tar.bz2 linux-5d77dca82839ef016a93ad7acd7058b14d967752.zip |
net: diag: support SOCK_DESTROY for UDP sockets
This implements SOCK_DESTROY for UDP sockets similar to what was done
for TCP with commit c1e64e298b8ca ("net: diag: Support destroying TCP
sockets.") A process with a UDP socket targeted for destroy is awakened
and recvmsg fails with ECONNABORTED.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/udp.c')
-rw-r--r-- | net/ipv4/udp.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 8f5f7f6026f7..e9ffc27b23d0 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -2193,6 +2193,20 @@ unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait) } EXPORT_SYMBOL(udp_poll); +int udp_abort(struct sock *sk, int err) +{ + lock_sock(sk); + + sk->sk_err = err; + sk->sk_error_report(sk); + udp_disconnect(sk, 0); + + release_sock(sk); + + return 0; +} +EXPORT_SYMBOL_GPL(udp_abort); + struct proto udp_prot = { .name = "UDP", .owner = THIS_MODULE, @@ -2224,6 +2238,7 @@ struct proto udp_prot = { .compat_getsockopt = compat_udp_getsockopt, #endif .clear_sk = sk_prot_clear_portaddr_nulls, + .diag_destroy = udp_abort, }; EXPORT_SYMBOL(udp_prot); |