Skip to contentSkip to conversation

SO_ZEROCOPY should return -EOPNOTSUPP rather than -ENOTSUPP

PATCH Applied Samuel Thibault 3 participants 3 messages Mar 7, 2022 – Mar 9, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 SO_ZEROCOPY should return -EOPNOTSUPP rather than -ENOTSUPP

ENOTSUPP is documented as "should never be seen by user programs", and thus not exposed in <errno.h>, and thus applications cannot safely check against it (they get "Unknown error 524" as strerror). We should rather return the well-known -EOPNOTSUPP.

This is similar to 2230a7ef5198 ("drop_monitor: Use correct error code") and 4a5cdc604b9c ("net/tls: Fix return values to avoid ENOTSUPP"), which did not seem to cause problems.

---
Difference with v1: use -EOPNOTSUPP instead of -ENOPROTOOPT.

net/core/sock.c +2 -2
index 4ff806d71921..839eb076afee 100644
@@ -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 = -EOPNOTSUPP;
 		} else if (sk->sk_family != PF_RDS) {
-			ret = -ENOTSUPP;
+			ret = -EOPNOTSUPP;
 		}
 		if (!ret) {
 			if (val < 0 || val > 1)
Acked-by on v2 1/1
#1 lore raw
Quoted 11 lines · Samuel Thibault

ENOTSUPP is documented as "should never be seen by user programs", and thus not exposed in <errno.h>, and thus applications cannot safely check against it (they get "Unknown error 524" as strerror). We should rather return the well-known -EOPNOTSUPP.

This is similar to 2230a7ef5198 ("drop_monitor: Use correct error code") and 4a5cdc604b9c ("net/tls: Fix return values to avoid ENOTSUPP"), which did not seem to cause problems.

From what I can tell, the first of the two referenced patches went to net-next, the second one to net and stable. I would suggest only net-next for this. Else, we should also add a Fixes tag.

Small nit, for future patches: preferred syntax is commit $SHA1 ("subject"), including the commit keyword.

#2 lore raw
In reply to Samuel Thibault
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Mon, 7 Mar 2022 23:31:26 +0100 you wrote:

ENOTSUPP is documented as "should never be seen by user programs", and thus not exposed in <errno.h>, and thus applications cannot safely check against it (they get "Unknown error 524" as strerror). We should rather return the well-known -EOPNOTSUPP.

This is similar to 2230a7ef5198 ("drop_monitor: Use correct error code") and 4a5cdc604b9c ("net/tls: Fix return values to avoid ENOTSUPP"), which did not seem to cause problems.

[...]

Here is the summary with links:
- [PATCHv2] SO_ZEROCOPY should return -EOPNOTSUPP rather than -ENOTSUPP

    https://git.kernel.org/netdev/net-next/c/869420a8be19

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html