* [PATCH] rtnetlink: expose value from SET_NETDEV_DEVTYPE via IFLA_DEVTYPE attribute @ 2018-08-28 20:58 Marcel Holtmann 2018-08-29 7:18 ` Jiri Pirko 0 siblings, 1 reply; 9+ messages in thread From: Marcel Holtmann @ 2018-08-28 20:58 UTC (permalink / raw) To: netdev, davem The name value from SET_NETDEV_DEVTYPE only ended up in the uevent sysfs file as DEVTYPE= information. To avoid any kind of race conditions between netlink messages and reading from sysfs, it is useful to add the same string as new IFLA_DEVTYPE attribute included in the RTM_NEWLINK messages. For network managing daemons that have to classify ARPHRD_ETHER network devices into different types (like Wireless LAN, Bluetooth etc.), this avoids the extra round trip to sysfs and parsing of the uevent file. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> --- include/uapi/linux/if_link.h | 2 ++ net/core/rtnetlink.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index 43391e2d1153..781294972bb4 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -166,6 +166,8 @@ enum { IFLA_NEW_IFINDEX, IFLA_MIN_MTU, IFLA_MAX_MTU, + IFLA_DEVTYPE, /* Name value from SET_NETDEV_DEVTYPE */ +#define IFLA_DEVTYPE IFLA_DEVTYPE __IFLA_MAX }; diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 24431e578310..bd288710f9bf 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -970,6 +970,14 @@ static size_t rtnl_xdp_size(void) return xdp_size; } +static size_t rtnl_devtype_size(const struct net_device *dev) +{ + if (!dev->dev.type || !dev->dev.type->name) + return 0; + + return strlen(dev->dev.type->name) + 1; +} + static noinline size_t if_nlmsg_size(const struct net_device *dev, u32 ext_filter_mask) { @@ -1017,6 +1025,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, + nla_total_size(4) /* IFLA_CARRIER_DOWN_COUNT */ + nla_total_size(4) /* IFLA_MIN_MTU */ + nla_total_size(4) /* IFLA_MAX_MTU */ + + rtnl_devtype_size(dev) /* IFLA_DEVTYPE */ + 0; } @@ -1679,6 +1688,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, nla_put_s32(skb, IFLA_NEW_IFINDEX, new_ifindex) < 0) goto nla_put_failure; + if (dev->dev.type && dev->dev.type->name) + nla_put_string(skb, IFLA_DEVTYPE, dev->dev.type->name); rcu_read_lock(); if (rtnl_fill_link_af(skb, dev, ext_filter_mask)) @@ -1738,6 +1749,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { [IFLA_CARRIER_DOWN_COUNT] = { .type = NLA_U32 }, [IFLA_MIN_MTU] = { .type = NLA_U32 }, [IFLA_MAX_MTU] = { .type = NLA_U32 }, + [IFLA_DEVTYPE] = { .type = NLA_STRING }, }; static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { -- 2.14.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] rtnetlink: expose value from SET_NETDEV_DEVTYPE via IFLA_DEVTYPE attribute 2018-08-28 20:58 [PATCH] rtnetlink: expose value from SET_NETDEV_DEVTYPE via IFLA_DEVTYPE attribute Marcel Holtmann @ 2018-08-29 7:18 ` Jiri Pirko 2018-08-29 15:23 ` Marcel Holtmann 2018-08-29 15:24 ` Stephen Hemminger 0 siblings, 2 replies; 9+ messages in thread From: Jiri Pirko @ 2018-08-29 7:18 UTC (permalink / raw) To: Marcel Holtmann; +Cc: netdev, davem Tue, Aug 28, 2018 at 10:58:11PM CEST, marcel@holtmann.org wrote: >The name value from SET_NETDEV_DEVTYPE only ended up in the uevent sysfs >file as DEVTYPE= information. To avoid any kind of race conditions >between netlink messages and reading from sysfs, it is useful to add the >same string as new IFLA_DEVTYPE attribute included in the RTM_NEWLINK >messages. > >For network managing daemons that have to classify ARPHRD_ETHER network >devices into different types (like Wireless LAN, Bluetooth etc.), this >avoids the extra round trip to sysfs and parsing of the uevent file. > >Signed-off-by: Marcel Holtmann <marcel@holtmann.org> >--- > include/uapi/linux/if_link.h | 2 ++ > net/core/rtnetlink.c | 12 ++++++++++++ > 2 files changed, 14 insertions(+) > >diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h >index 43391e2d1153..781294972bb4 100644 >--- a/include/uapi/linux/if_link.h >+++ b/include/uapi/linux/if_link.h >@@ -166,6 +166,8 @@ enum { > IFLA_NEW_IFINDEX, > IFLA_MIN_MTU, > IFLA_MAX_MTU, >+ IFLA_DEVTYPE, /* Name value from SET_NETDEV_DEVTYPE */ This is not something netdev-related. dev->dev.type is struct device_type. This is a generic "device" thing. Incorrect to expose over netdev-specific API. Please use "device" API for this. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] rtnetlink: expose value from SET_NETDEV_DEVTYPE via IFLA_DEVTYPE attribute 2018-08-29 7:18 ` Jiri Pirko @ 2018-08-29 15:23 ` Marcel Holtmann 2018-08-30 5:12 ` Jiri Pirko 2018-08-29 15:24 ` Stephen Hemminger 1 sibling, 1 reply; 9+ messages in thread From: Marcel Holtmann @ 2018-08-29 15:23 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, David S. Miller Hi Jiri, >> The name value from SET_NETDEV_DEVTYPE only ended up in the uevent sysfs >> file as DEVTYPE= information. To avoid any kind of race conditions >> between netlink messages and reading from sysfs, it is useful to add the >> same string as new IFLA_DEVTYPE attribute included in the RTM_NEWLINK >> messages. >> >> For network managing daemons that have to classify ARPHRD_ETHER network >> devices into different types (like Wireless LAN, Bluetooth etc.), this >> avoids the extra round trip to sysfs and parsing of the uevent file. >> >> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> >> --- >> include/uapi/linux/if_link.h | 2 ++ >> net/core/rtnetlink.c | 12 ++++++++++++ >> 2 files changed, 14 insertions(+) >> >> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h >> index 43391e2d1153..781294972bb4 100644 >> --- a/include/uapi/linux/if_link.h >> +++ b/include/uapi/linux/if_link.h >> @@ -166,6 +166,8 @@ enum { >> IFLA_NEW_IFINDEX, >> IFLA_MIN_MTU, >> IFLA_MAX_MTU, >> + IFLA_DEVTYPE, /* Name value from SET_NETDEV_DEVTYPE */ > > This is not something netdev-related. dev->dev.type is struct device_type. > This is a generic "device" thing. Incorrect to expose over > netdev-specific API. Please use "device" API for this. it is not just "device" related since this is a sub-classification of ARPHRD_ETHER type as a wrote above. Don't get hang up that this information is part of struct device. The dev->dev.type contains strings like "wlan", "bluetooth", "wimax", "gadget" etc. so that you can tell what kind of Ethernet card you have. We can revive the patches for adding this information as IFLA_INFO_KIND, but last time they where reverted since NetworkManager did all the wrong decisions based on that. That part is fixed now and we can put that back and declare the sub-type classification of Ethernet device in two places. Or we just take the information that we added a long time ago for exactly this sub-classification and provide them to userspace via RTNL. Regards Marcel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] rtnetlink: expose value from SET_NETDEV_DEVTYPE via IFLA_DEVTYPE attribute 2018-08-29 15:23 ` Marcel Holtmann @ 2018-08-30 5:12 ` Jiri Pirko 2018-08-30 10:13 ` Marcel Holtmann 0 siblings, 1 reply; 9+ messages in thread From: Jiri Pirko @ 2018-08-30 5:12 UTC (permalink / raw) To: Marcel Holtmann; +Cc: netdev, David S. Miller Wed, Aug 29, 2018 at 05:23:58PM CEST, marcel@holtmann.org wrote: >Hi Jiri, > >>> The name value from SET_NETDEV_DEVTYPE only ended up in the uevent sysfs >>> file as DEVTYPE= information. To avoid any kind of race conditions >>> between netlink messages and reading from sysfs, it is useful to add the >>> same string as new IFLA_DEVTYPE attribute included in the RTM_NEWLINK >>> messages. >>> >>> For network managing daemons that have to classify ARPHRD_ETHER network >>> devices into different types (like Wireless LAN, Bluetooth etc.), this >>> avoids the extra round trip to sysfs and parsing of the uevent file. >>> >>> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> >>> --- >>> include/uapi/linux/if_link.h | 2 ++ >>> net/core/rtnetlink.c | 12 ++++++++++++ >>> 2 files changed, 14 insertions(+) >>> >>> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h >>> index 43391e2d1153..781294972bb4 100644 >>> --- a/include/uapi/linux/if_link.h >>> +++ b/include/uapi/linux/if_link.h >>> @@ -166,6 +166,8 @@ enum { >>> IFLA_NEW_IFINDEX, >>> IFLA_MIN_MTU, >>> IFLA_MAX_MTU, >>> + IFLA_DEVTYPE, /* Name value from SET_NETDEV_DEVTYPE */ >> >> This is not something netdev-related. dev->dev.type is struct device_type. >> This is a generic "device" thing. Incorrect to expose over >> netdev-specific API. Please use "device" API for this. > >it is not just "device" related since this is a sub-classification of ARPHRD_ETHER type as a wrote above. Don't get hang up that this information is part of struct device. The dev->dev.type contains strings like "wlan", "bluetooth", "wimax", "gadget" etc. so that you can tell what kind of Ethernet card you have. I understand. But using dev->dev.type for that purpose seems like an abuse. If this is subtype of netdev, it should not be stored in parent device. I believe that you need to re-introduce this as a part of struct net_device - preferably an enum - and that you can expose over rtnl (and net-sysfs). > >We can revive the patches for adding this information as IFLA_INFO_KIND, but last time they where reverted since NetworkManager did all the wrong decisions based on that. That part is fixed now and we can put that back and declare the sub-type classification of Ethernet device in two places. Or we just take the information that we added a long time ago for exactly this sub-classification and provide them to userspace via RTNL. IFLA_INFO_KIND serves for different purpose. It is for drivers that register rtnl_link_ops. I don't think it would be wise to mix it with this. Btw, could you wrap the sentences at 72 cols? Would be easier to read that way. > >Regards > >Marcel > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] rtnetlink: expose value from SET_NETDEV_DEVTYPE via IFLA_DEVTYPE attribute 2018-08-30 5:12 ` Jiri Pirko @ 2018-08-30 10:13 ` Marcel Holtmann 2018-08-30 10:20 ` Jiri Pirko 0 siblings, 1 reply; 9+ messages in thread From: Marcel Holtmann @ 2018-08-30 10:13 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, David S. Miller Hi Jiri, >>>> The name value from SET_NETDEV_DEVTYPE only ended up in the uevent sysfs >>>> file as DEVTYPE= information. To avoid any kind of race conditions >>>> between netlink messages and reading from sysfs, it is useful to add the >>>> same string as new IFLA_DEVTYPE attribute included in the RTM_NEWLINK >>>> messages. >>>> >>>> For network managing daemons that have to classify ARPHRD_ETHER network >>>> devices into different types (like Wireless LAN, Bluetooth etc.), this >>>> avoids the extra round trip to sysfs and parsing of the uevent file. >>>> >>>> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> >>>> --- >>>> include/uapi/linux/if_link.h | 2 ++ >>>> net/core/rtnetlink.c | 12 ++++++++++++ >>>> 2 files changed, 14 insertions(+) >>>> >>>> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h >>>> index 43391e2d1153..781294972bb4 100644 >>>> --- a/include/uapi/linux/if_link.h >>>> +++ b/include/uapi/linux/if_link.h >>>> @@ -166,6 +166,8 @@ enum { >>>> IFLA_NEW_IFINDEX, >>>> IFLA_MIN_MTU, >>>> IFLA_MAX_MTU, >>>> + IFLA_DEVTYPE, /* Name value from SET_NETDEV_DEVTYPE */ >>> >>> This is not something netdev-related. dev->dev.type is struct device_type. >>> This is a generic "device" thing. Incorrect to expose over >>> netdev-specific API. Please use "device" API for this. >> >> it is not just "device" related since this is a sub-classification of ARPHRD_ETHER type as a wrote above. Don't get hang up that this information is part of struct device. The dev->dev.type contains strings like "wlan", "bluetooth", "wimax", "gadget" etc. so that you can tell what kind of Ethernet card you have. > > I understand. But using dev->dev.type for that purpose seems like an > abuse. If this is subtype of netdev, it should not be stored in parent > device. I believe that you need to re-introduce this as a part of struct > net_device - preferably an enum - and that you can expose over rtnl (and > net-sysfs). it is not stored in the parent device. It is stored in the device of the netdev. As Stephen said, there is no device API. And why would I add the same info again and bloat netdev? drivers/net/bonding/bond_main.c: SET_NETDEV_DEVTYPE(bond_dev, &bond_type); drivers/net/geneve.c: SET_NETDEV_DEVTYPE(dev, &geneve_type); drivers/net/macsec.c: SET_NETDEV_DEVTYPE(dev, &macsec_type); drivers/net/ppp/ppp_generic.c: SET_NETDEV_DEVTYPE(dev, &ppp_type); drivers/net/usb/hso.c: SET_NETDEV_DEVTYPE(net, &hso_type); drivers/net/usb/usbnet.c: SET_NETDEV_DEVTYPE(net, &wlan_type); drivers/net/usb/usbnet.c: SET_NETDEV_DEVTYPE(net, &wwan_type); drivers/net/vxlan.c: SET_NETDEV_DEVTYPE(dev, &vxlan_type); drivers/net/wimax/i2400m/usb.c: SET_NETDEV_DEVTYPE(net_dev, &i2400mu_type); drivers/net/wireless/intersil/prism54/islpci_dev.c: SET_NETDEV_DEVTYPE(ndev, &wlan_type); drivers/staging/gdm724x/gdm_lte.c: SET_NETDEV_DEVTYPE(net, &wwan_type); drivers/usb/gadget/function/u_ether.c: SET_NETDEV_DEVTYPE(net, &gadget_type); drivers/usb/gadget/function/u_ether.c: SET_NETDEV_DEVTYPE(net, &gadget_type); net/8021q/vlan_dev.c: SET_NETDEV_DEVTYPE(dev, &vlan_type); net/bluetooth/6lowpan.c: SET_NETDEV_DEVTYPE(netdev, &bt_type); net/bluetooth/bnep/core.c: SET_NETDEV_DEVTYPE(dev, &bnep_type); net/bridge/br_device.c: SET_NETDEV_DEVTYPE(dev, &br_type); net/dsa/slave.c: SET_NETDEV_DEVTYPE(slave_dev, &dsa_type); net/hsr/hsr_device.c: SET_NETDEV_DEVTYPE(dev, &hsr_type); net/l2tp/l2tp_eth.c: SET_NETDEV_DEVTYPE(dev, &l2tpeth_type); net/wireless/core.c: SET_NETDEV_DEVTYPE(dev, &wiphy_type); So for all these devices we have to add duplicate information now? I actually don't like that idea. I can rename it to IFLA_FOO or any other proposal, but adding the same information twice is pointless. >> We can revive the patches for adding this information as IFLA_INFO_KIND, but last time they where reverted since NetworkManager did all the wrong decisions based on that. That part is fixed now and we can put that back and declare the sub-type classification of Ethernet device in two places. Or we just take the information that we added a long time ago for exactly this sub-classification and provide them to userspace via RTNL. > > IFLA_INFO_KIND serves for different purpose. It is for drivers that > register rtnl_link_ops. I don't think it would be wise to mix it with > this. We could register rtnl_link_ops for these Ethernet drivers, but then we are duplicating the information as well. Regards Marcel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] rtnetlink: expose value from SET_NETDEV_DEVTYPE via IFLA_DEVTYPE attribute 2018-08-30 10:13 ` Marcel Holtmann @ 2018-08-30 10:20 ` Jiri Pirko 0 siblings, 0 replies; 9+ messages in thread From: Jiri Pirko @ 2018-08-30 10:20 UTC (permalink / raw) To: Marcel Holtmann; +Cc: netdev, David S. Miller Thu, Aug 30, 2018 at 12:13:40PM CEST, marcel@holtmann.org wrote: >Hi Jiri, > >>>>> The name value from SET_NETDEV_DEVTYPE only ended up in the uevent sysfs >>>>> file as DEVTYPE= information. To avoid any kind of race conditions >>>>> between netlink messages and reading from sysfs, it is useful to add the >>>>> same string as new IFLA_DEVTYPE attribute included in the RTM_NEWLINK >>>>> messages. >>>>> >>>>> For network managing daemons that have to classify ARPHRD_ETHER network >>>>> devices into different types (like Wireless LAN, Bluetooth etc.), this >>>>> avoids the extra round trip to sysfs and parsing of the uevent file. >>>>> >>>>> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> >>>>> --- >>>>> include/uapi/linux/if_link.h | 2 ++ >>>>> net/core/rtnetlink.c | 12 ++++++++++++ >>>>> 2 files changed, 14 insertions(+) >>>>> >>>>> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h >>>>> index 43391e2d1153..781294972bb4 100644 >>>>> --- a/include/uapi/linux/if_link.h >>>>> +++ b/include/uapi/linux/if_link.h >>>>> @@ -166,6 +166,8 @@ enum { >>>>> IFLA_NEW_IFINDEX, >>>>> IFLA_MIN_MTU, >>>>> IFLA_MAX_MTU, >>>>> + IFLA_DEVTYPE, /* Name value from SET_NETDEV_DEVTYPE */ >>>> >>>> This is not something netdev-related. dev->dev.type is struct device_type. >>>> This is a generic "device" thing. Incorrect to expose over >>>> netdev-specific API. Please use "device" API for this. >>> >>> it is not just "device" related since this is a sub-classification of ARPHRD_ETHER type as a wrote above. Don't get hang up that this information is part of struct device. The dev->dev.type contains strings like "wlan", "bluetooth", "wimax", "gadget" etc. so that you can tell what kind of Ethernet card you have. >> >> I understand. But using dev->dev.type for that purpose seems like an >> abuse. If this is subtype of netdev, it should not be stored in parent >> device. I believe that you need to re-introduce this as a part of struct >> net_device - preferably an enum - and that you can expose over rtnl (and >> net-sysfs). > >it is not stored in the parent device. It is stored in the device of the netdev. Yeah. That is what I ment. "Device struct" associated with the netdevice. > >As Stephen said, there is no device API. And why would I add the same info again and bloat netdev? > >drivers/net/bonding/bond_main.c: SET_NETDEV_DEVTYPE(bond_dev, &bond_type); >drivers/net/geneve.c: SET_NETDEV_DEVTYPE(dev, &geneve_type); >drivers/net/macsec.c: SET_NETDEV_DEVTYPE(dev, &macsec_type); >drivers/net/ppp/ppp_generic.c: SET_NETDEV_DEVTYPE(dev, &ppp_type); >drivers/net/usb/hso.c: SET_NETDEV_DEVTYPE(net, &hso_type); >drivers/net/usb/usbnet.c: SET_NETDEV_DEVTYPE(net, &wlan_type); >drivers/net/usb/usbnet.c: SET_NETDEV_DEVTYPE(net, &wwan_type); >drivers/net/vxlan.c: SET_NETDEV_DEVTYPE(dev, &vxlan_type); >drivers/net/wimax/i2400m/usb.c: SET_NETDEV_DEVTYPE(net_dev, &i2400mu_type); >drivers/net/wireless/intersil/prism54/islpci_dev.c: SET_NETDEV_DEVTYPE(ndev, &wlan_type); >drivers/staging/gdm724x/gdm_lte.c: SET_NETDEV_DEVTYPE(net, &wwan_type); >drivers/usb/gadget/function/u_ether.c: SET_NETDEV_DEVTYPE(net, &gadget_type); >drivers/usb/gadget/function/u_ether.c: SET_NETDEV_DEVTYPE(net, &gadget_type); >net/8021q/vlan_dev.c: SET_NETDEV_DEVTYPE(dev, &vlan_type); >net/bluetooth/6lowpan.c: SET_NETDEV_DEVTYPE(netdev, &bt_type); >net/bluetooth/bnep/core.c: SET_NETDEV_DEVTYPE(dev, &bnep_type); >net/bridge/br_device.c: SET_NETDEV_DEVTYPE(dev, &br_type); >net/dsa/slave.c: SET_NETDEV_DEVTYPE(slave_dev, &dsa_type); >net/hsr/hsr_device.c: SET_NETDEV_DEVTYPE(dev, &hsr_type); >net/l2tp/l2tp_eth.c: SET_NETDEV_DEVTYPE(dev, &l2tpeth_type); >net/wireless/core.c: SET_NETDEV_DEVTYPE(dev, &wiphy_type); > >So for all these devices we have to add duplicate information now? The fact the things are done now it a wrong way does not justify extending UAPI in the same wrong way. So yes, change them all if you need it. The "ethernet-subtype" should not an attribute of "struct device" but rather "struct net_device". > >I actually don't like that idea. I can rename it to IFLA_FOO or any other proposal, but adding the same information twice is pointless. So don't expose the "struct device" attribute over rtnetlink. Use "struct device"-specific interface for that. > >>> We can revive the patches for adding this information as IFLA_INFO_KIND, but last time they where reverted since NetworkManager did all the wrong decisions based on that. That part is fixed now and we can put that back and declare the sub-type classification of Ethernet device in two places. Or we just take the information that we added a long time ago for exactly this sub-classification and provide them to userspace via RTNL. >> >> IFLA_INFO_KIND serves for different purpose. It is for drivers that >> register rtnl_link_ops. I don't think it would be wise to mix it with >> this. > >We could register rtnl_link_ops for these Ethernet drivers, but then we are duplicating the information as well. That is not the purpose of "rtnl_link_ops". > >Regards > >Marcel > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] rtnetlink: expose value from SET_NETDEV_DEVTYPE via IFLA_DEVTYPE attribute 2018-08-29 7:18 ` Jiri Pirko 2018-08-29 15:23 ` Marcel Holtmann @ 2018-08-29 15:24 ` Stephen Hemminger 2018-08-29 15:31 ` Marcel Holtmann 2018-08-30 5:14 ` Jiri Pirko 1 sibling, 2 replies; 9+ messages in thread From: Stephen Hemminger @ 2018-08-29 15:24 UTC (permalink / raw) To: Jiri Pirko; +Cc: Marcel Holtmann, netdev, davem On Wed, 29 Aug 2018 09:18:55 +0200 Jiri Pirko <jiri@resnulli.us> wrote: > Tue, Aug 28, 2018 at 10:58:11PM CEST, marcel@holtmann.org wrote: > >The name value from SET_NETDEV_DEVTYPE only ended up in the uevent sysfs > >file as DEVTYPE= information. To avoid any kind of race conditions > >between netlink messages and reading from sysfs, it is useful to add the > >same string as new IFLA_DEVTYPE attribute included in the RTM_NEWLINK > >messages. > > > >For network managing daemons that have to classify ARPHRD_ETHER network > >devices into different types (like Wireless LAN, Bluetooth etc.), this > >avoids the extra round trip to sysfs and parsing of the uevent file. > > > >Signed-off-by: Marcel Holtmann <marcel@holtmann.org> > >--- > > include/uapi/linux/if_link.h | 2 ++ > > net/core/rtnetlink.c | 12 ++++++++++++ > > 2 files changed, 14 insertions(+) > > > >diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h > >index 43391e2d1153..781294972bb4 100644 > >--- a/include/uapi/linux/if_link.h > >+++ b/include/uapi/linux/if_link.h > >@@ -166,6 +166,8 @@ enum { > > IFLA_NEW_IFINDEX, > > IFLA_MIN_MTU, > > IFLA_MAX_MTU, > >+ IFLA_DEVTYPE, /* Name value from SET_NETDEV_DEVTYPE */ > > This is not something netdev-related. dev->dev.type is struct device_type. > This is a generic "device" thing. Incorrect to expose over > netdev-specific API. Please use "device" API for this. There is no device API in netlink. The whole point of this patch is to do it in one message. It might be a performance optimization, but I can't see how it could be a race condition. Devices set type before registering. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] rtnetlink: expose value from SET_NETDEV_DEVTYPE via IFLA_DEVTYPE attribute 2018-08-29 15:24 ` Stephen Hemminger @ 2018-08-29 15:31 ` Marcel Holtmann 2018-08-30 5:14 ` Jiri Pirko 1 sibling, 0 replies; 9+ messages in thread From: Marcel Holtmann @ 2018-08-29 15:31 UTC (permalink / raw) To: Stephen Hemminger; +Cc: Jiri Pirko, netdev, David S. Miller Hi Stephen, >>> The name value from SET_NETDEV_DEVTYPE only ended up in the uevent sysfs >>> file as DEVTYPE= information. To avoid any kind of race conditions >>> between netlink messages and reading from sysfs, it is useful to add the >>> same string as new IFLA_DEVTYPE attribute included in the RTM_NEWLINK >>> messages. >>> >>> For network managing daemons that have to classify ARPHRD_ETHER network >>> devices into different types (like Wireless LAN, Bluetooth etc.), this >>> avoids the extra round trip to sysfs and parsing of the uevent file. >>> >>> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> >>> --- >>> include/uapi/linux/if_link.h | 2 ++ >>> net/core/rtnetlink.c | 12 ++++++++++++ >>> 2 files changed, 14 insertions(+) >>> >>> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h >>> index 43391e2d1153..781294972bb4 100644 >>> --- a/include/uapi/linux/if_link.h >>> +++ b/include/uapi/linux/if_link.h >>> @@ -166,6 +166,8 @@ enum { >>> IFLA_NEW_IFINDEX, >>> IFLA_MIN_MTU, >>> IFLA_MAX_MTU, >>> + IFLA_DEVTYPE, /* Name value from SET_NETDEV_DEVTYPE */ >> >> This is not something netdev-related. dev->dev.type is struct device_type. >> This is a generic "device" thing. Incorrect to expose over >> netdev-specific API. Please use "device" API for this. > > There is no device API in netlink. The whole point of this patch is to > do it in one message. It might be a performance optimization, but I can't > see how it could be a race condition. Devices set type before registering. the only way right now to pick up the DEVTYPE= value is from the /sys/class/net/*/uevent file. That is based on the ifname and not the index. When udev + systemd start renaming things behind your back, your daemon does not have a clean one-shot way of getting that information. As stated, the information in DEVTYPE= are a sub-classification of ARPHRD_ETHER and allows to differentiate a wired Ethernet card from a WiFi interface, from a Bluetooth interface, from WiMAX and so on. They just happen to be in dev.dev_type data structure at the moment and I didn't want to duplicate that information. I am actually fine doing this via IFLA_INFO_KIND since NetworkManager seems to be fixed now or do this via a different method or maybe just a different attribute name. I really just want to get the sub-classification of ARPHRD_ETHER that we need in userspace networking daemons from the kernel without having to go poke left and right over sysfs or interact with udev or systemd. Regards Marcel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] rtnetlink: expose value from SET_NETDEV_DEVTYPE via IFLA_DEVTYPE attribute 2018-08-29 15:24 ` Stephen Hemminger 2018-08-29 15:31 ` Marcel Holtmann @ 2018-08-30 5:14 ` Jiri Pirko 1 sibling, 0 replies; 9+ messages in thread From: Jiri Pirko @ 2018-08-30 5:14 UTC (permalink / raw) To: Stephen Hemminger; +Cc: Marcel Holtmann, netdev, davem Wed, Aug 29, 2018 at 05:24:28PM CEST, stephen@networkplumber.org wrote: >On Wed, 29 Aug 2018 09:18:55 +0200 >Jiri Pirko <jiri@resnulli.us> wrote: > >> Tue, Aug 28, 2018 at 10:58:11PM CEST, marcel@holtmann.org wrote: >> >The name value from SET_NETDEV_DEVTYPE only ended up in the uevent sysfs >> >file as DEVTYPE= information. To avoid any kind of race conditions >> >between netlink messages and reading from sysfs, it is useful to add the >> >same string as new IFLA_DEVTYPE attribute included in the RTM_NEWLINK >> >messages. >> > >> >For network managing daemons that have to classify ARPHRD_ETHER network >> >devices into different types (like Wireless LAN, Bluetooth etc.), this >> >avoids the extra round trip to sysfs and parsing of the uevent file. >> > >> >Signed-off-by: Marcel Holtmann <marcel@holtmann.org> >> >--- >> > include/uapi/linux/if_link.h | 2 ++ >> > net/core/rtnetlink.c | 12 ++++++++++++ >> > 2 files changed, 14 insertions(+) >> > >> >diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h >> >index 43391e2d1153..781294972bb4 100644 >> >--- a/include/uapi/linux/if_link.h >> >+++ b/include/uapi/linux/if_link.h >> >@@ -166,6 +166,8 @@ enum { >> > IFLA_NEW_IFINDEX, >> > IFLA_MIN_MTU, >> > IFLA_MAX_MTU, >> >+ IFLA_DEVTYPE, /* Name value from SET_NETDEV_DEVTYPE */ >> >> This is not something netdev-related. dev->dev.type is struct device_type. >> This is a generic "device" thing. Incorrect to expose over >> netdev-specific API. Please use "device" API for this. > >There is no device API in netlink. The whole point of this patch is to >do it in one message. It might be a performance optimization, but I can't >see how it could be a race condition. Devices set type before registering. I understand. My point is to avoid exposing generic "struct device" values over rtnetlink. It mixes apples and oranges. ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-08-30 14:25 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-08-28 20:58 [PATCH] rtnetlink: expose value from SET_NETDEV_DEVTYPE via IFLA_DEVTYPE attribute Marcel Holtmann 2018-08-29 7:18 ` Jiri Pirko 2018-08-29 15:23 ` Marcel Holtmann 2018-08-30 5:12 ` Jiri Pirko 2018-08-30 10:13 ` Marcel Holtmann 2018-08-30 10:20 ` Jiri Pirko 2018-08-29 15:24 ` Stephen Hemminger 2018-08-29 15:31 ` Marcel Holtmann 2018-08-30 5:14 ` Jiri Pirko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox