aboutsummaryrefslogtreecommitdiffstats
path: root/net/decnet
diff options
context:
space:
mode:
Diffstat (limited to 'net/decnet')
-rw-r--r--net/decnet/af_decnet.c11
-rw-r--r--net/decnet/dn_dev.c85
-rw-r--r--net/decnet/dn_fib.c2
-rw-r--r--net/decnet/dn_route.c14
4 files changed, 57 insertions, 55 deletions
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index a205eaa87f52..9fbe87c93802 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -721,7 +721,7 @@ static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
721 struct sock *sk = sock->sk; 721 struct sock *sk = sock->sk;
722 struct dn_scp *scp = DN_SK(sk); 722 struct dn_scp *scp = DN_SK(sk);
723 struct sockaddr_dn *saddr = (struct sockaddr_dn *)uaddr; 723 struct sockaddr_dn *saddr = (struct sockaddr_dn *)uaddr;
724 struct net_device *dev; 724 struct net_device *dev, *ldev;
725 int rv; 725 int rv;
726 726
727 if (addr_len != sizeof(struct sockaddr_dn)) 727 if (addr_len != sizeof(struct sockaddr_dn))
@@ -746,14 +746,17 @@ static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
746 if (!(saddr->sdn_flags & SDF_WILD)) { 746 if (!(saddr->sdn_flags & SDF_WILD)) {
747 if (dn_ntohs(saddr->sdn_nodeaddrl)) { 747 if (dn_ntohs(saddr->sdn_nodeaddrl)) {
748 read_lock(&dev_base_lock); 748 read_lock(&dev_base_lock);
749 for(dev = dev_base; dev; dev = dev->next) { 749 ldev = NULL;
750 for_each_netdev(dev) {
750 if (!dev->dn_ptr) 751 if (!dev->dn_ptr)
751 continue; 752 continue;
752 if (dn_dev_islocal(dev, dn_saddr2dn(saddr))) 753 if (dn_dev_islocal(dev, dn_saddr2dn(saddr))) {
754 ldev = dev;
753 break; 755 break;
756 }
754 } 757 }
755 read_unlock(&dev_base_lock); 758 read_unlock(&dev_base_lock);
756 if (dev == NULL) 759 if (ldev == NULL)
757 return -EADDRNOTAVAIL; 760 return -EADDRNOTAVAIL;
758 } 761 }
759 } 762 }
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index 5c2a9951b638..764a56a13e38 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -799,9 +799,10 @@ static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
799 skip_ndevs = cb->args[0]; 799 skip_ndevs = cb->args[0];
800 skip_naddr = cb->args[1]; 800 skip_naddr = cb->args[1];
801 801
802 for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) { 802 idx = 0;
803 for_each_netdev(dev) {
803 if (idx < skip_ndevs) 804 if (idx < skip_ndevs)
804 continue; 805 goto cont;
805 else if (idx > skip_ndevs) { 806 else if (idx > skip_ndevs) {
806 /* Only skip over addresses for first dev dumped 807 /* Only skip over addresses for first dev dumped
807 * in this iteration (idx == skip_ndevs) */ 808 * in this iteration (idx == skip_ndevs) */
@@ -809,18 +810,20 @@ static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
809 } 810 }
810 811
811 if ((dn_db = dev->dn_ptr) == NULL) 812 if ((dn_db = dev->dn_ptr) == NULL)
812 continue; 813 goto cont;
813 814
814 for (ifa = dn_db->ifa_list, dn_idx = 0; ifa; 815 for (ifa = dn_db->ifa_list, dn_idx = 0; ifa;
815 ifa = ifa->ifa_next, dn_idx++) { 816 ifa = ifa->ifa_next, dn_idx++) {
816 if (dn_idx < skip_naddr) 817 if (dn_idx < skip_naddr)
817 continue; 818 goto cont;
818 819
819 if (dn_nl_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid, 820 if (dn_nl_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
820 cb->nlh->nlmsg_seq, RTM_NEWADDR, 821 cb->nlh->nlmsg_seq, RTM_NEWADDR,
821 NLM_F_MULTI) < 0) 822 NLM_F_MULTI) < 0)
822 goto done; 823 goto done;
823 } 824 }
825cont:
826 idx++;
824 } 827 }
825done: 828done:
826 cb->args[0] = idx; 829 cb->args[0] = idx;
@@ -1296,7 +1299,7 @@ void dn_dev_devices_off(void)
1296 struct net_device *dev; 1299 struct net_device *dev;
1297 1300
1298 rtnl_lock(); 1301 rtnl_lock();
1299 for(dev = dev_base; dev; dev = dev->next) 1302 for_each_netdev(dev)
1300 dn_dev_down(dev); 1303 dn_dev_down(dev);
1301 rtnl_unlock(); 1304 rtnl_unlock();
1302 1305
@@ -1307,7 +1310,7 @@ void dn_dev_devices_on(void)
1307 struct net_device *dev; 1310 struct net_device *dev;
1308 1311
1309 rtnl_lock(); 1312 rtnl_lock();
1310 for(dev = dev_base; dev; dev = dev->next) { 1313 for_each_netdev(dev) {
1311 if (dev->flags & IFF_UP) 1314 if (dev->flags & IFF_UP)
1312 dn_dev_up(dev); 1315 dn_dev_up(dev);
1313 } 1316 }
@@ -1325,62 +1328,56 @@ int unregister_dnaddr_notifier(struct notifier_block *nb)
1325} 1328}
1326 1329
1327#ifdef CONFIG_PROC_FS 1330#ifdef CONFIG_PROC_FS
1328static inline struct net_device *dn_dev_get_next(struct seq_file *seq, struct net_device *dev) 1331static inline int is_dn_dev(struct net_device *dev)
1329{ 1332{
1330 do { 1333 return dev->dn_ptr != NULL;
1331 dev = dev->next;
1332 } while(dev && !dev->dn_ptr);
1333
1334 return dev;
1335} 1334}
1336 1335
1337static struct net_device *dn_dev_get_idx(struct seq_file *seq, loff_t pos) 1336static void *dn_dev_seq_start(struct seq_file *seq, loff_t *pos)
1338{ 1337{
1338 int i;
1339 struct net_device *dev; 1339 struct net_device *dev;
1340 1340
1341 dev = dev_base; 1341 read_lock(&dev_base_lock);
1342 if (dev && !dev->dn_ptr)
1343 dev = dn_dev_get_next(seq, dev);
1344 if (pos) {
1345 while(dev && (dev = dn_dev_get_next(seq, dev)))
1346 --pos;
1347 }
1348 return dev;
1349}
1350 1342
1351static void *dn_dev_seq_start(struct seq_file *seq, loff_t *pos) 1343 if (*pos == 0)
1352{ 1344 return SEQ_START_TOKEN;
1353 if (*pos) { 1345
1354 struct net_device *dev; 1346 i = 1;
1355 read_lock(&dev_base_lock); 1347 for_each_netdev(dev) {
1356 dev = dn_dev_get_idx(seq, *pos - 1); 1348 if (!is_dn_dev(dev))
1357 if (dev == NULL) 1349 continue;
1358 read_unlock(&dev_base_lock); 1350
1359 return dev; 1351 if (i++ == *pos)
1352 return dev;
1360 } 1353 }
1361 return SEQ_START_TOKEN; 1354
1355 return NULL;
1362} 1356}
1363 1357
1364static void *dn_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) 1358static void *dn_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1365{ 1359{
1366 struct net_device *dev = v; 1360 struct net_device *dev;
1367 loff_t one = 1;
1368 1361
1369 if (v == SEQ_START_TOKEN) {
1370 dev = dn_dev_seq_start(seq, &one);
1371 } else {
1372 dev = dn_dev_get_next(seq, dev);
1373 if (dev == NULL)
1374 read_unlock(&dev_base_lock);
1375 }
1376 ++*pos; 1362 ++*pos;
1377 return dev; 1363
1364 dev = (struct net_device *)v;
1365 if (v == SEQ_START_TOKEN)
1366 dev = net_device_entry(&dev_base_head);
1367
1368 for_each_netdev_continue(dev) {
1369 if (!is_dn_dev(dev))
1370 continue;
1371
1372 return dev;
1373 }
1374
1375 return NULL;
1378} 1376}
1379 1377
1380static void dn_dev_seq_stop(struct seq_file *seq, void *v) 1378static void dn_dev_seq_stop(struct seq_file *seq, void *v)
1381{ 1379{
1382 if (v && v != SEQ_START_TOKEN) 1380 read_unlock(&dev_base_lock);
1383 read_unlock(&dev_base_lock);
1384} 1381}
1385 1382
1386static char *dn_type2asc(char type) 1383static char *dn_type2asc(char type)
diff --git a/net/decnet/dn_fib.c b/net/decnet/dn_fib.c
index 310a86268d2b..d2bc19d47950 100644
--- a/net/decnet/dn_fib.c
+++ b/net/decnet/dn_fib.c
@@ -602,7 +602,7 @@ static void dn_fib_del_ifaddr(struct dn_ifaddr *ifa)
602 602
603 /* Scan device list */ 603 /* Scan device list */
604 read_lock(&dev_base_lock); 604 read_lock(&dev_base_lock);
605 for(dev = dev_base; dev; dev = dev->next) { 605 for_each_netdev(dev) {
606 dn_db = dev->dn_ptr; 606 dn_db = dev->dn_ptr;
607 if (dn_db == NULL) 607 if (dn_db == NULL)
608 continue; 608 continue;
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 5d7337bcf0fe..a8bf106b7a61 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -886,7 +886,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
886 .iif = loopback_dev.ifindex, 886 .iif = loopback_dev.ifindex,
887 .oif = oldflp->oif }; 887 .oif = oldflp->oif };
888 struct dn_route *rt = NULL; 888 struct dn_route *rt = NULL;
889 struct net_device *dev_out = NULL; 889 struct net_device *dev_out = NULL, *dev;
890 struct neighbour *neigh = NULL; 890 struct neighbour *neigh = NULL;
891 unsigned hash; 891 unsigned hash;
892 unsigned flags = 0; 892 unsigned flags = 0;
@@ -925,15 +925,17 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
925 goto out; 925 goto out;
926 } 926 }
927 read_lock(&dev_base_lock); 927 read_lock(&dev_base_lock);
928 for(dev_out = dev_base; dev_out; dev_out = dev_out->next) { 928 for_each_netdev(dev) {
929 if (!dev_out->dn_ptr) 929 if (!dev->dn_ptr)
930 continue; 930 continue;
931 if (!dn_dev_islocal(dev_out, oldflp->fld_src)) 931 if (!dn_dev_islocal(dev, oldflp->fld_src))
932 continue; 932 continue;
933 if ((dev_out->flags & IFF_LOOPBACK) && 933 if ((dev->flags & IFF_LOOPBACK) &&
934 oldflp->fld_dst && 934 oldflp->fld_dst &&
935 !dn_dev_islocal(dev_out, oldflp->fld_dst)) 935 !dn_dev_islocal(dev, oldflp->fld_dst))
936 continue; 936 continue;
937
938 dev_out = dev;
937 break; 939 break;
938 } 940 }
939 read_unlock(&dev_base_lock); 941 read_unlock(&dev_base_lock);