]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
QUIC QSM: Clean up SEND_STREAM/RECV_STREAM handling
authorHugo Landau <hlandau@openssl.org>
Tue, 18 Apr 2023 18:30:55 +0000 (19:30 +0100)
committerHugo Landau <hlandau@openssl.org>
Fri, 12 May 2023 13:47:12 +0000 (14:47 +0100)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20765)

include/internal/quic_stream_map.h
ssl/quic/quic_channel.c
ssl/quic/quic_stream_map.c
test/quic_txp_test.c

index 2be73286ea286ba9998e4781fe0c403ddf688586..51e175ffb8125c5acf82399288f42b541f40af16 100644 (file)
@@ -107,18 +107,6 @@ struct quic_stream_st {
     unsigned int    deleted                 : 1;
 };
 
-/*
- * Marks a stream for STOP_SENDING. aec is the application error code (AEC).
- * This can only fail if it has already been called.
- */
-int ossl_quic_stream_stop_sending(QUIC_STREAM *s, uint64_t aec);
-
-/*
- * Marks a stream for reset. aec is the application error code (AEC).
- * This can only fail if it has already been called.
- */
-int ossl_quic_stream_reset(QUIC_STREAM *s, uint64_t aec);
-
 /* 
  * QUIC Stream Map
  * ===============
@@ -239,10 +227,24 @@ void ossl_quic_stream_map_set_rr_stepping(QUIC_STREAM_MAP *qsm, size_t stepping)
 
 /*
  * Resets the sending part of a stream.
+ *
+ * Returns 1 if the sending part of a stream was not already reset.
+ * Returns 0 otherwise, which need not be considered an error.
+ */
+int ossl_quic_stream_map_reset_stream_send_part(QUIC_STREAM_MAP *qsm,
+                                                QUIC_STREAM *qs,
+                                                uint64_t aec);
+
+/*
+ * Marks the receiving part of a stream for STOP_SENDING.
+ *
+ * Returns  1 if the receiving part of a stream was not already marked for
+ * STOP_SENDING.
+ * Returns 0 otherwise, which need not be considered an error.
  */
-void ossl_quic_stream_map_reset_stream_send_part(QUIC_STREAM_MAP *qsm,
-                                                 QUIC_STREAM *qs,
-                                                 uint64_t aec);
+int ossl_quic_stream_map_stop_sending_recv_part(QUIC_STREAM_MAP *qsm,
+                                                QUIC_STREAM *qs,
+                                                uint64_t aec);
 
 /*
  * Adds a stream to the accept queue.
index da2436b3c62285c84d9130b0fcd55cbc2bf99a1f..ec0364ee686dd2493f69c6028ad81f5dc4e0eae2 100644 (file)
@@ -2380,9 +2380,11 @@ void ossl_quic_channel_set_incoming_stream_auto_reject(QUIC_CHANNEL *ch,
 
 void ossl_quic_channel_reject_stream(QUIC_CHANNEL *ch, QUIC_STREAM *qs)
 {
-    ossl_quic_stream_stop_sending(qs, ch->incoming_stream_auto_reject_aec);
-    ossl_quic_stream_reset(qs, ch->incoming_stream_auto_reject_aec);
+    ossl_quic_stream_map_stop_sending_recv_part(&ch->qsm, qs,
+                                                ch->incoming_stream_auto_reject_aec);
 
+    ossl_quic_stream_map_reset_stream_send_part(&ch->qsm, qs,
+                                                ch->incoming_stream_auto_reject_aec);
     qs->deleted = 1;
 
     ossl_quic_stream_map_update_state(&ch->qsm, qs);
index 2f58b2a51a99c5fbcd80a3eba4a463eb80f74118..cbc947398f7c8c61dc0c6e859417b27196568e7f 100644 (file)
 #include "internal/quic_stream_map.h"
 #include "internal/nelem.h"
 
-/* QUIC Stream
- * ===========
- */
-
-int ossl_quic_stream_stop_sending(QUIC_STREAM *s, uint64_t aec)
-{
-    if (s->stop_sending)
-        return 0;
-
-    s->stop_sending_aec     = aec;
-    s->stop_sending         = 1;
-    s->want_stop_sending    = 1;
-    return 1;
-}
-
-int ossl_quic_stream_reset(QUIC_STREAM *s, uint64_t aec)
-{
-    if (s->reset_stream)
-        return 0;
-
-    s->reset_stream_aec     = aec;
-    s->reset_stream         = 1;
-    s->want_reset_stream    = 1;
-    return 1;
-}
-
 /*
  * QUIC Stream Map
  * ===============
@@ -284,18 +258,34 @@ void ossl_quic_stream_map_update_state(QUIC_STREAM_MAP *qsm, QUIC_STREAM *s)
         stream_map_mark_inactive(qsm, s);
 }
 
-void ossl_quic_stream_map_reset_stream_send_part(QUIC_STREAM_MAP *qsm,
-                                                 QUIC_STREAM *qs,
-                                                 uint64_t aec)
+int ossl_quic_stream_map_reset_stream_send_part(QUIC_STREAM_MAP *qsm,
+                                                QUIC_STREAM *qs,
+                                                uint64_t aec)
 {
     if (qs->reset_stream)
-        return;
+        return 0;
 
     qs->reset_stream        = 1;
     qs->reset_stream_aec    = aec;
     qs->want_reset_stream   = 1;
 
     ossl_quic_stream_map_update_state(qsm, qs);
+    return 1;
+}
+
+int ossl_quic_stream_map_stop_sending_recv_part(QUIC_STREAM_MAP *qsm,
+                                                QUIC_STREAM *qs,
+                                                uint64_t aec)
+{
+    if (qs->stop_sending)
+        return 0;
+
+    qs->stop_sending        = 1;
+    qs->stop_sending_aec    = aec;
+    qs->want_stop_sending   = 1;
+
+    ossl_quic_stream_map_update_state(qsm, qs);
+    return 1;
 }
 
 QUIC_STREAM *ossl_quic_stream_map_peek_accept_queue(QUIC_STREAM_MAP *qsm)
index dca8c71398213ebac756b54cdb24203ce3e07a6b..1d71721a6cd75d0b807ab37cf84098fc513d8d27 100644 (file)
@@ -1470,7 +1470,8 @@ static int run_script(const struct script_op *script)
                                                                  op->arg0)))
                     goto err;
 
-                if (!TEST_true(ossl_quic_stream_stop_sending(s, op->arg1)))
+                if (!TEST_true(ossl_quic_stream_map_stop_sending_recv_part(h.args.qsm,
+                                                                           s, op->arg1)))
                     goto err;
 
                 ossl_quic_stream_map_update_state(h.args.qsm, s);
@@ -1487,7 +1488,8 @@ static int run_script(const struct script_op *script)
                                                                  op->arg0)))
                     goto err;
 
-                if (!TEST_true(ossl_quic_stream_reset(s, op->arg1)))
+                if (!TEST_true(ossl_quic_stream_map_reset_stream_send_part(h.args.qsm,
+                                                                           s, op->arg1)))
                     goto err;
 
                 ossl_quic_stream_map_update_state(h.args.qsm, s);