aboutsummaryrefslogtreecommitdiffstats
path: root/net/decnet/dn_route.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/decnet/dn_route.c')
-rw-r--r--net/decnet/dn_route.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 66663e5d7acd..31be29b8b5a3 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -107,7 +107,7 @@ static const int dn_rt_mtu_expires = 10 * 60 * HZ;
107 107
108static unsigned long dn_rt_deadline; 108static unsigned long dn_rt_deadline;
109 109
110static int dn_dst_gc(void); 110static int dn_dst_gc(struct dst_ops *ops);
111static struct dst_entry *dn_dst_check(struct dst_entry *, __u32); 111static struct dst_entry *dn_dst_check(struct dst_entry *, __u32);
112static struct dst_entry *dn_dst_negative_advice(struct dst_entry *); 112static struct dst_entry *dn_dst_negative_advice(struct dst_entry *);
113static void dn_dst_link_failure(struct sk_buff *); 113static void dn_dst_link_failure(struct sk_buff *);
@@ -185,7 +185,7 @@ static void dn_dst_check_expire(unsigned long dummy)
185 mod_timer(&dn_route_timer, now + decnet_dst_gc_interval * HZ); 185 mod_timer(&dn_route_timer, now + decnet_dst_gc_interval * HZ);
186} 186}
187 187
188static int dn_dst_gc(void) 188static int dn_dst_gc(struct dst_ops *ops)
189{ 189{
190 struct dn_route *rt, **rtp; 190 struct dn_route *rt, **rtp;
191 int i; 191 int i;
@@ -765,17 +765,6 @@ drop:
765} 765}
766 766
767/* 767/*
768 * Drop packet. This is used for endnodes and for
769 * when we should not be forwarding packets from
770 * this dest.
771 */
772static int dn_blackhole(struct sk_buff *skb)
773{
774 kfree_skb(skb);
775 return NET_RX_DROP;
776}
777
778/*
779 * Used to catch bugs. This should never normally get 768 * Used to catch bugs. This should never normally get
780 * called. 769 * called.
781 */ 770 */
@@ -995,7 +984,7 @@ source_ok:
995 * here 984 * here
996 */ 985 */
997 if (!try_hard) { 986 if (!try_hard) {
998 neigh = neigh_lookup_nodev(&dn_neigh_table, &fl.fld_dst); 987 neigh = neigh_lookup_nodev(&dn_neigh_table, &init_net, &fl.fld_dst);
999 if (neigh) { 988 if (neigh) {
1000 if ((oldflp->oif && 989 if ((oldflp->oif &&
1001 (neigh->dev->ifindex != oldflp->oif)) || 990 (neigh->dev->ifindex != oldflp->oif)) ||
@@ -1207,7 +1196,8 @@ int dn_route_output_sock(struct dst_entry **pprt, struct flowi *fl, struct sock
1207 1196
1208 err = __dn_route_output_key(pprt, fl, flags & MSG_TRYHARD); 1197 err = __dn_route_output_key(pprt, fl, flags & MSG_TRYHARD);
1209 if (err == 0 && fl->proto) { 1198 if (err == 0 && fl->proto) {
1210 err = xfrm_lookup(pprt, fl, sk, !(flags & MSG_DONTWAIT)); 1199 err = xfrm_lookup(pprt, fl, sk, (flags & MSG_DONTWAIT) ?
1200 0 : XFRM_LOOKUP_WAIT);
1211 } 1201 }
1212 return err; 1202 return err;
1213} 1203}
@@ -1396,7 +1386,7 @@ make_route:
1396 default: 1386 default:
1397 case RTN_UNREACHABLE: 1387 case RTN_UNREACHABLE:
1398 case RTN_BLACKHOLE: 1388 case RTN_BLACKHOLE:
1399 rt->u.dst.input = dn_blackhole; 1389 rt->u.dst.input = dst_discard;
1400 } 1390 }
1401 rt->rt_flags = flags; 1391 rt->rt_flags = flags;
1402 if (rt->u.dst.dev) 1392 if (rt->u.dst.dev)
@@ -1522,6 +1512,7 @@ rtattr_failure:
1522 */ 1512 */
1523static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void *arg) 1513static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void *arg)
1524{ 1514{
1515 struct net *net = in_skb->sk->sk_net;
1525 struct rtattr **rta = arg; 1516 struct rtattr **rta = arg;
1526 struct rtmsg *rtm = NLMSG_DATA(nlh); 1517 struct rtmsg *rtm = NLMSG_DATA(nlh);
1527 struct dn_route *rt = NULL; 1518 struct dn_route *rt = NULL;
@@ -1530,6 +1521,9 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void
1530 struct sk_buff *skb; 1521 struct sk_buff *skb;
1531 struct flowi fl; 1522 struct flowi fl;
1532 1523
1524 if (net != &init_net)
1525 return -EINVAL;
1526
1533 memset(&fl, 0, sizeof(fl)); 1527 memset(&fl, 0, sizeof(fl));
1534 fl.proto = DNPROTO_NSP; 1528 fl.proto = DNPROTO_NSP;
1535 1529
@@ -1557,7 +1551,7 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void
1557 kfree_skb(skb); 1551 kfree_skb(skb);
1558 return -ENODEV; 1552 return -ENODEV;
1559 } 1553 }
1560 skb->protocol = __constant_htons(ETH_P_DNA_RT); 1554 skb->protocol = htons(ETH_P_DNA_RT);
1561 skb->dev = dev; 1555 skb->dev = dev;
1562 cb->src = fl.fld_src; 1556 cb->src = fl.fld_src;
1563 cb->dst = fl.fld_dst; 1557 cb->dst = fl.fld_dst;
@@ -1594,7 +1588,7 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void
1594 goto out_free; 1588 goto out_free;
1595 } 1589 }
1596 1590
1597 return rtnl_unicast(skb, NETLINK_CB(in_skb).pid); 1591 return rtnl_unicast(skb, &init_net, NETLINK_CB(in_skb).pid);
1598 1592
1599out_free: 1593out_free:
1600 kfree_skb(skb); 1594 kfree_skb(skb);
@@ -1607,10 +1601,14 @@ out_free:
1607 */ 1601 */
1608int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb) 1602int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb)
1609{ 1603{
1604 struct net *net = skb->sk->sk_net;
1610 struct dn_route *rt; 1605 struct dn_route *rt;
1611 int h, s_h; 1606 int h, s_h;
1612 int idx, s_idx; 1607 int idx, s_idx;
1613 1608
1609 if (net != &init_net)
1610 return 0;
1611
1614 if (NLMSG_PAYLOAD(cb->nlh, 0) < sizeof(struct rtmsg)) 1612 if (NLMSG_PAYLOAD(cb->nlh, 0) < sizeof(struct rtmsg))
1615 return -EINVAL; 1613 return -EINVAL;
1616 if (!(((struct rtmsg *)NLMSG_DATA(cb->nlh))->rtm_flags&RTM_F_CLONED)) 1614 if (!(((struct rtmsg *)NLMSG_DATA(cb->nlh))->rtm_flags&RTM_F_CLONED))
@@ -1665,12 +1663,12 @@ static struct dn_route *dn_rt_cache_get_first(struct seq_file *seq)
1665 break; 1663 break;
1666 rcu_read_unlock_bh(); 1664 rcu_read_unlock_bh();
1667 } 1665 }
1668 return rt; 1666 return rcu_dereference(rt);
1669} 1667}
1670 1668
1671static struct dn_route *dn_rt_cache_get_next(struct seq_file *seq, struct dn_route *rt) 1669static struct dn_route *dn_rt_cache_get_next(struct seq_file *seq, struct dn_route *rt)
1672{ 1670{
1673 struct dn_rt_cache_iter_state *s = rcu_dereference(seq->private); 1671 struct dn_rt_cache_iter_state *s = seq->private;
1674 1672
1675 rt = rt->u.dst.dn_next; 1673 rt = rt->u.dst.dn_next;
1676 while(!rt) { 1674 while(!rt) {
@@ -1680,7 +1678,7 @@ static struct dn_route *dn_rt_cache_get_next(struct seq_file *seq, struct dn_rou
1680 rcu_read_lock_bh(); 1678 rcu_read_lock_bh();
1681 rt = dn_rt_hash_table[s->bucket].chain; 1679 rt = dn_rt_hash_table[s->bucket].chain;
1682 } 1680 }
1683 return rt; 1681 return rcu_dereference(rt);
1684} 1682}
1685 1683
1686static void *dn_rt_cache_seq_start(struct seq_file *seq, loff_t *pos) 1684static void *dn_rt_cache_seq_start(struct seq_file *seq, loff_t *pos)
@@ -1752,8 +1750,7 @@ void __init dn_route_init(void)
1752 dn_dst_ops.kmem_cachep = 1750 dn_dst_ops.kmem_cachep =
1753 kmem_cache_create("dn_dst_cache", sizeof(struct dn_route), 0, 1751 kmem_cache_create("dn_dst_cache", sizeof(struct dn_route), 0,
1754 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); 1752 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
1755 init_timer(&dn_route_timer); 1753 setup_timer(&dn_route_timer, dn_dst_check_expire, 0);
1756 dn_route_timer.function = dn_dst_check_expire;
1757 dn_route_timer.expires = jiffies + decnet_dst_gc_interval * HZ; 1754 dn_route_timer.expires = jiffies + decnet_dst_gc_interval * HZ;
1758 add_timer(&dn_route_timer); 1755 add_timer(&dn_route_timer);
1759 1756