netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] sock: return uapi errno in sock_setsockopt() for SO_ZEROCOPY
@ 2019-02-15 16:52 Alexey Kodanev
  2019-02-15 16:58 ` Willem de Bruijn
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Kodanev @ 2019-02-15 16:52 UTC (permalink / raw)
  To: netdev; +Cc: Willem de Bruijn, Petr Vorel, David Miller, Alexey Kodanev

For unsupported protocols, setsockopt() with SO_ZEROCOPY
option sets errno to ENOTSUPP(524). But this number is
not defined anywhere in the include/uapi/ headers.

To make sure userspace sees the known number, replace
ENOTSUPP(524) with EOPNOTSUPP(95).

Fixes: 76851d1212c1 ("sock: add SOCK_ZEROCOPY sockopt")
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
Reported-by: Petr Vorel <pvorel@suse.cz>
---
 net/core/sock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index 6aa2e7e..f6c57de 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1023,9 +1023,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
 			       sk->sk_protocol == IPPROTO_TCP) ||
 			      (sk->sk_type == SOCK_DGRAM &&
 			       sk->sk_protocol == IPPROTO_UDP)))
-				ret = -ENOTSUPP;
+				ret = -EOPNOTSUPP;
 		} else if (sk->sk_family != PF_RDS) {
-			ret = -ENOTSUPP;
+			ret = -EOPNOTSUPP;
 		}
 		if (!ret) {
 			if (val < 0 || val > 1)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net] sock: return uapi errno in sock_setsockopt() for SO_ZEROCOPY
  2019-02-15 16:52 [PATCH net] sock: return uapi errno in sock_setsockopt() for SO_ZEROCOPY Alexey Kodanev
@ 2019-02-15 16:58 ` Willem de Bruijn
  2019-02-15 21:44   ` Petr Vorel
  2019-02-18 11:35   ` Alexey Kodanev
  0 siblings, 2 replies; 5+ messages in thread
From: Willem de Bruijn @ 2019-02-15 16:58 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: Network Development, Petr Vorel, David Miller

On Fri, Feb 15, 2019 at 11:51 AM Alexey Kodanev
<alexey.kodanev@oracle.com> wrote:
>
> For unsupported protocols, setsockopt() with SO_ZEROCOPY
> option sets errno to ENOTSUPP(524). But this number is
> not defined anywhere in the include/uapi/ headers.
>
> To make sure userspace sees the known number, replace
> ENOTSUPP(524) with EOPNOTSUPP(95).
>
> Fixes: 76851d1212c1 ("sock: add SOCK_ZEROCOPY sockopt")
> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> Reported-by: Petr Vorel <pvorel@suse.cz>

