From fc4b98fb885941580435c01be73d1915b8e8b20f Mon Sep 17 00:00:00 2001 From: Dmitry Chagin Date: Tue, 8 Mar 2016 15:15:34 +0000 Subject: [PATCH] Linux accept() system call return EOPNOTSUPP errno instead of EINVAL for UDP sockets. MFC after: 1 week --- sys/compat/linux/linux_socket.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index a3f3d0e58a5e..80dab32530d5 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -781,7 +781,10 @@ linux_accept_common(struct thread *td, int s, l_uintptr_t addr, socklen_t * __restrict anamelen; int flags; } */ bsd_args; - int error; + cap_rights_t rights; + struct socket *so; + struct file *fp; + int error, error1; bsd_args.s = s; /* XXX: */ @@ -796,6 +799,14 @@ linux_accept_common(struct thread *td, int s, l_uintptr_t addr, if (error) { if (error == EFAULT && namelen != sizeof(struct sockaddr_in)) return (EINVAL); + if (error == EINVAL) { + error1 = getsock_cap(td, s, &rights, &fp, NULL); + if (error1 != 0) + return (error1); + so = (struct socket *)fp->f_data; + if (so->so_type == SOCK_DGRAM) + return (EOPNOTSUPP); + } return (error); } if (addr)