ktls: Use ATF_REQUIRE instead of assert() for validating TLS header lengths.

The TLS header length field is set by the kernel, so if it is
incorrect that is an indication of a kernel bug, not an internal error
in the tests.

Prompted by:	markj (comment in an earlier review)
Reviewed by:	markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D33003

(cherry picked from commit d71830cdf0)
This commit is contained in:
John Baldwin 2021-11-16 09:56:15 -08:00
parent 6987f78ea1
commit b2d704ea88

View file

@ -913,8 +913,8 @@ test_ktls_transmit_app_data(struct tls_enable *en, uint64_t seqno, size_t len)
record_len = sizeof(struct tls_record_layer) +
ntohs(hdr->tls_length);
assert(record_len <= outbuf_cap);
assert(record_len > outbuf_len);
ATF_REQUIRE(record_len <= outbuf_cap);
ATF_REQUIRE(record_len > outbuf_len);
rv = read(ev.ident, outbuf + outbuf_len,
record_len - outbuf_len);
if (rv == -1 && errno == EAGAIN)
@ -1013,7 +1013,7 @@ test_ktls_transmit_control(struct tls_enable *en, uint64_t seqno, uint8_t type,
ATF_REQUIRE(rv == sizeof(struct tls_record_layer));
payload_len = ntohs(hdr->tls_length);
record_len = payload_len + sizeof(struct tls_record_layer);
assert(record_len <= outbuf_cap);
ATF_REQUIRE(record_len <= outbuf_cap);
rv = read(sockets[0], outbuf + sizeof(struct tls_record_layer),
payload_len);
ATF_REQUIRE(rv == (ssize_t)payload_len);