diff --git a/include/haproxy/conn_stream.h b/include/haproxy/conn_stream.h index 112b27e2a..e3d2b71f7 100644 --- a/include/haproxy/conn_stream.h +++ b/include/haproxy/conn_stream.h @@ -283,25 +283,6 @@ static inline void cs_ep_set_error(struct sedesc *endp) se_fl_set(endp, SE_FL_ERR_PENDING); } -/* Retrieves any valid stream connector from this connection, preferably the first - * valid one. The purpose is to be able to figure one other end of a private - * connection for purposes like source binding or proxy protocol header - * emission. In such cases, any stream connector is expected to be valid so the - * mux is encouraged to return the first one it finds. If the connection has - * no mux or the mux has no get_first_cs() method or the mux has no valid - * stream connector, NULL is returned. The output pointer is purposely marked - * const to discourage the caller from modifying anything there. - */ -static inline struct stconn *cs_conn_get_first(const struct connection *conn) -{ - BUG_ON(!conn || !conn->mux); - - if (!conn->mux->get_first_cs) - return NULL; - return conn->mux->get_first_cs(conn); -} - - /* Returns non-zero if the stream connector's Rx path is blocked */ static inline int cs_rx_blocked(const struct stconn *cs) { diff --git a/include/haproxy/connection.h b/include/haproxy/connection.h index 30e689e15..34d3f70d7 100644 --- a/include/haproxy/connection.h +++ b/include/haproxy/connection.h @@ -493,6 +493,24 @@ static inline int conn_install_mux(struct connection *conn, const struct mux_ops return ret; } +/* Retrieves any valid stream connector from this connection, preferably the first + * valid one. The purpose is to be able to figure one other end of a private + * connection for purposes like source binding or proxy protocol header + * emission. In such cases, any stream connector is expected to be valid so the + * mux is encouraged to return the first one it finds. If the connection has + * no mux or the mux has no get_first_cs() method or the mux has no valid + * stream connector, NULL is returned. The output pointer is purposely marked + * const to discourage the caller from modifying anything there. + */ +static inline struct stconn *conn_get_first_sc(const struct connection *conn) +{ + BUG_ON(!conn || !conn->mux); + + if (!conn->mux->get_first_cs) + return NULL; + return conn->mux->get_first_cs(conn); +} + int conn_update_alpn(struct connection *conn, const struct ist alpn, int force); static inline const char *conn_get_ctrl_name(const struct connection *conn) diff --git a/src/connection.c b/src/connection.c index f3775e85f..7ba4b17cd 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1176,7 +1176,7 @@ int conn_send_proxy(struct connection *conn, unsigned int flag) /* If there is no mux attached to the connection, it means the * connection context is a stream connector. */ - cs = (conn->mux ? cs_conn_get_first(conn) : conn->ctx); + cs = conn->mux ? conn_get_first_sc(conn) : conn->ctx; /* The target server expects a PROXY line to be sent first. * If the send_proxy_ofs is negative, it corresponds to the