aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2021-09-17 16:14:29 +0000
committerMark Johnston <markj@FreeBSD.org>2021-09-17 18:19:05 +0000
commitbf25678226f0d9b52c27610c734c97d76a7cae59 (patch)
tree5d4a9701b848e5a8d2e9b032f38b3d7c9bb41b86 /sys/netinet
parentd6e77cda9be1509ea170142cca3ff0d3b9f12e35 (diff)
downloadsrc-bf25678226f0d9b52c27610c734c97d76a7cae59.tar.gz
src-bf25678226f0d9b52c27610c734c97d76a7cae59.zip
ktls: Fix error/mode confusion in TCP_*TLS_MODE getsockopt handlers
ktls_get_(rx|tx)_mode() can return an errno value or a TLS mode, so errors are effectively hidden. Fix this by using a separate output parameter. Convert to the new socket buffer locking macros while here. Note that the socket buffer lock is not needed to synchronize the SOLISTENING check here, we can rely on the PCB lock. Reviewed by: jhb Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31977
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/tcp_usrreq.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 3a1608cc106a..e9f7fa541461 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -2563,14 +2563,18 @@ unhold:
#endif
#ifdef KERN_TLS
case TCP_TXTLS_MODE:
- optval = ktls_get_tx_mode(so);
+ error = ktls_get_tx_mode(so, &optval);
INP_WUNLOCK(inp);
- error = sooptcopyout(sopt, &optval, sizeof(optval));
+ if (error == 0)
+ error = sooptcopyout(sopt, &optval,
+ sizeof(optval));
break;
case TCP_RXTLS_MODE:
- optval = ktls_get_rx_mode(so);
+ error = ktls_get_rx_mode(so, &optval);
INP_WUNLOCK(inp);
- error = sooptcopyout(sopt, &optval, sizeof(optval));
+ if (error == 0)
+ error = sooptcopyout(sopt, &optval,
+ sizeof(optval));
break;
#endif
case TCP_LRD: