From: Leon Romanovsky <leon@kernel.org>
To: oulijun <oulijun@huawei.com>
Cc: David Ahern <dsahern@gmail.com>,
Steve Wise <swise@opengridcomputing.com>,
netdev <netdev@vger.kernel.org>,
RDMA mailing list <linux-rdma@vger.kernel.org>,
Stephen Hemminger <stephen@networkplumber.org>
Subject: Re: [PATCH iproute2-next] rdma: Add the prefix for driver attributes
Date: Wed, 27 Feb 2019 13:38:07 +0200 [thread overview]
Message-ID: <20190227113807.GC15253@mtr-leonro.mtl.com> (raw)
In-Reply-To: <d6d1bd56-5def-aa25-4845-e41d2ea5d667@huawei.com>
[-- Attachment #1: Type: text/plain, Size: 2899 bytes --]
On Wed, Feb 27, 2019 at 07:30:34PM +0800, oulijun wrote:
> 在 2019/2/27 14:41, Leon Romanovsky 写道:
> > From: Leon Romanovsky <leonro@mellanox.com>
> >
> > There is a need to distinguish between driver vs. general exposed
> > attributes. The most common use case is to expose some internal
> > garbage under extremely common and sexy name, e.g. pi, ci e.t.c
> >
> > In order to achieve that, we will add "drv_" prefix to all strings
> > which were received through RDMA_NLDEV_ATTR_DRIVER_* attributes.
> >
> > Signed-off-by: Leon Romanovsky <leonro@mellanox.com>a
> > ---
> > rdma/utils.c | 34 ++++++++++++++++++++++------------
> > 1 file changed, 22 insertions(+), 12 deletions(-)
> >
> > diff --git a/rdma/utils.c b/rdma/utils.c
> > index 6bc14cd5..1f6bf330 100644
> > --- a/rdma/utils.c
> > +++ b/rdma/utils.c
> > @@ -829,27 +829,37 @@ static int print_driver_entry(struct rd *rd, struct nlattr *key_attr,
> > struct nlattr *val_attr,
> > enum rdma_nldev_print_type print_type)
> > {
> > - const char *key_str = mnl_attr_get_str(key_attr);
> > int attr_type = nla_type(val_attr);
> > + int ret = -EINVAL;
> > + char *key_str;
> > +
> > + if (asprintf(&key_str, "drv_%s", mnl_attr_get_str(key_attr)) == -1)
> > + return -ENOMEM;
> >
> > switch (attr_type) {
> > case RDMA_NLDEV_ATTR_DRIVER_STRING:
> > - return print_driver_string(rd, key_str,
> > - mnl_attr_get_str(val_attr));
> > + ret = print_driver_string(rd, key_str,
> > + mnl_attr_get_str(val_attr));
> > + break;
> > case RDMA_NLDEV_ATTR_DRIVER_S32:
> > - return print_driver_s32(rd, key_str,
> > - mnl_attr_get_u32(val_attr), print_type);
> > + ret = print_driver_s32(rd, key_str, mnl_attr_get_u32(val_attr),
> > + print_type);
> > + break;
> > case RDMA_NLDEV_ATTR_DRIVER_U32:
> > - return print_driver_u32(rd, key_str,
> > - mnl_attr_get_u32(val_attr), print_type);
> > + ret = print_driver_u32(rd, key_str, mnl_attr_get_u32(val_attr),
> > + print_type);
> > + break;
> > case RDMA_NLDEV_ATTR_DRIVER_S64:
> > - return print_driver_s64(rd, key_str,
> > - mnl_attr_get_u64(val_attr), print_type);
> > + ret = print_driver_s64(rd, key_str, mnl_attr_get_u64(val_attr),
> > + print_type);
> > + break;
> > case RDMA_NLDEV_ATTR_DRIVER_U64:
> > - return print_driver_u64(rd, key_str,
> > - mnl_attr_get_u64(val_attr), print_type);
> > + ret = print_driver_u64(rd, key_str, mnl_attr_get_u64(val_attr),
> > + print_type);
> > + break;
> > }
> > - return -EINVAL;
> > + free(key_str);
> > + return ret;
> > }
> >
> > void print_driver_table(struct rd *rd, struct nlattr *tb)
> > --
> > 2.19.1
> >
> >
> > .
> >
> This is fine to me and the implementation is more simple.
>
> Tested-by: Lijun Ou <oulijun@huawei.com>
Thanks a lot.
>
> thanks.
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
next prev parent reply other threads:[~2019-02-27 11:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-27 6:41 [PATCH iproute2-next] rdma: Add the prefix for driver attributes Leon Romanovsky
2019-02-27 6:41 ` Leon Romanovsky
[not found] ` <d6d1bd56-5def-aa25-4845-e41d2ea5d667@huawei.com>
2019-02-27 11:38 ` Leon Romanovsky [this message]
2019-02-27 16:26 ` David Ahern
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=20190227113807.GC15253@mtr-leonro.mtl.com \
--to=leon@kernel.org \
--cc=dsahern@gmail.com \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oulijun@huawei.com \
--cc=stephen@networkplumber.org \
--cc=swise@opengridcomputing.com \
/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.