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 417e49c..becb4ae 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -9148,23 +9148,16 @@
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 @@
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;
}