mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
MINOR: quic: use global datagram headlen definition
Each emitted QUIC datagram is prefixed by an out-of-band header. This header specify the datagram length and the pointer to the first QUIC packet instance. This header length is defined via QUIC_DGRAM_HEADLEN. Replace every occurences of manually calculated header length with globally defined QUIC_DGRAM_HEADLEN. This should ease code maintenance and simplify GSO implementation.
This commit is contained in:
parent
88681681cc
commit
ba00431625
@ -153,8 +153,7 @@ struct buffer *qc_get_txb(struct quic_conn *qc)
|
|||||||
static void qc_txb_store(struct buffer *buf, uint16_t length,
|
static void qc_txb_store(struct buffer *buf, uint16_t length,
|
||||||
struct quic_tx_packet *first_pkt)
|
struct quic_tx_packet *first_pkt)
|
||||||
{
|
{
|
||||||
const size_t hdlen = sizeof(uint16_t) + sizeof(void *);
|
BUG_ON_HOT(b_contig_space(buf) < QUIC_DGRAM_HEADLEN); /* this must not happen */
|
||||||
BUG_ON_HOT(b_contig_space(buf) < hdlen); /* this must not happen */
|
|
||||||
|
|
||||||
/* If first packet is INITIAL, ensure datagram is sufficiently padded. */
|
/* If first packet is INITIAL, ensure datagram is sufficiently padded. */
|
||||||
BUG_ON(first_pkt->type == QUIC_PACKET_TYPE_INITIAL &&
|
BUG_ON(first_pkt->type == QUIC_PACKET_TYPE_INITIAL &&
|
||||||
@ -163,7 +162,7 @@ static void qc_txb_store(struct buffer *buf, uint16_t length,
|
|||||||
|
|
||||||
write_u16(b_tail(buf), length);
|
write_u16(b_tail(buf), length);
|
||||||
write_ptr(b_tail(buf) + sizeof(length), first_pkt);
|
write_ptr(b_tail(buf) + sizeof(length), first_pkt);
|
||||||
b_add(buf, hdlen + length);
|
b_add(buf, QUIC_DGRAM_HEADLEN + length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reports if data are ready to be sent for <qel> encryption level on <qc>
|
/* Reports if data are ready to be sent for <qel> encryption level on <qc>
|
||||||
@ -254,12 +253,11 @@ static void qc_purge_tx_buf(struct quic_conn *qc, struct buffer *buf)
|
|||||||
while (b_contig_data(buf, 0)) {
|
while (b_contig_data(buf, 0)) {
|
||||||
uint16_t dglen;
|
uint16_t dglen;
|
||||||
struct quic_tx_packet *pkt;
|
struct quic_tx_packet *pkt;
|
||||||
size_t headlen = sizeof dglen + sizeof pkt;
|
|
||||||
|
|
||||||
dglen = read_u16(b_head(buf));
|
dglen = read_u16(b_head(buf));
|
||||||
pkt = read_ptr(b_head(buf) + sizeof dglen);
|
pkt = read_ptr(b_head(buf) + sizeof(dglen));
|
||||||
qc_free_tx_coalesced_pkts(qc, pkt);
|
qc_free_tx_coalesced_pkts(qc, pkt);
|
||||||
b_del(buf, dglen + headlen);
|
b_del(buf, dglen + QUIC_DGRAM_HEADLEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
BUG_ON(b_data(buf));
|
BUG_ON(b_data(buf));
|
||||||
@ -289,16 +287,14 @@ static int qc_send_ppkts(struct buffer *buf, struct ssl_sock_ctx *ctx)
|
|||||||
struct buffer tmpbuf = { };
|
struct buffer tmpbuf = { };
|
||||||
struct quic_tx_packet *first_pkt, *pkt, *next_pkt;
|
struct quic_tx_packet *first_pkt, *pkt, *next_pkt;
|
||||||
uint16_t dglen;
|
uint16_t dglen;
|
||||||
size_t headlen = sizeof dglen + sizeof first_pkt;
|
|
||||||
unsigned int time_sent;
|
unsigned int time_sent;
|
||||||
|
|
||||||
pos = (unsigned char *)b_head(buf);
|
pos = (unsigned char *)b_head(buf);
|
||||||
dglen = read_u16(pos);
|
dglen = read_u16(pos);
|
||||||
BUG_ON_HOT(!dglen); /* this should not happen */
|
BUG_ON_HOT(!dglen); /* this should not happen */
|
||||||
|
|
||||||
pos += sizeof dglen;
|
first_pkt = read_ptr(pos + sizeof(dglen));
|
||||||
first_pkt = read_ptr(pos);
|
pos += QUIC_DGRAM_HEADLEN;
|
||||||
pos += sizeof first_pkt;
|
|
||||||
tmpbuf.area = (char *)pos;
|
tmpbuf.area = (char *)pos;
|
||||||
tmpbuf.size = tmpbuf.data = dglen;
|
tmpbuf.size = tmpbuf.data = dglen;
|
||||||
|
|
||||||
@ -319,7 +315,7 @@ static int qc_send_ppkts(struct buffer *buf, struct ssl_sock_ctx *ctx)
|
|||||||
TRACE_ERROR("sendto fatal error", QUIC_EV_CONN_SPPKTS, qc, first_pkt);
|
TRACE_ERROR("sendto fatal error", QUIC_EV_CONN_SPPKTS, qc, first_pkt);
|
||||||
qc_kill_conn(qc);
|
qc_kill_conn(qc);
|
||||||
qc_free_tx_coalesced_pkts(qc, first_pkt);
|
qc_free_tx_coalesced_pkts(qc, first_pkt);
|
||||||
b_del(buf, dglen + headlen);
|
b_del(buf, dglen + QUIC_DGRAM_HEADLEN);
|
||||||
qc_purge_tx_buf(qc, buf);
|
qc_purge_tx_buf(qc, buf);
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
@ -336,7 +332,7 @@ static int qc_send_ppkts(struct buffer *buf, struct ssl_sock_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
b_del(buf, dglen + headlen);
|
b_del(buf, dglen + QUIC_DGRAM_HEADLEN);
|
||||||
qc->bytes.tx += tmpbuf.data;
|
qc->bytes.tx += tmpbuf.data;
|
||||||
time_sent = now_ms;
|
time_sent = now_ms;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user