]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: set listener accept cb on parsing
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 18 Jan 2022 14:39:02 +0000 (15:39 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 24 Jan 2022 09:30:49 +0000 (10:30 +0100)
Define a special accept cb for QUIC listeners to quic_session_accept().
This operation is conducted during the proto.add callback when creating
listeners.

A special care is now taken care when setting the standard callback
session_accept_fd() to not overwrite if already defined by the proto
layer.

include/haproxy/quic_sock.h
src/cfgparse.c
src/proto_quic.c
src/quic_sock.c

index 672255ed300b171295a1becae8ad32d0c5141665..652bc414b07f1eb2c53eae440ea1d2b9ea32d879 100644 (file)
@@ -33,6 +33,7 @@
 #include <haproxy/connection-t.h>
 #include <haproxy/listener-t.h>
 
+int quic_session_accept(struct connection *cli_conn);
 int quic_sock_accepting_conn(const struct receiver *rx);
 struct connection *quic_sock_accept_conn(struct listener *l, int *status);
 void quic_sock_fd_iocb(int fd);
index 77af77323b80aea7055e327bc4286cf9c5728543..6ce2f529edb18ca05108c95d336d9c4fd3659157 100644 (file)
@@ -3901,7 +3901,12 @@ out_uri_auth_compat:
                        if (!listener->maxaccept)
                                listener->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : MAX_ACCEPT;
 
-                       listener->accept = session_accept_fd;
+                       /* 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->analysers |= curproxy->fe_req_ana;
                        listener->default_target = curproxy->default_target;
 
index 9c2bbd6ef76da0da11d460da89c9b4328b4db52a..29ae209bde25bfe1c08a95e0a7d1b8c45c0014da 100644 (file)
@@ -518,6 +518,9 @@ 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;
+
        MT_LIST_INIT(&listener->rx.pkts);
        listener->rx.odcids = EB_ROOT_UNIQUE;
        listener->rx.cids = EB_ROOT_UNIQUE;
index 080853f48b392b2894749607e403131e2c628ada..bb593738e52450a4bd4381be4bbbb29b83b472aa 100644 (file)
@@ -107,8 +107,6 @@ static int new_quic_cli_conn(struct quic_conn *qc, struct listener *l,
        cli_conn->handle.fd = l->rx.fd;
        cli_conn->target = &l->obj_type;
 
-       /* XXX Should not be there. */
-       l->accept = quic_session_accept;
        /* We need the xprt context before accepting (->accept()) the connection:
         * we may receive packet before this connection acception.
         */