Skip to content

Commit 4a5cdc6

Browse files
vvidicdavem330
authored andcommitted
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 <[email protected]> Acked-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1af6622 commit 4a5cdc6

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

net/tls/tls_device.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ static int tls_push_data(struct sock *sk,
429429

430430
if (flags &
431431
~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_SENDPAGE_NOTLAST))
432-
return -ENOTSUPP;
432+
return -EOPNOTSUPP;
433433

434434
if (unlikely(sk->sk_err))
435435
return -sk->sk_err;
@@ -571,7 +571,7 @@ int tls_device_sendpage(struct sock *sk, struct page *page,
571571
lock_sock(sk);
572572

573573
if (flags & MSG_OOB) {
574-
rc = -ENOTSUPP;
574+
rc = -EOPNOTSUPP;
575575
goto out;
576576
}
577577

@@ -1023,7 +1023,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx)
10231023
}
10241024

10251025
if (!(netdev->features & NETIF_F_HW_TLS_TX)) {
1026-
rc = -ENOTSUPP;
1026+
rc = -EOPNOTSUPP;
10271027
goto release_netdev;
10281028
}
10291029

@@ -1098,7 +1098,7 @@ int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx)
10981098
}
10991099

11001100
if (!(netdev->features & NETIF_F_HW_TLS_RX)) {
1101-
rc = -ENOTSUPP;
1101+
rc = -EOPNOTSUPP;
11021102
goto release_netdev;
11031103
}
11041104

net/tls/tls_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval,
487487
/* check version */
488488
if (crypto_info->version != TLS_1_2_VERSION &&
489489
crypto_info->version != TLS_1_3_VERSION) {
490-
rc = -ENOTSUPP;
490+
rc = -EINVAL;
491491
goto err_crypto_info;
492492
}
493493

@@ -714,7 +714,7 @@ static int tls_init(struct sock *sk)
714714
* share the ulp context.
715715
*/
716716
if (sk->sk_state != TCP_ESTABLISHED)
717-
return -ENOTSUPP;
717+
return -ENOTCONN;
718718

719719
/* allocate tls context */
720720
write_lock_bh(&sk->sk_callback_lock);

net/tls/tls_sw.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
905905
int ret = 0;
906906

907907
if (msg->msg_flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL))
908-
return -ENOTSUPP;
908+
return -EOPNOTSUPP;
909909

910910
mutex_lock(&tls_ctx->tx_lock);
911911
lock_sock(sk);
@@ -1220,7 +1220,7 @@ int tls_sw_sendpage_locked(struct sock *sk, struct page *page,
12201220
if (flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL |
12211221
MSG_SENDPAGE_NOTLAST | MSG_SENDPAGE_NOPOLICY |
12221222
MSG_NO_SHARED_FRAGS))
1223-
return -ENOTSUPP;
1223+
return -EOPNOTSUPP;
12241224

12251225
return tls_sw_do_sendpage(sk, page, offset, size, flags);
12261226
}
@@ -1233,7 +1233,7 @@ int tls_sw_sendpage(struct sock *sk, struct page *page,
12331233

12341234
if (flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL |
12351235
MSG_SENDPAGE_NOTLAST | MSG_SENDPAGE_NOPOLICY))
1236-
return -ENOTSUPP;
1236+
return -EOPNOTSUPP;
12371237

12381238
mutex_lock(&tls_ctx->tx_lock);
12391239
lock_sock(sk);
@@ -1932,7 +1932,7 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
19321932

19331933
/* splice does not support reading control messages */
19341934
if (ctx->control != TLS_RECORD_TYPE_DATA) {
1935-
err = -ENOTSUPP;
1935+
err = -EINVAL;
19361936
goto splice_read_end;
19371937
}
19381938

tools/testing/selftests/net/tls.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525
#define TLS_PAYLOAD_MAX_LEN 16384
2626
#define SOL_TLS 282
2727

28-
#ifndef ENOTSUPP
29-
#define ENOTSUPP 524
30-
#endif
31-
3228
FIXTURE(tls_basic)
3329
{
3430
int fd, cfd;
@@ -1205,11 +1201,11 @@ TEST(non_established) {
12051201
/* TLS ULP not supported */
12061202
if (errno == ENOENT)
12071203
return;
1208-
EXPECT_EQ(errno, ENOTSUPP);
1204+
EXPECT_EQ(errno, ENOTCONN);
12091205

12101206
ret = setsockopt(sfd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls"));
12111207
EXPECT_EQ(ret, -1);
1212-
EXPECT_EQ(errno, ENOTSUPP);
1208+
EXPECT_EQ(errno, ENOTCONN);
12131209

12141210
ret = getsockname(sfd, &addr, &len);
12151211
ASSERT_EQ(ret, 0);

0 commit comments

Comments
 (0)