diff options
Diffstat (limited to 'net/ipv4/devinet.c')
-rw-r--r-- | net/ipv4/devinet.c | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 98a00d0edc76..088888db8b3d 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -48,7 +48,6 @@ | |||
48 | #include <linux/netdevice.h> | 48 | #include <linux/netdevice.h> |
49 | #include <linux/etherdevice.h> | 49 | #include <linux/etherdevice.h> |
50 | #include <linux/skbuff.h> | 50 | #include <linux/skbuff.h> |
51 | #include <linux/rtnetlink.h> | ||
52 | #include <linux/init.h> | 51 | #include <linux/init.h> |
53 | #include <linux/notifier.h> | 52 | #include <linux/notifier.h> |
54 | #include <linux/inetdevice.h> | 53 | #include <linux/inetdevice.h> |
@@ -62,7 +61,7 @@ | |||
62 | #include <net/ip.h> | 61 | #include <net/ip.h> |
63 | #include <net/route.h> | 62 | #include <net/route.h> |
64 | #include <net/ip_fib.h> | 63 | #include <net/ip_fib.h> |
65 | #include <net/netlink.h> | 64 | #include <net/rtnetlink.h> |
66 | 65 | ||
67 | struct ipv4_devconf ipv4_devconf = { | 66 | struct ipv4_devconf ipv4_devconf = { |
68 | .accept_redirects = 1, | 67 | .accept_redirects = 1, |
@@ -633,7 +632,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg) | |||
633 | dev_load(ifr.ifr_name); | 632 | dev_load(ifr.ifr_name); |
634 | #endif | 633 | #endif |
635 | 634 | ||
636 | switch(cmd) { | 635 | switch (cmd) { |
637 | case SIOCGIFADDR: /* Get interface address */ | 636 | case SIOCGIFADDR: /* Get interface address */ |
638 | case SIOCGIFBRDADDR: /* Get the broadcast address */ | 637 | case SIOCGIFBRDADDR: /* Get the broadcast address */ |
639 | case SIOCGIFDSTADDR: /* Get the destination address */ | 638 | case SIOCGIFDSTADDR: /* Get the destination address */ |
@@ -708,7 +707,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg) | |||
708 | if (!ifa && cmd != SIOCSIFADDR && cmd != SIOCSIFFLAGS) | 707 | if (!ifa && cmd != SIOCSIFADDR && cmd != SIOCSIFFLAGS) |
709 | goto done; | 708 | goto done; |
710 | 709 | ||
711 | switch(cmd) { | 710 | switch (cmd) { |
712 | case SIOCGIFADDR: /* Get interface address */ | 711 | case SIOCGIFADDR: /* Get interface address */ |
713 | sin->sin_addr.s_addr = ifa->ifa_local; | 712 | sin->sin_addr.s_addr = ifa->ifa_local; |
714 | goto rarok; | 713 | goto rarok; |
@@ -1183,17 +1182,13 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) | |||
1183 | int s_ip_idx, s_idx = cb->args[0]; | 1182 | int s_ip_idx, s_idx = cb->args[0]; |
1184 | 1183 | ||
1185 | s_ip_idx = ip_idx = cb->args[1]; | 1184 | s_ip_idx = ip_idx = cb->args[1]; |
1186 | read_lock(&dev_base_lock); | ||
1187 | for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) { | 1185 | for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) { |
1188 | if (idx < s_idx) | 1186 | if (idx < s_idx) |
1189 | continue; | 1187 | continue; |
1190 | if (idx > s_idx) | 1188 | if (idx > s_idx) |
1191 | s_ip_idx = 0; | 1189 | s_ip_idx = 0; |
1192 | rcu_read_lock(); | 1190 | if ((in_dev = __in_dev_get_rtnl(dev)) == NULL) |
1193 | if ((in_dev = __in_dev_get_rcu(dev)) == NULL) { | ||
1194 | rcu_read_unlock(); | ||
1195 | continue; | 1191 | continue; |
1196 | } | ||
1197 | 1192 | ||
1198 | for (ifa = in_dev->ifa_list, ip_idx = 0; ifa; | 1193 | for (ifa = in_dev->ifa_list, ip_idx = 0; ifa; |
1199 | ifa = ifa->ifa_next, ip_idx++) { | 1194 | ifa = ifa->ifa_next, ip_idx++) { |
@@ -1201,16 +1196,12 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) | |||
1201 | continue; | 1196 | continue; |
1202 | if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid, | 1197 | if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid, |
1203 | cb->nlh->nlmsg_seq, | 1198 | cb->nlh->nlmsg_seq, |
1204 | RTM_NEWADDR, NLM_F_MULTI) <= 0) { | 1199 | RTM_NEWADDR, NLM_F_MULTI) <= 0) |
1205 | rcu_read_unlock(); | ||
1206 | goto done; | 1200 | goto done; |
1207 | } | ||
1208 | } | 1201 | } |
1209 | rcu_read_unlock(); | ||
1210 | } | 1202 | } |
1211 | 1203 | ||
1212 | done: | 1204 | done: |
1213 | read_unlock(&dev_base_lock); | ||
1214 | cb->args[0] = idx; | 1205 | cb->args[0] = idx; |
1215 | cb->args[1] = ip_idx; | 1206 | cb->args[1] = ip_idx; |
1216 | 1207 | ||
@@ -1241,19 +1232,6 @@ errout: | |||
1241 | rtnl_set_sk_err(RTNLGRP_IPV4_IFADDR, err); | 1232 | rtnl_set_sk_err(RTNLGRP_IPV4_IFADDR, err); |
1242 | } | 1233 | } |
1243 | 1234 | ||
1244 | static struct rtnetlink_link inet_rtnetlink_table[RTM_NR_MSGTYPES] = { | ||
1245 | [RTM_NEWADDR - RTM_BASE] = { .doit = inet_rtm_newaddr, }, | ||
1246 | [RTM_DELADDR - RTM_BASE] = { .doit = inet_rtm_deladdr, }, | ||
1247 | [RTM_GETADDR - RTM_BASE] = { .dumpit = inet_dump_ifaddr, }, | ||
1248 | [RTM_NEWROUTE - RTM_BASE] = { .doit = inet_rtm_newroute, }, | ||
1249 | [RTM_DELROUTE - RTM_BASE] = { .doit = inet_rtm_delroute, }, | ||
1250 | [RTM_GETROUTE - RTM_BASE] = { .doit = inet_rtm_getroute, | ||
1251 | .dumpit = inet_dump_fib, }, | ||
1252 | #ifdef CONFIG_IP_MULTIPLE_TABLES | ||
1253 | [RTM_GETRULE - RTM_BASE] = { .dumpit = fib4_rules_dump, }, | ||
1254 | #endif | ||
1255 | }; | ||
1256 | |||
1257 | #ifdef CONFIG_SYSCTL | 1235 | #ifdef CONFIG_SYSCTL |
1258 | 1236 | ||
1259 | void inet_forward_change(void) | 1237 | void inet_forward_change(void) |
@@ -1636,7 +1614,10 @@ void __init devinet_init(void) | |||
1636 | { | 1614 | { |
1637 | register_gifconf(PF_INET, inet_gifconf); | 1615 | register_gifconf(PF_INET, inet_gifconf); |
1638 | register_netdevice_notifier(&ip_netdev_notifier); | 1616 | register_netdevice_notifier(&ip_netdev_notifier); |
1639 | rtnetlink_links[PF_INET] = inet_rtnetlink_table; | 1617 | |
1618 | rtnl_register(PF_INET, RTM_NEWADDR, inet_rtm_newaddr, NULL); | ||
1619 | rtnl_register(PF_INET, RTM_DELADDR, inet_rtm_deladdr, NULL); | ||
1620 | rtnl_register(PF_INET, RTM_GETADDR, NULL, inet_dump_ifaddr); | ||
1640 | #ifdef CONFIG_SYSCTL | 1621 | #ifdef CONFIG_SYSCTL |
1641 | devinet_sysctl.sysctl_header = | 1622 | devinet_sysctl.sysctl_header = |
1642 | register_sysctl_table(devinet_sysctl.devinet_root_dir); | 1623 | register_sysctl_table(devinet_sysctl.devinet_root_dir); |