Re: [PATCH rdma-next v2 2/2] RDMA/nldev: Allow IB device rename through RDMA netlink

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 09, 2018 at 07:34:02PM +0000, Parav Pandit wrote:
>
>
> > -----Original Message-----
> > From: linux-rdma-owner@xxxxxxxxxxxxxxx <linux-rdma-
> > owner@xxxxxxxxxxxxxxx> On Behalf Of Leon Romanovsky
> > Sent: Wednesday, September 26, 2018 1:46 AM
> > To: Doug Ledford <dledford@xxxxxxxxxx>; Jason Gunthorpe
> > <jgg@xxxxxxxxxxxx>
> > Cc: Leon Romanovsky <leonro@xxxxxxxxxxxx>; RDMA mailing list <linux-
> > rdma@xxxxxxxxxxxxxxx>
> > Subject: [PATCH rdma-next v2 2/2] RDMA/nldev: Allow IB device rename
> > through RDMA netlink
> >
> > From: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> >
> > Provide an option to rename IB device name through RDMA netlink and limit
> > it to users with ADMIN capability only.
> >
> > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> > ---
> >  drivers/infiniband/core/nldev.c  | 33 +++++++++++++++++++++++++++++++++
> > include/uapi/rdma/rdma_netlink.h |  3 ++-
> >  2 files changed, 35 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
> > index ba5403fbcd88..e841725a0ee0 100644
> > --- a/drivers/infiniband/core/nldev.c
> > +++ b/drivers/infiniband/core/nldev.c
> > @@ -646,6 +646,35 @@ static int nldev_get_doit(struct sk_buff *skb, struct
> > nlmsghdr *nlh,
> >  	return err;
> >  }
> >
> > +static int nldev_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
> > +			  struct netlink_ext_ack *extack)
> > +{
> > +	struct nlattr *tb[RDMA_NLDEV_ATTR_MAX];
> > +	struct ib_device *device;
> > +	u32 index;
> > +	int err;
> > +
> > +	err = nlmsg_parse(nlh, 0, tb, RDMA_NLDEV_ATTR_MAX - 1,
> > nldev_policy,
> > +			  extack);
> > +	if (err || !tb[RDMA_NLDEV_ATTR_DEV_INDEX])
> > +		return -EINVAL;
> > +
> > +	index = nla_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]);
> > +	device = ib_device_get_by_index(index);
> > +	if (!device)
> > +		return -EINVAL;
> > +
> > +	if (tb[RDMA_NLDEV_ATTR_DEV_NAME]) {
> > +		char name[IB_DEVICE_NAME_MAX] = {};
> > +
> > +		nla_strlcpy(name, tb[RDMA_NLDEV_ATTR_DEV_NAME],
> > +			    IB_DEVICE_NAME_MAX);
> > +		return ib_device_rename(device, name);
>
> Missing call to put_device()? (counter part of ib_device_get_by_index())

You are absolutely right, I don't know why I missed it, sending new
version now.

>
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> >  static int _nldev_get_dumpit(struct ib_device *device,
> >  			     struct sk_buff *skb,
> >  			     struct netlink_callback *cb,
> > @@ -1078,6 +1107,10 @@ static const struct rdma_nl_cbs
> > nldev_cb_table[RDMA_NLDEV_NUM_OPS] = {
> >  		.doit = nldev_get_doit,
> >  		.dump = nldev_get_dumpit,
> >  	},
> > +	[RDMA_NLDEV_CMD_SET] = {
> > +		.doit = nldev_set_doit,
> > +		.flags = RDMA_NL_ADMIN_PERM,
> > +	},
> >  	[RDMA_NLDEV_CMD_PORT_GET] = {
> >  		.doit = nldev_port_get_doit,
> >  		.dump = nldev_port_get_dumpit,
> > diff --git a/include/uapi/rdma/rdma_netlink.h
> > b/include/uapi/rdma/rdma_netlink.h
> > index edba6351ac13..f9c41bf59efc 100644
> > --- a/include/uapi/rdma/rdma_netlink.h
> > +++ b/include/uapi/rdma/rdma_netlink.h
> > @@ -227,8 +227,9 @@ enum rdma_nldev_command {
> >  	RDMA_NLDEV_CMD_UNSPEC,
> >
> >  	RDMA_NLDEV_CMD_GET, /* can dump */
> > +	RDMA_NLDEV_CMD_SET,
> >
> > -	/* 2 - 4 are free to use */
> > +	/* 3 - 4 are free to use */
> >
> >  	RDMA_NLDEV_CMD_PORT_GET = 5, /* can dump */
> >
> > --
> > 2.14.4
>

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux