]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
net: wrap the wireless pointers in struct net_device in an ifdef
authorJakub Kicinski <kuba@kernel.org>
Thu, 19 May 2022 20:20:54 +0000 (13:20 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 22 May 2022 20:51:54 +0000 (21:51 +0100)
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.

Acked-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: Stefan Schmidt <stefan@datenfreihafen.org> # ieee802154
Acked-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netdevice.h
include/net/cfg80211.h
include/net/cfg802154.h
net/batman-adv/hard-interface.c
net/core/net-sysfs.c

index 1ce91cb8074a18797d2f990c7fd91b3f20c67cf0..f615a66c89e98b5d58e1b23d6674fa142106fb6e 100644 (file)
@@ -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_CFG80211)
        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
index cc8a9880b9d649cf7335789dab71306e30ca4a75..6d02e12e4702e91f915136e5cceb15af86da9dce 100644 (file)
@@ -8006,7 +8006,9 @@ int cfg80211_register_netdevice(struct net_device *dev);
  */
 static inline void cfg80211_unregister_netdevice(struct net_device *dev)
 {
+#if IS_ENABLED(CONFIG_CFG80211)
        cfg80211_unregister_wdev(dev->ieee80211_ptr);
+#endif
 }
 
 /**
index 85f9e84176884dd33bc0a442a3dfdf12cf3123cb..d8d8719315fd8400d5fb1dcff5c091c8c65a379c 100644 (file)
@@ -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);
index 83fb51b6e2994cb29a956667a53116581d94929b..b8f8da7ee3dea4ba09f958e476c6b6f77b05e23a 100644 (file)
@@ -307,9 +307,11 @@ static bool batadv_is_cfg80211_netdev(struct net_device *net_device)
        if (!net_device)
                return false;
 
+#if IS_ENABLED(CONFIG_CFG80211)
        /* cfg80211 drivers have to set ieee80211_ptr */
        if (net_device->ieee80211_ptr)
                return true;
+#endif
 
        return false;
 }
index 4980c3a50475936d0a5f70510ef9a812bc840bfc..e319e242dddf005492147fb066dbe0cfa56d2636 100644 (file)
@@ -746,7 +746,6 @@ static const struct attribute_group netstat_group = {
        .attrs  = netstat_attrs,
 };
 
-#if IS_ENABLED(CONFIG_WIRELESS_EXT) || IS_ENABLED(CONFIG_CFG80211)
 static struct attribute *wireless_attrs[] = {
        NULL
 };
@@ -755,7 +754,19 @@ static const struct attribute_group wireless_group = {
        .name = "wireless",
        .attrs = wireless_attrs,
 };
+
+static bool wireless_group_needed(struct net_device *ndev)
+{
+#if IS_ENABLED(CONFIG_CFG80211)
+       if (ndev->ieee80211_ptr)
+               return true;
 #endif
+#if IS_ENABLED(CONFIG_WIRELESS_EXT)
+       if (ndev->wireless_handlers)
+               return true;
+#endif
+       return false;
+}
 
 #else /* CONFIG_SYSFS */
 #define net_class_groups       NULL
@@ -1996,14 +2007,8 @@ 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)
-               *groups++ = &wireless_group;
-#if IS_ENABLED(CONFIG_WIRELESS_EXT)
-       else if (ndev->wireless_handlers)
+       if (wireless_group_needed(ndev))
                *groups++ = &wireless_group;
-#endif
-#endif
 #endif /* CONFIG_SYSFS */
 
        error = device_add(dev);