Skip to content

Commit 175a2bb

Browse files
committed
MINOR: connection: pass the proxy when creating a connection
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.
1 parent eb528db commit 175a2bb

File tree

6 files changed

+12
-10
lines changed

6 files changed

+12
-10
lines changed

include/proto/connection.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -796,11 +796,12 @@ static inline struct wait_list *wl_set_waitcb(struct wait_list *wl, struct task
796796
/* Installs the connection's mux layer for upper context <ctx>.
797797
* Returns < 0 on error.
798798
*/
799-
static inline int conn_install_mux(struct connection *conn, const struct mux_ops *mux, void *ctx)
799+
static inline int conn_install_mux(struct connection *conn, const struct mux_ops *mux,
800+
void *ctx, struct proxy *prx)
800801
{
801802
conn->mux = mux;
802803
conn->mux_ctx = ctx;
803-
return mux->init ? mux->init(conn) : 0;
804+
return mux->init ? mux->init(conn, prx) : 0;
804805
}
805806

806807
/* 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)
10451046
if (!mux_ops)
10461047
return -1;
10471048
}
1048-
return conn_install_mux(conn, mux_ops, ctx);
1049+
return conn_install_mux(conn, mux_ops, ctx, bind_conf->frontend);
10491050
}
10501051

10511052
/* 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)
10741075
if (!mux_ops)
10751076
return -1;
10761077
}
1077-
return conn_install_mux(conn, mux_ops, ctx);
1078+
return conn_install_mux(conn, mux_ops, ctx, prx);
10781079
}
10791080

10801081
#endif /* _PROTO_CONNECTION_H */

include/types/connection.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
struct connection;
4242
struct conn_stream;
4343
struct buffer;
44+
struct proxy;
4445
struct server;
4546
struct pipe;
4647

@@ -310,7 +311,7 @@ struct xprt_ops {
310311
* layer is not ready yet.
311312
*/
312313
struct mux_ops {
313-
int (*init)(struct connection *conn); /* early initialization */
314+
int (*init)(struct connection *conn, struct proxy *prx); /* early initialization */
314315
int (*wake)(struct connection *conn); /* mux-layer callback to report activity, mandatory */
315316
void (*update_poll)(struct conn_stream *cs); /* commit cs flags to mux/conn */
316317
size_t (*rcv_buf)(struct conn_stream *cs, struct buffer *buf, size_t count, int flags); /* Called from the upper layer to get data */

src/checks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ static int connect_conn_chk(struct task *t)
16111611
clear_addr(&conn->addr.from);
16121612

16131613
conn_prepare(conn, proto, check->xprt);
1614-
conn_install_mux(conn, &mux_pt_ops, cs);
1614+
conn_install_mux(conn, &mux_pt_ops, cs, s->proxy);
16151615
cs_attach(cs, check, &check_conn_cb);
16161616

16171617
/* only plain tcp-check supports quick ACK */
@@ -2806,7 +2806,7 @@ static int tcpcheck_main(struct check *check)
28062806
}
28072807

28082808
conn_prepare(conn, proto, xprt);
2809-
conn_install_mux(conn, &mux_pt_ops, cs);
2809+
conn_install_mux(conn, &mux_pt_ops, cs, s->proxy);
28102810
cs_attach(cs, check, &check_conn_cb);
28112811

28122812
ret = SF_ERR_INTERNAL;

src/mux_h2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ static int h2c_frt_init(struct connection *conn)
438438
* connections from the fact that the context is still NULL. Returns < 0 on
439439
* error.
440440
*/
441-
static int h2_init(struct connection *conn)
441+
static int h2_init(struct connection *conn, struct proxy *prx)
442442
{
443443
if (conn->mux_ctx) {
444444
/* we don't support outgoing connections for now */

src/mux_pt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* incoming ones, in which case one will be allocated and a new stream will be
2020
* instanciated). Returns < 0 on error.
2121
*/
22-
static int mux_pt_init(struct connection *conn)
22+
static int mux_pt_init(struct connection *conn, struct proxy *prx)
2323
{
2424
struct conn_stream *cs = conn->mux_ctx;
2525

src/peers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@ static struct appctx *peer_session_create(struct peers *peers, struct peer *peer
19711971
memcpy(&conn->addr.to, &peer->addr, sizeof(conn->addr.to));
19721972

19731973
conn_prepare(conn, peer->proto, peer->xprt);
1974-
conn_install_mux(conn, &mux_pt_ops, cs);
1974+
conn_install_mux(conn, &mux_pt_ops, cs, s->be);
19751975
si_attach_cs(&s->si[1], cs);
19761976

19771977
s->do_log = NULL;

0 commit comments

Comments
 (0)