From: Willy Tarreau Date: Fri, 26 Jun 2026 09:07:11 +0000 (+0200) Subject: CLEANUP: backend: drop checks for OBJ_TYPE_PROXY in connect() code X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7adf94cfe19374043d2c9bddc18a5643e4d1bcb9;p=thirdparty%2Fhaproxy.git CLEANUP: backend: drop checks for OBJ_TYPE_PROXY in connect() code In tcp_connect_server(), uxst_connect_server(), and quic_connect_server(), we can no longer see obj_type(conn->target) == OBJ_TYPE_PROXY so let's drop that code. This implies that srv may no longer be NULL so we can drop these checks as well. --- diff --git a/src/proto_quic.c b/src/proto_quic.c index 4becdea32..547e6d9de 100644 --- a/src/proto_quic.c +++ b/src/proto_quic.c @@ -291,10 +291,6 @@ int quic_connect_server(struct connection *conn, int flags) BUG_ON(!conn->dst); switch (obj_type(conn->target)) { - case OBJ_TYPE_PROXY: - be = __objt_proxy(conn->target); - srv = NULL; - break; case OBJ_TYPE_SERVER: srv = __objt_server(conn->target); be = srv->proxy; @@ -314,7 +310,7 @@ int quic_connect_server(struct connection *conn, int flags) * - server-specific at first * - proxy-specific next */ - if (srv && srv->conn_src.opts & CO_SRC_BIND) + if (srv->conn_src.opts & CO_SRC_BIND) src = &srv->conn_src; else if (be->conn_src.opts & CO_SRC_BIND) src = &be->conn_src; diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 0b6b71f7e..932e7a53b 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -377,10 +377,6 @@ int tcp_connect_server(struct connection *conn, int flags) conn->flags |= CO_FL_WAIT_L4_CONN; /* connection in progress */ switch (obj_type(conn->target)) { - case OBJ_TYPE_PROXY: - be = __objt_proxy(conn->target); - srv = NULL; - break; case OBJ_TYPE_SERVER: srv = __objt_server(conn->target); be = srv->proxy; @@ -429,7 +425,7 @@ int tcp_connect_server(struct connection *conn, int flags) * - server-specific at first * - proxy-specific next */ - if (srv && srv->conn_src.opts & CO_SRC_BIND) + if (srv->conn_src.opts & CO_SRC_BIND) src = &srv->conn_src; else if (be->conn_src.opts & CO_SRC_BIND) src = &be->conn_src; @@ -536,7 +532,7 @@ int tcp_connect_server(struct connection *conn, int flags) #endif #if defined(TCP_CONGESTION) - if (srv && srv->cc_algo) { + if (srv->cc_algo) { /* Changing congestion control might fail due to loaded * algorithms or permission. In this case the default algorithm * remains active so we silently ignore it. Note: it would be @@ -548,7 +544,7 @@ int tcp_connect_server(struct connection *conn, int flags) #if defined(__linux__) && defined(TCP_MD5SIG) /* if it fails, the connection will fail, so reported an error */ - if (srv && srv->tcp_md5sig) { + if (srv->tcp_md5sig) { struct tcp_md5sig md5; memset(&md5, 0, sizeof(md5)); @@ -568,7 +564,7 @@ int tcp_connect_server(struct connection *conn, int flags) #ifdef TCP_USER_TIMEOUT /* there is not much more we can do here when it fails, it's still minor */ - if (srv && srv->tcp_ut) + if (srv->tcp_ut) setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &srv->tcp_ut, sizeof(srv->tcp_ut)); #endif diff --git a/src/proto_uxst.c b/src/proto_uxst.c index 434a702aa..a714167de 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -316,10 +316,6 @@ static int uxst_connect_server(struct connection *conn, int flags) BUG_ON(!conn->dst); switch (obj_type(conn->target)) { - case OBJ_TYPE_PROXY: - be = __objt_proxy(conn->target); - srv = NULL; - break; case OBJ_TYPE_SERVER: srv = __objt_server(conn->target); be = srv->proxy;