From fc8f1f03828358b97b250532bedbaaa67379dd7a Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sat, 8 Dec 2012 18:53:44 +0100 Subject: [PATCH] BUG/MINOR: tcp: set the ADDR_TO_SET flag on outgoing connections tcp_connect_server() resets all of the connection's flags. This means that an outgoing connection does not have the ADDR_TO_SET flag eventhough the address is set. The first impact is that logging the outgoing address or displaying it on the CLI while dumping sessions will result in an extra call to getpeername(). But there is a nastier impact. If such a lookup happens *after* the first connect() attempt and this one fails, the destination address is corrupted by the call to getsockname(), and subsequent connection retries will fail with socket errors. For now we fix this by making tcp_connect_server() set the flag. But we'll soon need a function to initialize an outgoing connection with appropriate address and flags before calling the connect() function. --- src/proto_tcp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 551603677a..0df4abadbd 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -470,6 +470,7 @@ int tcp_connect_server(struct connection *conn, int data, int delack) fdtab[fd].owner = conn; conn->flags = CO_FL_WAIT_L4_CONN; /* connection in progress */ + conn->flags |= CO_FL_ADDR_TO_SET; fdtab[fd].iocb = conn_fd_handler; fd_insert(fd); -- 2.47.2