From: Frédéric Lécaille Date: Tue, 25 Jan 2022 21:33:11 +0000 (+0100) Subject: MINOR: quic: Get rid of a struct buffer in quic_lstnr_dgram_read() X-Git-Tag: v2.6-dev1~61 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3d55462654c4ef426ad1081c126101887fbd369f;p=thirdparty%2Fhaproxy.git MINOR: quic: Get rid of a struct buffer in quic_lstnr_dgram_read() This is to be sure xprt functions do not manipulate the buffer struct passed as parameter to quic_lstnr_dgram_read() from low level datagram I/O callback in quic_sock.c (quic_sock_fd_iocb()). --- diff --git a/include/haproxy/xprt_quic.h b/include/haproxy/xprt_quic.h index ab52808a8c..a24df7480e 100644 --- a/include/haproxy/xprt_quic.h +++ b/include/haproxy/xprt_quic.h @@ -1184,7 +1184,7 @@ 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); -ssize_t quic_lstnr_dgram_read(struct buffer *buf, size_t len, void *owner, +ssize_t quic_lstnr_dgram_read(unsigned char *buf, size_t len, void *owner, struct sockaddr_storage *saddr); #endif /* USE_QUIC */ diff --git a/src/quic_sock.c b/src/quic_sock.c index ee6a2fad7d..ef94acb159 100644 --- a/src/quic_sock.c +++ b/src/quic_sock.c @@ -212,7 +212,7 @@ void quic_sock_fd_iocb(int fd) } while (0); b_add(buf, ret); - quic_lstnr_dgram_read(buf, ret, l, &saddr); + quic_lstnr_dgram_read((unsigned char *)b_head(buf), ret, l, &saddr); b_del(buf, ret); out: MT_LIST_APPEND(&l->rx.rxbuf_list, &rxbuf->mt_list); diff --git a/src/xprt_quic.c b/src/xprt_quic.c index 8a9b4f2937..e08a1a47b3 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -5527,7 +5527,7 @@ static void __quic_conn_deinit(void) * as owner calling function. * Return the number of bytes read if succeeded, -1 if not. */ -static ssize_t quic_dgram_read(struct buffer *buf, size_t len, void *owner, +static ssize_t quic_dgram_read(unsigned char *buf, size_t len, void *owner, struct sockaddr_storage *saddr, qpkt_read_func *func) { unsigned char *pos; @@ -5538,7 +5538,7 @@ static ssize_t quic_dgram_read(struct buffer *buf, size_t len, void *owner, .owner = owner, }; - pos = (unsigned char *)b_head(buf); + pos = buf; end = pos + len; do { int ret; @@ -5563,13 +5563,13 @@ static ssize_t quic_dgram_read(struct buffer *buf, size_t len, void *owner, if (dgram_ctx.qc) dgram_ctx.qc->rx.bytes += len; - return pos - (unsigned char *)b_head(buf); + return pos - buf; err: return -1; } -ssize_t quic_lstnr_dgram_read(struct buffer *buf, size_t len, void *owner, +ssize_t quic_lstnr_dgram_read(unsigned char *buf, size_t len, void *owner, struct sockaddr_storage *saddr) { return quic_dgram_read(buf, len, owner, saddr, qc_lstnr_pkt_rcv);