diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2009-11-05 01:05:10 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-05 01:05:10 -0500 |
commit | 9f9354b92defa15aa0e215946c6e2dbccecb6aa7 (patch) | |
tree | c0523c0ee5346c726245921ec93b4a400784e765 /net | |
parent | b4d745db12bd2d45a456565ed63325bbfc689e68 (diff) |
net: net/ipv4/devinet.c cleanups
As pointed by Stephen Rothwell, commit c6d14c84 added a warning :
net/ipv4/devinet.c: In function 'inet_select_addr':
net/ipv4/devinet.c:902: warning: label 'out' defined but not used
delete unused 'out' label and do some cleanups as well
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/devinet.c | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 8aa7a134c1f1..c2045f9615da 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -140,11 +140,11 @@ void in_dev_finish_destroy(struct in_device *idev) | |||
140 | #endif | 140 | #endif |
141 | dev_put(dev); | 141 | dev_put(dev); |
142 | if (!idev->dead) | 142 | if (!idev->dead) |
143 | printk("Freeing alive in_device %p\n", idev); | 143 | pr_err("Freeing alive in_device %p\n", idev); |
144 | else { | 144 | else |
145 | kfree(idev); | 145 | kfree(idev); |
146 | } | ||
147 | } | 146 | } |
147 | EXPORT_SYMBOL(in_dev_finish_destroy); | ||
148 | 148 | ||
149 | static struct in_device *inetdev_init(struct net_device *dev) | 149 | static struct in_device *inetdev_init(struct net_device *dev) |
150 | { | 150 | { |
@@ -159,7 +159,8 @@ static struct in_device *inetdev_init(struct net_device *dev) | |||
159 | sizeof(in_dev->cnf)); | 159 | sizeof(in_dev->cnf)); |
160 | in_dev->cnf.sysctl = NULL; | 160 | in_dev->cnf.sysctl = NULL; |
161 | in_dev->dev = dev; | 161 | in_dev->dev = dev; |
162 | if ((in_dev->arp_parms = neigh_parms_alloc(dev, &arp_tbl)) == NULL) | 162 | in_dev->arp_parms = neigh_parms_alloc(dev, &arp_tbl); |
163 | if (!in_dev->arp_parms) | ||
163 | goto out_kfree; | 164 | goto out_kfree; |
164 | if (IPV4_DEVCONF(in_dev->cnf, FORWARDING)) | 165 | if (IPV4_DEVCONF(in_dev->cnf, FORWARDING)) |
165 | dev_disable_lro(dev); | 166 | dev_disable_lro(dev); |
@@ -413,6 +414,7 @@ struct in_device *inetdev_by_index(struct net *net, int ifindex) | |||
413 | rcu_read_unlock(); | 414 | rcu_read_unlock(); |
414 | return in_dev; | 415 | return in_dev; |
415 | } | 416 | } |
417 | EXPORT_SYMBOL(inetdev_by_index); | ||
416 | 418 | ||
417 | /* Called only from RTNL semaphored context. No locks. */ | 419 | /* Called only from RTNL semaphored context. No locks. */ |
418 | 420 | ||
@@ -558,7 +560,7 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg | |||
558 | * Determine a default network mask, based on the IP address. | 560 | * Determine a default network mask, based on the IP address. |
559 | */ | 561 | */ |
560 | 562 | ||
561 | static __inline__ int inet_abc_len(__be32 addr) | 563 | static inline int inet_abc_len(__be32 addr) |
562 | { | 564 | { |
563 | int rc = -1; /* Something else, probably a multicast. */ | 565 | int rc = -1; /* Something else, probably a multicast. */ |
564 | 566 | ||
@@ -647,13 +649,15 @@ int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg) | |||
647 | rtnl_lock(); | 649 | rtnl_lock(); |
648 | 650 | ||
649 | ret = -ENODEV; | 651 | ret = -ENODEV; |
650 | if ((dev = __dev_get_by_name(net, ifr.ifr_name)) == NULL) | 652 | dev = __dev_get_by_name(net, ifr.ifr_name); |
653 | if (!dev) | ||
651 | goto done; | 654 | goto done; |
652 | 655 | ||
653 | if (colon) | 656 | if (colon) |
654 | *colon = ':'; | 657 | *colon = ':'; |
655 | 658 | ||
656 | if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) { | 659 | in_dev = __in_dev_get_rtnl(dev); |
660 | if (in_dev) { | ||
657 | if (tryaddrmatch) { | 661 | if (tryaddrmatch) { |
658 | /* Matthias Andree */ | 662 | /* Matthias Andree */ |
659 | /* compare label and address (4.4BSD style) */ | 663 | /* compare label and address (4.4BSD style) */ |
@@ -721,7 +725,8 @@ int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg) | |||
721 | 725 | ||
722 | if (!ifa) { | 726 | if (!ifa) { |
723 | ret = -ENOBUFS; | 727 | ret = -ENOBUFS; |
724 | if ((ifa = inet_alloc_ifa()) == NULL) | 728 | ifa = inet_alloc_ifa(); |
729 | if (!ifa) | ||
725 | break; | 730 | break; |
726 | if (colon) | 731 | if (colon) |
727 | memcpy(ifa->ifa_label, ifr.ifr_name, IFNAMSIZ); | 732 | memcpy(ifa->ifa_label, ifr.ifr_name, IFNAMSIZ); |
@@ -823,10 +828,10 @@ static int inet_gifconf(struct net_device *dev, char __user *buf, int len) | |||
823 | struct ifreq ifr; | 828 | struct ifreq ifr; |
824 | int done = 0; | 829 | int done = 0; |
825 | 830 | ||
826 | if (!in_dev || (ifa = in_dev->ifa_list) == NULL) | 831 | if (!in_dev) |
827 | goto out; | 832 | goto out; |
828 | 833 | ||
829 | for (; ifa; ifa = ifa->ifa_next) { | 834 | for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { |
830 | if (!buf) { | 835 | if (!buf) { |
831 | done += sizeof(ifr); | 836 | done += sizeof(ifr); |
832 | continue; | 837 | continue; |
@@ -877,16 +882,17 @@ __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope) | |||
877 | addr = ifa->ifa_local; | 882 | addr = ifa->ifa_local; |
878 | } endfor_ifa(in_dev); | 883 | } endfor_ifa(in_dev); |
879 | 884 | ||
880 | no_in_dev: | ||
881 | if (addr) | 885 | if (addr) |
882 | goto out_unlock; | 886 | goto out_unlock; |
887 | no_in_dev: | ||
883 | 888 | ||
884 | /* Not loopback addresses on loopback should be preferred | 889 | /* Not loopback addresses on loopback should be preferred |
885 | in this case. It is importnat that lo is the first interface | 890 | in this case. It is importnat that lo is the first interface |
886 | in dev_base list. | 891 | in dev_base list. |
887 | */ | 892 | */ |
888 | for_each_netdev_rcu(net, dev) { | 893 | for_each_netdev_rcu(net, dev) { |
889 | if ((in_dev = __in_dev_get_rcu(dev)) == NULL) | 894 | in_dev = __in_dev_get_rcu(dev); |
895 | if (!in_dev) | ||
890 | continue; | 896 | continue; |
891 | 897 | ||
892 | for_primary_ifa(in_dev) { | 898 | for_primary_ifa(in_dev) { |
@@ -899,9 +905,9 @@ no_in_dev: | |||
899 | } | 905 | } |
900 | out_unlock: | 906 | out_unlock: |
901 | rcu_read_unlock(); | 907 | rcu_read_unlock(); |
902 | out: | ||
903 | return addr; | 908 | return addr; |
904 | } | 909 | } |
910 | EXPORT_SYMBOL(inet_select_addr); | ||
905 | 911 | ||
906 | static __be32 confirm_addr_indev(struct in_device *in_dev, __be32 dst, | 912 | static __be32 confirm_addr_indev(struct in_device *in_dev, __be32 dst, |
907 | __be32 local, int scope) | 913 | __be32 local, int scope) |
@@ -937,7 +943,7 @@ static __be32 confirm_addr_indev(struct in_device *in_dev, __be32 dst, | |||
937 | } | 943 | } |
938 | } endfor_ifa(in_dev); | 944 | } endfor_ifa(in_dev); |
939 | 945 | ||
940 | return same? addr : 0; | 946 | return same ? addr : 0; |
941 | } | 947 | } |
942 | 948 | ||
943 | /* | 949 | /* |
@@ -960,7 +966,8 @@ __be32 inet_confirm_addr(struct in_device *in_dev, | |||
960 | net = dev_net(in_dev->dev); | 966 | net = dev_net(in_dev->dev); |
961 | rcu_read_lock(); | 967 | rcu_read_lock(); |
962 | for_each_netdev_rcu(net, dev) { | 968 | for_each_netdev_rcu(net, dev) { |
963 | if ((in_dev = __in_dev_get_rcu(dev))) { | 969 | in_dev = __in_dev_get_rcu(dev); |
970 | if (in_dev) { | ||
964 | addr = confirm_addr_indev(in_dev, dst, local, scope); | 971 | addr = confirm_addr_indev(in_dev, dst, local, scope); |
965 | if (addr) | 972 | if (addr) |
966 | break; | 973 | break; |
@@ -979,14 +986,16 @@ int register_inetaddr_notifier(struct notifier_block *nb) | |||
979 | { | 986 | { |
980 | return blocking_notifier_chain_register(&inetaddr_chain, nb); | 987 | return blocking_notifier_chain_register(&inetaddr_chain, nb); |
981 | } | 988 | } |
989 | EXPORT_SYMBOL(register_inetaddr_notifier); | ||
982 | 990 | ||
983 | int unregister_inetaddr_notifier(struct notifier_block *nb) | 991 | int unregister_inetaddr_notifier(struct notifier_block *nb) |
984 | { | 992 | { |
985 | return blocking_notifier_chain_unregister(&inetaddr_chain, nb); | 993 | return blocking_notifier_chain_unregister(&inetaddr_chain, nb); |
986 | } | 994 | } |
995 | EXPORT_SYMBOL(unregister_inetaddr_notifier); | ||
987 | 996 | ||
988 | /* Rename ifa_labels for a device name change. Make some effort to preserve existing | 997 | /* Rename ifa_labels for a device name change. Make some effort to preserve |
989 | * alias numbering and to create unique labels if possible. | 998 | * existing alias numbering and to create unique labels if possible. |
990 | */ | 999 | */ |
991 | static void inetdev_changename(struct net_device *dev, struct in_device *in_dev) | 1000 | static void inetdev_changename(struct net_device *dev, struct in_device *in_dev) |
992 | { | 1001 | { |
@@ -1005,11 +1014,10 @@ static void inetdev_changename(struct net_device *dev, struct in_device *in_dev) | |||
1005 | sprintf(old, ":%d", named); | 1014 | sprintf(old, ":%d", named); |
1006 | dot = old; | 1015 | dot = old; |
1007 | } | 1016 | } |
1008 | if (strlen(dot) + strlen(dev->name) < IFNAMSIZ) { | 1017 | if (strlen(dot) + strlen(dev->name) < IFNAMSIZ) |
1009 | strcat(ifa->ifa_label, dot); | 1018 | strcat(ifa->ifa_label, dot); |
1010 | } else { | 1019 | else |
1011 | strcpy(ifa->ifa_label + (IFNAMSIZ - strlen(dot) - 1), dot); | 1020 | strcpy(ifa->ifa_label + (IFNAMSIZ - strlen(dot) - 1), dot); |
1012 | } | ||
1013 | skip: | 1021 | skip: |
1014 | rtmsg_ifa(RTM_NEWADDR, ifa, NULL, 0); | 1022 | rtmsg_ifa(RTM_NEWADDR, ifa, NULL, 0); |
1015 | } | 1023 | } |
@@ -1056,8 +1064,9 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
1056 | if (!inetdev_valid_mtu(dev->mtu)) | 1064 | if (!inetdev_valid_mtu(dev->mtu)) |
1057 | break; | 1065 | break; |
1058 | if (dev->flags & IFF_LOOPBACK) { | 1066 | if (dev->flags & IFF_LOOPBACK) { |
1059 | struct in_ifaddr *ifa; | 1067 | struct in_ifaddr *ifa = inet_alloc_ifa(); |
1060 | if ((ifa = inet_alloc_ifa()) != NULL) { | 1068 | |
1069 | if (ifa) { | ||
1061 | ifa->ifa_local = | 1070 | ifa->ifa_local = |
1062 | ifa->ifa_address = htonl(INADDR_LOOPBACK); | 1071 | ifa->ifa_address = htonl(INADDR_LOOPBACK); |
1063 | ifa->ifa_prefixlen = 8; | 1072 | ifa->ifa_prefixlen = 8; |
@@ -1178,7 +1187,8 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) | |||
1178 | goto cont; | 1187 | goto cont; |
1179 | if (idx > s_idx) | 1188 | if (idx > s_idx) |
1180 | s_ip_idx = 0; | 1189 | s_ip_idx = 0; |
1181 | if ((in_dev = __in_dev_get_rtnl(dev)) == NULL) | 1190 | in_dev = __in_dev_get_rtnl(dev); |
1191 | if (!in_dev) | ||
1182 | goto cont; | 1192 | goto cont; |
1183 | 1193 | ||
1184 | for (ifa = in_dev->ifa_list, ip_idx = 0; ifa; | 1194 | for (ifa = in_dev->ifa_list, ip_idx = 0; ifa; |
@@ -1673,8 +1683,3 @@ void __init devinet_init(void) | |||
1673 | rtnl_register(PF_INET, RTM_GETADDR, NULL, inet_dump_ifaddr); | 1683 | rtnl_register(PF_INET, RTM_GETADDR, NULL, inet_dump_ifaddr); |
1674 | } | 1684 | } |
1675 | 1685 | ||
1676 | EXPORT_SYMBOL(in_dev_finish_destroy); | ||
1677 | EXPORT_SYMBOL(inet_select_addr); | ||
1678 | EXPORT_SYMBOL(inetdev_by_index); | ||
1679 | EXPORT_SYMBOL(register_inetaddr_notifier); | ||
1680 | EXPORT_SYMBOL(unregister_inetaddr_notifier); | ||