MINOR: quic: store source address for backend conns

quic_conn has a local_addr member which is used to store the connection
source address. On backend side, this member is initialized to NULL as
the address is not yet known prior to connect. With this patch,
quic_connect_server() is extended so that local_addr is updated after
connect() success.

Also, quic_sock_get_src() is completed for the backend side which now
returns local_addr member. This step is necessary to properly support
fetches bc_src/bc_src_port.
This commit is contained in:
Amaury Denoyelle 2025-11-20 16:26:41 +01:00
parent a14b7790ad
commit cd2962ee64
2 changed files with 16 additions and 3 deletions

View File

@ -285,8 +285,9 @@ int quic_connect_server(struct connection *conn, int flags)
struct server *srv;
struct proxy *be;
struct conn_src *src;
struct sockaddr_storage *addr;
struct sockaddr_storage *addr, saddr;
struct quic_conn *qc = conn->handle.qc;
socklen_t saddr_len;
BUG_ON(qc->fd != -1);
BUG_ON(!conn->dst);
@ -427,6 +428,12 @@ int quic_connect_server(struct connection *conn, int flags)
return SF_ERR_SRVCL;
}
/* Update quic-conn source address after connect. */
if (getsockname(fd, (struct sockaddr *)&saddr, &saddr_len) == 0) {
if (saddr_len <= sizeof(qc->local_addr))
qc->local_addr = saddr;
}
qc->fd = fd;
fd_insert(fd, qc, quic_conn_sock_fd_iocb, tgid, ti->ltid_bit);
fd_want_recv(fd);

View File

@ -60,8 +60,14 @@ int quic_sock_get_src(struct connection *conn, struct sockaddr *addr, socklen_t
qc = conn->handle.qc;
if (conn_is_back(conn)) {
/* no source address defined for outgoing connections for now */
return -1;
/* source address should be known since connect() */
if (!is_addr(&qc->local_addr))
return -1;
if (len > sizeof(qc->local_addr))
len = sizeof(qc->local_addr);
memcpy(addr, &qc->local_addr, len);
return 0;
} else {
/* front connection, return the peer's address */
if (len > sizeof(qc->peer_addr))