From: Leon Romanovsky <leon@kernel.org>
To: Stephen Hemminger <stephen@networkplumber.org>,
David Ahern <dsahern@gmail.com>
Cc: Leon Romanovsky <leonro@nvidia.com>,
Doug Ledford <dledford@redhat.com>,
Jason Gunthorpe <jgg@nvidia.com>,
linux-netdev <netdev@vger.kernel.org>,
RDMA mailing list <linux-rdma@vger.kernel.org>
Subject: [PATCH iproute2-rc v1 2/2] rdma: Properly print device and link names in CLI output
Date: Tue, 11 Aug 2020 10:32:01 +0300 [thread overview]
Message-ID: <20200811073201.663398-3-leon@kernel.org> (raw)
In-Reply-To: <20200811073201.663398-1-leon@kernel.org>
From: Leon Romanovsky <leonro@nvidia.com>
The citied commit broke the CLI output and printed ifindex/ifname
instead of dev/link.
Before:
[leonro@vm ~]$ rdma res show qp
link mlx5_0/lqpn 1 type GSI state RTS sq-psn 0 comm ib_core
[leonro@vm ~]$ rdma res show cq
ifindex 0 ifname rocep0s9 cqn 0 cqe 1023 users 2 poll-ctx WORKQUEUE adaptive-moderation on comm ib_core
After:
[leonro@vm ~]$ rdma res show qp
link mlx5_0/- lqpn 1 type GSI state RTS sq-psn 0 comm [ib_core]
[leonro@vm ~]$ rdma res show cq
dev rocep0s9 cqn 0 cqe 1023 users 2 poll-ctx WORKQUEUE adaptive-moderation on comm [ib_core]
It was missed because rdmatool mostly used in JSON mode.
Fixes: b0a688a542cd ("rdma: Rewrite custom JSON and prints logic to use common API")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
rdma/res.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/rdma/res.c b/rdma/res.c
index b7a703f8..dc12bbe4 100644
--- a/rdma/res.c
+++ b/rdma/res.c
@@ -166,17 +166,27 @@ void print_comm(struct rd *rd, const char *str, struct nlattr **nla_line)
void print_dev(struct rd *rd, uint32_t idx, const char *name)
{
- print_color_int(PRINT_ANY, COLOR_NONE, "ifindex", "ifindex %d ", idx);
- print_color_string(PRINT_ANY, COLOR_NONE, "ifname", "ifname %s ", name);
+ print_color_int(PRINT_ANY, COLOR_NONE, "ifindex", NULL, idx);
+ print_color_string(PRINT_ANY, COLOR_NONE, "ifname", "dev %s ", name);
}
void print_link(struct rd *rd, uint32_t idx, const char *name, uint32_t port,
struct nlattr **nla_line)
{
+ char tmp[64] = {};
+
print_color_uint(PRINT_JSON, COLOR_NONE, "ifindex", NULL, idx);
- print_color_string(PRINT_ANY, COLOR_NONE, "ifname", "link %s/", name);
- if (nla_line[RDMA_NLDEV_ATTR_PORT_INDEX])
- print_color_uint(PRINT_ANY, COLOR_NONE, "port", "%u ", port);
+ print_color_string(PRINT_ANY, COLOR_NONE, "ifname", NULL, name);
+ if (nla_line[RDMA_NLDEV_ATTR_PORT_INDEX]) {
+ print_color_uint(PRINT_ANY, COLOR_NONE, "port", NULL, port);
+ snprintf(tmp, sizeof(tmp), "%s/%d", name, port);
+ } else {
+ snprintf(tmp, sizeof(tmp), "%s/-", name);
+ }
+
+ if (!rd->json_output)
+ print_color_string(PRINT_ANY, COLOR_NONE, NULL, "link %s ",
+ tmp);
}
void print_qp_type(struct rd *rd, uint32_t val)
--
2.26.2
next prev parent reply other threads:[~2020-08-11 7:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-11 7:31 [PATCH iproute2-rc v1 0/2] Fix rdmatool JSON conversion Leon Romanovsky
2020-08-11 7:32 ` [PATCH iproute2-rc v1 1/2] rdma: Fix owner name for the kernel resources Leon Romanovsky
2020-08-11 7:32 ` Leon Romanovsky [this message]
2020-08-16 22:48 ` [PATCH iproute2-rc v1 2/2] rdma: Properly print device and link names in CLI output Stephen Hemminger
2020-08-17 7:44 ` Leon Romanovsky
2020-08-16 7:58 ` [PATCH iproute2-rc v1 0/2] Fix rdmatool JSON conversion Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200811073201.663398-3-leon@kernel.org \
--to=leon@kernel.org \
--cc=dledford@redhat.com \
--cc=dsahern@gmail.com \
--cc=jgg@nvidia.com \
--cc=leonro@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.