Re: [PATCH rdma-next] RDMA/nldev: Provide netdevice name and index

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

 



On Mon, Mar 26, 2018 at 11:19:51AM +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> 
> Export the net device name and index to easily find connection
> between IB devices and relevant net devices.
> 
> We also updated the comment regarding the devices without FW.
> 
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
>  drivers/infiniband/core/nldev.c  | 24 ++++++++++++++++++++++--
>  include/uapi/rdma/rdma_netlink.h |  4 ++++
>  2 files changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
> index 192084c78352..29d4518c3f6f 100644
> +++ b/drivers/infiniband/core/nldev.c
> @@ -95,6 +95,9 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
>  	[RDMA_NLDEV_ATTR_RES_PD_ENTRY]		= { .type = NLA_NESTED },
>  	[RDMA_NLDEV_ATTR_RES_LOCAL_DMA_LKEY]	= { .type = NLA_U32 },
>  	[RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY] = { .type = NLA_U32 },
> +	[RDMA_NLDEV_ATTR_NDEV_INDEX]		= { .type = NLA_U32 },
> +	[RDMA_NLDEV_ATTR_NDEV_NAME]		= { .type = NLA_NUL_STRING,
> +						    .len = IFNAMSIZ },
>  };
>  
>  static int fill_nldev_handle(struct sk_buff *msg, struct ib_device *device)
> @@ -123,7 +126,7 @@ static int fill_dev_info(struct sk_buff *msg, struct ib_device *device)
>  		return -EMSGSIZE;
>  
>  	ib_get_device_fw_str(device, fw);
> -	/* Device without FW has strlen(fw) */
> +	/* Device without FW has strlen(fw) = 0 */
>  	if (strlen(fw) && nla_put_string(msg, RDMA_NLDEV_ATTR_FW_VERSION, fw))
>  		return -EMSGSIZE;
>  
> @@ -141,6 +144,7 @@ static int fill_dev_info(struct sk_buff *msg, struct ib_device *device)
>  static int fill_port_info(struct sk_buff *msg,
>  			  struct ib_device *device, u32 port)
>  {
> +	struct net_device *netdev = NULL;
>  	struct ib_port_attr attr;
>  	int ret;
>  
> @@ -174,7 +178,23 @@ static int fill_port_info(struct sk_buff *msg,
>  		return -EMSGSIZE;
>  	if (nla_put_u8(msg, RDMA_NLDEV_ATTR_PORT_PHYS_STATE, attr.phys_state))
>  		return -EMSGSIZE;
> -	return 0;
> +
> +	if (device->get_netdev)
> +		netdev = device->get_netdev(device, port);
> +
> +	if (netdev) {
> +		ret = nla_put_u32(msg,
> +				  RDMA_NLDEV_ATTR_NDEV_INDEX, netdev->ifindex);
> +		if (ret)
> +			goto out;
> +		ret = nla_put_string(msg,
> +				     RDMA_NLDEV_ATTR_NDEV_NAME, netdev->name);
> +	}

Needs to interact with net namespaces.. Can't return this information
unless the netdev is visible to the current process.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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