diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-12-11 05:17:40 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:57:09 -0500 |
commit | 51602b2a5e849babd94311e555bf1ba58151b8d4 (patch) | |
tree | 5082a8d99c8b9a83f1b0b491ceda9b9c315b1700 | |
parent | 01ecfe9ba63aa0f23bbdb15371916ba4d5382330 (diff) |
[IPV4]: Cleanup sysctl manipulations in devinet.c
This includes:
* moving neigh_sysctl_(un)register calls inside
devinet_sysctl_(un)register ones, as they are always
called in pairs;
* making __devinet_sysctl_unregister() to unregister
the ipv4_devconf struct, while original devinet_sysctl_unregister()
works with the in_device to handle both - devconf and
neigh sysctls;
* make stubs for CONFIG_SYSCTL=n case to get rid of
in-code ifdefs.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/devinet.c | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index d1dc0150647d..2dc2f7ed6bbe 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -99,7 +99,14 @@ 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 *idev); | 101 | static void devinet_sysctl_register(struct in_device *idev); |
102 | static void devinet_sysctl_unregister(struct ipv4_devconf *p); | 102 | static void devinet_sysctl_unregister(struct in_device *idev); |
103 | #else | ||
104 | static inline void devinet_sysctl_register(struct in_device *idev) | ||
105 | { | ||
106 | } | ||
107 | static inline void devinet_sysctl_unregister(struct in_device *idev) | ||
108 | { | ||
109 | } | ||
103 | #endif | 110 | #endif |
104 | 111 | ||
105 | /* Locks all the inet devices. */ | 112 | /* Locks all the inet devices. */ |
@@ -163,17 +170,10 @@ static struct in_device *inetdev_init(struct net_device *dev) | |||
163 | goto out_kfree; | 170 | goto out_kfree; |
164 | /* Reference in_dev->dev */ | 171 | /* Reference in_dev->dev */ |
165 | dev_hold(dev); | 172 | dev_hold(dev); |
166 | #ifdef CONFIG_SYSCTL | ||
167 | neigh_sysctl_register(dev, in_dev->arp_parms, NET_IPV4, | ||
168 | NET_IPV4_NEIGH, "ipv4", NULL, NULL); | ||
169 | #endif | ||
170 | |||
171 | /* Account for reference dev->ip_ptr (below) */ | 173 | /* Account for reference dev->ip_ptr (below) */ |
172 | in_dev_hold(in_dev); | 174 | in_dev_hold(in_dev); |
173 | 175 | ||
174 | #ifdef CONFIG_SYSCTL | ||
175 | devinet_sysctl_register(in_dev); | 176 | devinet_sysctl_register(in_dev); |
176 | #endif | ||
177 | ip_mc_init_dev(in_dev); | 177 | ip_mc_init_dev(in_dev); |
178 | if (dev->flags & IFF_UP) | 178 | if (dev->flags & IFF_UP) |
179 | ip_mc_up(in_dev); | 179 | ip_mc_up(in_dev); |
@@ -212,15 +212,9 @@ static void inetdev_destroy(struct in_device *in_dev) | |||
212 | inet_free_ifa(ifa); | 212 | inet_free_ifa(ifa); |
213 | } | 213 | } |
214 | 214 | ||
215 | #ifdef CONFIG_SYSCTL | ||
216 | devinet_sysctl_unregister(&in_dev->cnf); | ||
217 | #endif | ||
218 | |||
219 | dev->ip_ptr = NULL; | 215 | dev->ip_ptr = NULL; |
220 | 216 | ||
221 | #ifdef CONFIG_SYSCTL | 217 | devinet_sysctl_unregister(in_dev); |
222 | neigh_sysctl_unregister(in_dev->arp_parms); | ||
223 | #endif | ||
224 | neigh_parms_release(&arp_tbl, in_dev->arp_parms); | 218 | neigh_parms_release(&arp_tbl, in_dev->arp_parms); |
225 | arp_ifdown(dev); | 219 | arp_ifdown(dev); |
226 | 220 | ||
@@ -1113,13 +1107,8 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
1113 | */ | 1107 | */ |
1114 | inetdev_changename(dev, in_dev); | 1108 | inetdev_changename(dev, in_dev); |
1115 | 1109 | ||
1116 | #ifdef CONFIG_SYSCTL | 1110 | devinet_sysctl_unregister(in_dev); |
1117 | devinet_sysctl_unregister(&in_dev->cnf); | ||
1118 | neigh_sysctl_unregister(in_dev->arp_parms); | ||
1119 | neigh_sysctl_register(dev, in_dev->arp_parms, NET_IPV4, | ||
1120 | NET_IPV4_NEIGH, "ipv4", NULL, NULL); | ||
1121 | devinet_sysctl_register(in_dev); | 1111 | devinet_sysctl_register(in_dev); |
1122 | #endif | ||
1123 | break; | 1112 | break; |
1124 | } | 1113 | } |
1125 | out: | 1114 | out: |
@@ -1518,21 +1507,31 @@ out: | |||
1518 | return; | 1507 | return; |
1519 | } | 1508 | } |
1520 | 1509 | ||
1510 | static void __devinet_sysctl_unregister(struct ipv4_devconf *cnf) | ||
1511 | { | ||
1512 | struct devinet_sysctl_table *t = cnf->sysctl; | ||
1513 | |||
1514 | if (t == NULL) | ||
1515 | return; | ||
1516 | |||
1517 | cnf->sysctl = NULL; | ||
1518 | unregister_sysctl_table(t->sysctl_header); | ||
1519 | kfree(t->dev_name); | ||
1520 | kfree(t); | ||
1521 | } | ||
1522 | |||
1521 | static void devinet_sysctl_register(struct in_device *idev) | 1523 | static void devinet_sysctl_register(struct in_device *idev) |
1522 | { | 1524 | { |
1523 | return __devinet_sysctl_register(idev->dev->name, idev->dev->ifindex, | 1525 | neigh_sysctl_register(idev->dev, idev->arp_parms, NET_IPV4, |
1526 | NET_IPV4_NEIGH, "ipv4", NULL, NULL); | ||
1527 | __devinet_sysctl_register(idev->dev->name, idev->dev->ifindex, | ||
1524 | &idev->cnf); | 1528 | &idev->cnf); |
1525 | } | 1529 | } |
1526 | 1530 | ||
1527 | static void devinet_sysctl_unregister(struct ipv4_devconf *p) | 1531 | static void devinet_sysctl_unregister(struct in_device *idev) |
1528 | { | 1532 | { |
1529 | if (p->sysctl) { | 1533 | __devinet_sysctl_unregister(&idev->cnf); |
1530 | struct devinet_sysctl_table *t = p->sysctl; | 1534 | neigh_sysctl_unregister(idev->arp_parms); |
1531 | p->sysctl = NULL; | ||
1532 | unregister_sysctl_table(t->sysctl_header); | ||
1533 | kfree(t->dev_name); | ||
1534 | kfree(t); | ||
1535 | } | ||
1536 | } | 1535 | } |
1537 | #endif | 1536 | #endif |
1538 | 1537 | ||