From: Amaury Denoyelle Date: Thu, 16 Nov 2023 16:13:28 +0000 (+0100) Subject: MINOR: connection: update rhttp flags usage X-Git-Tag: v2.9-dev10~67 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8cc3fc73f13fe94d2454996fddd3fc046818ec78;p=thirdparty%2Fhaproxy.git MINOR: connection: update rhttp flags usage Change the flags used for reversed connection : * CO_FL_REVERSED is now put after reversal for passive connect. For active connect, it is delayed when accept is completed after reversal. * CO_FL_ACT_REVERSING replace the old CO_FL_REVERSED. It is put only for active connect on reversal and removes once accept is done. This allows to identify a connection as reversed during its whole lifetime. This should be useful to extend reverse connect. --- diff --git a/include/haproxy/connection-t.h b/include/haproxy/connection-t.h index 2029bf851b..8081cb3750 100644 --- a/include/haproxy/connection-t.h +++ b/include/haproxy/connection-t.h @@ -85,7 +85,8 @@ enum { CO_FL_IDLE_LIST = 0x00000002, /* 2 = in idle_list, 3 = invalid */ CO_FL_LIST_MASK = 0x00000003, /* Is the connection in any server-managed list ? */ - CO_FL_REVERSED = 0x00000004, /* connection has been reversed but not yet accepted */ + CO_FL_REVERSED = 0x00000004, /* connection has been reversed to backend / reversed and accepted on frontend */ + CO_FL_ACT_REVERSING = 0x00000008, /* connection has been reversed to frontend but not yet accepted */ /* unused : 0x00000008 */ /* unused : 0x00000010 */ diff --git a/include/haproxy/connection.h b/include/haproxy/connection.h index b384f5099d..c7d98834ac 100644 --- a/include/haproxy/connection.h +++ b/include/haproxy/connection.h @@ -703,7 +703,7 @@ static inline int conn_is_reverse(const struct connection *conn) static inline int conn_reverse_in_preconnect(const struct connection *conn) { return conn_is_back(conn) ? !!(conn->reverse.target) : - !!(conn->flags & CO_FL_REVERSED); + !!(conn->flags & CO_FL_ACT_REVERSING); } /* Initialize as a reverse connection to . */ diff --git a/src/connection.c b/src/connection.c index 3a13c25425..cf0bd4e20e 100644 --- a/src/connection.c +++ b/src/connection.c @@ -2670,6 +2670,8 @@ int conn_reverse(struct connection *conn) sess->origin = NULL; session_free(sess); conn_set_owner(conn, NULL, NULL); + + conn->flags |= CO_FL_REVERSED; } else { /* Wake up receiver to proceed to connection accept. */ @@ -2678,7 +2680,7 @@ int conn_reverse(struct connection *conn) conn_backend_deinit(conn); conn->target = &l->obj_type; - conn->flags |= CO_FL_REVERSED; + conn->flags |= CO_FL_ACT_REVERSING; task_wakeup(l->rx.reverse_connect.task, TASK_WOKEN_ANY); } diff --git a/src/proto_reverse_connect.c b/src/proto_reverse_connect.c index fc5e377982..6c0b1e4c4d 100644 --- a/src/proto_reverse_connect.c +++ b/src/proto_reverse_connect.c @@ -183,7 +183,7 @@ struct task *rev_process(struct task *task, void *ctx, unsigned int state) } else { /* Spurrious receiver task woken up despite pend_conn not ready/on error. */ - BUG_ON(!(conn->flags & CO_FL_REVERSED)); + BUG_ON(!(conn->flags & CO_FL_ACT_REVERSING)); /* A connection is ready to be accepted. */ listener_accept(l); @@ -349,8 +349,9 @@ struct connection *rev_accept_conn(struct listener *l, int *status) } /* listener_accept() must not be called if no pending connection is not yet reversed. */ - BUG_ON(!(conn->flags & CO_FL_REVERSED)); - conn->flags &= ~CO_FL_REVERSED; + BUG_ON(!(conn->flags & CO_FL_ACT_REVERSING)); + conn->flags &= ~CO_FL_ACT_REVERSING; + conn->flags |= CO_FL_REVERSED; conn->mux->ctl(conn, MUX_REVERSE_CONN, NULL); l->rx.reverse_connect.pend_conn = NULL;