net: ifdefy the wireless pointers in struct net_device
Subsystems (5)
Jakub Kicinski
maintainerPATCH 1/1 net: ifdefy the wireless pointers in struct net_device
Most protocol-specific pointers in struct net_device are under a respective ifdef. Wireless is the notable exception. Since there's a sizable number of custom-built kernels for datacenter workloads which don't build wireless it seems reasonable to ifdefy those pointers as well.
While at it move IPv4 and IPv6 pointers up, those are special for obvious reasons.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- include/linux/netdevice.h | 8 ++++++-- include/net/cfg80211.h | 5 +---- include/net/cfg802154.h | 2 ++ net/batman-adv/hard-interface.c | 2 ++ net/wireless/core.c | 6 ++++++ 5 files changed, 17 insertions(+), 6 deletions(-)
include/linux/netdevice.h +6 -2
@@ -2119,6 +2119,8 @@ struct net_device {/* Protocol-specific pointers */ +struct in_device __rcu *ip_ptr; +struct inet6_dev __rcu *ip6_ptr;#if IS_ENABLED (CONFIG_VLAN_8021Q )struct vlan_info __rcu *vlan_info;#endif
@@ -2131,16 +2133,18 @@ struct net_device {#if IS_ENABLED (CONFIG_ATALK )void *atalk_ptr;#endif -struct in_device __rcu *ip_ptr;#if IS_ENABLED (CONFIG_DECNET )struct dn_dev __rcu *dn_ptr;#endif -struct inet6_dev __rcu *ip6_ptr;#if IS_ENABLED (CONFIG_AX25 )void *ax25_ptr;#endif +#if IS_ENABLED (CONFIG_WIRELESS )struct wireless_dev *ieee80211_ptr; +#endif +#if IS_ENABLED (CONFIG_IEEE802154 ) ||IS_ENABLED (CONFIG_6LOWPAN )struct wpan_dev *ieee802154_ptr; +#endif #if IS_ENABLED (CONFIG_MPLS_ROUTING )struct mpls_dev __rcu *mpls_ptr;#endif
include/net/cfg80211.h +1 -4
@@ -8004,10 +8004,7 @@ int cfg80211_register_netdevice(struct net_device *dev);* * Requires the RTNL and wiphy mutex to be held. */ -static inline void cfg80211_unregister_netdevice (struct net_device *dev) -{ -cfg80211_unregister_wdev (dev->ieee80211_ptr); -} +void cfg80211_unregister_netdevice (struct net_device *dev);/** * struct cfg80211_ft_event_params - FT Information Elements
include/net/cfg802154.h +2 -0
@@ -373,6 +373,7 @@ struct wpan_dev {#define to_phy (_dev) container_of(_dev, struct wpan_phy, dev) +#if IS_ENABLED (CONFIG_IEEE802154 ) ||IS_ENABLED (CONFIG_6LOWPAN ) static inline int wpan_dev_hard_header(struct sk_buff *skb, struct net_device *dev, const struct ieee802154_addr *daddr,
@@ -383,6 +384,7 @@ wpan_dev_hard_header(struct sk_buff *skb, struct net_device *dev, return wpan_dev->header_ops->create(skb, dev, daddr, saddr, len); } +#endif struct wpan_phy *wpan_phy_new (const struct cfg802154_ops *ops,size_t priv_size);
net/batman-adv/hard-interface.c +2 -0
@@ -307,9 +307,11 @@ static bool batadv_is_cfg80211_netdev(struct net_device *net_device)if (!net_device)return false; +#if IS_ENABLED (CONFIG_WIRELESS )/* cfg80211 drivers have to set ieee80211_ptr */ if (net_device->ieee80211_ptr)return true; +#endif return false; }
net/wireless/core.c +6 -0
@@ -1374,6 +1374,12 @@ int cfg80211_register_netdevice(struct net_device *dev) }EXPORT_SYMBOL (cfg80211_register_netdevice); +void cfg80211_unregister_netdevice (struct net_device *dev) +{ +cfg80211_unregister_wdev (dev->ieee80211_ptr); +} +EXPORT_SYMBOL (cfg80211_unregister_netdevice); +static int cfg80211_netdev_notifier_call (struct notifier_block *nb,unsigned long state,void *ptr) {
Signature · 1 line
2.34.3
Quoted 10 lines · Jakub Kicinski
Most protocol-specific pointers in struct
net_deviceare under a respective ifdef. Wireless is the notable exception. Since there's a sizable number of custom-built kernels for datacenter workloads which don't build wireless it seems reasonable to ifdefy those pointers as well.While at it move IPv4 and IPv6 pointers up, those are special for obvious reasons.
Signed-off-by Jakub Kicinski <[email protected]>
Could not we move to an union of pointers in the future since in many cases a network device can only have one of those pointers at any given time?
Signature · 1 line
Florian
Johannes Berg
maintainerQuoted 8 lines · Florian Fainelli
Quoted 6 lines · Jakub Kicinski
Most protocol-specific pointers in struct
net_deviceare under a respective ifdef. Wireless is the notable exception. Since there's a sizable number of custom-built kernels for datacenter workloads which don't build wireless it seems reasonable to ifdefy those pointers as well.
Quoted 8 lines
Quoted 4 lines
While at it move IPv4 and IPv6 pointers up, those are special for obvious reasons.
Signed-off-by Jakub Kicinski <[email protected]>Could not we move to an union of pointers in the future since in many cases a network device can only have one of those pointers at any given time?
Then at the very least we'd need some kind of type that we can assign to disambiguate, because today e.g. we have a netdev notifier (and other code) that could get a non-wireless netdev and check like this:
static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
unsigned long state, void *ptr)
{
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct wireless_dev *wdev = dev->ieee80211_ptr;
[...]
if (!wdev)
return NOTIFY_DONE;We could probably use the netdev->dev.type for this though, that's just a pointer we can compare to. We'd have to set it differently (today cfg80211 sets it based on whether or not you have ieee80211_ptr, we'd have to turn that around), but that's not terribly hard, especially since wireless drivers now have to call cfg80211_register_netdevice() anyway, rather than register_netdevice() directly.
Something like the patch below might do that, but I haven't carefully checked it yet, nor checked if there are any paths in mac80211/drivers that might be doing this check - and it looks from Jakub's patch that batman code would like to check this too.
johannes
net/wireless/core.c +5 -3
@@ -1192,7 +1192,7 @@ void cfg80211_unregister_wdev(struct wireless_dev *wdev) }EXPORT_SYMBOL (cfg80211_unregister_wdev); -static const struct device_type wiphy_type = { +const struct device_type wiphy_type = { .name ="wlan" , };
@@ -1369,6 +1369,9 @@ int cfg80211_register_netdevice(struct net_device *dev)lockdep_assert_held (&rdev->wiphy.mtx); +/* this lets us identify our netdevs in the future */ +SET_NETDEV_DEVTYPE (dev, &wiphy_type); +/* we'll take care of this */ wdev->registered = true; wdev->registering = true;
@@ -1394,7 +1397,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,struct cfg80211_registered_device *rdev;struct cfg80211_sched_scan_request *pos, *tmp; -if (!wdev) +if (!netdev_is_wireless (dev))return NOTIFY_DONE ; rdev =wiphy_to_rdev (wdev->wiphy);
@@ -1403,7 +1406,6 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,switch (state) {case NETDEV_POST_INIT : -SET_NETDEV_DEVTYPE (dev, &wiphy_type); wdev->netdev = dev;/* can only change netns with wiphy */ dev->features |=NETIF_F_NETNS_LOCAL ;
net/wireless/core.h +7 -0
@@ -219,6 +219,13 @@ void cfg80211_init_wdev(struct wireless_dev *wdev);void cfg80211_register_wdev (struct cfg80211_registered_device *rdev,struct wireless_dev *wdev); +extern const struct device_type wiphy_type; + +static inline bool netdev_is_wireless (struct net_device *dev) +{ +return dev && dev->dev.type == &wiphy_type && dev->ieee80211_ptr; +} +static inline void wdev_lock (struct wireless_dev *wdev)__acquires (wdev) {
net/wireless/nl80211.c +3 -3
@@ -182,7 +182,7 @@ __cfg80211_rdev_from_attrs(struct net *netns, struct nlattr **attrs) netdev =__dev_get_by_index (netns, ifindex);if (netdev) { -if (netdev->ieee80211_ptr) +if (netdev_is_wireless (netdev)) tmp =wiphy_to_rdev ( netdev->ieee80211_ptr->wiphy);else
@@ -2978,7 +2978,7 @@ static int nl80211_dump_wiphy_parse(struct sk_buff *skb, ret = -ENODEV ; goto out; } -if (netdev->ieee80211_ptr) { +if (netdev_is_wireless (netdev)) { rdev =wiphy_to_rdev ( netdev->ieee80211_ptr->wiphy); state->filter_wiphy = rdev->wiphy_idx;
@@ -3364,7 +3364,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)int ifindex =nla_get_u32 (info->attrs[NL80211_ATTR_IFINDEX ]); netdev =__dev_get_by_index (genl_info_net (info), ifindex); -if (netdev && netdev->ieee80211_ptr) +if (netdev_is_wireless (netdev)) rdev =wiphy_to_rdev (netdev->ieee80211_ptr->wiphy);else netdev =NULL ;
Jakub Kicinski
maintainerQuoted 22 lines · On Tue, 17 May 2022 09:48:24 +0200 Johannes Berg wrote:
Quoted 8 lines · Florian Fainelli
Quoted 6 lines · Jakub Kicinski
Most protocol-specific pointers in struct
net_deviceare under a respective ifdef. Wireless is the notable exception. Since there's a sizable number of custom-built kernels for datacenter workloads which don't build wireless it seems reasonable to ifdefy those pointers as well.Quoted 8 lines
Quoted 4 lines
While at it move IPv4 and IPv6 pointers up, those are special for obvious reasons.
Signed-off-by Jakub Kicinski <[email protected]>Could not we move to an union of pointers in the future since in many cases a network device can only have one of those pointers at any given time?
Then at the very least we'd need some kind of type that we can assign to disambiguate, because today e.g. we have a netdev notifier (and other code) that could get a non-wireless netdev and check like this:
Quoted 8 lines
static int cfg80211_netdev_notifier_call(struct
notifier_block*nb,
unsigned long state, void *ptr){ struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct wireless_dev *wdev = dev->ieee80211_ptr; [...] if (!wdev) return NOTIFY_DONE;
Can we use enum netdev_ml_priv_type netdev::ml_priv and netdev::ml_priv_type for this?
Johannes Berg
maintainerQuoted 14 lines · Jakub Kicinski
Quoted 5 lines
Then at the very least we'd need some kind of type that we can assign to disambiguate, because today e.g. we have a netdev notifier (and other code) that could get a non-wireless netdev and check like this:
Quoted 8 lines
static int cfg80211_netdev_notifier_call(struct
notifier_block*nb,
unsigned long state, void *ptr){ struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct wireless_dev *wdev = dev->ieee80211_ptr; [...] if (!wdev) return NOTIFY_DONE;
Quoted 3 lines
Can we use enum
netdev_ml_priv_typenetdev::ml_privandnetdev::ml_priv_typefor this?
Hm, yeah, I guess we can. I think I'd prefer something along the lines of the below, then we don't even need the ifdef.
johannes
include/linux/netdevice.h +5 -2
@@ -1702,6 +1702,7 @@ enum netdev_priv_flags {enum netdev_ml_priv_type {ML_PRIV_NONE ,ML_PRIV_CAN , +ML_PRIV_WIFI , };/**
@@ -2127,7 +2128,6 @@ struct net_device {#if IS_ENABLED (CONFIG_AX25 )void *ax25_ptr;#endif -struct wireless_dev *ieee80211_ptr;struct wpan_dev *ieee802154_ptr;#if IS_ENABLED (CONFIG_MPLS_ROUTING )struct mpls_dev __rcu *mpls_ptr;
@@ -2235,7 +2235,10 @@ struct net_device {possible_net_t nd_net;/* mid-layer private */ -void *ml_priv; +union { +void *ml_priv; +struct wireless_dev *ieee80211_ptr; + };enum netdev_ml_priv_type ml_priv_type;union {
net/batman-adv/hard-interface.c +1 -5
@@ -307,11 +307,7 @@ static bool batadv_is_cfg80211_netdev(struct net_device *net_device)if (!net_device)return false; -/* cfg80211 drivers have to set ieee80211_ptr */ -if (net_device->ieee80211_ptr) -return true; - -return false; +return netdev_get_ml_priv (net_device,ML_PRIV_WIFI ); }/**
net/core/net-sysfs.c +1 -1
@@ -1997,7 +1997,7 @@ int netdev_register_kobject(struct net_device *ndev) *groups++ = &netstat_group;#if IS_ENABLED (CONFIG_WIRELESS_EXT ) ||IS_ENABLED (CONFIG_CFG80211 ) -if (ndev->ieee80211_ptr) +if (netdev_get_ml_priv (ndev,ML_PRIV_WIFI )) *groups++ = &wireless_group;#if IS_ENABLED (CONFIG_WIRELESS_EXT ) else if (ndev->wireless_handlers)
net/wireless/core.c +7 -1
@@ -1369,6 +1369,12 @@ int cfg80211_register_netdevice(struct net_device *dev)lockdep_assert_held (&rdev->wiphy.mtx); +/* +* This lets us identify our netdevs in the future, +* the driver already set dev->ieee80211_ptr. +*/ +netdev_set_ml_priv (dev, wdev,ML_PRIV_WIFI ); +/* we'll take care of this */ wdev->registered = true; wdev->registering = true;
@@ -1390,7 +1396,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, unsigned long state, void *ptr) { struct net_device *dev = netdev_notifier_info_to_dev(ptr); -struct wireless_dev *wdev = dev->ieee80211_ptr; +struct wireless_dev *wdev =netdev_get_ml_priv (dev,ML_PRIV_WIFI );struct cfg80211_registered_device *rdev;struct cfg80211_sched_scan_request *pos, *tmp;
net/wireless/nl80211.c +14 -8
@@ -182,9 +182,12 @@ __cfg80211_rdev_from_attrs(struct net *netns, struct nlattr **attrs) netdev =__dev_get_by_index (netns, ifindex);if (netdev) { -if (netdev->ieee80211_ptr) - tmp =wiphy_to_rdev ( - netdev->ieee80211_ptr->wiphy); +struct wireless_dev *wdev; + + wdev =netdev_get_ml_priv (netdev,ML_PRIV_WIFI ); + +if (wdev) + tmp =wiphy_to_rdev (wdev->wiphy);else tmp =NULL ;
@@ -2972,15 +2975,17 @@ static int nl80211_dump_wiphy_parse(struct sk_buff *skb,struct net_device *netdev;struct cfg80211_registered_device *rdev;int ifidx =nla_get_u32 (tb[NL80211_ATTR_IFINDEX ]); +struct wireless_dev *wdev; netdev =__dev_get_by_index (sock_net (skb->sk), ifidx);if (!netdev) { ret = -ENODEV ; goto out; } -if (netdev->ieee80211_ptr) { - rdev =wiphy_to_rdev ( - netdev->ieee80211_ptr->wiphy); + + wdev =netdev_is_wireless (netdev,ML_PRIV_WIFI ); +if (wdev) { + rdev =wiphy_to_rdev (wdev->wiphy); state->filter_wiphy = rdev->wiphy_idx; } }
@@ -3364,8 +3369,9 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)int ifindex =nla_get_u32 (info->attrs[NL80211_ATTR_IFINDEX ]); netdev =__dev_get_by_index (genl_info_net (info), ifindex); -if (netdev && netdev->ieee80211_ptr) - rdev =wiphy_to_rdev (netdev->ieee80211_ptr->wiphy); + wdev =netdev_is_wireless (netdev); +if (wdev) + rdev =wiphy_to_rdev (wdev->wiphy);else netdev =NULL ; }
net/wireless/scan.c +4 -2
@@ -2715,6 +2715,7 @@ static struct cfg80211_registered_device * cfg80211_get_dev_from_ifindex(struct net *net, int ifindex) {struct cfg80211_registered_device *rdev; +struct wireless_dev *wdev;struct net_device *dev;ASSERT_RTNL ();
@@ -2722,8 +2723,9 @@ cfg80211_get_dev_from_ifindex(struct net *net, int ifindex) dev =dev_get_by_index (net, ifindex);if (!dev)return ERR_PTR (-ENODEV ); -if (dev->ieee80211_ptr) - rdev =wiphy_to_rdev (dev->ieee80211_ptr->wiphy); + wdev =netdev_get_ml_priv (dev,ML_PRIV_WIFI ); +if (wdev) + rdev =wiphy_to_rdev (wdev->wiphy);else rdev =ERR_PTR (-ENODEV );dev_put (dev);
net/wireless/wext-proc.c +1 -1
@@ -40,7 +40,7 @@ static void wireless_seq_printf_stats(struct seq_file *seq, stats = &nullstats;#endif #ifdef CONFIG_CFG80211 -if (dev->ieee80211_ptr) +if (netdev_get_ml_priv (dev,ML_PRIV_WIFI )) stats = &nullstats;#endif }
Hi,
Quoted 10 lines · Florian Fainelli
Quoted 6 lines · Jakub Kicinski
Most protocol-specific pointers in struct
net_deviceare under a respective ifdef. Wireless is the notable exception. Since there's a sizable number of custom-built kernels for datacenter workloads which don't build wireless it seems reasonable to ifdefy those pointers as well.
Quoted 8 lines
Quoted 4 lines
While at it move IPv4 and IPv6 pointers up, those are special for obvious reasons.
Signed-off-by Jakub Kicinski <[email protected]>Could not we move to an union of pointers in the future since in many cases a network device can only have one of those pointers at any given time?
note that ieee802154 has also functionality like __dev_get_by_index() and checks via "if (netdev->ieee802154_ptr)" if it's a wpan interface or not, guess the solution would be like it's done in wireless then.
- Alex
Jakub Kicinski
maintainerQuoted 7 lines · On Tue, 17 May 2022 15:33:02 -0400 Alexander Aring wrote:
Quoted 3 lines
Could not we move to an union of pointers in the future since in many cases a network device can only have one of those pointers at any given time?
note that ieee802154 has also functionality like
__dev_get_by_index()and checks via "if (netdev->ieee802154_ptr)" if it's a wpan interface or not, guess the solution would be like it's done in wireless then.
Ack, but that code must live somewhere under
#if IS_ENABLED(CONFIG_IEEE802154) || IS_ENABLED(CONFIG_6LOWPAN)
otherwise I think I'd see a build failure. I guess a nice thing about having the typed pointers is that we can depend on the compiler for basic checking :)
Quoted 20 lines · Jakub Kicinski
Most protocol-specific pointers in struct
net_deviceare under a respective ifdef. Wireless is the notable exception. Since there's a sizable number of custom-built kernels for datacenter workloads which don't build wireless it seems reasonable to ifdefy those pointers as well.While at it move IPv4 and IPv6 pointers up, those are special for obvious reasons.
Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
[...]
Quoted 14 lines
include/net/cfg80211.h +1
-4@@ -8004,10 +8004,7 @@ int cfg80211_register_netdevice(struct net_device *dev);* * Requires the RTNL and wiphy mutex to be held. */ -static inline void cfg80211_unregister_netdevice (struct net_device *dev) -{ -cfg80211_unregister_wdev (dev->ieee80211_ptr); -} +void cfg80211_unregister_netdevice (struct net_device *dev);/** * struct cfg80211_ft_event_params - FT Information Elements
[...]
net/wireless/core.c int cfg80211_register_netdevice(struct net_device *dev) · line 1381
Quoted 11 lines
net/wireless/core.c +5
-0@@ -1374,6 +1374,12 @@ int cfg80211_register_netdevice(struct net_device *dev) }EXPORT_SYMBOL (cfg80211_register_netdevice); +void cfg80211_unregister_netdevice (struct net_device *dev) +{ +cfg80211_unregister_wdev (dev->ieee80211_ptr); +} +EXPORT_SYMBOL (cfg80211_unregister_netdevice);
Why moving this to a proper function? Just curious, I couldn't figure it out.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Jakub Kicinski
maintainerQuoted 8 lines · On Tue, 17 May 2022 07:36:54 +0300 Kalle Valo wrote:
net/wireless/core.c int cfg80211_register_netdevice(struct net_device *dev) · line 1381
Quoted 5 lines
net/wireless/core.c +5
-0+void cfg80211_unregister_netdevice (struct net_device *dev) +{ +cfg80211_unregister_wdev (dev->ieee80211_ptr); +} +EXPORT_SYMBOL (cfg80211_unregister_netdevice);Why moving this to a proper function? Just curious, I couldn't figure it out.
Sorry, I went too far with the "explain what not why". The header is included in places which get built without WIRELESS while the C source is not.
Hello.
Quoted 20 lines · Jakub Kicinski
Most protocol-specific pointers in struct
net_deviceare under a respective ifdef. Wireless is the notable exception. Since there's a sizable number of custom-built kernels for datacenter workloads which don't build wireless it seems reasonable to ifdefy those pointers as well.While at it move IPv4 and IPv6 pointers up, those are special for obvious reasons.
Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
Quoted 7 lines
--- include/linux/netdevice.h | 8 ++++++-- include/net/cfg80211.h | 5 +---- include/net/cfg802154.h | 2 ++ net/batman-adv/hard-interface.c | 2 ++ net/wireless/core.c | 6 ++++++ 5 files changed, 17 insertions(+), 6 deletions(-)
For the ieee802154 changes:
regards
Stefan Schmidt
Johannes Berg
maintainerinclude/linux/netdevice.h struct net_device { · line 2144
Quoted 4 lines · Jakub Kicinski
include/linux/netdevice.h +2
-0+#if IS_ENABLED (CONFIG_WIRELESS )struct wireless_dev *ieee80211_ptr; +#endif
Technically, you should be able to use CONFIG_CFG80211 here, but in practice I'd really hope nobody enables WIRELESS without CFG80211 :)
include/net/cfg80211.h int cfg80211_register_netdevice(struct net_device *dev); · line 8007
Quoted 10 lines
+++
b/include/net/cfg80211.hinclude/net/cfg80211.h +1
-4@@ -8004,10 +8004,7 @@ int cfg80211_register_netdevice(struct net_device *dev);* * Requires the RTNL and wiphy mutex to be held. */ -static inline void cfg80211_unregister_netdevice (struct net_device *dev) -{ -cfg80211_unregister_wdev (dev->ieee80211_ptr); -} +void cfg80211_unregister_netdevice (struct net_device *dev);
Exported functions aren't free either - I think in this case I'd (slightly) prefer the extra ifdef.
Anyway, we can do this, but I also like Florian's suggestion about the union, and sent an attempt at a disambiguation patch there.
johannes
Jakub Kicinski
maintainerQuoted 8 lines · On Tue, 17 May 2022 09:51:31 +0200 Johannes Berg wrote:
include/linux/netdevice.h struct net_device { · line 2144
Quoted 4 lines · Jakub Kicinski
include/linux/netdevice.h +2
-0+#if IS_ENABLED (CONFIG_WIRELESS )struct wireless_dev *ieee80211_ptr; +#endif Technically, you should be able to use
CONFIG_CFG80211here, but in practice I'd really hope nobody enables WIRELESS without CFG80211 :)
ack
Quoted 5 lines
Quoted 5 lines
+++
b/include/net/cfg80211.hinclude/net/cfg80211.h +0
-0@@ -8004,10 +8004,7 @@ int cfg80211_register_netdevice(struct net_device *dev);* * Requires the RTNL and wiphy mutex to be held. */
Quoted 8 lines
include/net/cfg80211.h int cfg80211_register_netdevice(struct net_device *dev); · line 8007
Quoted 5 lines
include/net/cfg80211.h +1
-4-static inline void cfg80211_unregister_netdevice (struct net_device *dev) -{ -cfg80211_unregister_wdev (dev->ieee80211_ptr); -} +void cfg80211_unregister_netdevice (struct net_device *dev);Exported functions aren't free either - I think in this case I'd (slightly) prefer the extra ifdef.
fine
Quoted 2 lines
Anyway, we can do this, but I also like Florian's suggestion about the union, and sent an attempt at a disambiguation patch there.
Would you be willing to do that as a follow up? Are you talking about wifi only or all the proto pointers?
As a netdev maintainer I'd like to reduce the divergence in whether the proto pointers are ifdef'd or not.
Johannes Berg
maintainerQuoted 3 lines · Jakub Kicinski
Would you be willing to do that as a follow up?
Sure.
Quoted 2 lines
Are you talking about
wifi only or all the proto pointers?
Well it only makes sense if at least two protocols join forces :-)
Quoted 3 lines
As a netdev maintainer I'd like to reduce the divergence in whether the proto pointers are ifdef'd or not.
Sure, no objection to the ifdef.
johannes
Quoted 6 lines · On Monday, 16 May 2022 23:56:38 CEST Jakub Kicinski wrote:
net/batman-adv/hard-interface.c +0
-0@@ -307,9 +307,11 @@ static bool batadv_is_cfg80211_netdev(struct net_device *net_device)if (!net_device)
net/batman-adv/hard-interface.c static bool batadv_is_cfg80211_netdev(struct net_device *net_device) · line 317
Quoted 10 lines
net/batman-adv/hard-interface.c +2
-0return false; +#if IS_ENABLED (CONFIG_WIRELESS )/* cfg80211 drivers have to set ieee80211_ptr */ if (net_device->ieee80211_ptr)return true; +#endif return false; }
Quoted 4 lines · On Tuesday, 17 May 2022 09:48:24 CEST Johannes Berg wrote:
Something like the patch below might do that, but I haven't carefully checked it yet, nor checked if there are any paths in mac80211/drivers that might be doing this check - and it looks from Jakub's patch that batman code would like to check this too.
Yes, if something like netdev_is_wireless would be available then we could change it to:
net/batman-adv/hard-interface.c +2 -22
@@ -294,26 +294,6 @@ static bool batadv_is_wext_netdev(struct net_device *net_device)return false; } -/** -* batadv_is_cfg80211_netdev() - check if the given net_device struct is a -* cfg80211 wifi interface -* @net_device: the device to check -* -* Return: true if the net device is a cfg80211 wireless device, false -* otherwise. -*/ -static bool batadv_is_cfg80211_netdev (struct net_device *net_device) -{ -if (!net_device) -return false; - -/* cfg80211 drivers have to set ieee80211_ptr */ -if (net_device->ieee80211_ptr) -return true; - -return false; -} -/** * batadv_wifi_flags_evaluate() - calculate wifi flags for net_device * @net_device: the device to check
@@ -328,7 +308,7 @@ static u32 batadv_wifi_flags_evaluate(struct net_device *net_device)if (batadv_is_wext_netdev (net_device)) wifi_flags |=BATADV_HARDIF_WIFI_WEXT_DIRECT ; -if (batadv_is_cfg80211_netdev (net_device)) +if (netdev_is_wireless (net_device)) wifi_flags |=BATADV_HARDIF_WIFI_CFG80211_DIRECT ; real_netdev =batadv_get_real_netdevice (net_device);
@@ -341,7 +321,7 @@ static u32 batadv_wifi_flags_evaluate(struct net_device *net_device)if (batadv_is_wext_netdev (real_netdev)) wifi_flags |=BATADV_HARDIF_WIFI_WEXT_INDIRECT ; -if (batadv_is_cfg80211_netdev (real_netdev)) +if (netdev_is_wireless (real_netdev)) wifi_flags |=BATADV_HARDIF_WIFI_CFG80211_INDIRECT ; out: