SO_ZEROCOPY should rather return -ENOPROTOOPT
Subsystems (3)
PATCH 1/1 SO_ZEROCOPY should rather return -ENOPROTOOPT
ENOTSUPP is documented as "should never be seen by user programs", and is not exposed in <errno.h>, so applications cannot safely check against it. We should rather return the well-known -ENOPROTOOPT.
net/core/sock.c +2 -2
@@ -1377,9 +1377,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname,if (!(sk_is_tcp (sk) || (sk->sk_type ==SOCK_DGRAM && sk->sk_protocol ==IPPROTO_UDP ))) - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }else if (sk->sk_family !=PF_RDS ) { - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }if (!ret) {if (val <0 || val >1 )
Quoted 13 lines · Samuel Thibault
ENOTSUPP is documented as "should never be seen by user programs", and is not exposed in <
errno.h>, so applications cannot safely check against it. We should rather return the well-known-ENOPROTOOPT.Signed-off-by Samuel Thibault <[email protected]>net/core/sock.c +0
-0@@ -1377,9 +1377,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname, if (!(sk_is_tcp(sk) ||
net/core/sock.c int sock_setsockopt(struct socket *sock, int level, int optname, · line 1385
Quoted 10 lines
net/core/sock.c +2
-2(sk->sk_type == SOCK_DGRAM && sk->sk_protocol == IPPROTO_UDP))) - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }else if (sk->sk_family !=PF_RDS ) { - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }if (!ret) {if (val <0 || val >1 )
That should have been a public error code. Perhaps rather EOPNOTSUPP.
The problem with a change now is that it will confuse existing applications that check for -524 (ENOTSUPP).
Willem de Bruijn, le mar. 01 mars 2022 09:51:45 -0500, a ecrit:
Quoted 27 lines · Samuel Thibault
Quoted 13 lines
ENOTSUPP is documented as "should never be seen by user programs", and is not exposed in <
errno.h>, so applications cannot safely check against it. We should rather return the well-known-ENOPROTOOPT.Signed-off-by Samuel Thibault <[email protected]>net/core/sock.c +0
-0@@ -1377,9 +1377,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname, if (!(sk_is_tcp(sk) ||net/core/sock.c int sock_setsockopt(struct socket *sock, int level, int optname, · line 1385
Quoted 10 lines
net/core/sock.c +2
-2(sk->sk_type == SOCK_DGRAM && sk->sk_protocol == IPPROTO_UDP))) - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }else if (sk->sk_family !=PF_RDS ) { - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }if (!ret) {if (val <0 || val >1 )That should have been a public error code. Perhaps rather EOPNOTSUPP.
Quoted 2 lines
The problem with a change now is that it will confuse existing applications that check for -524 (ENOTSUPP).
They were not supposed to hardcord -524...
Actually, they already had to check against EOPNOTSUPP to support older kernels, so EOPNOTSUPP is not supposed to pose a problem.
Samuel
Quoted 29 lines · Samuel Thibault
Willem de Bruijn, le mar. 01 mars 2022 09:51:45 -0500, a ecrit:
Quoted 27 lines · Samuel Thibault
Quoted 13 lines
ENOTSUPP is documented as "should never be seen by user programs", and is not exposed in <
errno.h>, so applications cannot safely check against it. We should rather return the well-known-ENOPROTOOPT.Signed-off-by Samuel Thibault <[email protected]>net/core/sock.c +0
-0@@ -1377,9 +1377,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname, if (!(sk_is_tcp(sk) ||net/core/sock.c int sock_setsockopt(struct socket *sock, int level, int optname, · line 1385
Quoted 10 lines
net/core/sock.c +2
-2(sk->sk_type == SOCK_DGRAM && sk->sk_protocol == IPPROTO_UDP))) - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }else if (sk->sk_family !=PF_RDS ) { - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }if (!ret) {if (val <0 || val >1 )That should have been a public error code. Perhaps rather EOPNOTSUPP.
Quoted 7 lines
Quoted 2 lines
The problem with a change now is that it will confuse existing applications that check for -524 (ENOTSUPP).
They were not supposed to hardcord -524...
Actually, they already had to check against EOPNOTSUPP to support older kernels, so EOPNOTSUPP is not supposed to pose a problem.
Which older kernels returned EOPNOTSUPP on SO_ZEROCOPY?
There is prior art in changing this error code when it leaks to userspace, such as commit 2230a7ef5198 ("drop_monitor: Use correct error code") and commit 4a5cdc604b9c ("net/tls: Fix return values to avoid ENOTSUPP").
I certainly wrote code in the past that explicitly checks for 524 (ENOTSUPP). But do not immediately see public code that does this. Indeed, udpgso_bench_tx checks for both these codes.
So it's probably fine. Note that there is some risk. But no more than with those prior commits.
Willem de Bruijn, le mar. 01 mars 2022 10:14:18 -0500, a ecrit:
Quoted 34 lines
Quoted 32 lines · Samuel Thibault
Willem de Bruijn, le mar. 01 mars 2022 09:51:45 -0500, a ecrit:
Quoted 29 lines · Samuel Thibault
Quoted 13 lines
ENOTSUPP is documented as "should never be seen by user programs", and is not exposed in <
errno.h>, so applications cannot safely check against it. We should rather return the well-known-ENOPROTOOPT.Signed-off-by Samuel Thibault <[email protected]>net/core/sock.c +0
-0@@ -1377,9 +1377,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname, if (!(sk_is_tcp(sk) ||net/core/sock.c int sock_setsockopt(struct socket *sock, int level, int optname, · line 1385
Quoted 10 lines
net/core/sock.c +2
-2(sk->sk_type == SOCK_DGRAM && sk->sk_protocol == IPPROTO_UDP))) - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }else if (sk->sk_family !=PF_RDS ) { - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }if (!ret) {if (val <0 || val >1 )That should have been a public error code. Perhaps rather EOPNOTSUPP.
The problem with a change now is that it will confuse existing applications that check for -524 (ENOTSUPP).
Quoted 6 lines
Quoted 4 lines
They were not supposed to hardcord -524...
Actually, they already had to check against EOPNOTSUPP to support older kernels, so EOPNOTSUPP is not supposed to pose a problem.
Which older kernels returned EOPNOTSUPP on
SO_ZEROCOPY?
Sorry, bad copy/paste, I meant ENOPROTOOPT.
Samuel
Quoted 36 lines · Samuel Thibault
Willem de Bruijn, le mar. 01 mars 2022 10:14:18 -0500, a ecrit:
Quoted 34 lines
Quoted 32 lines · Samuel Thibault
Willem de Bruijn, le mar. 01 mars 2022 09:51:45 -0500, a ecrit:
Quoted 29 lines · Samuel Thibault
Quoted 13 lines
ENOTSUPP is documented as "should never be seen by user programs", and is not exposed in <
errno.h>, so applications cannot safely check against it. We should rather return the well-known-ENOPROTOOPT.Signed-off-by Samuel Thibault <[email protected]>net/core/sock.c +0
-0@@ -1377,9 +1377,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname, if (!(sk_is_tcp(sk) ||net/core/sock.c int sock_setsockopt(struct socket *sock, int level, int optname, · line 1385
Quoted 10 lines
net/core/sock.c +2
-2(sk->sk_type == SOCK_DGRAM && sk->sk_protocol == IPPROTO_UDP))) - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }else if (sk->sk_family !=PF_RDS ) { - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }if (!ret) {if (val <0 || val >1 )That should have been a public error code. Perhaps rather EOPNOTSUPP.
The problem with a change now is that it will confuse existing applications that check for -524 (ENOTSUPP).
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
They were not supposed to hardcord -524...
Actually, they already had to check against EOPNOTSUPP to support older kernels, so EOPNOTSUPP is not supposed to pose a problem.
Which older kernels returned EOPNOTSUPP on
SO_ZEROCOPY?Sorry, bad copy/paste, I meant ENOPROTOOPT.
Same point though, right? These are not legacy concerns, but specific to applications written to SO_ZEROCOPY.
I expect that most will just ignore the exact error code and will work with either.
Willem de Bruijn, le mar. 01 mars 2022 10:21:41 -0500, a ecrit:
Quoted 45 lines
Quoted 43 lines · Samuel Thibault
Willem de Bruijn, le mar. 01 mars 2022 10:14:18 -0500, a ecrit:
Quoted 40 lines
Quoted 29 lines · Samuel Thibault
Willem de Bruijn, le mar. 01 mars 2022 09:51:45 -0500, a ecrit:
Quoted 27 lines · Samuel Thibault
Quoted 13 lines
ENOTSUPP is documented as "should never be seen by user programs", and is not exposed in <
errno.h>, so applications cannot safely check against it. We should rather return the well-known-ENOPROTOOPT.Signed-off-by Samuel Thibault <[email protected]>net/core/sock.c +0
-0@@ -1377,9 +1377,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname, if (!(sk_is_tcp(sk) ||net/core/sock.c int sock_setsockopt(struct socket *sock, int level, int optname, · line 1385
Quoted 10 lines
net/core/sock.c +2
-2(sk->sk_type == SOCK_DGRAM && sk->sk_protocol == IPPROTO_UDP))) - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }else if (sk->sk_family !=PF_RDS ) { - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }if (!ret) {if (val <0 || val >1 )That should have been a public error code. Perhaps rather EOPNOTSUPP.
Quoted 7 lines
Quoted 2 lines
The problem with a change now is that it will confuse existing applications that check for -524 (ENOTSUPP).
They were not supposed to hardcord -524...
Actually, they already had to check against EOPNOTSUPP to support older kernels, so EOPNOTSUPP is not supposed to pose a problem.
Which older kernels returned EOPNOTSUPP on
SO_ZEROCOPY?
Quoted 7 lines
Quoted 1 line
Sorry, bad copy/paste, I meant ENOPROTOOPT.
Same point though, right? These are not legacy concerns, but specific to applications written to
SO_ZEROCOPY.I expect that most will just ignore the exact error code and will work with either.
Well, in the code I just wrote, I ignored ENOPROTOOPT due to older kernels, and it's only when the code happened to be run against PF_LOCAL sockets that the ENOTSUPP question raised. My code has never been exposed to a EOPNOTSUPP error, so I would have never written a check against EOPNOTSUPP if you didn't mention it as a possibility.
Samuel
Hello,
Willem de Bruijn, le mar. 01 mars 2022 10:21:41 -0500, a ecrit:
Quoted 25 lines
Quoted 25 lines
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
net/core/sock.c int sock_setsockopt(struct socket *sock, int level, int optname, · line 1385
Quoted 12 lines
net/core/sock.c +2
-2@@ -1377,9 +1377,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname,if (!(sk_is_tcp (sk) || (sk->sk_type ==SOCK_DGRAM && sk->sk_protocol ==IPPROTO_UDP ))) - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }else if (sk->sk_family !=PF_RDS ) { - ret = -ENOTSUPP ; + ret = -ENOPROTOOPT ; }if (!ret) {if (val <0 || val >1 )That should have been a public error code. Perhaps rather EOPNOTSUPP.
Quoted 7 lines
Quoted 2 lines
The problem with a change now is that it will confuse existing applications that check for -524 (ENOTSUPP).
They were not supposed to hardcord -524...
Actually, they already had to check against EOPNOTSUPP to support older kernels, so EOPNOTSUPP is not supposed to pose a problem.
Which older kernels returned EOPNOTSUPP on
SO_ZEROCOPY?
Quoted 7 lines
Quoted 1 line
Sorry, bad copy/paste, I meant ENOPROTOOPT.
Same point though, right? These are not legacy concerns, but specific to applications written to
SO_ZEROCOPY.I expect that most will just ignore the exact error code and will work with either.
Ok, so, is this an Acked-by: you? :)
Samuel
Quoted 31 lines · Samuel Thibault
Hello,
Willem de Bruijn, le mar. 01 mars 2022 10:21:41 -0500, a ecrit:
Quoted 27 lines
Quoted 26 lines
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Review int sock_setsockopt(struct socket *sock, int level, int optname, · line 1385
Quoted 12 lines
(quoted diff) +2
-2@@ -1377,9 +1377,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname, if (!(sk_is_tcp(sk) || (sk->sk_type == SOCK_DGRAM && sk->sk_protocol == IPPROTO_UDP))) - ret = -ENOTSUPP; + ret = -ENOPROTOOPT; } else if (sk->sk_family != PF_RDS) { - ret = -ENOTSUPP; + ret = -ENOPROTOOPT; } if (!ret) { if (val < 0 || val > 1)That should have been a public error code. Perhaps rather EOPNOTSUPP.
The problem with a change now is that it will confuse existing applications that check for -524 (ENOTSUPP).
Quoted 6 lines
Quoted 4 lines
They were not supposed to hardcord -524...
Actually, they already had to check against EOPNOTSUPP to support older kernels, so EOPNOTSUPP is not supposed to pose a problem.
Which older kernels returned EOPNOTSUPP on
SO_ZEROCOPY?Sorry, bad copy/paste, I meant ENOPROTOOPT.
Quoted 7 lines
Quoted 5 lines
Same point though, right? These are not legacy concerns, but specific to applications written to
SO_ZEROCOPY.I expect that most will just ignore the exact error code and will work with either.
Ok, so, is this an Acked-by: you? :)
I did not touch this code on purpose, due to the small risk of legacy users that expect 524.
If you think the benefit outweighs the risk --the same conclusion reached in the commits I mentioned, 2230a7ef5198 ("drop_monitor: Use correct
error code") and commit 4a5cdc604b9c ("net/tls: Fix return values to avoid ENOTSUPP")-- then I can support that.
But like those, I think the correct error code then is EOPNOTSUPP. And the commit message would be stronger by explicitly referencing that prior art, and the fact that those changes did not seem to cause problems.