aboutsummaryrefslogtreecommitdiffstats
path: root/net/decnet
diff options
context:
space:
mode:
Diffstat (limited to 'net/decnet')
-rw-r--r--net/decnet/af_decnet.c15
-rw-r--r--net/decnet/dn_dev.c53
-rw-r--r--net/decnet/dn_fib.c10
-rw-r--r--net/decnet/dn_route.c10
-rw-r--r--net/decnet/dn_rules.c22
-rw-r--r--net/decnet/dn_table.c7
6 files changed, 65 insertions, 52 deletions
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index 7a58c87baf17..2b494fac9468 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -675,11 +675,12 @@ char *dn_addr2asc(__u16 addr, char *buf)
675 675
676 676
677 677
678static int dn_create(struct net *net, struct socket *sock, int protocol) 678static int dn_create(struct net *net, struct socket *sock, int protocol,
679 int kern)
679{ 680{
680 struct sock *sk; 681 struct sock *sk;
681 682
682 if (net != &init_net) 683 if (!net_eq(net, &init_net))
683 return -EAFNOSUPPORT; 684 return -EAFNOSUPPORT;
684 685
685 switch(sock->type) { 686 switch(sock->type) {
@@ -749,9 +750,9 @@ static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
749 750
750 if (!(saddr->sdn_flags & SDF_WILD)) { 751 if (!(saddr->sdn_flags & SDF_WILD)) {
751 if (le16_to_cpu(saddr->sdn_nodeaddrl)) { 752 if (le16_to_cpu(saddr->sdn_nodeaddrl)) {
752 read_lock(&dev_base_lock); 753 rcu_read_lock();
753 ldev = NULL; 754 ldev = NULL;
754 for_each_netdev(&init_net, dev) { 755 for_each_netdev_rcu(&init_net, dev) {
755 if (!dev->dn_ptr) 756 if (!dev->dn_ptr)
756 continue; 757 continue;
757 if (dn_dev_islocal(dev, dn_saddr2dn(saddr))) { 758 if (dn_dev_islocal(dev, dn_saddr2dn(saddr))) {
@@ -759,7 +760,7 @@ static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
759 break; 760 break;
760 } 761 }
761 } 762 }
762 read_unlock(&dev_base_lock); 763 rcu_read_unlock();
763 if (ldev == NULL) 764 if (ldev == NULL)
764 return -EADDRNOTAVAIL; 765 return -EADDRNOTAVAIL;
765 } 766 }
@@ -1955,7 +1956,7 @@ static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,
1955 } 1956 }
1956 1957
1957 if ((flags & MSG_TRYHARD) && sk->sk_dst_cache) 1958 if ((flags & MSG_TRYHARD) && sk->sk_dst_cache)
1958 dst_negative_advice(&sk->sk_dst_cache); 1959 dst_negative_advice(&sk->sk_dst_cache, sk);
1959 1960
1960 mss = scp->segsize_rem; 1961 mss = scp->segsize_rem;
1961 fctype = scp->services_rem & NSP_FC_MASK; 1962 fctype = scp->services_rem & NSP_FC_MASK;
@@ -2325,7 +2326,7 @@ static const struct file_operations dn_socket_seq_fops = {
2325}; 2326};
2326#endif 2327#endif
2327 2328
2328static struct net_proto_family dn_family_ops = { 2329static const struct net_proto_family dn_family_ops = {
2329 .family = AF_DECnet, 2330 .family = AF_DECnet,
2330 .create = dn_create, 2331 .create = dn_create,
2331 .owner = THIS_MODULE, 2332 .owner = THIS_MODULE,
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index 1b1daeb151f2..238af093495b 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -68,7 +68,7 @@ extern struct neigh_table dn_neigh_table;
68 */ 68 */
69__le16 decnet_address = 0; 69__le16 decnet_address = 0;
70 70
71static DEFINE_RWLOCK(dndev_lock); 71static DEFINE_SPINLOCK(dndev_lock);
72static struct net_device *decnet_default_device; 72static struct net_device *decnet_default_device;
73static BLOCKING_NOTIFIER_HEAD(dnaddr_chain); 73static BLOCKING_NOTIFIER_HEAD(dnaddr_chain);
74 74
@@ -499,7 +499,8 @@ rarok:
499struct net_device *dn_dev_get_default(void) 499struct net_device *dn_dev_get_default(void)
500{ 500{
501 struct net_device *dev; 501 struct net_device *dev;
502 read_lock(&dndev_lock); 502
503 spin_lock(&dndev_lock);
503 dev = decnet_default_device; 504 dev = decnet_default_device;
504 if (dev) { 505 if (dev) {
505 if (dev->dn_ptr) 506 if (dev->dn_ptr)
@@ -507,7 +508,8 @@ struct net_device *dn_dev_get_default(void)
507 else 508 else
508 dev = NULL; 509 dev = NULL;
509 } 510 }
510 read_unlock(&dndev_lock); 511 spin_unlock(&dndev_lock);
512
511 return dev; 513 return dev;
512} 514}
513 515
@@ -517,13 +519,15 @@ int dn_dev_set_default(struct net_device *dev, int force)
517 int rv = -EBUSY; 519 int rv = -EBUSY;
518 if (!dev->dn_ptr) 520 if (!dev->dn_ptr)
519 return -ENODEV; 521 return -ENODEV;
520 write_lock(&dndev_lock); 522
523 spin_lock(&dndev_lock);
521 if (force || decnet_default_device == NULL) { 524 if (force || decnet_default_device == NULL) {
522 old = decnet_default_device; 525 old = decnet_default_device;
523 decnet_default_device = dev; 526 decnet_default_device = dev;
524 rv = 0; 527 rv = 0;
525 } 528 }
526 write_unlock(&dndev_lock); 529 spin_unlock(&dndev_lock);
530
527 if (old) 531 if (old)
528 dev_put(old); 532 dev_put(old);
529 return rv; 533 return rv;
@@ -531,26 +535,29 @@ int dn_dev_set_default(struct net_device *dev, int force)
531 535
532static void dn_dev_check_default(struct net_device *dev) 536static void dn_dev_check_default(struct net_device *dev)
533{ 537{
534 write_lock(&dndev_lock); 538 spin_lock(&dndev_lock);
535 if (dev == decnet_default_device) { 539 if (dev == decnet_default_device) {
536 decnet_default_device = NULL; 540 decnet_default_device = NULL;
537 } else { 541 } else {
538 dev = NULL; 542 dev = NULL;
539 } 543 }
540 write_unlock(&dndev_lock); 544 spin_unlock(&dndev_lock);
545
541 if (dev) 546 if (dev)
542 dev_put(dev); 547 dev_put(dev);
543} 548}
544 549
550/*
551 * Called with RTNL
552 */
545static struct dn_dev *dn_dev_by_index(int ifindex) 553static struct dn_dev *dn_dev_by_index(int ifindex)
546{ 554{
547 struct net_device *dev; 555 struct net_device *dev;
548 struct dn_dev *dn_dev = NULL; 556 struct dn_dev *dn_dev = NULL;
549 dev = dev_get_by_index(&init_net, ifindex); 557
550 if (dev) { 558 dev = __dev_get_by_index(&init_net, ifindex);
559 if (dev)
551 dn_dev = dev->dn_ptr; 560 dn_dev = dev->dn_ptr;
552 dev_put(dev);
553 }
554 561
555 return dn_dev; 562 return dn_dev;
556} 563}
@@ -571,7 +578,7 @@ static int dn_nl_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
571 struct dn_ifaddr *ifa, **ifap; 578 struct dn_ifaddr *ifa, **ifap;
572 int err = -EINVAL; 579 int err = -EINVAL;
573 580
574 if (net != &init_net) 581 if (!net_eq(net, &init_net))
575 goto errout; 582 goto errout;
576 583
577 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy); 584 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy);
@@ -610,7 +617,7 @@ static int dn_nl_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
610 struct dn_ifaddr *ifa; 617 struct dn_ifaddr *ifa;
611 int err; 618 int err;
612 619
613 if (net != &init_net) 620 if (!net_eq(net, &init_net))
614 return -EINVAL; 621 return -EINVAL;
615 622
616 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy); 623 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy);
@@ -724,7 +731,7 @@ static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
724 struct dn_dev *dn_db; 731 struct dn_dev *dn_db;
725 struct dn_ifaddr *ifa; 732 struct dn_ifaddr *ifa;
726 733
727 if (net != &init_net) 734 if (!net_eq(net, &init_net))
728 return 0; 735 return 0;
729 736
730 skip_ndevs = cb->args[0]; 737 skip_ndevs = cb->args[0];
@@ -768,13 +775,17 @@ static int dn_dev_get_first(struct net_device *dev, __le16 *addr)
768 struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr; 775 struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr;
769 struct dn_ifaddr *ifa; 776 struct dn_ifaddr *ifa;
770 int rv = -ENODEV; 777 int rv = -ENODEV;
778
771 if (dn_db == NULL) 779 if (dn_db == NULL)
772 goto out; 780 goto out;
781
782 rtnl_lock();
773 ifa = dn_db->ifa_list; 783 ifa = dn_db->ifa_list;
774 if (ifa != NULL) { 784 if (ifa != NULL) {
775 *addr = ifa->ifa_local; 785 *addr = ifa->ifa_local;
776 rv = 0; 786 rv = 0;
777 } 787 }
788 rtnl_unlock();
778out: 789out:
779 return rv; 790 return rv;
780} 791}
@@ -796,9 +807,7 @@ int dn_dev_bind_default(__le16 *addr)
796 dev = dn_dev_get_default(); 807 dev = dn_dev_get_default();
797last_chance: 808last_chance:
798 if (dev) { 809 if (dev) {
799 read_lock(&dev_base_lock);
800 rv = dn_dev_get_first(dev, addr); 810 rv = dn_dev_get_first(dev, addr);
801 read_unlock(&dev_base_lock);
802 dev_put(dev); 811 dev_put(dev);
803 if (rv == 0 || dev == init_net.loopback_dev) 812 if (rv == 0 || dev == init_net.loopback_dev)
804 return rv; 813 return rv;
@@ -1263,18 +1272,18 @@ static inline int is_dn_dev(struct net_device *dev)
1263} 1272}
1264 1273
1265static void *dn_dev_seq_start(struct seq_file *seq, loff_t *pos) 1274static void *dn_dev_seq_start(struct seq_file *seq, loff_t *pos)
1266 __acquires(&dev_base_lock) 1275 __acquires(rcu)
1267{ 1276{
1268 int i; 1277 int i;
1269 struct net_device *dev; 1278 struct net_device *dev;
1270 1279
1271 read_lock(&dev_base_lock); 1280 rcu_read_lock();
1272 1281
1273 if (*pos == 0) 1282 if (*pos == 0)
1274 return SEQ_START_TOKEN; 1283 return SEQ_START_TOKEN;
1275 1284
1276 i = 1; 1285 i = 1;
1277 for_each_netdev(&init_net, dev) { 1286 for_each_netdev_rcu(&init_net, dev) {
1278 if (!is_dn_dev(dev)) 1287 if (!is_dn_dev(dev))
1279 continue; 1288 continue;
1280 1289
@@ -1295,7 +1304,7 @@ static void *dn_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1295 if (v == SEQ_START_TOKEN) 1304 if (v == SEQ_START_TOKEN)
1296 dev = net_device_entry(&init_net.dev_base_head); 1305 dev = net_device_entry(&init_net.dev_base_head);
1297 1306
1298 for_each_netdev_continue(&init_net, dev) { 1307 for_each_netdev_continue_rcu(&init_net, dev) {
1299 if (!is_dn_dev(dev)) 1308 if (!is_dn_dev(dev))
1300 continue; 1309 continue;
1301 1310
@@ -1306,9 +1315,9 @@ static void *dn_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1306} 1315}
1307 1316
1308static void dn_dev_seq_stop(struct seq_file *seq, void *v) 1317static void dn_dev_seq_stop(struct seq_file *seq, void *v)
1309 __releases(&dev_base_lock) 1318 __releases(rcu)
1310{ 1319{
1311 read_unlock(&dev_base_lock); 1320 rcu_read_unlock();
1312} 1321}
1313 1322
1314static char *dn_type2asc(char type) 1323static char *dn_type2asc(char type)
diff --git a/net/decnet/dn_fib.c b/net/decnet/dn_fib.c
index 27ea2e9b080a..e9d48700e83a 100644
--- a/net/decnet/dn_fib.c
+++ b/net/decnet/dn_fib.c
@@ -509,7 +509,7 @@ static int dn_fib_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *
509 struct rtattr **rta = arg; 509 struct rtattr **rta = arg;
510 struct rtmsg *r = NLMSG_DATA(nlh); 510 struct rtmsg *r = NLMSG_DATA(nlh);
511 511
512 if (net != &init_net) 512 if (!net_eq(net, &init_net))
513 return -EINVAL; 513 return -EINVAL;
514 514
515 if (dn_fib_check_attr(r, rta)) 515 if (dn_fib_check_attr(r, rta))
@@ -529,7 +529,7 @@ static int dn_fib_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *
529 struct rtattr **rta = arg; 529 struct rtattr **rta = arg;
530 struct rtmsg *r = NLMSG_DATA(nlh); 530 struct rtmsg *r = NLMSG_DATA(nlh);
531 531
532 if (net != &init_net) 532 if (!net_eq(net, &init_net))
533 return -EINVAL; 533 return -EINVAL;
534 534
535 if (dn_fib_check_attr(r, rta)) 535 if (dn_fib_check_attr(r, rta))
@@ -607,8 +607,8 @@ static void dn_fib_del_ifaddr(struct dn_ifaddr *ifa)
607 ASSERT_RTNL(); 607 ASSERT_RTNL();
608 608
609 /* Scan device list */ 609 /* Scan device list */
610 read_lock(&dev_base_lock); 610 rcu_read_lock();
611 for_each_netdev(&init_net, dev) { 611 for_each_netdev_rcu(&init_net, dev) {
612 dn_db = dev->dn_ptr; 612 dn_db = dev->dn_ptr;
613 if (dn_db == NULL) 613 if (dn_db == NULL)
614 continue; 614 continue;
@@ -619,7 +619,7 @@ static void dn_fib_del_ifaddr(struct dn_ifaddr *ifa)
619 } 619 }
620 } 620 }
621 } 621 }
622 read_unlock(&dev_base_lock); 622 rcu_read_unlock();
623 623
624 if (found_it == 0) { 624 if (found_it == 0) {
625 fib_magic(RTM_DELROUTE, RTN_LOCAL, ifa->ifa_local, 16, ifa); 625 fib_magic(RTM_DELROUTE, RTN_LOCAL, ifa->ifa_local, 16, ifa);
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 57662cabaf9b..a03284061a31 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -908,8 +908,8 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
908 dev_put(dev_out); 908 dev_put(dev_out);
909 goto out; 909 goto out;
910 } 910 }
911 read_lock(&dev_base_lock); 911 rcu_read_lock();
912 for_each_netdev(&init_net, dev) { 912 for_each_netdev_rcu(&init_net, dev) {
913 if (!dev->dn_ptr) 913 if (!dev->dn_ptr)
914 continue; 914 continue;
915 if (!dn_dev_islocal(dev, oldflp->fld_src)) 915 if (!dn_dev_islocal(dev, oldflp->fld_src))
@@ -922,7 +922,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
922 dev_out = dev; 922 dev_out = dev;
923 break; 923 break;
924 } 924 }
925 read_unlock(&dev_base_lock); 925 rcu_read_unlock();
926 if (dev_out == NULL) 926 if (dev_out == NULL)
927 goto out; 927 goto out;
928 dev_hold(dev_out); 928 dev_hold(dev_out);
@@ -1517,7 +1517,7 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void
1517 struct sk_buff *skb; 1517 struct sk_buff *skb;
1518 struct flowi fl; 1518 struct flowi fl;
1519 1519
1520 if (net != &init_net) 1520 if (!net_eq(net, &init_net))
1521 return -EINVAL; 1521 return -EINVAL;
1522 1522
1523 memset(&fl, 0, sizeof(fl)); 1523 memset(&fl, 0, sizeof(fl));
@@ -1602,7 +1602,7 @@ int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb)
1602 int h, s_h; 1602 int h, s_h;
1603 int idx, s_idx; 1603 int idx, s_idx;
1604 1604
1605 if (net != &init_net) 1605 if (!net_eq(net, &init_net))
1606 return 0; 1606 return 0;
1607 1607
1608 if (NLMSG_PAYLOAD(cb->nlh, 0) < sizeof(struct rtmsg)) 1608 if (NLMSG_PAYLOAD(cb->nlh, 0) < sizeof(struct rtmsg))
diff --git a/net/decnet/dn_rules.c b/net/decnet/dn_rules.c
index 72495f25269f..7466c546f286 100644
--- a/net/decnet/dn_rules.c
+++ b/net/decnet/dn_rules.c
@@ -33,7 +33,7 @@
33#include <net/dn_dev.h> 33#include <net/dn_dev.h>
34#include <net/dn_route.h> 34#include <net/dn_route.h>
35 35
36static struct fib_rules_ops dn_fib_rules_ops; 36static struct fib_rules_ops *dn_fib_rules_ops;
37 37
38struct dn_fib_rule 38struct dn_fib_rule
39{ 39{
@@ -56,7 +56,7 @@ int dn_fib_lookup(struct flowi *flp, struct dn_fib_res *res)
56 }; 56 };
57 int err; 57 int err;
58 58
59 err = fib_rules_lookup(&dn_fib_rules_ops, flp, 0, &arg); 59 err = fib_rules_lookup(dn_fib_rules_ops, flp, 0, &arg);
60 res->r = arg.rule; 60 res->r = arg.rule;
61 61
62 return err; 62 return err;
@@ -217,9 +217,9 @@ static u32 dn_fib_rule_default_pref(struct fib_rules_ops *ops)
217 struct list_head *pos; 217 struct list_head *pos;
218 struct fib_rule *rule; 218 struct fib_rule *rule;
219 219
220 if (!list_empty(&dn_fib_rules_ops.rules_list)) { 220 if (!list_empty(&dn_fib_rules_ops->rules_list)) {
221 pos = dn_fib_rules_ops.rules_list.next; 221 pos = dn_fib_rules_ops->rules_list.next;
222 if (pos->next != &dn_fib_rules_ops.rules_list) { 222 if (pos->next != &dn_fib_rules_ops->rules_list) {
223 rule = list_entry(pos->next, struct fib_rule, list); 223 rule = list_entry(pos->next, struct fib_rule, list);
224 if (rule->pref) 224 if (rule->pref)
225 return rule->pref - 1; 225 return rule->pref - 1;
@@ -234,7 +234,7 @@ static void dn_fib_rule_flush_cache(struct fib_rules_ops *ops)
234 dn_rt_cache_flush(-1); 234 dn_rt_cache_flush(-1);
235} 235}
236 236
237static struct fib_rules_ops dn_fib_rules_ops = { 237static struct fib_rules_ops dn_fib_rules_ops_template = {
238 .family = AF_DECnet, 238 .family = AF_DECnet,
239 .rule_size = sizeof(struct dn_fib_rule), 239 .rule_size = sizeof(struct dn_fib_rule),
240 .addr_size = sizeof(u16), 240 .addr_size = sizeof(u16),
@@ -247,21 +247,23 @@ static struct fib_rules_ops dn_fib_rules_ops = {
247 .flush_cache = dn_fib_rule_flush_cache, 247 .flush_cache = dn_fib_rule_flush_cache,
248 .nlgroup = RTNLGRP_DECnet_RULE, 248 .nlgroup = RTNLGRP_DECnet_RULE,
249 .policy = dn_fib_rule_policy, 249 .policy = dn_fib_rule_policy,
250 .rules_list = LIST_HEAD_INIT(dn_fib_rules_ops.rules_list),
251 .owner = THIS_MODULE, 250 .owner = THIS_MODULE,
252 .fro_net = &init_net, 251 .fro_net = &init_net,
253}; 252};
254 253
255void __init dn_fib_rules_init(void) 254void __init dn_fib_rules_init(void)
256{ 255{
257 BUG_ON(fib_default_rule_add(&dn_fib_rules_ops, 0x7fff, 256 dn_fib_rules_ops =
257 fib_rules_register(&dn_fib_rules_ops_template, &init_net);
258 BUG_ON(IS_ERR(dn_fib_rules_ops));
259 BUG_ON(fib_default_rule_add(dn_fib_rules_ops, 0x7fff,
258 RT_TABLE_MAIN, 0)); 260 RT_TABLE_MAIN, 0));
259 fib_rules_register(&dn_fib_rules_ops);
260} 261}
261 262
262void __exit dn_fib_rules_cleanup(void) 263void __exit dn_fib_rules_cleanup(void)
263{ 264{
264 fib_rules_unregister(&dn_fib_rules_ops); 265 fib_rules_unregister(dn_fib_rules_ops);
266 rcu_barrier();
265} 267}
266 268
267 269
diff --git a/net/decnet/dn_table.c b/net/decnet/dn_table.c
index 67054b0d550f..b9a33bb5e9cc 100644
--- a/net/decnet/dn_table.c
+++ b/net/decnet/dn_table.c
@@ -471,7 +471,7 @@ int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb)
471 struct hlist_node *node; 471 struct hlist_node *node;
472 int dumped = 0; 472 int dumped = 0;
473 473
474 if (net != &init_net) 474 if (!net_eq(net, &init_net))
475 return 0; 475 return 0;
476 476
477 if (NLMSG_PAYLOAD(cb->nlh, 0) >= sizeof(struct rtmsg) && 477 if (NLMSG_PAYLOAD(cb->nlh, 0) >= sizeof(struct rtmsg) &&
@@ -581,8 +581,9 @@ static int dn_fib_table_insert(struct dn_fib_table *tb, struct rtmsg *r, struct
581 DN_FIB_SCAN_KEY(f, fp, key) { 581 DN_FIB_SCAN_KEY(f, fp, key) {
582 if (fi->fib_priority != DN_FIB_INFO(f)->fib_priority) 582 if (fi->fib_priority != DN_FIB_INFO(f)->fib_priority)
583 break; 583 break;
584 if (f->fn_type == type && f->fn_scope == r->rtm_scope 584 if (f->fn_type == type &&
585 && DN_FIB_INFO(f) == fi) 585 f->fn_scope == r->rtm_scope &&
586 DN_FIB_INFO(f) == fi)
586 goto out; 587 goto out;
587 } 588 }
588 589