From: Willy Tarreau Date: Mon, 30 Sep 2013 12:37:14 +0000 (+0200) Subject: MINOR: http: prevent smp_fetch_url_{ip,port} from using si->conn X-Git-Tag: v1.5-dev20~135 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c804ec6ee0f9d4862248ee82cd76787f9dfe8db;p=thirdparty%2Fhaproxy.git MINOR: http: prevent smp_fetch_url_{ip,port} from using si->conn These two fetch methods predate the samples and used to store the destination address into the server-facing connection's address field because we had no other place at this time. This will become problematic with the current connection changes, so let's fix this. --- diff --git a/src/proto_http.c b/src/proto_http.c index 417e49c21b..becb4ae17f 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -9148,23 +9148,16 @@ smp_fetch_url_ip(struct proxy *px, struct session *l4, void *l7, unsigned int op const struct arg *args, struct sample *smp, const char *kw) { struct http_txn *txn = l7; + struct sockaddr_storage addr; CHECK_HTTP_MESSAGE_FIRST(); - /* Parse HTTP request */ - url2sa(txn->req.chn->buf->p + txn->req.sl.rq.u, txn->req.sl.rq.u_l, &l4->req->cons->conn->addr.to); - if (((struct sockaddr_in *)&l4->req->cons->conn->addr.to)->sin_family != AF_INET) + url2sa(txn->req.chn->buf->p + txn->req.sl.rq.u, txn->req.sl.rq.u_l, &addr); + if (((struct sockaddr_in *)&addr)->sin_family != AF_INET) return 0; - smp->type = SMP_T_IPV4; - smp->data.ipv4 = ((struct sockaddr_in *)&l4->req->cons->conn->addr.to)->sin_addr; - - /* - * If we are parsing url in frontend space, we prepare backend stage - * to not parse again the same url ! optimization lazyness... - */ - if (px->options & PR_O_HTTP_PROXY) - l4->flags |= SN_ADDR_SET; + smp->type = SMP_T_IPV4; + smp->data.ipv4 = ((struct sockaddr_in *)&addr)->sin_addr; smp->flags = 0; return 1; } @@ -9174,17 +9167,16 @@ smp_fetch_url_port(struct proxy *px, struct session *l4, void *l7, unsigned int const struct arg *args, struct sample *smp, const char *kw) { struct http_txn *txn = l7; + struct sockaddr_storage addr; CHECK_HTTP_MESSAGE_FIRST(); - /* Same optimization as url_ip */ - url2sa(txn->req.chn->buf->p + txn->req.sl.rq.u, txn->req.sl.rq.u_l, &l4->req->cons->conn->addr.to); - smp->type = SMP_T_UINT; - smp->data.uint = ntohs(((struct sockaddr_in *)&l4->req->cons->conn->addr.to)->sin_port); - - if (px->options & PR_O_HTTP_PROXY) - l4->flags |= SN_ADDR_SET; + url2sa(txn->req.chn->buf->p + txn->req.sl.rq.u, txn->req.sl.rq.u_l, &addr); + if (((struct sockaddr_in *)&addr)->sin_family != AF_INET) + return 0; + smp->type = SMP_T_UINT; + smp->data.uint = ntohs(((struct sockaddr_in *)&addr)->sin_port); smp->flags = 0; return 1; }