From: Frédéric Lécaille Date: Tue, 28 Nov 2023 14:01:01 +0000 (+0100) Subject: REORG: quic: Move quic_increment_curr_handshake() to quic_sock X-Git-Tag: v2.9-dev12~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad61a5dde34cab4fb05da005b10e772f4ea8899f;p=thirdparty%2Fhaproxy.git REORG: quic: Move quic_increment_curr_handshake() to quic_sock Move quic_increment_curr_handshake() from quic_conn.c to quic_sock.h to be inlined. Also move all the inlined functions at the end of this header. --- diff --git a/include/haproxy/quic_sock.h b/include/haproxy/quic_sock.h index c1053f9c67..531cf62a03 100644 --- a/include/haproxy/quic_sock.h +++ b/include/haproxy/quic_sock.h @@ -48,6 +48,16 @@ int qc_snd_buf(struct quic_conn *qc, const struct buffer *buf, size_t count, int qc_rcv_buf(struct quic_conn *qc); void quic_conn_sock_fd_iocb(int fd); +void qc_alloc_fd(struct quic_conn *qc, const struct sockaddr_storage *src, + const struct sockaddr_storage *dst); +void qc_release_fd(struct quic_conn *qc, int reinit); +void qc_want_recv(struct quic_conn *qc); + +void quic_accept_push_qc(struct quic_conn *qc); + +int quic_listener_max_handshake(const struct listener *l); +int quic_listener_max_accept(const struct listener *l); + /* Set default value for socket as uninitialized. */ static inline void qc_init_fd(struct quic_conn *qc) { @@ -62,15 +72,29 @@ static inline char qc_test_fd(struct quic_conn *qc) return qc->fd >= 0; } -void qc_alloc_fd(struct quic_conn *qc, const struct sockaddr_storage *src, - const struct sockaddr_storage *dst); -void qc_release_fd(struct quic_conn *qc, int reinit); -void qc_want_recv(struct quic_conn *qc); +/* Try to increment handshake current counter. If listener limit is + * reached, incrementation is rejected and 0 is returned. + */ +static inline int quic_increment_curr_handshake(struct listener *l) +{ + unsigned int count, next; + const int max = quic_listener_max_handshake(l); -void quic_accept_push_qc(struct quic_conn *qc); + do { + count = l->rx.quic_curr_handshake; + if (count >= max) { + /* maxconn reached */ + next = 0; + goto end; + } -int quic_listener_max_handshake(const struct listener *l); -int quic_listener_max_accept(const struct listener *l); + /* try to increment quic_curr_handshake */ + next = count + 1; + } while (!_HA_ATOMIC_CAS(&l->rx.quic_curr_handshake, &count, next) && __ha_cpu_relax()); + + end: + return next; +} #endif /* USE_QUIC */ #endif /* _HAPROXY_QUIC_SOCK_H */ diff --git a/src/quic_conn.c b/src/quic_conn.c index b5545976a2..5233496e3a 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -945,30 +945,6 @@ struct task *qc_process_timer(struct task *task, void *ctx, unsigned int state) return task; } -/* Try to increment handshake current counter. If listener limit is - * reached, incrementation is rejected and 0 is returned. - */ -static int quic_increment_curr_handshake(struct listener *l) -{ - unsigned int count, next; - const int max = quic_listener_max_handshake(l); - - do { - count = l->rx.quic_curr_handshake; - if (count >= max) { - /* maxconn reached */ - next = 0; - goto end; - } - - /* try to increment quic_curr_handshake */ - next = count + 1; - } while (!_HA_ATOMIC_CAS(&l->rx.quic_curr_handshake, &count, next) && __ha_cpu_relax()); - - end: - return next; -} - /* Allocate a new QUIC connection with as QUIC version. * boolean is set to 1 for IPv4 connection, 0 for IPv6. is set to 1 * for QUIC servers (or haproxy listeners).