From: Dongli Zhang <dongli.zhang@oracle.com>
To: linux-nvme@lists.infradead.org, james.smart@broadcom.com
Cc: sagi@grimberg.me, linux-kernel@vger.kernel.org,
chaitanya.kulkarni@wdc.com, hch@lst.de
Subject: Re: [PATCH 1/1] nvme-fcloop: verify wwnn and wwpn format
Date: Wed, 3 Jun 2020 23:43:47 -0700 [thread overview]
Message-ID: <38a2cfb9-df2a-c5cb-6797-2b96ef049c7c@oracle.com> (raw)
In-Reply-To: <20200526042118.17836-1-dongli.zhang@oracle.com>
May I get feedback for this?
For the first time I use fcloop, I set:
# echo "wwnn=0x3,wwpn=0x1" > /sys/class/fcloop/ctl/add_target_port
However, I would not be able to move forward if I use "0x3" or "0x1" for nvme-fc
target or host further. Instead, the address and port should be
0x0000000000000003 and 0x0000000000000001.
This patch would sync the requirements of input format for nvme-fc and
nvme-fcloop, unless this would break existing test suite (e.g., blktest).
Thank you very much!
Dongli Zhang
On 5/25/20 9:21 PM, Dongli Zhang wrote:
> The nvme host and target verify the wwnn and wwpn format via
> nvme_fc_parse_traddr(). For instance, it is required that the length of
> wwnn to be either 21 ("nn-0x") or 19 (nn-).
>
> Add this verification to nvme-fcloop so that the input should always be in
> hex and the length of input should always be 18.
>
> Otherwise, the user may use e.g. 0x2 to create fcloop local port, while
> 0x0000000000000002 is required for nvme host and target. This makes the
> requirement of format confusing.
>
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
> ---
> drivers/nvme/target/fcloop.c | 29 +++++++++++++++++++++++------
> 1 file changed, 23 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c
> index f69ce66e2d44..14124e6d4bf2 100644
> --- a/drivers/nvme/target/fcloop.c
> +++ b/drivers/nvme/target/fcloop.c
> @@ -43,6 +43,17 @@ static const match_table_t opt_tokens = {
> { NVMF_OPT_ERR, NULL }
> };
>
> +static int fcloop_verify_addr(substring_t *s)
> +{
> + size_t blen = s->to - s->from + 1;
> +
> + if (strnlen(s->from, blen) != NVME_FC_TRADDR_HEXNAMELEN + 2 ||
> + strncmp(s->from, "0x", 2))
> + return -EINVAL;
> +
> + return 0;
> +}
> +
> static int
> fcloop_parse_options(struct fcloop_ctrl_options *opts,
> const char *buf)
> @@ -64,14 +75,16 @@ fcloop_parse_options(struct fcloop_ctrl_options *opts,
> opts->mask |= token;
> switch (token) {
> case NVMF_OPT_WWNN:
> - if (match_u64(args, &token64)) {
> + if (fcloop_verify_addr(args) ||
> + match_u64(args, &token64)) {
> ret = -EINVAL;
> goto out_free_options;
> }
> opts->wwnn = token64;
> break;
> case NVMF_OPT_WWPN:
> - if (match_u64(args, &token64)) {
> + if (fcloop_verify_addr(args) ||
> + match_u64(args, &token64)) {
> ret = -EINVAL;
> goto out_free_options;
> }
> @@ -92,14 +105,16 @@ fcloop_parse_options(struct fcloop_ctrl_options *opts,
> opts->fcaddr = token;
> break;
> case NVMF_OPT_LPWWNN:
> - if (match_u64(args, &token64)) {
> + if (fcloop_verify_addr(args) ||
> + match_u64(args, &token64)) {
> ret = -EINVAL;
> goto out_free_options;
> }
> opts->lpwwnn = token64;
> break;
> case NVMF_OPT_LPWWPN:
> - if (match_u64(args, &token64)) {
> + if (fcloop_verify_addr(args) ||
> + match_u64(args, &token64)) {
> ret = -EINVAL;
> goto out_free_options;
> }
> @@ -141,14 +156,16 @@ fcloop_parse_nm_options(struct device *dev, u64 *nname, u64 *pname,
> token = match_token(p, opt_tokens, args);
> switch (token) {
> case NVMF_OPT_WWNN:
> - if (match_u64(args, &token64)) {
> + if (fcloop_verify_addr(args) ||
> + match_u64(args, &token64)) {
> ret = -EINVAL;
> goto out_free_options;
> }
> *nname = token64;
> break;
> case NVMF_OPT_WWPN:
> - if (match_u64(args, &token64)) {
> + if (fcloop_verify_addr(args) ||
> + match_u64(args, &token64)) {
> ret = -EINVAL;
> goto out_free_options;
> }
>
next prev parent reply other threads:[~2020-06-04 6:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-26 4:21 Dongli Zhang
2020-06-04 6:43 ` Dongli Zhang [this message]
2020-06-04 6:54 ` Chaitanya Kulkarni
2020-06-04 14:03 ` Hannes Reinecke
2020-06-04 15:20 ` James Smart
2020-06-10 14:53 ` Dongli Zhang
2020-06-04 17:27 ` Sagi Grimberg
2020-06-17 8:06 ` Christoph Hellwig
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=38a2cfb9-df2a-c5cb-6797-2b96ef049c7c@oracle.com \
--to=dongli.zhang@oracle.com \
--cc=chaitanya.kulkarni@wdc.com \
--cc=hch@lst.de \
--cc=james.smart@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/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
all inboxes | Powered by JetHome®