]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connection: extend conn_reverse() for active reverse
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 7 Aug 2023 12:46:24 +0000 (14:46 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 24 Aug 2023 15:02:37 +0000 (17:02 +0200)
Implement active reverse support inside conn_reverse(). This is used to
transfer the connection from the backend to the frontend side.

A new flag is defined CO_FL_REVERSED which is set just after this
transition. This will be used to identify connections which were
reversed but not yet accepted.

include/haproxy/connection-t.h
src/connection.c

index cf4ec5a95dce43fe37d3a082a6de49daed150608..678cc96b2921039e4d3db50d425e014e944c90aa 100644 (file)
@@ -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 ? */
 
-       /* unused : 0x00000004, 0x00000008 */
+       CO_FL_REVERSED      = 0x00000004,  /* connection has been reversed but not yet accepted */
+       /* unused : 0x00000008 */
 
        /* unused : 0x00000010 */
        /* unused : 0x00000020 */
index 6363ff7fd488df8248e4a362ac38bfd4104a0c19..70c9e45c28e9e2422944de611c0f59378112c22c 100644 (file)
@@ -2440,6 +2440,11 @@ uint64_t conn_calculate_hash(const struct conn_hash_params *params)
 /* Reverse a <conn> connection instance. This effectively moves the connection
  * from frontend to backend side or vice-versa depending on its initial status.
  *
+ * For active reversal, 'reverse' member points to the listener used as the new
+ * connection target. Once transition is completed, the connection needs to be
+ * accepted on the listener to instantiate its parent session before using
+ * streams.
+ *
  * For passive reversal, 'reverse' member points to the server used as the new
  * connection target. Once transition is completed, the connection appears as a
  * normal backend connection.
@@ -2486,7 +2491,10 @@ int conn_reverse(struct connection *conn)
                conn_set_owner(conn, NULL, NULL);
        }
        else {
-               ABORT_NOW();
+               conn_backend_deinit(conn);
+
+               conn->target = conn->reverse.target;
+               conn->flags |= CO_FL_REVERSED;
        }
 
        /* Invert source and destination addresses if already set. */