All of lore.kernel.org
 help / color / mirror / Atom feed
From: Parav Pandit <parav@nvidia.com>
To: Loic Poulain <loic.poulain@linaro.org>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"johannes.berg@intel.com" <johannes.berg@intel.com>,
	"leon@kernel.org" <leon@kernel.org>,
	"m.chetan.kumar@intel.com" <m.chetan.kumar@intel.com>,
	Sergey Ryazanov <ryazanov.s.a@gmail.com>
Subject: RE: [PATCH net-next v2 2/3] rtnetlink: add IFLA_PARENT_[DEV|DEV_BUS]_NAME
Date: Fri, 11 Jun 2021 13:01:47 +0000	[thread overview]
Message-ID: <PH0PR12MB5481986BF646806E23909CD7DC349@PH0PR12MB5481.namprd12.prod.outlook.com> (raw)
In-Reply-To: <1623347089-28788-2-git-send-email-loic.poulain@linaro.org>



> From: Loic Poulain <loic.poulain@linaro.org>
> Sent: Thursday, June 10, 2021 11:15 PM
> 
> From: Johannes Berg <johannes.berg@intel.com>
> 
> In some cases, for example in the upcoming WWAN framework changes,
> there's no natural "parent netdev", so sometimes dummy netdevs are
> created or similar. IFLA_PARENT_DEV_NAME is a new attribute intended to
> contain a device (sysfs, struct device) name that can be used instead when
> creating a new netdev, if the rtnetlink family implements it.
> 
> As suggested by Parav Pandit, we also introduce
> IFLA_PARENT_DEV_BUS_NAME attribute in order to uniquely identify a
> device on the system (with bus/name pair).
> 
> ip-link(8) support for the generic parent device attributes will help us avoid
> code duplication, so no other link type will require a custom code to handle
> the parent name attribute. E.g. the WWAN interface creation command will
> looks like this:
> 
> $ ip link add wwan0-1 parent-dev wwan0 type wwan channel-id 1
> 
> So, some future subsystem (or driver) FOO will have an interface creation
> command that looks like this:
> 
> $ ip link add foo1-3 parent-dev foo1 type foo bar-id 3 baz-type Y
> 
> Below is an example of dumping link info of a random device with these new
> attributes:
> 
> $ ip --details link show wlp0s20f3
>   4: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
> noqueue
>      state UP mode DORMANT group default qlen 1000
>      ...
>      parent_devname 0000:00:14.3 parent_busname pci

Showing bus first followed device is more preferred approach to see hierarchy.
Please change their sequence.

You should drop "name" suffix.
"parent_bus" and "parent_dev" are just fine.

> 
> Co-developed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
> Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
> Co-developed-by: Loic Poulain <loic.poulain@linaro.org>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> Suggested-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
>  v2: - Squashed Johannes and Sergey changes
>      - Added IFLA_PARENT_DEV_BUS_NAME attribute
>      - reworded commit message + introduce Sergey's comment
> 
>  include/uapi/linux/if_link.h |  7 +++++++
>  net/core/rtnetlink.c         | 12 ++++++++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index
> a5a7f0e..4882e81 100644
> --- a/include/uapi/linux/if_link.h
> +++ b/include/uapi/linux/if_link.h
> @@ -341,6 +341,13 @@ enum {
>  	IFLA_ALT_IFNAME, /* Alternative ifname */
>  	IFLA_PERM_ADDRESS,
>  	IFLA_PROTO_DOWN_REASON,
> +
> +	/* device (sysfs) name as parent, used instead
> +	 * of IFLA_LINK where there's no parent netdev
> +	 */
> +	IFLA_PARENT_DEV_NAME,
> +	IFLA_PARENT_DEV_BUS_NAME,
> +
>  	__IFLA_MAX
>  };
> 
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 92c3e43..32599f3
> 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -1821,6 +1821,16 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
>  	if (rtnl_fill_prop_list(skb, dev))
>  		goto nla_put_failure;
> 
> +	if (dev->dev.parent &&
> +	    nla_put_string(skb, IFLA_PARENT_DEV_NAME,
> +			   dev_name(dev->dev.parent)))
> +		goto nla_put_failure;
> +
> +	if (dev->dev.parent && dev->dev.parent->bus &&
> +	    nla_put_string(skb, IFLA_PARENT_DEV_BUS_NAME,
> +			   dev->dev.parent->bus->name))
> +		goto nla_put_failure;
> +
>  	nlmsg_end(skb, nlh);
>  	return 0;
> 
> @@ -1880,6 +1890,8 @@ static const struct nla_policy
> ifla_policy[IFLA_MAX+1] = {
>  	[IFLA_PERM_ADDRESS]	= { .type = NLA_REJECT },
>  	[IFLA_PROTO_DOWN_REASON] = { .type = NLA_NESTED },
>  	[IFLA_NEW_IFINDEX]	= NLA_POLICY_MIN(NLA_S32, 1),
> +	[IFLA_PARENT_DEV_NAME]	= { .type = NLA_NUL_STRING },
> +	[IFLA_PARENT_DEV_BUS_NAME] = { .type = NLA_NUL_STRING },
>  };
> 
This hunk should go in the patch that enables users to use these fields to specify it for new link creation.

  reply	other threads:[~2021-06-11 13:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-10 17:44 [PATCH net-next v2 1/3] rtnetlink: add alloc() method to rtnl_link_ops Loic Poulain
2021-06-10 17:44 ` [PATCH net-next v2 2/3] rtnetlink: add IFLA_PARENT_[DEV|DEV_BUS]_NAME Loic Poulain
2021-06-11 13:01   ` Parav Pandit [this message]
2021-06-11 15:07     ` Loic Poulain
2021-06-11 15:43       ` Parav Pandit
2021-06-11 15:46     ` Loic Poulain
2021-06-11 16:00       ` Parav Pandit
2021-06-11 16:12         ` Loic Poulain
2021-06-10 17:44 ` [PATCH net-next v2 3/3] wwan: add interface creation support Loic Poulain
2021-06-11 12:47   ` Parav Pandit

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=PH0PR12MB5481986BF646806E23909CD7DC349@PH0PR12MB5481.namprd12.prod.outlook.com \
    --to=parav@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=johannes.berg@intel.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=loic.poulain@linaro.org \
    --cc=m.chetan.kumar@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=ryazanov.s.a@gmail.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.