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.c66
1 files changed, 17 insertions, 49 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 6e447ff94dfa..10e15a144e95 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -217,8 +217,7 @@ void in_dev_finish_destroy(struct in_device *idev)
217 WARN_ON(idev->ifa_list); 217 WARN_ON(idev->ifa_list);
218 WARN_ON(idev->mc_list); 218 WARN_ON(idev->mc_list);
219#ifdef NET_REFCNT_DEBUG 219#ifdef NET_REFCNT_DEBUG
220 printk(KERN_DEBUG "in_dev_finish_destroy: %p=%s\n", 220 pr_debug("%s: %p=%s\n", __func__, idev, dev ? dev->name : "NIL");
221 idev, dev ? dev->name : "NIL");
222#endif 221#endif
223 dev_put(dev); 222 dev_put(dev);
224 if (!idev->dead) 223 if (!idev->dead)
@@ -1125,7 +1124,7 @@ skip:
1125 } 1124 }
1126} 1125}
1127 1126
1128static inline bool inetdev_valid_mtu(unsigned mtu) 1127static inline bool inetdev_valid_mtu(unsigned int mtu)
1129{ 1128{
1130 return mtu >= 68; 1129 return mtu >= 68;
1131} 1130}
@@ -1174,7 +1173,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
1174 1173
1175 switch (event) { 1174 switch (event) {
1176 case NETDEV_REGISTER: 1175 case NETDEV_REGISTER:
1177 printk(KERN_DEBUG "inetdev_event: bug\n"); 1176 pr_debug("%s: bug\n", __func__);
1178 RCU_INIT_POINTER(dev->ip_ptr, NULL); 1177 RCU_INIT_POINTER(dev->ip_ptr, NULL);
1179 break; 1178 break;
1180 case NETDEV_UP: 1179 case NETDEV_UP:
@@ -1266,17 +1265,15 @@ static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa,
1266 ifm->ifa_scope = ifa->ifa_scope; 1265 ifm->ifa_scope = ifa->ifa_scope;
1267 ifm->ifa_index = ifa->ifa_dev->dev->ifindex; 1266 ifm->ifa_index = ifa->ifa_dev->dev->ifindex;
1268 1267
1269 if (ifa->ifa_address) 1268 if ((ifa->ifa_address &&
1270 NLA_PUT_BE32(skb, IFA_ADDRESS, ifa->ifa_address); 1269 nla_put_be32(skb, IFA_ADDRESS, ifa->ifa_address)) ||
1271 1270 (ifa->ifa_local &&
1272 if (ifa->ifa_local) 1271 nla_put_be32(skb, IFA_LOCAL, ifa->ifa_local)) ||
1273 NLA_PUT_BE32(skb, IFA_LOCAL, ifa->ifa_local); 1272 (ifa->ifa_broadcast &&
1274 1273 nla_put_be32(skb, IFA_BROADCAST, ifa->ifa_broadcast)) ||
1275 if (ifa->ifa_broadcast) 1274 (ifa->ifa_label[0] &&
1276 NLA_PUT_BE32(skb, IFA_BROADCAST, ifa->ifa_broadcast); 1275 nla_put_string(skb, IFA_LABEL, ifa->ifa_label)))
1277 1276 goto nla_put_failure;
1278 if (ifa->ifa_label[0])
1279 NLA_PUT_STRING(skb, IFA_LABEL, ifa->ifa_label);
1280 1277
1281 return nlmsg_end(skb, nlh); 1278 return nlmsg_end(skb, nlh);
1282 1279
@@ -1587,7 +1584,6 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
1587static struct devinet_sysctl_table { 1584static struct devinet_sysctl_table {
1588 struct ctl_table_header *sysctl_header; 1585 struct ctl_table_header *sysctl_header;
1589 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX]; 1586 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
1590 char *dev_name;
1591} devinet_sysctl = { 1587} devinet_sysctl = {
1592 .devinet_vars = { 1588 .devinet_vars = {
1593 DEVINET_SYSCTL_COMPLEX_ENTRY(FORWARDING, "forwarding", 1589 DEVINET_SYSCTL_COMPLEX_ENTRY(FORWARDING, "forwarding",
@@ -1629,16 +1625,7 @@ static int __devinet_sysctl_register(struct net *net, char *dev_name,
1629{ 1625{
1630 int i; 1626 int i;
1631 struct devinet_sysctl_table *t; 1627 struct devinet_sysctl_table *t;
1632 1628 char path[sizeof("net/ipv4/conf/") + IFNAMSIZ];
1633#define DEVINET_CTL_PATH_DEV 3
1634
1635 struct ctl_path devinet_ctl_path[] = {
1636 { .procname = "net", },
1637 { .procname = "ipv4", },
1638 { .procname = "conf", },
1639 { /* to be set */ },
1640 { },
1641 };
1642 1629
1643 t = kmemdup(&devinet_sysctl, sizeof(*t), GFP_KERNEL); 1630 t = kmemdup(&devinet_sysctl, sizeof(*t), GFP_KERNEL);
1644 if (!t) 1631 if (!t)
@@ -1650,27 +1637,15 @@ static int __devinet_sysctl_register(struct net *net, char *dev_name,
1650 t->devinet_vars[i].extra2 = net; 1637 t->devinet_vars[i].extra2 = net;
1651 } 1638 }
1652 1639
1653 /* 1640 snprintf(path, sizeof(path), "net/ipv4/conf/%s", dev_name);
1654 * Make a copy of dev_name, because '.procname' is regarded as const
1655 * by sysctl and we wouldn't want anyone to change it under our feet
1656 * (see SIOCSIFNAME).
1657 */
1658 t->dev_name = kstrdup(dev_name, GFP_KERNEL);
1659 if (!t->dev_name)
1660 goto free;
1661
1662 devinet_ctl_path[DEVINET_CTL_PATH_DEV].procname = t->dev_name;
1663 1641
1664 t->sysctl_header = register_net_sysctl_table(net, devinet_ctl_path, 1642 t->sysctl_header = register_net_sysctl(net, path, t->devinet_vars);
1665 t->devinet_vars);
1666 if (!t->sysctl_header) 1643 if (!t->sysctl_header)
1667 goto free_procname; 1644 goto free;
1668 1645
1669 p->sysctl = t; 1646 p->sysctl = t;
1670 return 0; 1647 return 0;
1671 1648
1672free_procname:
1673 kfree(t->dev_name);
1674free: 1649free:
1675 kfree(t); 1650 kfree(t);
1676out: 1651out:
@@ -1686,7 +1661,6 @@ static void __devinet_sysctl_unregister(struct ipv4_devconf *cnf)
1686 1661
1687 cnf->sysctl = NULL; 1662 cnf->sysctl = NULL;
1688 unregister_net_sysctl_table(t->sysctl_header); 1663 unregister_net_sysctl_table(t->sysctl_header);
1689 kfree(t->dev_name);
1690 kfree(t); 1664 kfree(t);
1691} 1665}
1692 1666
@@ -1716,12 +1690,6 @@ static struct ctl_table ctl_forward_entry[] = {
1716 }, 1690 },
1717 { }, 1691 { },
1718}; 1692};
1719
1720static __net_initdata struct ctl_path net_ipv4_path[] = {
1721 { .procname = "net", },
1722 { .procname = "ipv4", },
1723 { },
1724};
1725#endif 1693#endif
1726 1694
1727static __net_init int devinet_init_net(struct net *net) 1695static __net_init int devinet_init_net(struct net *net)
@@ -1767,7 +1735,7 @@ static __net_init int devinet_init_net(struct net *net)
1767 goto err_reg_dflt; 1735 goto err_reg_dflt;
1768 1736
1769 err = -ENOMEM; 1737 err = -ENOMEM;
1770 forw_hdr = register_net_sysctl_table(net, net_ipv4_path, tbl); 1738 forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
1771 if (forw_hdr == NULL) 1739 if (forw_hdr == NULL)
1772 goto err_reg_ctl; 1740 goto err_reg_ctl;
1773 net->ipv4.forw_hdr = forw_hdr; 1741 net->ipv4.forw_hdr = forw_hdr;