Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/tls: Fix return values to avoid ENOTSUPP

ENOTSUPP is not available in userspace, for example:

setsockopt failed, 524, Unknown error 524

Signed-off-by: Valentin Vidic <vvidic@valentin-vidic.from.hr>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Valentin Vidic and committed by
David S. Miller
4a5cdc60 1af66221

+12 -16
+4 -4
net/tls/tls_device.c
··· 429 429 430 430 if (flags & 431 431 ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_SENDPAGE_NOTLAST)) 432 - return -ENOTSUPP; 432 + return -EOPNOTSUPP; 433 433 434 434 if (unlikely(sk->sk_err)) 435 435 return -sk->sk_err; ··· 571 571 lock_sock(sk); 572 572 573 573 if (flags & MSG_OOB) { 574 - rc = -ENOTSUPP; 574 + rc = -EOPNOTSUPP; 575 575 goto out; 576 576 } 577 577 ··· 1023 1023 } 1024 1024 1025 1025 if (!(netdev->features & NETIF_F_HW_TLS_TX)) { 1026 - rc = -ENOTSUPP; 1026 + rc = -EOPNOTSUPP; 1027 1027 goto release_netdev; 1028 1028 } 1029 1029 ··· 1098 1098 } 1099 1099 1100 1100 if (!(netdev->features & NETIF_F_HW_TLS_RX)) { 1101 - rc = -ENOTSUPP; 1101 + rc = -EOPNOTSUPP; 1102 1102 goto release_netdev; 1103 1103 } 1104 1104
+2 -2
net/tls/tls_main.c
··· 487 487 /* check version */ 488 488 if (crypto_info->version != TLS_1_2_VERSION && 489 489 crypto_info->version != TLS_1_3_VERSION) { 490 - rc = -ENOTSUPP; 490 + rc = -EINVAL; 491 491 goto err_crypto_info; 492 492 } 493 493 ··· 714 714 * share the ulp context. 715 715 */ 716 716 if (sk->sk_state != TCP_ESTABLISHED) 717 - return -ENOTSUPP; 717 + return -ENOTCONN; 718 718 719 719 /* allocate tls context */ 720 720 write_lock_bh(&sk->sk_callback_lock);
+4 -4
net/tls/tls_sw.c
··· 905 905 int ret = 0; 906 906 907 907 if (msg->msg_flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL)) 908 - return -ENOTSUPP; 908 + return -EOPNOTSUPP; 909 909 910 910 mutex_lock(&tls_ctx->tx_lock); 911 911 lock_sock(sk); ··· 1220 1220 if (flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | 1221 1221 MSG_SENDPAGE_NOTLAST | MSG_SENDPAGE_NOPOLICY | 1222 1222 MSG_NO_SHARED_FRAGS)) 1223 - return -ENOTSUPP; 1223 + return -EOPNOTSUPP; 1224 1224 1225 1225 return tls_sw_do_sendpage(sk, page, offset, size, flags); 1226 1226 } ··· 1233 1233 1234 1234 if (flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | 1235 1235 MSG_SENDPAGE_NOTLAST | MSG_SENDPAGE_NOPOLICY)) 1236 - return -ENOTSUPP; 1236 + return -EOPNOTSUPP; 1237 1237 1238 1238 mutex_lock(&tls_ctx->tx_lock); 1239 1239 lock_sock(sk); ··· 1932 1932 1933 1933 /* splice does not support reading control messages */ 1934 1934 if (ctx->control != TLS_RECORD_TYPE_DATA) { 1935 - err = -ENOTSUPP; 1935 + err = -EINVAL; 1936 1936 goto splice_read_end; 1937 1937 } 1938 1938
+2 -6
tools/testing/selftests/net/tls.c
··· 25 25 #define TLS_PAYLOAD_MAX_LEN 16384 26 26 #define SOL_TLS 282 27 27 28 - #ifndef ENOTSUPP 29 - #define ENOTSUPP 524 30 - #endif 31 - 32 28 FIXTURE(tls_basic) 33 29 { 34 30 int fd, cfd; ··· 1201 1205 /* TLS ULP not supported */ 1202 1206 if (errno == ENOENT) 1203 1207 return; 1204 - EXPECT_EQ(errno, ENOTSUPP); 1208 + EXPECT_EQ(errno, ENOTCONN); 1205 1209 1206 1210 ret = setsockopt(sfd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls")); 1207 1211 EXPECT_EQ(ret, -1); 1208 - EXPECT_EQ(errno, ENOTSUPP); 1212 + EXPECT_EQ(errno, ENOTCONN); 1209 1213 1210 1214 ret = getsockname(sfd, &addr, &len); 1211 1215 ASSERT_EQ(ret, 0);