All of lore.kernel.org
 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 5/8] rdma: Make get_port_from_argv() returns valid port in strict port mode
Date: Wed, 10 Jul 2019 10:24:52 +0300	[thread overview]
Message-ID: <20190710072455.9125-6-leon@kernel.org> (raw)
In-Reply-To: <20190710072455.9125-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-10  7:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-10  7:24 [PATCH iproute2-rc 0/8] Statistics counter support Leon Romanovsky
2019-07-10  7:24 ` [PATCH iproute2-rc 1/8] rdma: Update uapi headers to add statistic " Leon Romanovsky
2019-07-15 20:52   ` Stephen Hemminger
2019-07-16  6:54     ` Leon Romanovsky
2019-07-10  7:24 ` [PATCH iproute2-rc 2/8] rdma: Add "stat qp show" support Leon Romanovsky
2019-07-16 19:01   ` Stephen Hemminger
2019-07-17 14:23     ` Leon Romanovsky
2019-07-10  7:24 ` [PATCH iproute2-rc 3/8] rdma: Add get per-port counter mode support Leon Romanovsky
2019-07-10  7:24 ` [PATCH iproute2-rc 4/8] rdma: Add rdma statistic counter per-port auto " Leon Romanovsky
2019-07-10  7:24 ` Leon Romanovsky [this message]
2019-07-10  7:24 ` [PATCH iproute2-rc 6/8] rdma: Add stat manual " Leon Romanovsky
2019-07-10  7:24 ` [PATCH iproute2-rc 7/8] rdma: Add default counter show support Leon Romanovsky
2019-07-10  7:24 ` [PATCH iproute2-rc 8/8] rdma: Document counter statistic Leon Romanovsky
2019-07-16  8:19   ` Gal Pressman
2019-07-16 12:19     ` 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=20190710072455.9125-6-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 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.