CLEANUP: quic: improve naming for rxbuf/datagrams handling
QUIC datagrams are read from a random thread. They are then redispatch to the connection thread according to the first packet DCID. These operations are implemented through a special buffer designed to avoid locking. Refactor this code with the following changes : * <rxbuf> type is renamed <quic_receiver_buf>. Its list element is also renamed to highligh its attach point to a receiver. * <quic_dgram> and <quic_receiver_buf> definition are moved to quic_sock-t.h. This helps to reduce the size of quic_conn-t.h. * <quic_dgram> list elements are renamed to highlight their attach point into a <quic_receiver_buf> and a <quic_dghdlr>. This should be backported up to 2.6.
This commit is contained in:
parent
8c4d062d25
commit
1cba8d60f3
@ -377,8 +377,9 @@ struct quic_dgram {
|
|||||||
struct sockaddr_storage saddr;
|
struct sockaddr_storage saddr;
|
||||||
struct sockaddr_storage daddr;
|
struct sockaddr_storage daddr;
|
||||||
struct quic_conn *qc;
|
struct quic_conn *qc;
|
||||||
struct list list;
|
|
||||||
struct mt_list mt_list;
|
struct list recv_list; /* elemt to quic_receiver_buf <dgram_list>. */
|
||||||
|
struct mt_list handler_list; /* elem to quic_dghdlr <dgrams>. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The QUIC packet numbers are 62-bits integers */
|
/* The QUIC packet numbers are 62-bits integers */
|
||||||
@ -578,13 +579,6 @@ struct qring {
|
|||||||
struct mt_list mt_list;
|
struct mt_list mt_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* QUIC RX buffer */
|
|
||||||
struct rxbuf {
|
|
||||||
struct buffer buf;
|
|
||||||
struct list dgrams;
|
|
||||||
struct mt_list mt_list;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Status of the connection/mux layer. This defines how to handle app data.
|
/* Status of the connection/mux layer. This defines how to handle app data.
|
||||||
*
|
*
|
||||||
* During a standard quic_conn lifetime it transitions like this :
|
* During a standard quic_conn lifetime it transitions like this :
|
||||||
|
@ -8,5 +8,14 @@ struct quic_accept_queue {
|
|||||||
struct tasklet *tasklet; /* task responsible to call listener_accept */
|
struct tasklet *tasklet; /* task responsible to call listener_accept */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Buffer used to receive QUIC datagrams on random thread and redispatch them
|
||||||
|
* to the connection thread.
|
||||||
|
*/
|
||||||
|
struct quic_receiver_buf {
|
||||||
|
struct buffer buf; /* storage for datagrams received. */
|
||||||
|
struct list dgram_list; /* datagrams received with this rxbuf. */
|
||||||
|
struct mt_list rxbuf_el; /* list element into receiver.rxbuf_list. */
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* USE_QUIC */
|
#endif /* USE_QUIC */
|
||||||
#endif /* _HAPROXY_QUIC_SOCK_T_H */
|
#endif /* _HAPROXY_QUIC_SOCK_T_H */
|
||||||
|
@ -65,7 +65,7 @@ struct receiver {
|
|||||||
struct rx_settings *settings; /* points to the settings used by this receiver */
|
struct rx_settings *settings; /* points to the settings used by this receiver */
|
||||||
struct list proto_list; /* list in the protocol header */
|
struct list proto_list; /* list in the protocol header */
|
||||||
#ifdef USE_QUIC
|
#ifdef USE_QUIC
|
||||||
struct mt_list rxbuf_list; /* The same as ->rxbufs but arranged in a list */
|
struct mt_list rxbuf_list; /* list of buffers to receive and dispatch QUIC datagrams. */
|
||||||
#endif
|
#endif
|
||||||
/* warning: this struct is huge, keep it at the bottom */
|
/* warning: this struct is huge, keep it at the bottom */
|
||||||
struct sockaddr_storage addr; /* the address the socket is bound to */
|
struct sockaddr_storage addr; /* the address the socket is bound to */
|
||||||
|
@ -538,14 +538,14 @@ static void quic_add_listener(struct protocol *proto, struct listener *listener)
|
|||||||
static int quic_alloc_rxbufs_listener(struct listener *l)
|
static int quic_alloc_rxbufs_listener(struct listener *l)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct rxbuf *rxbuf;
|
struct quic_receiver_buf *tmp;
|
||||||
|
|
||||||
MT_LIST_INIT(&l->rx.rxbuf_list);
|
MT_LIST_INIT(&l->rx.rxbuf_list);
|
||||||
for (i = 0; i < global.nbthread; i++) {
|
for (i = 0; i < global.nbthread; i++) {
|
||||||
|
struct quic_receiver_buf *rxbuf;
|
||||||
char *buf;
|
char *buf;
|
||||||
struct rxbuf *rxbuf;
|
|
||||||
|
|
||||||
rxbuf = calloc(1, sizeof *rxbuf);
|
rxbuf = calloc(1, sizeof(*rxbuf));
|
||||||
if (!rxbuf)
|
if (!rxbuf)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
@ -556,16 +556,16 @@ static int quic_alloc_rxbufs_listener(struct listener *l)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rxbuf->buf = b_make(buf, QUIC_RX_BUFSZ, 0, 0);
|
rxbuf->buf = b_make(buf, QUIC_RX_BUFSZ, 0, 0);
|
||||||
LIST_INIT(&rxbuf->dgrams);
|
LIST_INIT(&rxbuf->dgram_list);
|
||||||
MT_LIST_APPEND(&l->rx.rxbuf_list, &rxbuf->mt_list);
|
MT_LIST_APPEND(&l->rx.rxbuf_list, &rxbuf->rxbuf_el);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
while ((rxbuf = MT_LIST_POP(&l->rx.rxbuf_list, typeof(rxbuf), mt_list))) {
|
while ((tmp = MT_LIST_POP(&l->rx.rxbuf_list, typeof(tmp), rxbuf_el))) {
|
||||||
pool_free(pool_head_quic_rxbuf, rxbuf->buf.area);
|
pool_free(pool_head_quic_rxbuf, tmp->buf.area);
|
||||||
free(rxbuf);
|
free(tmp);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -7160,7 +7160,7 @@ struct task *quic_lstnr_dghdlr(struct task *t, void *ctx, unsigned int state)
|
|||||||
|
|
||||||
TRACE_ENTER(QUIC_EV_CONN_LPKT);
|
TRACE_ENTER(QUIC_EV_CONN_LPKT);
|
||||||
|
|
||||||
while ((dgram = MT_LIST_POP(&dghdlr->dgrams, typeof(dgram), mt_list))) {
|
while ((dgram = MT_LIST_POP(&dghdlr->dgrams, typeof(dgram), handler_list))) {
|
||||||
pos = dgram->buf;
|
pos = dgram->buf;
|
||||||
end = pos + dgram->len;
|
end = pos + dgram->len;
|
||||||
do {
|
do {
|
||||||
|
@ -268,8 +268,10 @@ static int quic_lstnr_dgram_dispatch(unsigned char *buf, size_t len, void *owner
|
|||||||
dgram->saddr = *saddr;
|
dgram->saddr = *saddr;
|
||||||
dgram->daddr = *daddr;
|
dgram->daddr = *daddr;
|
||||||
dgram->qc = NULL;
|
dgram->qc = NULL;
|
||||||
LIST_APPEND(dgrams, &dgram->list);
|
|
||||||
MT_LIST_APPEND(&quic_dghdlrs[cid_tid].dgrams, &dgram->mt_list);
|
/* Attached datagram to its quic_receiver_buf and quic_dghdlrs. */
|
||||||
|
LIST_APPEND(dgrams, &dgram->recv_list);
|
||||||
|
MT_LIST_APPEND(&quic_dghdlrs[cid_tid].dgrams, &dgram->handler_list);
|
||||||
|
|
||||||
/* typically quic_lstnr_dghdlr() */
|
/* typically quic_lstnr_dghdlr() */
|
||||||
tasklet_wakeup(quic_dghdlrs[cid_tid].task);
|
tasklet_wakeup(quic_dghdlrs[cid_tid].task);
|
||||||
@ -392,7 +394,7 @@ static ssize_t quic_recv(int fd, void *out, size_t len,
|
|||||||
void quic_sock_fd_iocb(int fd)
|
void quic_sock_fd_iocb(int fd)
|
||||||
{
|
{
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
struct rxbuf *rxbuf;
|
struct quic_receiver_buf *rxbuf;
|
||||||
struct buffer *buf;
|
struct buffer *buf;
|
||||||
struct listener *l = objt_listener(fdtab[fd].owner);
|
struct listener *l = objt_listener(fdtab[fd].owner);
|
||||||
struct quic_transport_params *params;
|
struct quic_transport_params *params;
|
||||||
@ -412,7 +414,7 @@ void quic_sock_fd_iocb(int fd)
|
|||||||
if (!(fdtab[fd].state & FD_POLL_IN) || !fd_recv_ready(fd))
|
if (!(fdtab[fd].state & FD_POLL_IN) || !fd_recv_ready(fd))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rxbuf = MT_LIST_POP(&l->rx.rxbuf_list, typeof(rxbuf), mt_list);
|
rxbuf = MT_LIST_POP(&l->rx.rxbuf_list, typeof(rxbuf), rxbuf_el);
|
||||||
if (!rxbuf)
|
if (!rxbuf)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -460,7 +462,7 @@ void quic_sock_fd_iocb(int fd)
|
|||||||
/* Append this datagram only to the RX buffer list. It will
|
/* Append this datagram only to the RX buffer list. It will
|
||||||
* not be treated by any datagram handler.
|
* not be treated by any datagram handler.
|
||||||
*/
|
*/
|
||||||
LIST_APPEND(&rxbuf->dgrams, &dgram->list);
|
LIST_APPEND(&rxbuf->dgram_list, &dgram->recv_list);
|
||||||
|
|
||||||
/* Consume the remaining space */
|
/* Consume the remaining space */
|
||||||
b_add(buf, cspace);
|
b_add(buf, cspace);
|
||||||
@ -478,7 +480,7 @@ void quic_sock_fd_iocb(int fd)
|
|||||||
|
|
||||||
b_add(buf, ret);
|
b_add(buf, ret);
|
||||||
if (!quic_lstnr_dgram_dispatch(dgram_buf, ret, l, &saddr, &daddr,
|
if (!quic_lstnr_dgram_dispatch(dgram_buf, ret, l, &saddr, &daddr,
|
||||||
new_dgram, &rxbuf->dgrams)) {
|
new_dgram, &rxbuf->dgram_list)) {
|
||||||
/* If wrong, consume this datagram */
|
/* If wrong, consume this datagram */
|
||||||
b_del(buf, ret);
|
b_del(buf, ret);
|
||||||
}
|
}
|
||||||
@ -487,7 +489,7 @@ void quic_sock_fd_iocb(int fd)
|
|||||||
goto start;
|
goto start;
|
||||||
out:
|
out:
|
||||||
pool_free(pool_head_quic_dgram, new_dgram);
|
pool_free(pool_head_quic_dgram, new_dgram);
|
||||||
MT_LIST_APPEND(&l->rx.rxbuf_list, &rxbuf->mt_list);
|
MT_LIST_APPEND(&l->rx.rxbuf_list, &rxbuf->rxbuf_el);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send a datagram stored into <buf> buffer with <sz> as size.
|
/* Send a datagram stored into <buf> buffer with <sz> as size.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user