This code has been there since 4.14. I think it's too late to change
system call behavior.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] sock: return uapi errno in sock_setsockopt() for SO_ZEROCOPY
  2019-02-15 16:58 ` Willem de Bruijn
@ 2019-02-15 21:44   ` Petr Vorel
  2019-02-18 11:35   ` Alexey Kodanev
  1 sibling, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2019-02-15 21:44 UTC (permalink / raw)
  To: Willem de Bruijn; +Cc: Alexey Kodanev, Network Development, David Miller

Hi,

> On Fri, Feb 15, 2019 at 11:51 AM Alexey Kodanev
> <alexey.kodanev@oracle.com> wrote:

> > For unsupported protocols, setsockopt() with SO_ZEROCOPY
> > option sets errno to ENOTSUPP(524). But this number is
> > not defined anywhere in the include/uapi/ headers.

> > To make sure userspace sees the known number, replace
> > ENOTSUPP(524) with EOPNOTSUPP(95).

> > Fixes: 76851d1212c1 ("sock: add SOCK_ZEROCOPY sockopt")
> > Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> > Reported-by: Petr Vorel <pvorel@suse.cz>

> This code has been there since 4.14. I think it's too late to change
> system call behavior.
BTW It reminds me commit 0fb44559ffd6 ("af_unix: move unix_mknod() out of
bindlock"), which while fixing a problem also for certain usage changed changed
from -EINVAL to -EADDRINUSE. Proposed fix to restore old behavior [1] was not
accepted, 0fb44559ffd6 was merged to some stable kernels so the behavior also
differs.
As there is no way to move these NFSv3 related definitions to uapi to make it
visible for userspace, I'd be for changing errno.

Kind regards,
Petr

[1] https://marc.info/?l=linux-kernel&m=149880810113888&w=2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] sock: return uapi errno in sock_setsockopt() for SO_ZEROCOPY
  2019-02-15 16:58 ` Willem de Bruijn
  2019-02-15 21:44   ` Petr Vorel
@ 2019-02-18 11:35   ` Alexey Kodanev
  2019-02-18 16:04     ` Willem de Bruijn
  1 sibling, 1 reply; 5+ messages in thread
From: Alexey Kodanev @ 2019-02-18 11:35 UTC (permalink / raw)
  To: Willem de Bruijn; +Cc: Network Development, Petr Vorel, David Miller

On 15.02.2019 19:58, Willem de Bruijn wrote:
> On Fri, Feb 15, 2019 at 11:51 AM Alexey Kodanev
> <alexey.kodanev@oracle.com> wrote:
>>
>> For unsupported protocols, setsockopt() with SO_ZEROCOPY
>> option sets errno to ENOTSUPP(524). But this number is
>> not defined anywhere in the include/uapi/ headers.
>>
>> To make sure userspace sees the known number, replace
>> ENOTSUPP(524) with EOPNOTSUPP(95).
>>
>> Fixes: 76851d1212c1 ("sock: add SOCK_ZEROCOPY sockopt")
>> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
>> Reported-by: Petr Vorel <pvorel@suse.cz>
> 
> This code has been there since 4.14. I think it's too late to change
> system call behavior.
> 

'ENOTSUPP' define is solely for an internal usage, it may be replaced
with another one or the number associated with it may be changed one day,
implicitly changing the behavior of setsockopt().

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] sock: return uapi errno in sock_setsockopt() for SO_ZEROCOPY
  2019-02-18 11:35   ` Alexey Kodanev
@ 2019-02-18 16:04     ` Willem de Bruijn
  0 siblings, 0 replies; 5+ messages in thread
From: Willem de Bruijn @ 2019-02-18 16:04 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: Network Development, Petr Vorel, David Miller

On Mon, Feb 18, 2019 at 6:35 AM Alexey Kodanev
<alexey.kodanev@oracle.com> wrote:
>
> On 15.02.2019 19:58, Willem de Bruijn wrote:
> > On Fri, Feb 15, 2019 at 11:51 AM Alexey Kodanev
> > <alexey.kodanev@oracle.com> wrote:
> >>
> >> For unsupported protocols, setsockopt() with SO_ZEROCOPY
> >> option sets errno to ENOTSUPP(524). But this number is
> >> not defined anywhere in the include/uapi/ headers.
> >>
> >> To make sure userspace sees the known number, replace
> >> ENOTSUPP(524) with EOPNOTSUPP(95).
> >>
> >> Fixes: 76851d1212c1 ("sock: add SOCK_ZEROCOPY sockopt")
> >> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> >> Reported-by: Petr Vorel <pvorel@suse.cz>
> >
> > This code has been there since 4.14. I think it's too late to change
> > system call behavior.
> >
>
> 'ENOTSUPP' define is solely for an internal usage, it may be replaced
> with another one or the number associated with it may be changed one day,
> implicitly changing the behavior of setsockopt().

I understand, and this was an error on my part.

But I'm afraid that it is already used by other interfaces, as well.
And indeed in that capacity expected by tests. See for instance
tools/testing/selftests/bpf/test_sock_addr.c

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-02-18 16:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-15 16:52 [PATCH net] sock: return uapi errno in sock_setsockopt() for SO_ZEROCOPY Alexey Kodanev
2019-02-15 16:58 ` Willem de Bruijn
2019-02-15 21:44   ` Petr Vorel
2019-02-18 11:35   ` Alexey Kodanev
2019-02-18 16:04     ` Willem de Bruijn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).