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.
This commit is contained in:
Willy Tarreau 2019-07-17 11:44:11 +02:00
parent 7bb447c3dd
commit 8dfffdb060
2 changed files with 5 additions and 17 deletions

View File

@ -3128,7 +3128,7 @@ static int peers_dump_peer(struct buffer *msg, struct stream_interface *si, stru
if (conn) if (conn)
chunk_appendf(&trash, "\n xprt=%s", conn_get_xprt_name(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_INET:
case AF_INET6: case AF_INET6:
chunk_appendf(&trash, " src=%s:%d", pn, get_host_port(&conn->addr.from)); 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; break;
} }
if (conn) switch (conn && conn_get_dst(conn) ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) {
conn_get_to_addr(conn);
switch (conn ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) {
case AF_INET: case AF_INET:
case AF_INET6: case AF_INET6:
chunk_appendf(&trash, " addr=%s:%d", pn, get_host_port(&conn->addr.to)); chunk_appendf(&trash, " addr=%s:%d", pn, get_host_port(&conn->addr.to));

View File

@ -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)->name ? strm_li(strm)->name : "?" : "?",
strm_li(strm) ? strm_li(strm)->luid : 0); strm_li(strm) ? strm_li(strm)->luid : 0);
if (conn) switch (conn && conn_get_dst(conn) ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) {
conn_get_to_addr(conn);
switch (conn ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) {
case AF_INET: case AF_INET:
case AF_INET6: case AF_INET6:
chunk_appendf(&trash, " addr=%s:%d\n", 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); cs = objt_cs(strm->si[1].end);
conn = cs_conn(cs); conn = cs_conn(cs);
if (conn) switch (conn && conn_get_src(conn) ? addr_to_str(&conn->addr.from, pn, sizeof(pn)) : AF_UNSPEC) {
conn_get_from_addr(conn);
switch (conn ? addr_to_str(&conn->addr.from, pn, sizeof(pn)) : AF_UNSPEC) {
case AF_INET: case AF_INET:
case AF_INET6: case AF_INET6:
chunk_appendf(&trash, " addr=%s:%d\n", 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 else
chunk_appendf(&trash, " server=<NONE> (id=-1)"); chunk_appendf(&trash, " server=<NONE> (id=-1)");
if (conn) switch (conn && conn_get_dst(conn) ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) {
conn_get_to_addr(conn);
switch (conn ? addr_to_str(&conn->addr.to, pn, sizeof(pn)) : AF_UNSPEC) {
case AF_INET: case AF_INET:
case AF_INET6: case AF_INET6:
chunk_appendf(&trash, " addr=%s:%d\n", chunk_appendf(&trash, " addr=%s:%d\n",