]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
QUIC CHANNEL: Introduce concept of (non-)addressed mode
authorHugo Landau <hlandau@openssl.org>
Wed, 9 Aug 2023 16:46:32 +0000 (17:46 +0100)
committerHugo Landau <hlandau@openssl.org>
Fri, 1 Sep 2023 09:45:34 +0000 (10:45 +0100)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21715)

include/internal/quic_txp.h
ssl/quic/quic_channel.c
ssl/quic/quic_channel_local.h
ssl/quic/quic_txp.c

index 09d552ef04362a175340598034f47b9f59cb888b..b2dbb85f9249851150db6076a1a9ab66e1bd6252 100644 (file)
@@ -128,7 +128,10 @@ int ossl_quic_tx_packetiser_set_cur_dcid(OSSL_QUIC_TX_PACKETISER *txp,
 int ossl_quic_tx_packetiser_set_cur_scid(OSSL_QUIC_TX_PACKETISER *txp,
                                          const QUIC_CONN_ID *scid);
 
-/* Change the destination L4 address the TXP uses to send datagrams. */
+/*
+ * Change the destination L4 address the TXP uses to send datagrams. Specify
+ * NULL (or AF_UNSPEC) to disable use of addressed mode.
+ */
 int ossl_quic_tx_packetiser_set_peer(OSSL_QUIC_TX_PACKETISER *txp,
                                      const BIO_ADDR *peer);
 
index 275d5f576beb3c9731ccd58c8a9d8f6498d65c1e..efbe1c16604a879eede8f1f95cdd5c5efd3507bf 100644 (file)
@@ -584,13 +584,26 @@ int ossl_quic_channel_set_mutator(QUIC_CHANNEL *ch,
 
 int ossl_quic_channel_get_peer_addr(QUIC_CHANNEL *ch, BIO_ADDR *peer_addr)
 {
+    if (!ch->addressed_mode)
+        return 0;
+
     *peer_addr = ch->cur_peer_addr;
     return 1;
 }
 
 int ossl_quic_channel_set_peer_addr(QUIC_CHANNEL *ch, const BIO_ADDR *peer_addr)
 {
-    ch->cur_peer_addr = *peer_addr;
+    if (ch->state != QUIC_CHANNEL_STATE_IDLE)
+        return 0;
+
+    if (peer_addr == NULL || BIO_ADDR_family(peer_addr) == AF_UNSPEC) {
+        BIO_ADDR_clear(&ch->cur_peer_addr);
+        ch->addressed_mode = 0;
+        return 1;
+    }
+
+    ch->cur_peer_addr   = *peer_addr;
+    ch->addressed_mode  = 1;
     return 1;
 }
 
index a60a539f9bbf38150ce0088fa752fd45d557b20e..8b2edc647a040187216962071ea6ff2bc6e30ac7 100644 (file)
@@ -456,6 +456,9 @@ struct quic_channel_st {
     /* Inhibit tick for testing purposes? */
     unsigned int                    inhibit_tick                        : 1;
 
+    /* Are we using addressed mode? */
+    unsigned int                    addressed_mode                      : 1;
+
     /* Saved error stack in case permanent error was encountered */
     ERR_STATE                       *err_state;
 };
index 51802ba7b6159df0c080e0672caabf2f09a3704d..97cba812e767c4c9e9456184394e829a92e5ebad 100644 (file)
@@ -555,8 +555,8 @@ int ossl_quic_tx_packetiser_set_peer(OSSL_QUIC_TX_PACKETISER *txp,
                                      const BIO_ADDR *peer)
 {
     if (peer == NULL) {
-        ERR_raise(ERR_LIB_SSL, ERR_R_PASSED_NULL_PARAMETER);
-        return 0;
+        BIO_ADDR_clear(&txp->args.peer);
+        return 1;
     }
 
     txp->args.peer = *peer;