Skip to content

Commit b0e99d0

Browse files
arndbdavem330
authored andcommitted
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>
1 parent 709566d commit b0e99d0

File tree

4 files changed

+20
-44
lines changed

4 files changed

+20
-44
lines changed

include/linux/inetdevice.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ static inline struct net_device *ip_dev_find(struct net *net, __be32 addr)
178178

179179
int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b);
180180
int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *);
181+
#ifdef CONFIG_INET
182+
int inet_gifconf(struct net_device *dev, char __user *buf, int len, int size);
183+
#else
184+
static inline int inet_gifconf(struct net_device *dev, char __user *buf,
185+
int len, int size)
186+
{
187+
return 0;
188+
}
189+
#endif
181190
void devinet_init(void);
182191
struct in_device *inetdev_by_index(struct net *, int);
183192
__be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope);

include/linux/netdevice.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,14 +3289,6 @@ static inline bool dev_has_header(const struct net_device *dev)
32893289
return dev->header_ops && dev->header_ops->create;
32903290
}
32913291

3292-
typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr,
3293-
int len, int size);
3294-
int register_gifconf(unsigned int family, gifconf_func_t *gifconf);
3295-
static inline int unregister_gifconf(unsigned int family)
3296-
{
3297-
return register_gifconf(family, NULL);
3298-
}
3299-
33003292
#ifdef CONFIG_NET_FLOW_LIMIT
33013293
#define FLOW_LIMIT_HISTORY (1 << 7) /* must be ^2 and !overflow buckets */
33023294
struct sd_flow_limit {

net/core/dev_ioctl.c

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <linux/kmod.h>
33
#include <linux/netdevice.h>
4+
#include <linux/inetdevice.h>
45
#include <linux/etherdevice.h>
56
#include <linux/rtnetlink.h>
67
#include <linux/net_tstamp.h>
@@ -25,26 +26,6 @@ static int dev_ifname(struct net *net, struct ifreq *ifr)
2526
return netdev_get_name(net, ifr->ifr_name, ifr->ifr_ifindex);
2627
}
2728

28-
static gifconf_func_t *gifconf_list[NPROTO];
29-
30-
/**
31-
* register_gifconf - register a SIOCGIF handler
32-
* @family: Address family
33-
* @gifconf: Function handler
34-
*
35-
* Register protocol dependent address dumping routines. The handler
36-
* that is passed must not be freed or reused until it has been replaced
37-
* by another handler.
38-
*/
39-
int register_gifconf(unsigned int family, gifconf_func_t *gifconf)
40-
{
41-
if (family >= NPROTO)
42-
return -EINVAL;
43-
gifconf_list[family] = gifconf;
44-
return 0;
45-
}
46-
EXPORT_SYMBOL(register_gifconf);
47-
4829
/*
4930
* Perform a SIOCGIFCONF call. This structure will change
5031
* size eventually, and there is nothing I can do about it.
@@ -72,19 +53,15 @@ int dev_ifconf(struct net *net, struct ifconf *ifc, int size)
7253

7354
total = 0;
7455
for_each_netdev(net, dev) {
75-
for (i = 0; i < NPROTO; i++) {
76-
if (gifconf_list[i]) {
77-
int done;
78-
if (!pos)
79-
done = gifconf_list[i](dev, NULL, 0, size);
80-
else
81-
done = gifconf_list[i](dev, pos + total,
82-
len - total, size);
83-
if (done < 0)
84-
return -EFAULT;
85-
total += done;
86-
}
87-
}
56+
int done;
57+
if (!pos)
58+
done = inet_gifconf(dev, NULL, 0, size);
59+
else
60+
done = inet_gifconf(dev, pos + total,
61+
len - total, size);
62+
if (done < 0)
63+
return -EFAULT;
64+
total += done;
8865
}
8966

9067
/*

net/ipv4/devinet.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr)
12431243
return ret;
12441244
}
12451245

1246-
static int inet_gifconf(struct net_device *dev, char __user *buf, int len, int size)
1246+
int inet_gifconf(struct net_device *dev, char __user *buf, int len, int size)
12471247
{
12481248
struct in_device *in_dev = __in_dev_get_rtnl(dev);
12491249
const struct in_ifaddr *ifa;
@@ -2766,8 +2766,6 @@ void __init devinet_init(void)
27662766
INIT_HLIST_HEAD(&inet_addr_lst[i]);
27672767

27682768
register_pernet_subsys(&devinet_ops);
2769-
2770-
register_gifconf(PF_INET, inet_gifconf);
27712769
register_netdevice_notifier(&ip_netdev_notifier);
27722770

27732771
queue_delayed_work(system_power_efficient_wq, &check_lifetime_work, 0);

0 commit comments

Comments
 (0)