mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
MEDIUM: connection: Rely on addresses at stream level to make proxy line
If the stream exists, the frontend stream-interface is used to get the client source and destination addresses when the proxy line is built. For now, stream-interface or session 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 appropriate level when set instead of those at the connection level.
This commit is contained in:
parent
c03be1a129
commit
b097aef2ef
@ -1567,7 +1567,7 @@ void list_mux_proto(FILE *out)
|
||||
* TCP6 and "UNKNOWN" formats. If any of <src> or <dst> is null, UNKNOWN is
|
||||
* emitted as well.
|
||||
*/
|
||||
static int make_proxy_line_v1(char *buf, int buf_len, struct sockaddr_storage *src, struct sockaddr_storage *dst)
|
||||
static int make_proxy_line_v1(char *buf, int buf_len, const struct sockaddr_storage *src, const struct sockaddr_storage *dst)
|
||||
{
|
||||
int ret = 0;
|
||||
char * protocol;
|
||||
@ -1662,8 +1662,8 @@ static int make_proxy_line_v2(char *buf, int buf_len, struct server *srv, struct
|
||||
int ret = 0;
|
||||
struct proxy_hdr_v2 *hdr = (struct proxy_hdr_v2 *)buf;
|
||||
struct sockaddr_storage null_addr = { .ss_family = 0 };
|
||||
struct sockaddr_storage *src = &null_addr;
|
||||
struct sockaddr_storage *dst = &null_addr;
|
||||
const struct sockaddr_storage *src = &null_addr;
|
||||
const struct sockaddr_storage *dst = &null_addr;
|
||||
const char *value;
|
||||
int value_len;
|
||||
|
||||
@ -1671,9 +1671,13 @@ static int make_proxy_line_v2(char *buf, int buf_len, struct server *srv, struct
|
||||
return 0;
|
||||
memcpy(hdr->sig, pp2_signature, PP2_SIGNATURE_LEN);
|
||||
|
||||
if (remote && conn_get_src(remote) && conn_get_dst(remote)) {
|
||||
src = remote->src;
|
||||
dst = remote->dst;
|
||||
if (strm) {
|
||||
src = si_src(&strm->si[0]);
|
||||
dst = si_dst(&strm->si[0]);
|
||||
}
|
||||
else if (remote && conn_get_src(remote) && conn_get_dst(remote)) {
|
||||
src = conn_src(remote);
|
||||
dst = conn_dst(remote);
|
||||
}
|
||||
|
||||
/* At least one of src or dst is not of AF_INET or AF_INET6 */
|
||||
@ -1863,8 +1867,20 @@ int make_proxy_line(char *buf, int buf_len, struct server *srv, struct connectio
|
||||
ret = make_proxy_line_v2(buf, buf_len, srv, remote, strm);
|
||||
}
|
||||
else {
|
||||
if (remote && conn_get_src(remote) && conn_get_dst(remote))
|
||||
ret = make_proxy_line_v1(buf, buf_len, remote->src, remote->dst);
|
||||
const struct sockaddr_storage *src = NULL;
|
||||
const struct sockaddr_storage *dst = NULL;
|
||||
|
||||
if (strm) {
|
||||
src = si_src(&strm->si[0]);
|
||||
dst = si_dst(&strm->si[0]);
|
||||
}
|
||||
else if (remote && conn_get_src(remote) && conn_get_dst(remote)) {
|
||||
src = conn_src(remote);
|
||||
dst = conn_dst(remote);
|
||||
}
|
||||
|
||||
if (src && dst)
|
||||
ret = make_proxy_line_v1(buf, buf_len, src, dst);
|
||||
else
|
||||
ret = make_proxy_line_v1(buf, buf_len, NULL, NULL);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user