]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-fcgi: Rely on client addresses at stream level to set default params
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 25 Oct 2021 05:56:51 +0000 (07:56 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 27 Oct 2021 09:34:21 +0000 (11:34 +0200)
Client source and destination addresses at stream level are now used to emit
SERVER_NAME/SERVER_PORT and REMOTE_ADDR/REMOTE_PORT parameters. For now,
stream-interface addresses are never set. So, thanks to the fallback
mechanism, no changes are expected with this patch. But its purpose is to
rely on addresses at the stream level, when set, instead of those at the
connection level.

src/mux_fcgi.c

index 46ee5eddf5961451900be11d863a414214fd62b6..f20b46b71eddbc85d0d24c78f83bbe5ce078ee6b 100644 (file)
@@ -1229,6 +1229,8 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst
                                  struct fcgi_strm_params *params)
 {
        struct connection *cli_conn = objt_conn(fstrm->sess->origin);
+       const struct sockaddr_storage *src = si_src(si_opposite(fstrm->cs->data));
+       const struct sockaddr_storage *dst = si_dst(si_opposite(fstrm->cs->data));
        struct ist p;
 
        if (!sl)
@@ -1255,8 +1257,8 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst
        if (!(params->mask & FCGI_SP_SRV_PORT)) {
                char *end;
                int port = 0;
-               if (cli_conn && conn_get_dst(cli_conn))
-                       port = get_host_port(cli_conn->dst);
+               if (dst)
+                       port = get_host_port(dst);
                end = ultoa_o(port, b_tail(params->p), b_room(params->p));
                if (!end)
                        goto error;
@@ -1269,8 +1271,8 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst
                if (!istlen(params->srv_name)) {
                        char *ptr = NULL;
 
-                       if (cli_conn && conn_get_dst(cli_conn))
-                               if (addr_to_str(cli_conn->dst, b_tail(params->p), b_room(params->p)) != -1)
+                       if (dst)
+                               if (addr_to_str(dst, b_tail(params->p), b_room(params->p)) != -1)
                                        ptr = b_tail(params->p);
                        if (ptr) {
                                params->srv_name = ist(ptr);
@@ -1281,8 +1283,8 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst
        if (!(params->mask & FCGI_SP_REM_ADDR)) {
                char *ptr = NULL;
 
-               if (cli_conn && conn_get_src(cli_conn))
-                       if (addr_to_str(cli_conn->src, b_tail(params->p), b_room(params->p)) != -1)
+               if (src)
+                       if (addr_to_str(src, b_tail(params->p), b_room(params->p)) != -1)
                                ptr = b_tail(params->p);
                if (ptr) {
                        params->rem_addr = ist(ptr);
@@ -1292,8 +1294,8 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst
        if (!(params->mask & FCGI_SP_REM_PORT)) {
                char *end;
                int port = 0;
-               if (cli_conn && conn_get_src(cli_conn))
-                       port = get_host_port(cli_conn->src);
+               if (src)
+                       port = get_host_port(src);
                end = ultoa_o(port, b_tail(params->p), b_room(params->p));
                if (!end)
                        goto error;