]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connection: update rhttp flags usage
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 16 Nov 2023 16:13:28 +0000 (17:13 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 16 Nov 2023 16:53:31 +0000 (17:53 +0100)
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.

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

index 2029bf851b89ee035d72f40d64ddb6921351a330..8081cb3750c5bfb0015a257b46d12b3b0efc1f88 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 ? */
 
-       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 */
index b384f5099d60eaecab9b91592e1af18e4206b2cd..c7d98834ac7d02e7f988ee771367a9e2c6774270 100644 (file)
@@ -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 <conn> as a reverse connection to <target>. */
index 3a13c2542527f5c85833663bb70118f15ea61f7f..cf0bd4e20ef50d6af7b6f98ae69711b911110f29 100644 (file)
@@ -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);
        }
 
index fc5e377982c16687288305e2f60de6660303aa02..6c0b1e4c4d9993d59665ebfd0029c205c655ab14 100644 (file)
@@ -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;