aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/devinet.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/devinet.c')
-rw-r--r--net/ipv4/devinet.c34
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);
98static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap, 98static 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
101static void devinet_sysctl_register(struct in_device *in_dev, 101static void devinet_sysctl_register(struct in_device *idev);
102 struct ipv4_devconf *p);
103static void devinet_sysctl_unregister(struct ipv4_devconf *p); 102static 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
1504static void devinet_sysctl_register(struct in_device *in_dev, 1503static 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
1550static 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
1559static void devinet_sysctl_unregister(struct ipv4_devconf *p) 1556static 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