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.
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);
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);
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))