net: diag: support SOCK_DESTROY for UDP sockets
This implements SOCK_DESTROY for UDP sockets similar to what was done
for TCP with commit c1e64e298b
("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>
This commit is contained in:

committed by
David S. Miller

parent
5128b18522
commit
5d77dca828
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user