]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Move conn_prepare() to ->accept_conn() callback
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 14 Jun 2021 08:31:43 +0000 (10:31 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 23 Sep 2021 13:27:25 +0000 (15:27 +0200)
The xprt context must be initialized before receiving further packets from
the I/O dgram handler.

src/quic_sock.c

index a2c4becb5b8011fc4be951704fd10f4259ffaccf..ad8ae6ad07c201e6b850eeb8b6b38cea7eb18aea 100644 (file)
@@ -35,9 +35,6 @@ int quic_session_accept(struct connection *cli_conn)
        struct session *sess;
 
        cli_conn->proxy_netns = l->rx.settings->netns;
-       if (conn_prepare(cli_conn, l->rx.proto, l->bind_conf->xprt) < 0)
-               goto out_free_conn;
-
        /* This flag is ordinarily set by conn_ctrl_init() which cannot
         * be called for now.
         */
@@ -113,14 +110,19 @@ static int new_quic_cli_conn(struct quic_conn *qc, struct listener *l,
 
        /* 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.
+        */
+       if (conn_prepare(cli_conn, l->rx.proto, l->bind_conf->xprt) < 0)
+               goto out_free_conn;
 
        return 1;
 
  out_free_conn:
+       qc->conn = NULL;
        conn_stop_tracking(cli_conn);
        conn_xprt_close(cli_conn);
        conn_free(cli_conn);
-       qc->conn = NULL;
  out:
 
        return 0;