diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-12-01 08:55:54 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:55:36 -0500 |
commit | 66f27a52037c89183e83689b0531412577be0101 (patch) | |
tree | a746d24ad70e9eb7d3aef9e4c798cd65db2cfe63 /net/ipv4/devinet.c | |
parent | edae58ead57319b0bcf16e48a32365145c7bf0b7 (diff) |
[IPV4]: Unify and cleanup calls to devinet_sysctl_register
Currently this call is used to register sysctls for devices
and for the "default" confs. The "all" sysctls are registered
separately.
Besides, the inet_device is passed to this function, but it is
not needed there at all - just the device name and ifindex are
required.
Thanks to Herbert, who noticed, that this call doesn't even
require the devconf pointer (the last argument) - all we need
we can take from the in_device itself.
The fix is to make a __devinet_sysctl_register(), which registers
sysctls for all "devices" we need, including "default" and "all" :)
The original devinet_sysctl_register() works with struct net_device,
not the inet_device, and calls the introduced function, passing
the device name and ifindex (to be used as procname and ctl_name)
into it.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/devinet.c')
-rw-r--r-- | net/ipv4/devinet.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 72dd0ecb1081..a3a7d301736e 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -98,8 +98,7 @@ static BLOCKING_NOTIFIER_HEAD(inetaddr_chain); | |||
98 | static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap, | 98 | static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap, |
99 | int destroy); | 99 | int destroy); |
100 | #ifdef CONFIG_SYSCTL | 100 | #ifdef CONFIG_SYSCTL |
101 | static void devinet_sysctl_register(struct in_device *in_dev, | 101 | static void devinet_sysctl_register(struct in_device *idev); |
102 | struct ipv4_devconf *p); | ||
103 | static void devinet_sysctl_unregister(struct ipv4_devconf *p); | 102 | static void devinet_sysctl_unregister(struct ipv4_devconf *p); |
104 | #endif | 103 | #endif |
105 | 104 | ||
@@ -173,7 +172,7 @@ static struct in_device *inetdev_init(struct net_device *dev) | |||
173 | in_dev_hold(in_dev); | 172 | in_dev_hold(in_dev); |
174 | 173 | ||
175 | #ifdef CONFIG_SYSCTL | 174 | #ifdef CONFIG_SYSCTL |
176 | devinet_sysctl_register(in_dev, &in_dev->cnf); | 175 | devinet_sysctl_register(in_dev); |
177 | #endif | 176 | #endif |
178 | ip_mc_init_dev(in_dev); | 177 | ip_mc_init_dev(in_dev); |
179 | if (dev->flags & IFF_UP) | 178 | if (dev->flags & IFF_UP) |
@@ -1119,7 +1118,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
1119 | neigh_sysctl_unregister(in_dev->arp_parms); | 1118 | neigh_sysctl_unregister(in_dev->arp_parms); |
1120 | neigh_sysctl_register(dev, in_dev->arp_parms, NET_IPV4, | 1119 | neigh_sysctl_register(dev, in_dev->arp_parms, NET_IPV4, |
1121 | NET_IPV4_NEIGH, "ipv4", NULL, NULL); | 1120 | NET_IPV4_NEIGH, "ipv4", NULL, NULL); |
1122 | devinet_sysctl_register(in_dev, &in_dev->cnf); | 1121 | devinet_sysctl_register(in_dev); |
1123 | #endif | 1122 | #endif |
1124 | break; | 1123 | break; |
1125 | } | 1124 | } |
@@ -1501,13 +1500,11 @@ static struct devinet_sysctl_table { | |||
1501 | }, | 1500 | }, |
1502 | }; | 1501 | }; |
1503 | 1502 | ||
1504 | static void devinet_sysctl_register(struct in_device *in_dev, | 1503 | static void __devinet_sysctl_register(char *dev_name, int ctl_name, |
1505 | struct ipv4_devconf *p) | 1504 | struct ipv4_devconf *p) |
1506 | { | 1505 | { |
1507 | int i; | 1506 | int i; |
1508 | struct net_device *dev = in_dev ? in_dev->dev : NULL; | ||
1509 | struct devinet_sysctl_table *t; | 1507 | struct devinet_sysctl_table *t; |
1510 | char *dev_name = NULL; | ||
1511 | 1508 | ||
1512 | t = kmemdup(&devinet_sysctl, sizeof(*t), GFP_KERNEL); | 1509 | t = kmemdup(&devinet_sysctl, sizeof(*t), GFP_KERNEL); |
1513 | if (!t) | 1510 | if (!t) |
@@ -1518,13 +1515,7 @@ static void devinet_sysctl_register(struct in_device *in_dev, | |||
1518 | t->devinet_vars[i].extra1 = p; | 1515 | t->devinet_vars[i].extra1 = p; |
1519 | } | 1516 | } |
1520 | 1517 | ||
1521 | if (dev) { | 1518 | t->devinet_dev[0].ctl_name = ctl_name; |
1522 | dev_name = dev->name; | ||
1523 | t->devinet_dev[0].ctl_name = dev->ifindex; | ||
1524 | } else { | ||
1525 | dev_name = "default"; | ||
1526 | t->devinet_dev[0].ctl_name = NET_PROTO_CONF_DEFAULT; | ||
1527 | } | ||
1528 | 1519 | ||
1529 | /* | 1520 | /* |
1530 | * Make a copy of dev_name, because '.procname' is regarded as const | 1521 | * Make a copy of dev_name, because '.procname' is regarded as const |
@@ -1556,6 +1547,12 @@ out: | |||
1556 | return; | 1547 | return; |
1557 | } | 1548 | } |
1558 | 1549 | ||
1550 | static void devinet_sysctl_register(struct in_device *idev) | ||
1551 | { | ||
1552 | return __devinet_sysctl_register(idev->dev->name, idev->dev->ifindex, | ||
1553 | &idev->cnf); | ||
1554 | } | ||
1555 | |||
1559 | static void devinet_sysctl_unregister(struct ipv4_devconf *p) | 1556 | static void devinet_sysctl_unregister(struct ipv4_devconf *p) |
1560 | { | 1557 | { |
1561 | if (p->sysctl) { | 1558 | if (p->sysctl) { |
@@ -1577,9 +1574,10 @@ void __init devinet_init(void) | |||
1577 | rtnl_register(PF_INET, RTM_DELADDR, inet_rtm_deladdr, NULL); | 1574 | rtnl_register(PF_INET, RTM_DELADDR, inet_rtm_deladdr, NULL); |
1578 | rtnl_register(PF_INET, RTM_GETADDR, NULL, inet_dump_ifaddr); | 1575 | rtnl_register(PF_INET, RTM_GETADDR, NULL, inet_dump_ifaddr); |
1579 | #ifdef CONFIG_SYSCTL | 1576 | #ifdef CONFIG_SYSCTL |
1580 | devinet_sysctl.sysctl_header = | 1577 | __devinet_sysctl_register("all", NET_PROTO_CONF_ALL, |
1581 | register_sysctl_table(devinet_sysctl.devinet_root_dir); | 1578 | &ipv4_devconf); |
1582 | devinet_sysctl_register(NULL, &ipv4_devconf_dflt); | 1579 | __devinet_sysctl_register("default", NET_PROTO_CONF_DEFAULT, |
1580 | &ipv4_devconf_dflt); | ||
1583 | #endif | 1581 | #endif |
1584 | } | 1582 | } |
1585 | 1583 | ||