]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
QUIC TEST: Ensure PING causes ACK generation
authorHugo Landau <hlandau@openssl.org>
Wed, 26 Jul 2023 17:10:16 +0000 (18:10 +0100)
committerHugo Landau <hlandau@openssl.org>
Thu, 10 Aug 2023 17:19:44 +0000 (18:19 +0100)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21565)

include/internal/quic_channel.h
include/internal/quic_tserver.h
ssl/quic/quic_channel.c
ssl/quic/quic_channel_local.h
ssl/quic/quic_rx_depack.c
ssl/quic/quic_tserver.c
test/quic_multistream_test.c

index f9f2e30e23329243746fdae12b68a246ff6c0977..0a033fa67ea2deae7d86f1c0923c7a852437865e 100644 (file)
@@ -384,6 +384,12 @@ int ossl_quic_channel_ping(QUIC_CHANNEL *ch);
 /* For testing use. While enabled, ticking is not performed. */
 void ossl_quic_channel_set_inhibit_tick(QUIC_CHANNEL *ch, int inhibit);
 
+/*
+ * These queries exist for diagnostic purposes only. They may roll over.
+ * Do not rely on them for non-testing purposes.
+ */
+uint16_t ossl_quic_channel_get_diag_num_rx_ack(QUIC_CHANNEL *ch);
+
 # endif
 
 #endif
index 3cbbc279a60c25202d346d4f88b91a38b8dfc9bd..9520deb0c17479584a76462be6faa6509822f3af 100644 (file)
@@ -195,6 +195,12 @@ void ossl_quic_tserver_set_msg_callback(QUIC_TSERVER *srv,
                                                   SSL *ssl, void *arg),
                                         void *arg);
 
+/*
+ * This is similar to ossl_quic_conn_get_channel; it should be used for test
+ * instrumentation only and not to bypass QUIC_TSERVER for 'normal' operations.
+ */
+QUIC_CHANNEL *ossl_quic_tserver_get_channel(QUIC_TSERVER *srv);
+
 # endif
 
 #endif
index af3a1d051a53ab2d5256e737acc4ec3ca901d114..52ec3d749e171c17fd8eef18da7280f77377d472 100644 (file)
@@ -3332,3 +3332,8 @@ void ossl_quic_channel_set_inhibit_tick(QUIC_CHANNEL *ch, int inhibit)
 {
     ch->inhibit_tick = (inhibit != 0);
 }
+
+uint16_t ossl_quic_channel_get_diag_num_rx_ack(QUIC_CHANNEL *ch)
+{
+    return ch->diag_num_rx_ack;
+}
index ba129d9db3b11370a3c5c994b9bf1c7259b5a656..dd86f390be55599f16a19728cb9a00cd84435e20 100644 (file)
@@ -202,7 +202,10 @@ struct quic_channel_st {
      */
     uint64_t                        txku_threshold_override;
 
-   /* Valid if we are in the TERMINATING or TERMINATED states. */
+    /* Diagnostic counters for testing purposes only. May roll over. */
+    uint16_t                        diag_num_rx_ack; /* Number of ACK frames received */
+
+    /* Valid if we are in the TERMINATING or TERMINATED states. */
     QUIC_TERMINATE_CAUSE            terminate_cause;
 
     /*
index a20aac61bfb25439042c2beecd5ead245abdb679..1b2b81e7f824a59b3e924770674aa7430b687b18 100644 (file)
@@ -117,6 +117,7 @@ static int depack_do_frame_ack(PACKET *pkt, QUIC_CHANNEL *ch,
                                    packet_space, received))
         goto malformed;
 
+    ++ch->diag_num_rx_ack;
     OPENSSL_free(ack_ranges);
     return 1;
 
index 9bd32146c306c745c476d1f6f9db4146973cd183..15444ecc5bc1e4e3d4a81429cd612987fd3c497c 100644 (file)
@@ -512,6 +512,11 @@ int ossl_quic_tserver_ping(QUIC_TSERVER *srv)
     return 1;
 }
 
+QUIC_CHANNEL *ossl_quic_tserver_get_channel(QUIC_TSERVER *srv)
+{
+    return srv->ch;
+}
+
 void ossl_quic_tserver_set_msg_callback(QUIC_TSERVER *srv,
                                         void (*f)(int write_p, int version,
                                                   int content_type,
index 84acfe0ceea0e8670d936a292e7f4a21f9b60a5f..7fb0de1817fc3e5122cb2ebe8305e06ffba4bcc0 100644 (file)
@@ -3157,6 +3157,55 @@ static const struct script_op script_44[] = {
     OP_END
 };
 
+/* 45. PING must generate ACK */
+static int force_ping(struct helper *h, const struct script_op *op)
+{
+    QUIC_CHANNEL *ch = ossl_quic_tserver_get_channel(h->s);
+
+    h->scratch0 = ossl_quic_channel_get_diag_num_rx_ack(ch);
+
+    if (!TEST_true(ossl_quic_tserver_ping(h->s)))
+        return 0;
+
+    return 1;
+}
+
+static int wait_incoming_acks_increased(struct helper *h, const struct script_op *op)
+{
+    QUIC_CHANNEL *ch = ossl_quic_tserver_get_channel(h->s);
+    uint16_t count;
+
+    count = ossl_quic_channel_get_diag_num_rx_ack(ch);
+
+    if (count == h->scratch0) {
+        h->check_spin_again = 1;
+        return 0;
+    }
+
+    return 1;
+}
+
+static const struct script_op script_45[] = {
+    OP_C_SET_ALPN           ("ossltest")
+    OP_C_CONNECT_WAIT       ()
+
+    OP_C_WRITE              (DEFAULT, "apple", 5)
+    OP_S_BIND_STREAM_ID     (a, C_BIDI_ID(0))
+    OP_S_READ_EXPECT        (a, "apple", 5)
+
+    OP_BEGIN_REPEAT         (2)
+
+    OP_CHECK                (force_ping, 0)
+    OP_CHECK                (wait_incoming_acks_increased, 0)
+
+    OP_END_REPEAT           ()
+
+    OP_S_WRITE              (a, "Strawberry", 10)
+    OP_C_READ_EXPECT        (DEFAULT, "Strawberry", 10)
+
+    OP_END
+};
+
 static const struct script_op *const scripts[] = {
     script_1,
     script_2,
@@ -3202,6 +3251,7 @@ static const struct script_op *const scripts[] = {
     script_42,
     script_43,
     script_44,
+    script_45,
 };
 
 static int test_script(int idx)