net: socket: remove register_gifconf

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>
This commit is contained in:
Arnd Bergmann 2021-07-22 16:29:01 +02:00 committed by David S. Miller
parent 709566d792
commit b0e99d0377
4 changed files with 20 additions and 44 deletions

View 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 inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b);
int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *); 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); void devinet_init(void);
struct in_device *inetdev_by_index(struct net *, int); struct in_device *inetdev_by_index(struct net *, int);
__be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope); __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope);

View File

@ -3289,14 +3289,6 @@ static inline bool dev_has_header(const struct net_device *dev)
return dev->header_ops && dev->header_ops->create; 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 #ifdef CONFIG_NET_FLOW_LIMIT
#define FLOW_LIMIT_HISTORY (1 << 7) /* must be ^2 and !overflow buckets */ #define FLOW_LIMIT_HISTORY (1 << 7) /* must be ^2 and !overflow buckets */
struct sd_flow_limit { struct sd_flow_limit {

View File

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include <linux/kmod.h> #include <linux/kmod.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/inetdevice.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/net_tstamp.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); 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 * Perform a SIOCGIFCONF call. This structure will change
* size eventually, and there is nothing I can do about it. * size eventually, and there is nothing I can do about it.
@ -72,20 +53,16 @@ int dev_ifconf(struct net *net, struct ifconf *ifc, int size)
total = 0; total = 0;
for_each_netdev(net, dev) { for_each_netdev(net, dev) {
for (i = 0; i < NPROTO; i++) {
if (gifconf_list[i]) {
int done; int done;
if (!pos) if (!pos)
done = gifconf_list[i](dev, NULL, 0, size); done = inet_gifconf(dev, NULL, 0, size);
else else
done = gifconf_list[i](dev, pos + total, done = inet_gifconf(dev, pos + total,
len - total, size); len - total, size);
if (done < 0) if (done < 0)
return -EFAULT; return -EFAULT;
total += done; total += done;
} }
}
}
/* /*
* All done. Write the updated control block back to the caller. * All done. Write the updated control block back to the caller.

View File

@ -1243,7 +1243,7 @@ out:
return ret; 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); struct in_device *in_dev = __in_dev_get_rtnl(dev);
const struct in_ifaddr *ifa; const struct in_ifaddr *ifa;
@ -2766,8 +2766,6 @@ void __init devinet_init(void)
INIT_HLIST_HEAD(&inet_addr_lst[i]); INIT_HLIST_HEAD(&inet_addr_lst[i]);
register_pernet_subsys(&devinet_ops); register_pernet_subsys(&devinet_ops);
register_gifconf(PF_INET, inet_gifconf);
register_netdevice_notifier(&ip_netdev_notifier); register_netdevice_notifier(&ip_netdev_notifier);
queue_delayed_work(system_power_efficient_wq, &check_lifetime_work, 0); queue_delayed_work(system_power_efficient_wq, &check_lifetime_work, 0);