Fix a failure in bio_dgram_test on the NonStop platform
authorMatt Caswell <matt@openssl.org>
Mon, 11 Sep 2023 09:03:22 +0000 (10:03 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 13 Sep 2023 10:53:13 +0000 (11:53 +0100)
The size of the datagram header is significantly larger that we might
expect on NonStop (probably driven by sizeof(BIO_ADDR)). We adjust the
size of the default buffer to take into account the header size and the
mtu.

Fixes #22013

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22058)

crypto/bio/bss_dgram_pair.c
test/bio_dgram_test.c

index 534a2216aa42a9c8df8f31217d4d7bfc014470a9..08dd802d8fd42a1b0b457175bde7a7a3693e6ea7 100644 (file)
@@ -279,8 +279,9 @@ static int dgram_pair_init(BIO *bio)
     if (b == NULL)
         return 0;
 
-    b->req_buf_len = 17*1024; /* default buffer size */
     b->mtu         = 1472;    /* conservative default MTU */
+    /* default buffer size */
+    b->req_buf_len = 9 * (sizeof(struct dgram_hdr) + b->mtu);
 
     b->lock = CRYPTO_THREAD_lock_new();
     if (b->lock == NULL) {
index f6c3e30c149255232bbb3dcf61b8f1e860891bb5..70157493f971ae42a33982d0d5c2f9e4fa96f3f6 100644 (file)
@@ -559,8 +559,11 @@ static int test_bio_dgram_pair(int idx)
         goto err;
 
     /*
-     * Should be able to fit at least 9 datagrams in default write buffer size
-     * in worst case
+     * The number of datagrams we can fit depends on the size of the default
+     * write buffer size, the size of the datagram header and the size of the
+     * payload data we send in each datagram. The max payload data is based on
+     * the mtu. The default write buffer size is 9 * (sizeof(header) + mtu) so
+     * we expect at least 9 maximally sized datagrams to fit in the buffer.
      */
     if (!TEST_int_ge(i, 9))
         goto err;