Skip to content

Commit 284504c

Browse files
vvidicgregkh
authored andcommitted
net/tls: Fix return values to avoid ENOTSUPP
[ Upstream commit 4a5cdc6 ] 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 01e73a8 commit 284504c

4 files changed

Lines changed: 12 additions & 16 deletions

File tree

‎net/tls/tls_device.c‎

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

386386
if (flags &
387387
~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_SENDPAGE_NOTLAST))
388-
return -ENOTSUPP;
388+
return -EOPNOTSUPP;
389389

390390
if (sk->sk_err)
391391
return -sk->sk_err;
@@ -519,7 +519,7 @@ int tls_device_sendpage(struct sock *sk, struct page *page,
519519
lock_sock(sk);
520520

521521
if (flags & MSG_OOB) {
522-
rc = -ENOTSUPP;
522+
rc = -EOPNOTSUPP;
523523
goto out;
524524
}
525525

@@ -961,7 +961,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx)
961961
}
962962

963963
if (!(netdev->features & NETIF_F_HW_TLS_TX)) {
964-
rc = -ENOTSUPP;
964+
rc = -EOPNOTSUPP;
965965
goto release_netdev;
966966
}
967967

@@ -1034,7 +1034,7 @@ int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx)
10341034
}
10351035

10361036
if (!(netdev->features & NETIF_F_HW_TLS_RX)) {
1037-
rc = -ENOTSUPP;
1037+
rc = -EOPNOTSUPP;
10381038
goto release_netdev;
10391039
}
10401040

‎net/tls/tls_main.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval,
473473
/* check version */
474474
if (crypto_info->version != TLS_1_2_VERSION &&
475475
crypto_info->version != TLS_1_3_VERSION) {
476-
rc = -ENOTSUPP;
476+
rc = -EINVAL;
477477
goto err_crypto_info;
478478
}
479479

@@ -782,7 +782,7 @@ static int tls_init(struct sock *sk)
782782
* share the ulp context.
783783
*/
784784
if (sk->sk_state != TCP_ESTABLISHED)
785-
return -ENOTSUPP;
785+
return -ENOTCONN;
786786

787787
tls_build_proto(sk);
788788

‎net/tls/tls_sw.c‎

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

902902
if (msg->msg_flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL))
903-
return -ENOTSUPP;
903+
return -EOPNOTSUPP;
904904

905905
mutex_lock(&tls_ctx->tx_lock);
906906
lock_sock(sk);
@@ -1215,7 +1215,7 @@ int tls_sw_sendpage_locked(struct sock *sk, struct page *page,
12151215
if (flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL |
12161216
MSG_SENDPAGE_NOTLAST | MSG_SENDPAGE_NOPOLICY |
12171217
MSG_NO_SHARED_FRAGS))
1218-
return -ENOTSUPP;
1218+
return -EOPNOTSUPP;
12191219

12201220
return tls_sw_do_sendpage(sk, page, offset, size, flags);
12211221
}
@@ -1228,7 +1228,7 @@ int tls_sw_sendpage(struct sock *sk, struct page *page,
12281228

12291229
if (flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL |
12301230
MSG_SENDPAGE_NOTLAST | MSG_SENDPAGE_NOPOLICY))
1231-
return -ENOTSUPP;
1231+
return -EOPNOTSUPP;
12321232

12331233
mutex_lock(&tls_ctx->tx_lock);
12341234
lock_sock(sk);
@@ -1928,7 +1928,7 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
19281928

19291929
/* splice does not support reading control messages */
19301930
if (ctx->control != TLS_RECORD_TYPE_DATA) {
1931-
err = -ENOTSUPP;
1931+
err = -EINVAL;
19321932
goto splice_read_end;
19331933
}
19341934

‎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)