From: Willy Tarreau Date: Wed, 17 Jul 2019 09:44:11 +0000 (+0200) Subject: MINOR: stream/cli: use conn_get_{src,dst} in "show sess" and "show peers" output X-Git-Tag: v2.1-dev2~323 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8dfffdb0602353c9eeecec13f24f65f8b189ba66;p=thirdparty%2Fhaproxy.git MINOR: stream/cli: use conn_get_{src,dst} in "show sess" and "show peers" output The stream outputs requires to retrieve connections sources and destinations. The previous call involving conn_get_{to,from}_addr() was missing a status check which has now been integrated with the new call since these places already handle connection errors there. The same code parts were reused for "show peers" and were modified similarly. --- diff --git a/src/peers.c b/src/peers.c index 69fed6dd26..bdaf498dc4 100644 --- a/src/peers.c +++ b/src/peers.c @@ -3128,7 +3128,7 @@ static int peers_dump_peer(struct buffer *msg, struct stream_interface *si, stru if (conn) chunk_appendf(&trash, "\n xprt=%s", conn_get_xprt_name(conn)); - switch (conn ? addr_to_str(&conn->addr.from, pn, sizeof(pn)) : AF_UNSPEC) { + switch (conn && conn_get_src(conn) ? addr_to_str(&conn->addr.from, pn, sizeof(pn)) : AF_UNSPEC) { case AF_INET: case AF_INET6: chunk_appendf(&trash, " src=%s:%d", pn, get_host_port(&conn->addr.from)); @@ -3138,10 +3138,7 @@ static int peers_dump_peer(struct buffer *msg, struct stream_interface *si, stru break; } - if (conn) - conn_get_to_addr(conn); - - switch (conn ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) { + switch (conn && conn_get_dst(conn) ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) { case AF_INET: case AF_INET6: chunk_appendf(&trash, " addr=%s:%d", pn, get_host_port(&conn->addr.to)); diff --git a/src/stream.c b/src/stream.c index e240551189..fb5555cc3b 100644 --- a/src/stream.c +++ b/src/stream.c @@ -3083,10 +3083,7 @@ static int stats_dump_full_strm_to_buffer(struct stream_interface *si, struct st strm_li(strm) ? strm_li(strm)->name ? strm_li(strm)->name : "?" : "?", strm_li(strm) ? strm_li(strm)->luid : 0); - if (conn) - conn_get_to_addr(conn); - - switch (conn ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) { + switch (conn && conn_get_dst(conn) ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) { case AF_INET: case AF_INET6: chunk_appendf(&trash, " addr=%s:%d\n", @@ -3112,10 +3109,7 @@ static int stats_dump_full_strm_to_buffer(struct stream_interface *si, struct st cs = objt_cs(strm->si[1].end); conn = cs_conn(cs); - if (conn) - conn_get_from_addr(conn); - - switch (conn ? addr_to_str(&conn->addr.from, pn, sizeof(pn)) : AF_UNSPEC) { + switch (conn && conn_get_src(conn) ? addr_to_str(&conn->addr.from, pn, sizeof(pn)) : AF_UNSPEC) { case AF_INET: case AF_INET6: chunk_appendf(&trash, " addr=%s:%d\n", @@ -3138,10 +3132,7 @@ static int stats_dump_full_strm_to_buffer(struct stream_interface *si, struct st else chunk_appendf(&trash, " server= (id=-1)"); - if (conn) - conn_get_to_addr(conn); - - switch (conn ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) { + switch (conn && conn_get_dst(conn) ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) { case AF_INET: case AF_INET6: chunk_appendf(&trash, " addr=%s:%d\n",