netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: Leon Romanovsky <leonro@mellanox.com>,
	netdev <netdev@vger.kernel.org>, David Ahern <dsahern@gmail.com>,
	Mark Zhang <markz@mellanox.com>,
	RDMA mailing list <linux-rdma@vger.kernel.org>
Subject: [PATCH iproute2-rc v1 4/7] rdma: Make get_port_from_argv() returns valid port in strict port mode
Date: Wed, 17 Jul 2019 17:31:53 +0300	[thread overview]
Message-ID: <20190717143157.27205-5-leon@kernel.org> (raw)
In-Reply-To: <20190717143157.27205-1-leon@kernel.org>

From: Mark Zhang <markz@mellanox.com>

When strict_port is set, make get_port_from_argv() returns failure if
no valid port is specified.

Signed-off-by: Mark Zhang <markz@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 rdma/utils.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/rdma/utils.c b/rdma/utils.c
index aed1a3d0..95b669f3 100644
--- a/rdma/utils.c
+++ b/rdma/utils.c
@@ -56,7 +56,7 @@ bool rd_no_arg(struct rd *rd)
  * mlx5_1/1    | 1          | false
  * mlx5_1/-    | 0          | false
  *
- * In strict mode, /- will return error.
+ * In strict port mode, a non-0 port must be provided
  */
 static int get_port_from_argv(struct rd *rd, uint32_t *port,
 			      bool *is_dump_all, bool strict_port)
@@ -64,7 +64,7 @@ static int get_port_from_argv(struct rd *rd, uint32_t *port,
 	char *slash;
 
 	*port = 0;
-	*is_dump_all = true;
+	*is_dump_all = strict_port ? false : true;
 
 	slash = strchr(rd_argv(rd), '/');
 	/* if no port found, return 0 */
@@ -83,6 +83,9 @@ static int get_port_from_argv(struct rd *rd, uint32_t *port,
 		if (!*port && strlen(slash))
 			return -EINVAL;
 	}
+	if (strict_port && (*port == 0))
+		return -EINVAL;
+
 	return 0;
 }
 
-- 
2.20.1


  parent reply	other threads:[~2019-07-17 14:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-17 14:31 [PATCH iproute2-rc v1 0/7] Statistics counter support Leon Romanovsky
2019-07-17 14:31 ` [PATCH iproute2-rc v1 1/7] rdma: Add "stat qp show" support Leon Romanovsky
2019-07-17 14:31 ` [PATCH iproute2-rc v1 2/7] rdma: Add get per-port counter mode support Leon Romanovsky
2019-07-17 14:31 ` [PATCH iproute2-rc v1 3/7] rdma: Add rdma statistic counter per-port auto " Leon Romanovsky
2019-07-17 14:31 ` Leon Romanovsky [this message]
2019-07-17 14:31 ` [PATCH iproute2-rc v1 5/7] rdma: Add stat manual " Leon Romanovsky
2019-07-17 14:31 ` [PATCH iproute2-rc v1 6/7] rdma: Add default counter show support Leon Romanovsky
2019-07-17 14:31 ` [PATCH iproute2-rc v1 7/7] rdma: Document counter statistic Leon Romanovsky
2019-07-19 17:53 ` [PATCH iproute2-rc v1 0/7] Statistics counter support Stephen Hemminger

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=20190717143157.27205-5-leon@kernel.org \
    --to=leon@kernel.org \
    --cc=dsahern@gmail.com \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=markz@mellanox.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).