]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: define QUIC flag on listener
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 25 Jan 2022 16:48:47 +0000 (17:48 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 26 Jan 2022 14:25:45 +0000 (15:25 +0100)
Mark QUIC listeners with the flag LI_F_QUIC_LISTENER. It is set by the
proto-quic layer on the add listener callback. This allows to override
more clearly the accept callback on quic_session_accept.

include/haproxy/listener-t.h
src/cfgparse.c
src/proto_quic.c

index 6fffc4a4ecefa9ea0f436b16d3ca730ded6b20d0..136ad1e22605530cc0e40b225e0fbd2efd189012 100644 (file)
@@ -191,6 +191,8 @@ struct bind_conf {
        struct rx_settings settings; /* all the settings needed for the listening socket */
 };
 
+#define LI_F_QUIC_LISTENER       0x00000001  /* listener uses proto quic */
+
 /* The listener will be directly referenced by the fdtab[] which holds its
  * socket. The listener provides the protocol-specific accept() function to
  * the fdtab.
index 6ce2f529edb18ca05108c95d336d9c4fd3659157..3dfaf65cb568b93a49ab86ca4f2411fd5587d3c7 100644 (file)
@@ -66,6 +66,7 @@
 #include <haproxy/log.h>
 #include <haproxy/mailers.h>
 #include <haproxy/namespace.h>
+#include <haproxy/quic_sock.h>
 #include <haproxy/obj_type-t.h>
 #include <haproxy/peers-t.h>
 #include <haproxy/peers.h>
@@ -3901,11 +3902,13 @@ out_uri_auth_compat:
                        if (!listener->maxaccept)
                                listener->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : MAX_ACCEPT;
 
-                       /* listener->accept may already be initialized by some
-                        * protocols so do not overwrite it in this case.
-                        */
-                       if (!listener->accept)
-                               listener->accept = session_accept_fd;
+                       /* listener accept callback */
+                       listener->accept = session_accept_fd;
+#ifdef USE_QUIC
+                       /* override the accept callback for QUIC listeners. */
+                       if (listener->flags & LI_F_QUIC_LISTENER)
+                               listener->accept = quic_session_accept;
+#endif
 
                        listener->analysers |= curproxy->fe_req_ana;
                        listener->default_target = curproxy->default_target;
index 283484596cef73d4ae1f9928bce13991ae0a3681..6fdb3f779cb1c0f0eeed0cec2fbafb716c8a7781 100644 (file)
@@ -518,8 +518,7 @@ int quic_connect_server(struct connection *conn, int flags)
  */
 static void quic_add_listener(struct protocol *proto, struct listener *listener)
 {
-       /* custom accept callback for QUIC */
-       listener->accept = quic_session_accept;
+       listener->flags |= LI_F_QUIC_LISTENER;
 
        MT_LIST_INIT(&listener->rx.pkts);
        listener->rx.odcids = EB_ROOT_UNIQUE;