Message ID | 1623347089-28788-2-git-send-email-loic.poulain@linaro.org (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next,v2,1/3] rtnetlink: add alloc() method to rtnl_link_ops | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | warning | Series does not have a cover letter |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 5 maintainers not CCed: laniel_francis@privacyrequired.com zhudi21@huawei.com cong.wang@bytedance.com avagin@gmail.com roopa@cumulusnetworks.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 5073 this patch: 5073 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 37 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 5135 this patch: 5135 |
netdev/header_inline | success | Link |
> 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.
Hi Parav, On Fri, 11 Jun 2021 at 15:01, Parav Pandit <parav@nvidia.com> wrote: > > > > > 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. Do you think it can also be dropped for the IFLA symbol (IFLA_PARENT_DEV && IFLA_PARENT_BUS_NAME). > > > > > 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. ack. Thx, Loic
> From: Loic Poulain <loic.poulain@linaro.org> > Sent: Friday, June 11, 2021 8:37 PM > > Hi Parav, > > On Fri, 11 Jun 2021 at 15:01, Parav Pandit <parav@nvidia.com> wrote: > > > > > > > > > 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. > > Do you think it can also be dropped for the IFLA symbol (IFLA_PARENT_DEV > && IFLA_PARENT_BUS_NAME). IFLA symbol with _NAME is fine as it covers what the field is.
Hi Parav, On Fri, 11 Jun 2021 at 15:01, Parav Pandit <parav@nvidia.com> wrote: > > > > > 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). [...] > > 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. Don't get it, the previous changes I see in the tree change both if_link.h and rtnetlink.c for new atributes (e.g. f74877a5457d). Can you elaborate on what you expect here? Thanks, Loic
> From: Loic Poulain <loic.poulain@linaro.org> > Sent: Friday, June 11, 2021 9:16 PM > > Hi Parav, > > On Fri, 11 Jun 2021 at 15:01, Parav Pandit <parav@nvidia.com> wrote: > > > > > > > > > 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). > > [...] > > > > 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. > > Don't get it, the previous changes I see in the tree change both if_link.h and > rtnetlink.c for new atributes (e.g. f74877a5457d). Can you elaborate on what > you expect here? > Commit f74877a5457d did in same patch because one of the objective of commit f74877a5457d is to also block PERM_ADDR using policy NLA_REJECT. This patch-2 is not enabling user to pass these params via new_link command. It is done in a later patch. So ifla_policy doesn’t need to have these fields in this patch.
On Fri, 11 Jun 2021 at 18:00, Parav Pandit <parav@nvidia.com> wrote: > > > > > From: Loic Poulain <loic.poulain@linaro.org> > > Sent: Friday, June 11, 2021 9:16 PM > > > > Hi Parav, > > > > On Fri, 11 Jun 2021 at 15:01, Parav Pandit <parav@nvidia.com> wrote: > > > > > > > > > > > > > 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). > > > > [...] > > > > > > 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. > > > > Don't get it, the previous changes I see in the tree change both if_link.h and > > rtnetlink.c for new atributes (e.g. f74877a5457d). Can you elaborate on what > > you expect here? > > > Commit f74877a5457d did in same patch because one of the objective of commit f74877a5457d is to also block PERM_ADDR using policy NLA_REJECT. > This patch-2 is not enabling user to pass these params via new_link command. > It is done in a later patch. So ifla_policy doesn’t need to have these fields in this patch. Understood, thanks. Loic
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 }, }; static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {