]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connection: pass the proxy when creating a connection
authorWilly Tarreau <w@1wt.eu>
Wed, 12 Sep 2018 10:02:05 +0000 (12:02 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 12 Sep 2018 15:39:22 +0000 (17:39 +0200)
Till now it was very difficult for a mux to know what proxy it was
working for. Let's pass the proxy when the mux is instanciated at
init() time. It's not yet used but the H1 mux will definitely need
it, just like the H2 mux when dealing with backend connections.

include/proto/connection.h
include/types/connection.h
src/checks.c
src/mux_h2.c
src/mux_pt.c
src/peers.c

index 2a45677b706679095dd123a5694f44273f94b8ca..85c5b633fcfab11a8eaaee00aca6ce5b9d6a4a20 100644 (file)
@@ -796,11 +796,12 @@ static inline struct wait_list *wl_set_waitcb(struct wait_list *wl, struct task
 /* Installs the connection's mux layer for upper context <ctx>.
  * Returns < 0 on error.
  */
-static inline int conn_install_mux(struct connection *conn, const struct mux_ops *mux, void *ctx)
+static inline int conn_install_mux(struct connection *conn, const struct mux_ops *mux,
+                                   void *ctx, struct proxy *prx)
 {
        conn->mux = mux;
        conn->mux_ctx = ctx;
-       return mux->init ? mux->init(conn) : 0;
+       return mux->init ? mux->init(conn, prx) : 0;
 }
 
 /* returns a human-readable error code for conn->err_code, or NULL if the code
@@ -1045,7 +1046,7 @@ static inline int conn_install_mux_fe(struct connection *conn, void *ctx)
                if (!mux_ops)
                        return -1;
        }
-       return conn_install_mux(conn, mux_ops, ctx);
+       return conn_install_mux(conn, mux_ops, ctx, bind_conf->frontend);
 }
 
 /* installs the best mux for outgoing connection <conn> using the upper context
@@ -1074,7 +1075,7 @@ static inline int conn_install_mux_be(struct connection *conn, void *ctx)
                if (!mux_ops)
                        return -1;
        }
-       return conn_install_mux(conn, mux_ops, ctx);
+       return conn_install_mux(conn, mux_ops, ctx, prx);
 }
 
 #endif /* _PROTO_CONNECTION_H */
index 59bb27d1ba1bd4d310b7cb46e34f0cefd2ca2dcc..27ae76e21c661ee4e9f15984f57abab376665d35 100644 (file)
@@ -41,6 +41,7 @@
 struct connection;
 struct conn_stream;
 struct buffer;
+struct proxy;
 struct server;
 struct pipe;
 
@@ -310,7 +311,7 @@ struct xprt_ops {
  * layer is not ready yet.
  */
 struct mux_ops {
-       int  (*init)(struct connection *conn);        /* early initialization */
+       int  (*init)(struct connection *conn, struct proxy *prx);  /* early initialization */
        int  (*wake)(struct connection *conn);        /* mux-layer callback to report activity, mandatory */
        void (*update_poll)(struct conn_stream *cs);  /* commit cs flags to mux/conn */
        size_t (*rcv_buf)(struct conn_stream *cs, struct buffer *buf, size_t count, int flags); /* Called from the upper layer to get data */
index 96374301c5b28bc348eea3a4eae7545b5580fcfa..6d19eef3f3528bcfc0131ae3a9c01c9ec2faa873 100644 (file)
@@ -1611,7 +1611,7 @@ static int connect_conn_chk(struct task *t)
        clear_addr(&conn->addr.from);
 
        conn_prepare(conn, proto, check->xprt);
-       conn_install_mux(conn, &mux_pt_ops, cs);
+       conn_install_mux(conn, &mux_pt_ops, cs, s->proxy);
        cs_attach(cs, check, &check_conn_cb);
 
        /* only plain tcp-check supports quick ACK */
@@ -2806,7 +2806,7 @@ static int tcpcheck_main(struct check *check)
                        }
 
                        conn_prepare(conn, proto, xprt);
-                       conn_install_mux(conn, &mux_pt_ops, cs);
+                       conn_install_mux(conn, &mux_pt_ops, cs, s->proxy);
                        cs_attach(cs, check, &check_conn_cb);
 
                        ret = SF_ERR_INTERNAL;
index 780bc57f6011ec89e9b9df1929219baa716514be..3faf5aeef85f0eccad86cf152a8fd0afccd5574d 100644 (file)
@@ -438,7 +438,7 @@ static int h2c_frt_init(struct connection *conn)
  * connections from the fact that the context is still NULL. Returns < 0 on
  * error.
  */
-static int h2_init(struct connection *conn)
+static int h2_init(struct connection *conn, struct proxy *prx)
 {
        if (conn->mux_ctx) {
                /* we don't support outgoing connections for now */
index 466ac21b92a01995072f7d44039a9a29cb4e4b92..5b864199ec02cf4ff209627c5740016cb4c884b8 100644 (file)
@@ -19,7 +19,7 @@
  * incoming ones, in which case one will be allocated and a new stream will be
  * instanciated). Returns < 0 on error.
  */
-static int mux_pt_init(struct connection *conn)
+static int mux_pt_init(struct connection *conn, struct proxy *prx)
 {
        struct conn_stream *cs = conn->mux_ctx;
 
index 50aee870dbe861a19599c53cd1213f4e34574f0a..e61caaf93f81eea0b9abbafd877d5e620f009feb 100644 (file)
@@ -1971,7 +1971,7 @@ static struct appctx *peer_session_create(struct peers *peers, struct peer *peer
        memcpy(&conn->addr.to, &peer->addr, sizeof(conn->addr.to));
 
        conn_prepare(conn, peer->proto, peer->xprt);
-       conn_install_mux(conn, &mux_pt_ops, cs);
+       conn_install_mux(conn, &mux_pt_ops, cs, s->be);
        si_attach_cs(&s->si[1], cs);
 
        s->do_log = NULL;