]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: connection: Use the session to get the origin address if needed.
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 29 May 2019 15:08:03 +0000 (17:08 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 29 May 2019 15:56:59 +0000 (17:56 +0200)
In conn_si_send_proxy(), if we don't have a conn_stream yet, because the mux
won't be created until the SSL handshake is done, retrieve the opposite's
connection from the session. At this point, we know the session associated
with the connection is the one that initiated it, and we can thus just use
the session's origin.

This should be backported to 1.9.

src/stream_interface.c

index 3a3824c670a3d7a7910ebe7ce04bbbbc9aa7a8c3..fd5311d837299cba56b60f77ec6830c19c711713 100644 (file)
@@ -360,6 +360,21 @@ int conn_si_send_proxy(struct connection *conn, unsigned int flag)
                        ret = make_proxy_line(trash.area, trash.size,
                                              objt_server(conn->target),
                                              remote_cs ? remote_cs->conn : NULL);
+                       /* We may not have a conn_stream yet, if we don't
+                        * know which mux to use, because it will be decided
+                        * during the SSL handshake. In this case, there should
+                        * be a session associated to the connection in
+                        * conn->owner, and we know it is the session that
+                        * initiated that connection, so we can just use
+                        * its origin, which should contain the client
+                        * connection.
+                        */
+               } else if (!cs && conn->owner) {
+                       struct session *sess = conn->owner;
+
+                       ret = make_proxy_line(trash.area, trash.size,
+                                             objt_server(conn->target),
+                                             objt_conn(sess->origin));
                }
                else {
                        /* The target server expects a LOCAL line to be sent first. Retrieving