From: Matt Caswell Date: Mon, 18 Sep 2023 10:41:42 +0000 (+0100) Subject: Add some optional debug output to the noisy dgram BIO X-Git-Tag: openssl-3.2.0-alpha2~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fbfcc3fe3458c50a11aa414a1e499a2eee0eb2e9;p=thirdparty%2Fopenssl.git Add some optional debug output to the noisy dgram BIO Reviewed-by: Tim Hudson Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/22157) --- diff --git a/test/helpers/noisydgrambio.c b/test/helpers/noisydgrambio.c index c1eb141ee5c..b42dbe6f4b5 100644 --- a/test/helpers/noisydgrambio.c +++ b/test/helpers/noisydgrambio.c @@ -202,6 +202,16 @@ static int noisy_dgram_recvmmsg(BIO *bio, BIO_MSG *msg, size_t stride, if (!BIO_recvmmsg(next, msg, stride, num_msg, flags, msgs_processed)) return 0; +#ifdef OSSL_NOISY_DGRAM_DEBUG + printf("Pre-filter datagram list:\n"); + for (i = 0; i < *msgs_processed; i++) { + printf("Pre-filter Datagram:\n"); + BIO_dump_fp(stdout, msg[i].data, msg[i].data_len); + printf("\n"); + } + printf("End of pre-filter datagram list\nApplying noise filters:\n"); +#endif + msg_cnt = *msgs_processed; /* Introduce noise */ @@ -224,6 +234,11 @@ static int noisy_dgram_recvmmsg(BIO *bio, BIO_MSG *msg, size_t stride, return 0; msg_cnt++; data->delayed_dgram = 0; +#ifdef OSSL_NOISY_DGRAM_DEBUG + printf("**Inserting a delayed datagram\n"); + BIO_dump_fp(stdout, thismsg->data, thismsg->data_len); + printf("\n"); +#endif continue; } /* else we have no space for the insertion, so just drop it */ data->delayed_dgram = 0; @@ -246,9 +261,21 @@ static int noisy_dgram_recvmmsg(BIO *bio, BIO_MSG *msg, size_t stride, return 0; data->delayed_dgram = data->this_dgram + delay; + +#ifdef OSSL_NOISY_DGRAM_DEBUG + printf("**Delaying a datagram for %u messages%s\n", + (unsigned int)delay, should_drop ? "" : "(duplicating)"); + BIO_dump_fp(stdout, thismsg->data, thismsg->data_len); + printf("\n"); +#endif } if (should_drop) { +#ifdef OSSL_NOISY_DGRAM_DEBUG + printf("**Dropping a datagram\n"); + BIO_dump_fp(stdout, thismsg->data, thismsg->data_len); + printf("\n"); +#endif for (j = i + 1; j < msg_cnt; j++) { if (!bio_msg_copy(&msg[j - 1], &msg[j])) return 0; @@ -257,6 +284,16 @@ static int noisy_dgram_recvmmsg(BIO *bio, BIO_MSG *msg, size_t stride, } } +#ifdef OSSL_NOISY_DGRAM_DEBUG + printf("End of noise filters\nPost-filter datagram list:\n"); + for (i = 0; i < msg_cnt; i++) { + printf("Post-filter Datagram:\n"); + BIO_dump_fp(stdout, msg[i].data, msg[i].data_len); + printf("\n"); + } + printf("End of post-filter datagram list\n"); +#endif + *msgs_processed = msg_cnt; if (msg_cnt == 0) {