mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-29 08:02:08 +00:00
MINOR: quic: Move quic_lstnr_dgram_dispatch() out of xprt_quic.c
Remove this function from xprt_quic.c which for now implements only "by thread attached to a connection" code.
This commit is contained in:
parent
ad20a56971
commit
6492e66e41
@ -1258,9 +1258,8 @@ void chunk_frm_appendf(struct buffer *buf, const struct quic_frame *frm);
|
||||
void quic_set_tls_alert(struct quic_conn *qc, int alert);
|
||||
int quic_set_app_ops(struct quic_conn *qc, const unsigned char *alpn, size_t alpn_len);
|
||||
struct task *quic_lstnr_dghdlr(struct task *t, void *ctx, unsigned int state);
|
||||
int quic_lstnr_dgram_dispatch(unsigned char *buf, size_t len, void *owner,
|
||||
struct sockaddr_storage *saddr,
|
||||
struct quic_dgram *new_dgram, struct list *dgrams);
|
||||
int quic_get_dgram_dcid(unsigned char *buf, const unsigned char *end,
|
||||
unsigned char **dcid, size_t *dcid_len);
|
||||
int qc_send_app_pkts(struct quic_conn *qc, int old_data, struct list *frms);
|
||||
|
||||
void qc_notify_close(struct quic_conn *qc);
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <haproxy/connection.h>
|
||||
#include <haproxy/listener.h>
|
||||
#include <haproxy/proto_quic.h>
|
||||
#include <haproxy/quic_sock.h>
|
||||
#include <haproxy/session.h>
|
||||
#include <haproxy/tools.h>
|
||||
@ -217,6 +218,47 @@ struct connection *quic_sock_accept_conn(struct listener *l, int *status)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Retrieve the DCID from the datagram found in <buf> and deliver it to the
|
||||
* correct datagram handler.
|
||||
* Return 1 if a correct datagram could be found, 0 if not.
|
||||
*/
|
||||
static int quic_lstnr_dgram_dispatch(unsigned char *buf, size_t len, void *owner,
|
||||
struct sockaddr_storage *saddr,
|
||||
struct quic_dgram *new_dgram, struct list *dgrams)
|
||||
{
|
||||
struct quic_dgram *dgram;
|
||||
unsigned char *dcid;
|
||||
size_t dcid_len;
|
||||
int cid_tid;
|
||||
|
||||
if (!len || !quic_get_dgram_dcid(buf, buf + len, &dcid, &dcid_len))
|
||||
goto err;
|
||||
|
||||
dgram = new_dgram ? new_dgram : pool_alloc(pool_head_quic_dgram);
|
||||
if (!dgram)
|
||||
goto err;
|
||||
|
||||
cid_tid = quic_get_cid_tid(dcid);
|
||||
|
||||
/* All the members must be initialized! */
|
||||
dgram->owner = owner;
|
||||
dgram->buf = buf;
|
||||
dgram->len = len;
|
||||
dgram->dcid = dcid;
|
||||
dgram->dcid_len = dcid_len;
|
||||
dgram->saddr = *saddr;
|
||||
dgram->qc = NULL;
|
||||
LIST_APPEND(dgrams, &dgram->list);
|
||||
MT_LIST_APPEND(&quic_dghdlrs[cid_tid].dgrams, &dgram->mt_list);
|
||||
|
||||
tasklet_wakeup(quic_dghdlrs[cid_tid].task);
|
||||
|
||||
return 1;
|
||||
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Function called on a read event from a listening socket. It tries
|
||||
* to handle as many connections as possible.
|
||||
*/
|
||||
|
@ -6411,8 +6411,8 @@ struct task *quic_lstnr_dghdlr(struct task *t, void *ctx, unsigned int state)
|
||||
/* Retreive the DCID from a QUIC datagram or packet with <buf> as first octet.
|
||||
* Returns 1 if succeeded, 0 if not.
|
||||
*/
|
||||
static int quic_get_dgram_dcid(unsigned char *buf, const unsigned char *end,
|
||||
unsigned char **dcid, size_t *dcid_len)
|
||||
int quic_get_dgram_dcid(unsigned char *buf, const unsigned char *end,
|
||||
unsigned char **dcid, size_t *dcid_len)
|
||||
{
|
||||
int long_header;
|
||||
size_t minlen, skip;
|
||||
@ -6441,47 +6441,6 @@ static int quic_get_dgram_dcid(unsigned char *buf, const unsigned char *end,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Retrieve the DCID from the datagram found in <buf> and deliver it to the
|
||||
* correct datagram handler.
|
||||
* Return 1 if a correct datagram could be found, 0 if not.
|
||||
*/
|
||||
int quic_lstnr_dgram_dispatch(unsigned char *buf, size_t len, void *owner,
|
||||
struct sockaddr_storage *saddr,
|
||||
struct quic_dgram *new_dgram, struct list *dgrams)
|
||||
{
|
||||
struct quic_dgram *dgram;
|
||||
unsigned char *dcid;
|
||||
size_t dcid_len;
|
||||
int cid_tid;
|
||||
|
||||
if (!len || !quic_get_dgram_dcid(buf, buf + len, &dcid, &dcid_len))
|
||||
goto err;
|
||||
|
||||
dgram = new_dgram ? new_dgram : pool_alloc(pool_head_quic_dgram);
|
||||
if (!dgram)
|
||||
goto err;
|
||||
|
||||
cid_tid = quic_get_cid_tid(dcid);
|
||||
|
||||
/* All the members must be initialized! */
|
||||
dgram->owner = owner;
|
||||
dgram->buf = buf;
|
||||
dgram->len = len;
|
||||
dgram->dcid = dcid;
|
||||
dgram->dcid_len = dcid_len;
|
||||
dgram->saddr = *saddr;
|
||||
dgram->qc = NULL;
|
||||
LIST_APPEND(dgrams, &dgram->list);
|
||||
MT_LIST_APPEND(&quic_dghdlrs[cid_tid].dgrams, &dgram->mt_list);
|
||||
|
||||
tasklet_wakeup(quic_dghdlrs[cid_tid].task);
|
||||
|
||||
return 1;
|
||||
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Notify the MUX layer if alive about an imminent close of <qc>. */
|
||||
void qc_notify_close(struct quic_conn *qc)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user