mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-16 16:31:26 +01:00
BUG: proto_tcp: don't try to bind to a foreign address if sin_family is unknown
This is 1.5-specific. It causes issues with transparent source binding involving hdr_ip. We must not try to bind() to a foreign address when the family is not set, and we must set the family when an address is set.
This commit is contained in:
parent
5e205524ad
commit
5dc1e98905
@ -881,6 +881,7 @@ static void assign_tproxy_address(struct session *s)
|
|||||||
case SRV_TPROXY_DYN:
|
case SRV_TPROXY_DYN:
|
||||||
if (srv->bind_hdr_occ) {
|
if (srv->bind_hdr_occ) {
|
||||||
/* bind to the IP in a header */
|
/* bind to the IP in a header */
|
||||||
|
((struct sockaddr_in *)&s->req->cons->addr.from)->sin_family = AF_INET;
|
||||||
((struct sockaddr_in *)&s->req->cons->addr.from)->sin_port = 0;
|
((struct sockaddr_in *)&s->req->cons->addr.from)->sin_port = 0;
|
||||||
((struct sockaddr_in *)&s->req->cons->addr.from)->sin_addr.s_addr =
|
((struct sockaddr_in *)&s->req->cons->addr.from)->sin_addr.s_addr =
|
||||||
htonl(get_ip_from_hdr2(&s->txn.req,
|
htonl(get_ip_from_hdr2(&s->txn.req,
|
||||||
@ -907,6 +908,7 @@ static void assign_tproxy_address(struct session *s)
|
|||||||
case PR_O_TPXY_DYN:
|
case PR_O_TPXY_DYN:
|
||||||
if (s->be->bind_hdr_occ) {
|
if (s->be->bind_hdr_occ) {
|
||||||
/* bind to the IP in a header */
|
/* bind to the IP in a header */
|
||||||
|
((struct sockaddr_in *)&s->req->cons->addr.from)->sin_family = AF_INET;
|
||||||
((struct sockaddr_in *)&s->req->cons->addr.from)->sin_port = 0;
|
((struct sockaddr_in *)&s->req->cons->addr.from)->sin_port = 0;
|
||||||
((struct sockaddr_in *)&s->req->cons->addr.from)->sin_addr.s_addr =
|
((struct sockaddr_in *)&s->req->cons->addr.from)->sin_addr.s_addr =
|
||||||
htonl(get_ip_from_hdr2(&s->txn.req,
|
htonl(get_ip_from_hdr2(&s->txn.req,
|
||||||
|
|||||||
@ -146,6 +146,9 @@ int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct so
|
|||||||
if (flags & 2)
|
if (flags & 2)
|
||||||
((struct sockaddr_in6 *)&bind_addr)->sin6_port = ((struct sockaddr_in6 *)remote)->sin6_port;
|
((struct sockaddr_in6 *)&bind_addr)->sin6_port = ((struct sockaddr_in6 *)remote)->sin6_port;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
/* we don't want to try to bind to an unknown address family */
|
||||||
|
foreign_ok = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user