]> git.itanic.dy.fi Git - linux-stable/commitdiff
net: socket: remove register_gifconf
authorArnd Bergmann <arnd@arndb.de>
Thu, 22 Jul 2021 14:29:01 +0000 (16:29 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Sep 2022 09:10:35 +0000 (11:10 +0200)
[ Upstream commit b0e99d03778b2418aec20db99d97d19d25d198b6 ]

Since dynamic registration of the gifconf() helper is only used for
IPv4, and this can not be in a loadable module, this can be simplified
noticeably by turning it into a direct function call as a preparation
for cleaning up the compat handling.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Stable-dep-of: 5641c751fe2f ("net: enetc: deny offload of tc-based TSN features on VF interfaces")
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/inetdevice.h
include/linux/netdevice.h
net/core/dev_ioctl.c
net/ipv4/devinet.c

index b68fca08be27cbb84644c9d7aa7f529f92f563b5..3088d94684c1c60cb93bf35d45a3d527769b453e 100644 (file)
@@ -178,6 +178,15 @@ static inline struct net_device *ip_dev_find(struct net *net, __be32 addr)
 
 int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b);
 int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *);
+#ifdef CONFIG_INET
+int inet_gifconf(struct net_device *dev, char __user *buf, int len, int size);
+#else
+static inline int inet_gifconf(struct net_device *dev, char __user *buf,
+                              int len, int size)
+{
+       return 0;
+}
+#endif
 void devinet_init(void);
 struct in_device *inetdev_by_index(struct net *, int);
 __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope);
index 6564fb4ac49e1a80639200d473038088417d7d5d..ef75567efd27ad922942270dde2c601f2be6031c 100644 (file)
@@ -3201,14 +3201,6 @@ static inline bool dev_has_header(const struct net_device *dev)
        return dev->header_ops && dev->header_ops->create;
 }
 
-typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr,
-                          int len, int size);
-int register_gifconf(unsigned int family, gifconf_func_t *gifconf);
-static inline int unregister_gifconf(unsigned int family)
-{
-       return register_gifconf(family, NULL);
-}
-
 #ifdef CONFIG_NET_FLOW_LIMIT
 #define FLOW_LIMIT_HISTORY     (1 << 7)  /* must be ^2 and !overflow buckets */
 struct sd_flow_limit {
index 54fb18b4f55e49a910b7b5931366ccba3e2397d2..993420da29307226a5c640dc926468f728b89eef 100644 (file)
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/kmod.h>
 #include <linux/netdevice.h>
+#include <linux/inetdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/rtnetlink.h>
 #include <linux/net_tstamp.h>
@@ -25,26 +26,6 @@ static int dev_ifname(struct net *net, struct ifreq *ifr)
        return netdev_get_name(net, ifr->ifr_name, ifr->ifr_ifindex);
 }
 
-static gifconf_func_t *gifconf_list[NPROTO];
-
-/**
- *     register_gifconf        -       register a SIOCGIF handler
- *     @family: Address family
- *     @gifconf: Function handler
- *
- *     Register protocol dependent address dumping routines. The handler
- *     that is passed must not be freed or reused until it has been replaced
- *     by another handler.
- */
-int register_gifconf(unsigned int family, gifconf_func_t *gifconf)
-{
-       if (family >= NPROTO)
-               return -EINVAL;
-       gifconf_list[family] = gifconf;
-       return 0;
-}
-EXPORT_SYMBOL(register_gifconf);
-
 /*
  *     Perform a SIOCGIFCONF call. This structure will change
  *     size eventually, and there is nothing I can do about it.
@@ -57,7 +38,6 @@ int dev_ifconf(struct net *net, struct ifconf *ifc, int size)
        char __user *pos;
        int len;
        int total;
-       int i;
 
        /*
         *      Fetch the caller's info block.
@@ -72,19 +52,15 @@ int dev_ifconf(struct net *net, struct ifconf *ifc, int size)
 
        total = 0;
        for_each_netdev(net, dev) {
-               for (i = 0; i < NPROTO; i++) {
-                       if (gifconf_list[i]) {
-                               int done;
-                               if (!pos)
-                                       done = gifconf_list[i](dev, NULL, 0, size);
-                               else
-                                       done = gifconf_list[i](dev, pos + total,
-                                                              len - total, size);
-                               if (done < 0)
-                                       return -EFAULT;
-                               total += done;
-                       }
-               }
+               int done;
+               if (!pos)
+                       done = inet_gifconf(dev, NULL, 0, size);
+               else
+                       done = inet_gifconf(dev, pos + total,
+                                           len - total, size);
+               if (done < 0)
+                       return -EFAULT;
+               total += done;
        }
 
        /*
index 8f17538755507d6ec67efeee5adf70e255976794..88b6120878cd9abfb3b9fe0423e5dbf0ffdd6375 100644 (file)
@@ -1244,7 +1244,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr)
        return ret;
 }
 
-static int inet_gifconf(struct net_device *dev, char __user *buf, int len, int size)
+int inet_gifconf(struct net_device *dev, char __user *buf, int len, int size)
 {
        struct in_device *in_dev = __in_dev_get_rtnl(dev);
        const struct in_ifaddr *ifa;
@@ -2766,8 +2766,6 @@ void __init devinet_init(void)
                INIT_HLIST_HEAD(&inet_addr_lst[i]);
 
        register_pernet_subsys(&devinet_ops);
-
-       register_gifconf(PF_INET, inet_gifconf);
        register_netdevice_notifier(&ip_netdev_notifier);
 
        queue_delayed_work(system_power_efficient_wq, &check_lifetime_work, 0);