MINOR: mux-quic: complete functions to detect stream type

Improve the functions used to detect the stream characteristics :
uni/bidirectional and local/remote initiated.

Most notably, these functions are now designed to work transparently for
a MUX in the frontend or backend side. For this, we use the connection
to determine the current MUX side. This will be useful if QUIC is
implemented on the server side.
This commit is contained in:
Amaury Denoyelle 2022-02-07 11:44:17 +01:00
parent 749cb647b1
commit 0dc40f06d1
2 changed files with 21 additions and 6 deletions

View File

@ -7,6 +7,7 @@
#endif
#include <haproxy/api.h>
#include <haproxy/connection.h>
#include <haproxy/mux_quic-t.h>
#include <haproxy/xprt_quic-t.h>
@ -42,12 +43,26 @@ static inline enum qcs_type qcs_id_type(uint64_t id)
return id & QCS_ID_TYPE_MASK;
}
/* Return 1 if the stream with <id> as ID attached to <qcc> connection
* has been locally initiated, 0 if not.
*/
static inline int qc_local_stream_id(struct qcc *qcc, uint64_t id)
/* Return true if stream has been opened locally. */
static inline int quic_stream_is_local(struct qcc *qcc, uint64_t id)
{
return id & QCS_ID_SRV_INTIATOR_BIT;
return conn_is_back(qcc->conn) == !(id & QCS_ID_SRV_INTIATOR_BIT);
}
/* Return true if stream is opened by peer. */
static inline int quic_stream_is_remote(struct qcc *qcc, uint64_t id)
{
return !quic_stream_is_local(qcc, id);
}
static inline int quic_stream_is_uni(uint64_t id)
{
return id & QCS_ID_DIR_BIT;
}
static inline int quic_stream_is_bidi(uint64_t id)
{
return !quic_stream_is_uni(id);
}
struct eb64_node *qcc_get_qcs(struct qcc *qcc, uint64_t id);

View File

@ -113,7 +113,7 @@ struct eb64_node *qcc_get_qcs(struct qcc *qcc, uint64_t id)
strm_type = id & QCS_ID_TYPE_MASK;
sub_id = id >> QCS_ID_TYPE_SHIFT;
strm_node = NULL;
if (qc_local_stream_id(qcc, id)) {
if (quic_stream_is_local(qcc, id)) {
/* Local streams: this stream must be already opened. */
strm_node = eb64_lookup(&qcc->streams_by_id, id);
if (!strm_node) {