MEDIUM: stream-int/conn-stream: Move src/dst addresses in the conn-stream

The source and destination addresses at the applicative layer are moved from
the stream-interface to the conn-stream. This simplifies a bit the code and
it is a logicial step to remove the stream-interface.
This commit is contained in:
Christopher Faulet 2022-03-29 17:53:09 +02:00
parent 731c8e6cf9
commit 8da67aae3e
24 changed files with 174 additions and 165 deletions

View File

@ -219,6 +219,8 @@ void show_cs_flags(unsigned int f)
printf("0\n");
return;
}
SHOW_FLAG(f, CS_FL_ADDR_FROM_SET);
SHOW_FLAG(f, CS_FL_ADDR_TO_SET);
SHOW_FLAG(f, CS_FL_ISBACK);
if (f) {
@ -279,8 +281,6 @@ void show_si_flags(unsigned int f)
SHOW_FLAG(f, SI_FL_RXBLK_SHUT);
SHOW_FLAG(f, SI_FL_RXBLK_CONN);
SHOW_FLAG(f, SI_FL_RX_WAIT_EP);
SHOW_FLAG(f, SI_FL_ADDR_FROM_SET);
SHOW_FLAG(f, SI_FL_ADDR_TO_SET);
if (f) {
printf("EXTRA(0x%08x)", f);

View File

@ -79,6 +79,9 @@ struct stream_interface;
enum {
CS_FL_NONE = 0x00000000, /* Just for initialization purposes */
CS_FL_ISBACK = 0x00000001, /* Set for CS on back-side */
CS_FL_ADDR_FROM_SET = 0x00000002, /* source address is set */
CS_FL_ADDR_TO_SET = 0x00000004, /* destination address is set */
};
/* cs_shutr() modes */
@ -125,6 +128,8 @@ struct conn_stream {
enum obj_type *app; /* points to the applicative point (stream or check) */
struct stream_interface *si;
const struct data_cb *data_cb; /* data layer callbacks. Must be set before xprt->init() */
struct sockaddr_storage *src; /* source address (pool), when known, otherwise NULL */
struct sockaddr_storage *dst; /* destination address (pool), when known, otherwise NULL */
};

View File

@ -27,7 +27,10 @@
#include <haproxy/channel-t.h>
#include <haproxy/stream-t.h>
#include <haproxy/task-t.h>
#include <haproxy/connection.h>
#include <haproxy/conn_stream.h>
#include <haproxy/session.h>
#include <haproxy/stream.h>
/* returns the channel which receives data from this conn-stream (input channel) */
static inline struct channel *cs_ic(struct conn_stream *cs)
@ -73,4 +76,105 @@ static inline struct conn_stream *cs_opposite(struct conn_stream *cs)
}
/* Returns the source address of the conn-stream and, if not set, fallbacks on
* the session for frontend CS and the server connection for the backend CS. It
* returns a const address on success or NULL on failure.
*/
static inline const struct sockaddr_storage *cs_src(struct conn_stream *cs)
{
if (cs->flags & CS_FL_ADDR_FROM_SET)
return cs->src;
if (!(cs->flags & CS_FL_ISBACK))
return sess_src(strm_sess(__cs_strm(cs)));
else {
struct connection *conn = cs_conn(cs);
if (conn)
return conn_src(conn);
}
return NULL;
}
/* Returns the destination address of the conn-stream and, if not set, fallbacks
* on the session for frontend CS and the server connection for the backend
* CS. It returns a const address on success or NULL on failure.
*/
static inline const struct sockaddr_storage *cs_dst(struct conn_stream *cs)
{
if (cs->flags & CS_FL_ADDR_TO_SET)
return cs->dst;
if (!(cs->flags & CS_FL_ISBACK))
return sess_dst(strm_sess(__cs_strm(cs)));
else {
struct connection *conn = cs_conn(cs);
if (conn)
return conn_dst(conn);
}
return NULL;
}
/* Retrieves the source address of the conn-stream. Returns non-zero on success
* or zero on failure. The operation is only performed once and the address is
* stored in the conn-stream for future use. On the first call, the conn-stream
* source address is copied from the session one for frontend CS and the server
* connection for the backend CS.
*/
static inline int cs_get_src(struct conn_stream *cs)
{
const struct sockaddr_storage *src = NULL;
if (cs->flags & CS_FL_ADDR_FROM_SET)
return 1;
if (!(cs->flags & CS_FL_ISBACK))
src = sess_src(strm_sess(__cs_strm(cs)));
else {
struct connection *conn = cs_conn(cs);
if (conn)
src = conn_src(conn);
}
if (!src)
return 0;
if (!sockaddr_alloc(&cs->src, src, sizeof(*src)))
return 0;
cs->flags |= CS_FL_ADDR_FROM_SET;
return 1;
}
/* Retrieves the destination address of the conn-stream. Returns non-zero on
* success or zero on failure. The operation is only performed once and the
* address is stored in the conn-stream for future use. On the first call, the
* conn-stream destination address is copied from the session one for frontend
* CS and the server connection for the backend CS.
*/
static inline int cs_get_dst(struct conn_stream *cs)
{
const struct sockaddr_storage *dst = NULL;
if (cs->flags & CS_FL_ADDR_TO_SET)
return 1;
if (!(cs->flags & CS_FL_ISBACK))
dst = sess_dst(strm_sess(__cs_strm(cs)));
else {
struct connection *conn = cs_conn(cs);
if (conn)
dst = conn_dst(conn);
}
if (!dst)
return 0;
if (!sockaddr_alloc(&cs->dst, dst, sizeof(*dst)))
return 0;
cs->flags |= CS_FL_ADDR_TO_SET;
return 1;
}
#endif /* _HAPROXY_CS_UTILS_H */

View File

@ -340,7 +340,7 @@ static inline void stream_choose_redispatch(struct stream *s)
if (may_dequeue_tasks(objt_server(s->target), s->be))
process_srv_queue(objt_server(s->target));
sockaddr_free(&cs_si(s->csb)->dst);
sockaddr_free(&s->csb->dst);
s->flags &= ~(SF_DIRECT | SF_ASSIGNED | SF_ADDR_SET);
si->state = SI_ST_REQ;
} else {

View File

@ -104,10 +104,6 @@ enum {
SI_FL_RXBLK_CONN = 0x00100000, /* other side is not connected */
SI_FL_RXBLK_ANY = 0x001F0000, /* any of the RXBLK flags above */
SI_FL_RX_WAIT_EP = 0x00200000, /* stream-int waits for more data from the end point */
/* unused: 0x01000000, 0x02000000 */
SI_FL_ADDR_FROM_SET = 0x04000000, /* source address is set */
SI_FL_ADDR_TO_SET = 0x08000000 /* destination address is set */
};
/* A stream interface has 3 parts :
@ -129,8 +125,6 @@ struct stream_interface {
unsigned int flags; /* SI_FL_* */
struct conn_stream *cs; /* points to the conn-streams that owns the endpoint (connection or applet) */
struct si_ops *ops; /* general operations at the stream interface layer */
struct sockaddr_storage *src; /* source address (pool), when known, otherwise NULL */
struct sockaddr_storage *dst; /* destination address (pool), when known, otherwise NULL */
unsigned int exp; /* wake up time for connect, queue, turn-around, ... */
/* struct members below are the "remote" part, as seen from the buffer side */

View File

@ -107,8 +107,6 @@ static inline struct stream_interface *si_opposite(struct stream_interface *si)
*/
static inline int si_init(struct stream_interface *si)
{
si->src = NULL;
si->dst = NULL;
si->err_type = SI_ET_NONE;
si->exp = TICK_ETERNITY;
si->flags &= SI_FL_ISBACK;
@ -429,108 +427,6 @@ static inline const char *si_state_str(int state)
}
}
/* Returns the source address of the stream-int and, if not set, fallbacks on
* the session for frontend SI and the server connection for the backend SI. It
* returns a const address on success or NULL on failure.
*/
static inline const struct sockaddr_storage *si_src(struct stream_interface *si)
{
if (si->flags & SI_FL_ADDR_FROM_SET)
return si->src;
if (!(si->flags & SI_FL_ISBACK))
return sess_src(strm_sess(si_strm(si)));
else {
struct connection *conn = cs_conn(si->cs);
if (conn)
return conn_src(conn);
}
return NULL;
}
/* Returns the destination address of the stream-int and, if not set, fallbacks
* on the session for frontend SI and the server connection for the backend
* SI. It returns a const address on success or NULL on failure.
*/
static inline const struct sockaddr_storage *si_dst(struct stream_interface *si)
{
if (si->flags & SI_FL_ADDR_TO_SET)
return si->dst;
if (!(si->flags & SI_FL_ISBACK))
return sess_dst(strm_sess(si_strm(si)));
else {
struct connection *conn = cs_conn(si->cs);
if (conn)
return conn_dst(conn);
}
return NULL;
}
/* Retrieves the source address of the stream-int. Returns non-zero on success
* or zero on failure. The operation is only performed once and the address is
* stored in the stream-int for future use. On the first call, the stream-int
* source address is copied from the session one for frontend SI and the server
* connection for the backend SI.
*/
static inline int si_get_src(struct stream_interface *si)
{
const struct sockaddr_storage *src = NULL;
if (si->flags & SI_FL_ADDR_FROM_SET)
return 1;
if (!(si->flags & SI_FL_ISBACK))
src = sess_src(strm_sess(si_strm(si)));
else {
struct connection *conn = cs_conn(si->cs);
if (conn)
src = conn_src(conn);
}
if (!src)
return 0;
if (!sockaddr_alloc(&si->src, src, sizeof(*src)))
return 0;
si->flags |= SI_FL_ADDR_FROM_SET;
return 1;
}
/* Retrieves the destination address of the stream-int. Returns non-zero on
* success or zero on failure. The operation is only performed once and the
* address is stored in the stream-int for future use. On the first call, the
* stream-int destination address is copied from the session one for frontend SI
* and the server connection for the backend SI.
*/
static inline int si_get_dst(struct stream_interface *si)
{
const struct sockaddr_storage *dst = NULL;
if (si->flags & SI_FL_ADDR_TO_SET)
return 1;
if (!(si->flags & SI_FL_ISBACK))
dst = sess_dst(strm_sess(si_strm(si)));
else {
struct connection *conn = cs_conn(si->cs);
if (conn)
dst = conn_dst(conn);
}
if (!dst)
return 0;
if (!sockaddr_alloc(&si->dst, dst, sizeof(*dst)))
return 0;
si->flags |= SI_FL_ADDR_TO_SET;
return 1;
}
#endif /* _HAPROXY_STREAM_INTERFACE_H */
/*

View File

@ -701,7 +701,7 @@ int assign_server(struct stream *s)
const struct sockaddr_storage *src;
case BE_LB_HASH_SRC:
src = si_src(cs_si(s->csf));
src = cs_src(s->csf);
if (src && src->ss_family == AF_INET) {
srv = get_server_sh(s->be,
(void *)&((struct sockaddr_in *)src)->sin_addr,
@ -854,7 +854,7 @@ static int alloc_dst_address(struct sockaddr_storage **ss,
* locally on multiple addresses at once. Nothing is done
* for AF_UNIX addresses.
*/
dst = si_dst(cs_si(s->csf));
dst = cs_dst(s->csf);
if (dst && dst->ss_family == AF_INET) {
((struct sockaddr_in *)*ss)->sin_family = AF_INET;
((struct sockaddr_in *)*ss)->sin_addr =
@ -871,7 +871,7 @@ static int alloc_dst_address(struct sockaddr_storage **ss,
if ((srv->flags & SRV_F_MAPPORTS)) {
int base_port;
dst = si_dst(cs_si(s->csf));
dst = cs_dst(s->csf);
if (dst) {
/* First, retrieve the port from the incoming connection */
base_port = get_host_port(dst);
@ -894,7 +894,7 @@ static int alloc_dst_address(struct sockaddr_storage **ss,
return SRV_STATUS_INTERNAL;
/* in transparent mode, use the original dest addr if no dispatch specified */
dst = si_dst(cs_si(s->csf));
dst = cs_dst(s->csf);
if (dst && (dst->ss_family == AF_INET || dst->ss_family == AF_INET6))
**ss = *dst;
}
@ -1069,7 +1069,7 @@ static int alloc_bind_address(struct sockaddr_storage **ss,
case CO_SRC_TPROXY_CLI:
case CO_SRC_TPROXY_CIP:
/* FIXME: what can we do if the client connects in IPv6 or unix socket ? */
addr = si_src(cs_si(s->csf));
addr = cs_src(s->csf);
if (!addr)
return SRV_STATUS_INTERNAL;
@ -1271,7 +1271,7 @@ static int connect_server(struct stream *s)
srv = objt_server(s->target);
if (!(s->flags & SF_ADDR_SET)) {
err = alloc_dst_address(&(cs_si(s->csb)->dst), srv, s);
err = alloc_dst_address(&s->csb->dst, srv, s);
if (err != SRV_STATUS_OK)
return SF_ERR_INTERNAL;
@ -1326,7 +1326,7 @@ static int connect_server(struct stream *s)
/* 3. destination address */
if (srv && (!is_addr(&srv->addr) || srv->flags & SRV_F_MAPPORTS))
hash_params.dst_addr = cs_si(s->csb)->dst;
hash_params.dst_addr = s->csb->dst;
/* 4. source address */
hash_params.src_addr = bind_addr;
@ -1546,7 +1546,7 @@ skip_reuse:
return SF_ERR_RESOURCE;
/* copy the target address into the connection */
*srv_conn->dst = *(cs_si(s->csb))->dst;
*srv_conn->dst = *s->csb->dst;
/* Copy network namespace from client connection */
srv_conn->proxy_netns = cli_conn ? cli_conn->proxy_netns : NULL;
@ -1820,7 +1820,7 @@ int srv_redispatch_connect(struct stream *s)
if (((s->flags & (SF_DIRECT|SF_FORCE_PRST)) == SF_DIRECT) &&
(s->be->options & PR_O_REDISP)) {
s->flags &= ~(SF_DIRECT | SF_ASSIGNED | SF_ADDR_SET);
sockaddr_free(&(cs_si(s->csb)->dst));
sockaddr_free(&s->csb->dst);
goto redispatch;
}

View File

@ -2764,7 +2764,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
}
}
sockaddr_free(&(cs_si(s->csb)->dst));
sockaddr_free(&s->csb->dst);
cs_si(s->csb)->state = cs_si(s->csb)->prev_state = SI_ST_INI;
cs_si(s->csb)->err_type = SI_ET_NONE;

View File

@ -60,7 +60,8 @@ struct conn_stream *cs_new(struct cs_endpoint *endp)
cs->app = NULL;
cs->si = NULL;
cs->data_cb = NULL;
cs->src = NULL;
cs->dst = NULL;
if (!endp) {
endp = cs_endpoint_new();
if (unlikely(!endp))
@ -147,6 +148,8 @@ struct conn_stream *cs_new_from_check(struct check *check, unsigned int flags)
void cs_free(struct conn_stream *cs)
{
si_free(cs->si);
sockaddr_free(&cs->src);
sockaddr_free(&cs->dst);
if (cs->endp) {
BUG_ON(!(cs->endp->flags & CS_EP_DETACHED));
cs_endpoint_free(cs->endp);
@ -282,7 +285,8 @@ void cs_detach_app(struct conn_stream *cs)
cs->app = NULL;
cs->si = NULL;
cs->data_cb = NULL;
sockaddr_free(&cs->src);
sockaddr_free(&cs->dst);
if (!cs->endp || (cs->endp->flags & CS_EP_DETACHED))
cs_free(cs);
}

View File

@ -18,6 +18,7 @@
#include <haproxy/cfgparse.h>
#include <haproxy/connection.h>
#include <haproxy/conn_stream.h>
#include <haproxy/cs_utils.h>
#include <haproxy/fd.h>
#include <haproxy/frontend.h>
#include <haproxy/hash.h>
@ -1746,8 +1747,8 @@ static int make_proxy_line_v2(char *buf, int buf_len, struct server *srv, struct
memcpy(hdr->sig, pp2_signature, PP2_SIGNATURE_LEN);
if (strm) {
src = si_src(strm->csf->si);
dst = si_dst(strm->csf->si);
src = cs_src(strm->csf);
dst = cs_dst(strm->csf);
}
else if (remote && conn_get_src(remote) && conn_get_dst(remote)) {
src = conn_src(remote);
@ -1945,8 +1946,8 @@ int make_proxy_line(char *buf, int buf_len, struct server *srv, struct connectio
const struct sockaddr_storage *dst = NULL;
if (strm) {
src = si_src(strm->csf->si);
dst = si_dst(strm->csf->si);
src = cs_src(strm->csf);
dst = cs_dst(strm->csf);
}
else if (remote && conn_get_src(remote) && conn_get_dst(remote)) {
src = conn_src(remote);

View File

@ -915,7 +915,7 @@ static struct appctx *dns_session_create(struct dns_session *ds)
}
s = DISGUISE(cs_strm(cs));
cs_si(s->csb)->dst = addr;
s->csb->dst = addr;
cs_si(s->csb)->flags |= SI_FL_NOLINGER;
s->target = &ds->dss->srv->obj_type;
s->flags = SF_ASSIGNED|SF_ADDR_SET;

View File

@ -26,6 +26,8 @@
#include <haproxy/api.h>
#include <haproxy/arg.h>
#include <haproxy/chunk.h>
#include <haproxy/connection.h>
#include <haproxy/cs_utils.h>
#include <haproxy/fd.h>
#include <haproxy/frontend.h>
#include <haproxy/global.h>
@ -62,7 +64,7 @@ int frontend_accept(struct stream *s)
s->do_log(s);
}
else if (conn) {
src = si_src(cs_si(s->csf));
src = cs_src(s->csf);
if (!src)
send_log(fe, LOG_INFO, "Connect from unknown source to listener %d (%s/%s)\n",
l->luid, fe->id, (fe->mode == PR_MODE_HTTP) ? "HTTP" : "TCP");
@ -73,7 +75,7 @@ int frontend_accept(struct stream *s)
switch (addr_to_str(src, pn, sizeof(pn))) {
case AF_INET:
case AF_INET6:
dst = si_dst(cs_si(s->csf));
dst = cs_dst(s->csf);
if (dst) {
addr_to_str(dst, sn, sizeof(sn));
port = get_host_port(dst);
@ -113,7 +115,7 @@ int frontend_accept(struct stream *s)
}
}
src = si_src(cs_si(s->csf));
src = cs_src(s->csf);
if (!src) {
chunk_printf(&trash, "%08x:%s.accept(%04x)=%04x from [listener:%d] ALPN=%s\n",
s->uniq_id, fe->id, (unsigned short)l->rx.fd, (unsigned short)conn->handle.fd,

View File

@ -2576,7 +2576,7 @@ __LJMP static int hlua_socket_getpeername(struct lua_State *L)
}
appctx = container_of(peer, struct appctx, ctx.hlua_cosocket.xref);
cs = appctx->owner;
dst = si_dst(cs_opposite(cs)->si);
dst = cs_dst(cs_opposite(cs));
if (!dst) {
xref_unlock(&socket->xref, peer);
lua_pushnil(L);
@ -2778,7 +2778,7 @@ __LJMP static int hlua_socket_connect(struct lua_State *L)
cs = appctx->owner;
s = __cs_strm(cs);
if (!sockaddr_alloc(&cs_opposite(cs)->si->dst, addr, sizeof(*addr))) {
if (!sockaddr_alloc(&cs_opposite(cs)->dst, addr, sizeof(*addr))) {
xref_unlock(&socket->xref, peer);
WILL_LJMP(luaL_error(L, "connect: internal error"));
}

View File

@ -20,6 +20,8 @@
#include <haproxy/channel.h>
#include <haproxy/check.h>
#include <haproxy/connection.h>
#include <haproxy/conn_stream.h>
#include <haproxy/cs_utils.h>
#include <haproxy/errors.h>
#include <haproxy/filters.h>
#include <haproxy/http.h>
@ -653,7 +655,7 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
* asks for it.
*/
if ((sess->fe->options | s->be->options) & PR_O_FWDFOR) {
const struct sockaddr_storage *src = si_src(cs_si(s->csf));
const struct sockaddr_storage *src = cs_src(s->csf);
struct http_hdr_ctx ctx = { .blk = NULL };
struct ist hdr = isttest(s->be->fwdfor_hdr_name) ? s->be->fwdfor_hdr_name : sess->fe->fwdfor_hdr_name;
@ -710,7 +712,7 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
* asks for it.
*/
if ((sess->fe->options | s->be->options) & PR_O_ORGTO) {
const struct sockaddr_storage *dst = si_dst(cs_si(s->csf));
const struct sockaddr_storage *dst = cs_dst(s->csf);
struct ist hdr = isttest(s->be->orgto_hdr_name) ? s->be->orgto_hdr_name : sess->fe->orgto_hdr_name;
if (dst && dst->ss_family == AF_INET) {

View File

@ -525,7 +525,7 @@ struct appctx *httpclient_start(struct httpclient *hc)
break;
}
cs_si(s->csb)->dst = addr;
s->csb->dst = addr;
cs_si(s->csb)->flags |= SI_FL_NOLINGER;
s->flags |= SF_ASSIGNED|SF_ADDR_SET;
s->res.flags |= CF_READ_DONTWAIT;

View File

@ -23,6 +23,7 @@
#include <haproxy/channel.h>
#include <haproxy/chunk.h>
#include <haproxy/connection.h>
#include <haproxy/cs_utils.h>
#include <haproxy/global.h>
#include <haproxy/h1.h>
#include <haproxy/h1_htx.h>
@ -1186,7 +1187,7 @@ static int smp_fetch_base32(const struct arg *args, struct sample *smp, const ch
*/
static int smp_fetch_base32_src(const struct arg *args, struct sample *smp, const char *kw, void *private)
{
const struct sockaddr_storage *src = (smp->strm ? si_src(smp->strm->csf->si) : NULL);
const struct sockaddr_storage *src = (smp->strm ? cs_src(smp->strm->csf) : NULL);
struct buffer *temp;
if (!src)
@ -2053,7 +2054,7 @@ static int smp_fetch_url32(const struct arg *args, struct sample *smp, const cha
*/
static int smp_fetch_url32_src(const struct arg *args, struct sample *smp, const char *kw, void *private)
{
const struct sockaddr_storage *src = (smp->strm ? si_src(smp->strm->csf->si) : NULL);
const struct sockaddr_storage *src = (smp->strm ? cs_src(smp->strm->csf) : NULL);
struct buffer *temp;
if (!src)

View File

@ -2116,7 +2116,7 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
break;
case LOG_FMT_CLIENTIP: // %ci
addr = (s ? si_src(cs_si(s->csf)) : sess_src(sess));
addr = (s ? cs_src(s->csf) : sess_src(sess));
if (addr)
ret = lf_ip(tmplog, (struct sockaddr *)addr, dst + maxsize - tmplog, tmp);
else
@ -2129,7 +2129,7 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
break;
case LOG_FMT_CLIENTPORT: // %cp
addr = (s ? si_src(cs_si(s->csf)) : sess_src(sess));
addr = (s ? cs_src(s->csf) : sess_src(sess));
if (addr) {
/* sess->listener is always defined when the session's owner is an inbound connections */
if (addr->ss_family == AF_UNIX)
@ -2147,7 +2147,7 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
break;
case LOG_FMT_FRONTENDIP: // %fi
addr = (s ? si_dst(cs_si(s->csf)) : sess_dst(sess));
addr = (s ? cs_dst(s->csf) : sess_dst(sess));
if (addr)
ret = lf_ip(tmplog, (struct sockaddr *)addr, dst + maxsize - tmplog, tmp);
else
@ -2160,7 +2160,7 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
break;
case LOG_FMT_FRONTENDPORT: // %fp
addr = (s ? si_dst(cs_si(s->csf)) : sess_dst(sess));
addr = (s ? cs_dst(s->csf) : sess_dst(sess));
if (addr) {
/* sess->listener is always defined when the session's owner is an inbound connections */
if (addr->ss_family == AF_UNIX)

View File

@ -1235,8 +1235,8 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst
struct fcgi_strm_params *params)
{
struct connection *cli_conn = objt_conn(fstrm->sess->origin);
const struct sockaddr_storage *src = (cs_check(fstrm->cs) ? conn_src(fconn->conn) : si_src(cs_opposite(fstrm->cs)->si));
const struct sockaddr_storage *dst = (cs_check(fstrm->cs) ? conn_dst(fconn->conn) : si_dst(cs_opposite(fstrm->cs)->si));
const struct sockaddr_storage *src = (cs_check(fstrm->cs) ? conn_src(fconn->conn) : cs_src(cs_opposite(fstrm->cs)));
const struct sockaddr_storage *dst = (cs_check(fstrm->cs) ? conn_dst(fconn->conn) : cs_dst(cs_opposite(fstrm->cs)));
struct ist p;
if (!sl)

View File

@ -3209,7 +3209,7 @@ static struct appctx *peer_session_create(struct peers *peers, struct peer *peer
appctx_wakeup(appctx);
/* initiate an outgoing connection */
cs_si(s->csb)->dst = addr;
s->csb->dst = addr;
cs_si(s->csb)->flags |= SI_FL_NOLINGER;
s->flags = SF_ASSIGNED|SF_ADDR_SET;
s->target = peer_session_target(peer, s);

View File

@ -601,7 +601,7 @@ int pendconn_dequeue(struct stream *strm)
/* the entry might have been redistributed to another server */
if (!(strm->flags & SF_ADDR_SET))
sockaddr_free(&cs_si(strm->csb)->dst);
sockaddr_free(&strm->csb->dst);
if (p->target) {
/* a server picked this pendconn, it must skip LB */

View File

@ -656,7 +656,7 @@ static struct appctx *sink_forward_session_create(struct sink *sink, struct sink
}
s = DISGUISE(cs_strm(cs));
cs_si(s->csb)->dst = addr;
s->csb->dst = addr;
cs_si(s->csb)->flags |= SI_FL_NOLINGER;
s->target = &sft->srv->obj_type;

View File

@ -125,8 +125,6 @@ void si_free(struct stream_interface *si)
return;
tasklet_free(si->wait_event.tasklet);
sockaddr_free(&si->src);
sockaddr_free(&si->dst);
pool_free(pool_head_streaminterface, si);
}

View File

@ -30,6 +30,7 @@
#include <haproxy/arg.h>
#include <haproxy/channel.h>
#include <haproxy/connection.h>
#include <haproxy/cs_utils.h>
#include <haproxy/global.h>
#include <haproxy/http_rules.h>
#include <haproxy/proto_tcp.h>
@ -68,9 +69,9 @@ static enum act_return tcp_action_req_set_src(struct act_rule *rule, struct prox
case ACT_F_TCP_REQ_CNT:
case ACT_F_HTTP_REQ:
if (!si_get_src(cs_si(s->csf)))
if (!cs_get_src(s->csf))
goto end;
src = cs_si(s->csf)->src;
src = s->csf->src;
break;
default:
@ -124,9 +125,9 @@ static enum act_return tcp_action_req_set_dst(struct act_rule *rule, struct prox
case ACT_F_TCP_REQ_CNT:
case ACT_F_HTTP_REQ:
if (!si_get_dst(cs_si(s->csf)))
if (!cs_get_dst(s->csf))
goto end;
dst = cs_si(s->csf)->dst;
dst = s->csf->dst;
break;
default:
@ -181,9 +182,9 @@ static enum act_return tcp_action_req_set_src_port(struct act_rule *rule, struct
case ACT_F_TCP_REQ_CNT:
case ACT_F_HTTP_REQ:
if (!si_get_src(cs_si(s->csf)))
if (!cs_get_src(s->csf))
goto end;
src = cs_si(s->csf)->src;
src = s->csf->src;
break;
default:
@ -236,9 +237,9 @@ static enum act_return tcp_action_req_set_dst_port(struct act_rule *rule, struct
case ACT_F_TCP_REQ_CNT:
case ACT_F_HTTP_REQ:
if (!si_get_dst(cs_si(s->csf)))
if (!cs_get_dst(s->csf))
goto end;
dst = cs_si(s->csf)->dst;
dst = s->csf->dst;
break;
default:

View File

@ -33,6 +33,7 @@
#include <haproxy/api.h>
#include <haproxy/arg.h>
#include <haproxy/connection.h>
#include <haproxy/cs_utils.h>
#include <haproxy/errors.h>
#include <haproxy/global.h>
#include <haproxy/listener-t.h>
@ -65,7 +66,7 @@ smp_fetch_src(const struct arg *args, struct sample *smp, const char *kw, void *
src = conn_src(conn);
}
else /* src */
src = (smp->strm ? si_src(smp->strm->csf->si) : sess_src(smp->sess));
src = (smp->strm ? cs_src(smp->strm->csf) : sess_src(smp->sess));
if (!src)
return 0;
@ -109,7 +110,7 @@ smp_fetch_sport(const struct arg *args, struct sample *smp, const char *kw, void
src = conn_src(conn);
}
else /* src_port */
src = (smp->strm ? si_src(smp->strm->csf->si) : sess_src(smp->sess));
src = (smp->strm ? cs_src(smp->strm->csf) : sess_src(smp->sess));
if (!src)
return 0;
@ -144,7 +145,7 @@ smp_fetch_dst(const struct arg *args, struct sample *smp, const char *kw, void *
dst = conn_dst(conn);
}
else /* dst */
dst = (smp->strm ? si_dst(smp->strm->csf->si) : sess_dst(smp->sess));
dst = (smp->strm ? cs_dst(smp->strm->csf) : sess_dst(smp->sess));
if (!dst)
return 0;
@ -181,7 +182,7 @@ int smp_fetch_dst_is_local(const struct arg *args, struct sample *smp, const cha
dst = conn_dst(conn);
}
else /* dst_is_local */
dst = (smp->strm ? si_dst(smp->strm->csf->si) : sess_dst(smp->sess));
dst = (smp->strm ? cs_dst(smp->strm->csf) : sess_dst(smp->sess));
if (!dst)
return 0;
@ -207,7 +208,7 @@ int smp_fetch_src_is_local(const struct arg *args, struct sample *smp, const cha
src = conn_src(conn);
}
else /* src_is_local */
src = (smp->strm ? si_src(smp->strm->csf->si) : sess_src(smp->sess));
src = (smp->strm ? cs_src(smp->strm->csf) : sess_src(smp->sess));
if (!src)
return 0;
@ -240,7 +241,7 @@ smp_fetch_dport(const struct arg *args, struct sample *smp, const char *kw, void
dst = conn_dst(conn);
}
else /* dst_port */
dst = (smp->strm ? si_dst(smp->strm->csf->si) : sess_dst(smp->sess));
dst = (smp->strm ? cs_dst(smp->strm->csf) : sess_dst(smp->sess));
if (!dst)
return 0;