]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: backend: drop checks for OBJ_TYPE_PROXY in connect() code
authorWilly Tarreau <w@1wt.eu>
Fri, 26 Jun 2026 09:07:11 +0000 (11:07 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 26 Jun 2026 09:09:34 +0000 (11:09 +0200)
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.

src/proto_quic.c
src/proto_tcp.c
src/proto_uxst.c

index 4becdea3250af36e6e2742ad2d1cc0299ba43e3b..547e6d9de233f0bc82823ab157a6828ef4d8027e 100644 (file)
@@ -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;
index 0b6b71f7e2e7c004fe0f26efc0c8c8289c718d05..932e7a53b87fa81995685655bf81ac4d80bb3f2c 100644 (file)
@@ -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
 
index 434a702aa5439d98c0a4f86165324ecfeb30280f..a714167de5e10e4c1979bab368e5a0864dae0326 100644 (file)
@@ -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;