Skip to content

Commit af36f54

Browse files
a-denoyellehaproxyFred
authored andcommitted
MINOR: quic: support pacing emission on quic_conn layer
1 parent 35843c9 commit af36f54

File tree

7 files changed

+45
-6
lines changed

7 files changed

+45
-6
lines changed

include/haproxy/quic_pacing-t.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
struct quic_pacer {
88
struct list frms;
99
const struct quic_cc_path *path;
10+
ullong next;
1011
};
1112

1213
#endif /* _HAPROXY_QUIC_PACING_T_H */

include/haproxy/quic_pacing.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ static inline void quic_pacing_init(struct quic_pacer *pacer,
1111
{
1212
LIST_INIT(&pacer->frms);
1313
pacer->path = path;
14+
pacer->next = 0;
1415
}
1516

1617
static inline void quic_pacing_reset(struct quic_pacer *pacer)
@@ -29,4 +30,13 @@ static inline struct list *quic_pacing_frms(struct quic_pacer *pacer)
2930
return &pacer->frms;
3031
}
3132

33+
static inline ullong quic_pacing_ns_pkt(const struct quic_pacer *pacer)
34+
{
35+
return pacer->path->loss.srtt * 1000000 / (pacer->path->cwnd / pacer->path->mtu + 1);
36+
}
37+
38+
int quic_pacing_expired(const struct quic_pacer *pacer);
39+
40+
void quic_pacing_sent_done(struct quic_pacer *pacer, int sent);
41+
3242
#endif /* _HAPROXY_QUIC_PACING_H */

include/haproxy/quic_tx-t.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ enum qc_build_pkt_err {
6666

6767
enum quic_tx_err {
6868
QUIC_TX_ERR_NONE,
69+
QUIC_TX_ERR_AGAIN,
6970
QUIC_TX_ERR_FATAL,
7071
};
7172

include/haproxy/quic_tx.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <haproxy/list-t.h>
2626
#include <haproxy/quic_conn-t.h>
2727
#include <haproxy/quic_tls-t.h>
28+
#include <haproxy/quic_pacing-t.h>
2829
#include <haproxy/quic_rx-t.h>
2930
#include <haproxy/quic_tx-t.h>
3031

@@ -33,7 +34,8 @@ void qc_txb_release(struct quic_conn *qc);
3334
int qc_purge_txbuf(struct quic_conn *qc, struct buffer *buf);
3435
struct buffer *qc_get_txb(struct quic_conn *qc);
3536

36-
enum quic_tx_err qc_send_mux(struct quic_conn *qc, struct list *frms);
37+
enum quic_tx_err qc_send_mux(struct quic_conn *qc, struct list *frms,
38+
struct quic_pacer *pacer);
3739

3840
void qel_register_send(struct list *send_list, struct quic_enc_level *qel,
3941
struct list *frms);

src/mux_quic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,7 @@ static int qcc_send_frames(struct qcc *qcc, struct list *frms)
20842084
return 1;
20852085
}
20862086

2087-
ret = qc_send_mux(qcc->conn->handle.qc, frms);
2087+
ret = qc_send_mux(qcc->conn->handle.qc, frms, NULL);
20882088
if (ret == QUIC_TX_ERR_FATAL) {
20892089
TRACE_DEVEL("error on sending", QMUX_EV_QCC_SEND, qcc->conn);
20902090
qcc_subscribe_send(qcc);

src/quic_pacing.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
11
#include <haproxy/quic_pacing.h>
2+
3+
#include <haproxy/quic_tx.h>
4+
5+
struct quic_conn;
6+
7+
int quic_pacing_expired(const struct quic_pacer *pacer)
8+
{
9+
return !pacer->next || pacer->next <= now_mono_time();
10+
}
11+
12+
void quic_pacing_sent_done(struct quic_pacer *pacer, int sent)
13+
{
14+
pacer->next = now_mono_time() + quic_pacing_ns_pkt(pacer) * sent;
15+
}

src/quic_tx.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <haproxy/trace.h>
2121
#include <haproxy/quic_cid.h>
2222
#include <haproxy/quic_conn.h>
23+
#include <haproxy/quic_pacing.h>
2324
#include <haproxy/quic_retransmit.h>
2425
#include <haproxy/quic_retry.h>
2526
#include <haproxy/quic_sock.h>
@@ -469,11 +470,12 @@ int qc_purge_txbuf(struct quic_conn *qc, struct buffer *buf)
469470
*
470471
* Returns the result from qc_send() function.
471472
*/
472-
enum quic_tx_err qc_send_mux(struct quic_conn *qc, struct list *frms)
473+
enum quic_tx_err qc_send_mux(struct quic_conn *qc, struct list *frms,
474+
struct quic_pacer *pacer)
473475
{
474476
struct list send_list = LIST_HEAD_INIT(send_list);
475477
enum quic_tx_err ret = QUIC_TX_ERR_NONE;
476-
int sent;
478+
int max_dgram = 0, sent;
477479

478480
TRACE_ENTER(QUIC_EV_CONN_TXPKT, qc);
479481
BUG_ON(qc->mux_state != QC_MUX_READY); /* Only MUX can uses this function so it must be ready. */
@@ -492,11 +494,20 @@ enum quic_tx_err qc_send_mux(struct quic_conn *qc, struct list *frms)
492494
qc_send(qc, 0, &send_list, 0);
493495
}
494496

497+
if (pacer)
498+
max_dgram = 1;
499+
495500
TRACE_STATE("preparing data (from MUX)", QUIC_EV_CONN_TXPKT, qc);
496501
qel_register_send(&send_list, qc->ael, frms);
497-
sent = qc_send(qc, 0, &send_list, 0);
498-
if (sent <= 0)
502+
sent = qc_send(qc, 0, &send_list, max_dgram);
503+
if (sent <= 0) {
499504
ret = QUIC_TX_ERR_FATAL;
505+
}
506+
else if (pacer) {
507+
if (max_dgram && max_dgram == sent && !LIST_ISEMPTY(frms))
508+
ret = QUIC_TX_ERR_AGAIN;
509+
quic_pacing_sent_done(pacer, sent);
510+
}
500511

501512
TRACE_LEAVE(QUIC_EV_CONN_TXPKT, qc);
502513
return ret;

0 commit comments

Comments
 (0)