]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: quic: Move quic_increment_curr_handshake() to quic_sock
authorFrédéric Lécaille <flecaille@haproxy.com>
Tue, 28 Nov 2023 14:01:01 +0000 (15:01 +0100)
committerFrédéric Lécaille <flecaille@haproxy.com>
Tue, 28 Nov 2023 14:47:18 +0000 (15:47 +0100)
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.

include/haproxy/quic_sock.h
src/quic_conn.c

index c1053f9c6753c8d5f68e4625399ee15e11ab4afe..531cf62a03b50b2b2613c2fcc5712240dc4daac8 100644 (file)
@@ -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 <qc> 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 <l> 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 */
index b5545976a2ace3e14160462229fe373af8a173d8..5233496e3a35d7dafe15cd9fd6ca02852e01aa2e 100644 (file)
@@ -945,30 +945,6 @@ struct task *qc_process_timer(struct task *task, void *ctx, unsigned int state)
        return task;
 }
 
-/* Try to increment <l> 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 <version> as QUIC version. <ipv4>
  * boolean is set to 1 for IPv4 connection, 0 for IPv6. <server> is set to 1
  * for QUIC servers (or haproxy listeners).