MINOR: stream: Use backend stream-interface dst address instead of target_addr

target_addr field in the stream structure is removed. The backend
stream-interface destination address is now used.
This commit is contained in:
Christopher Faulet 2021-10-27 09:34:56 +02:00
parent e1f3b547a1
commit 16f16afb31
9 changed files with 14 additions and 18 deletions

View File

@ -153,7 +153,6 @@ struct stream {
struct stktable *table;
} store[8]; /* tracked stickiness values to store */
struct sockaddr_storage *target_addr; /* the address to join if not null */
struct stkctr stkctr[MAX_SESS_STKCTR]; /* content-aware stick counters */
struct strm_flt strm_flt; /* current state of filters active on this stream */

View File

@ -1267,7 +1267,7 @@ int connect_server(struct stream *s)
srv = objt_server(s->target);
if (!(s->flags & SF_ADDR_SET)) {
err = alloc_dst_address(&s->target_addr, srv, s);
err = alloc_dst_address(&s->si[1].dst, srv, s);
if (err != SRV_STATUS_OK)
return SF_ERR_INTERNAL;
@ -1312,7 +1312,7 @@ int connect_server(struct stream *s)
/* 3. destination address */
if (srv && (!is_addr(&srv->addr) || srv->flags & SRV_F_MAPPORTS))
hash_params.dst_addr = s->target_addr;
hash_params.dst_addr = s->si[1].dst;
/* 4. source address */
hash_params.src_addr = bind_addr;
@ -1534,7 +1534,7 @@ skip_reuse:
return SF_ERR_RESOURCE;
/* copy the target address into the connection */
*srv_conn->dst = *s->target_addr;
*srv_conn->dst = *s->si[1].dst;
/* Copy network namespace from client connection */
srv_conn->proxy_netns = cli_conn ? cli_conn->proxy_netns : NULL;
@ -1783,7 +1783,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(&s->target_addr);
sockaddr_free(&s->si[1].dst);
goto redispatch;
}

View File

@ -2572,7 +2572,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
s->srv_conn = NULL;
}
sockaddr_free(&s->target_addr);
sockaddr_free(&s->si[1].dst);
s->si[1].state = s->si[1].prev_state = SI_ST_INI;
s->si[1].err_type = SI_ET_NONE;

View File

@ -909,7 +909,7 @@ static struct appctx *dns_session_create(struct dns_session *ds)
s->target = &ds->dss->srv->obj_type;
if (!sockaddr_alloc(&s->target_addr, &ds->dss->srv->addr, sizeof(ds->dss->srv->addr)))
if (!sockaddr_alloc(&s->si[1].dst, &ds->dss->srv->addr, sizeof(ds->dss->srv->addr)))
goto out_free_strm;
s->flags = SF_ASSIGNED|SF_ADDR_SET;
s->si[1].flags |= SI_FL_NOLINGER;

View File

@ -2553,7 +2553,7 @@ __LJMP static int hlua_socket_getpeername(struct lua_State *L)
struct xref *peer;
struct appctx *appctx;
struct stream_interface *si;
struct stream *s;
const struct sockaddr_storage *dst;
int ret;
MAY_LJMP(check_args(L, 1, "getpeername"));
@ -2574,15 +2574,14 @@ __LJMP static int hlua_socket_getpeername(struct lua_State *L)
}
appctx = container_of(peer, struct appctx, ctx.hlua_cosocket.xref);
si = appctx->owner;
s = si_strm(si);
if (!s->target_addr) {
dst = si_dst(si_opposite(si));
if (!dst) {
xref_unlock(&socket->xref, peer);
lua_pushnil(L);
return 1;
}
ret = MAY_LJMP(hlua_socket_info(L, s->target_addr));
ret = MAY_LJMP(hlua_socket_info(L, dst));
xref_unlock(&socket->xref, peer);
return ret;
}
@ -2781,7 +2780,7 @@ __LJMP static int hlua_socket_connect(struct lua_State *L)
si = appctx->owner;
s = si_strm(si);
if (!sockaddr_alloc(&s->target_addr, addr, sizeof(*addr))) {
if (!sockaddr_alloc(&si_opposite(si)->dst, addr, sizeof(*addr))) {
xref_unlock(&socket->xref, peer);
WILL_LJMP(luaL_error(L, "connect: internal error"));
}

View File

@ -372,7 +372,7 @@ struct appctx *httpclient_start(struct httpclient *hc)
goto out_free_appctx;
}
if (!sockaddr_alloc(&s->target_addr, &hc->dst, sizeof(hc->dst))) {
if (!sockaddr_alloc(&s->si[1].dst, &hc->dst, sizeof(hc->dst))) {
ha_alert("httpclient: Failed to initialize stream in %s:%d.\n", __FUNCTION__, __LINE__);
goto out_free_stream;
}

View File

@ -3215,7 +3215,7 @@ static struct appctx *peer_session_create(struct peers *peers, struct peer *peer
/* initiate an outgoing connection */
s->target = peer_session_target(peer, s);
if (!sockaddr_alloc(&s->target_addr, &peer->addr, sizeof(peer->addr)))
if (!sockaddr_alloc(&s->si[1].dst, &peer->addr, sizeof(peer->addr)))
goto out_free_strm;
s->flags = SF_ASSIGNED|SF_ADDR_SET;
s->si[1].flags |= SI_FL_NOLINGER;

View File

@ -661,7 +661,7 @@ static struct appctx *sink_forward_session_create(struct sink *sink, struct sink
s->target = &sft->srv->obj_type;
if (!sockaddr_alloc(&s->target_addr, &sft->srv->addr, sizeof(sft->srv->addr)))
if (!sockaddr_alloc(&s->si[1].dst, &sft->srv->addr, sizeof(sft->srv->addr)))
goto out_free_strm;
s->flags = SF_ASSIGNED|SF_ADDR_SET;
s->si[1].flags |= SI_FL_NOLINGER;

View File

@ -491,7 +491,6 @@ struct stream *stream_new(struct session *sess, enum obj_type *origin, struct bu
stream_init_srv_conn(s);
s->target = sess->listener ? sess->listener->default_target : NULL;
s->target_addr = NULL;
s->pend_pos = NULL;
s->priority_class = 0;
@ -743,7 +742,6 @@ static void stream_free(struct stream *s)
session_free(sess);
}
sockaddr_free(&s->target_addr);
sockaddr_free(&s->si[0].src);
sockaddr_free(&s->si[0].dst);
sockaddr_free(&s->si[1].src);