]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv6/route.c
[IPV6]: flowlabels are net-endian
[net-next-2.6.git] / net / ipv6 / route.c
index a1b0f075462e0e64fd76a91cd6696765e0f8b6e4..e9c1fc5f21b189eec4c0530a43b9a68675a621ce 100644 (file)
@@ -141,6 +141,10 @@ struct rt6_info ip6_null_entry = {
 
 #ifdef CONFIG_IPV6_MULTIPLE_TABLES
 
+static int ip6_pkt_prohibit(struct sk_buff *skb);
+static int ip6_pkt_prohibit_out(struct sk_buff *skb);
+static int ip6_pkt_blk_hole(struct sk_buff *skb);
+
 struct rt6_info ip6_prohibit_entry = {
        .u = {
                .dst = {
@@ -150,8 +154,8 @@ struct rt6_info ip6_prohibit_entry = {
                        .obsolete       = -1,
                        .error          = -EACCES,
                        .metrics        = { [RTAX_HOPLIMIT - 1] = 255, },
-                       .input          = ip6_pkt_discard,
-                       .output         = ip6_pkt_discard_out,
+                       .input          = ip6_pkt_prohibit,
+                       .output         = ip6_pkt_prohibit_out,
                        .ops            = &ip6_dst_ops,
                        .path           = (struct dst_entry*)&ip6_prohibit_entry,
                }
@@ -170,8 +174,8 @@ struct rt6_info ip6_blk_hole_entry = {
                        .obsolete       = -1,
                        .error          = -EINVAL,
                        .metrics        = { [RTAX_HOPLIMIT - 1] = 255, },
-                       .input          = ip6_pkt_discard,
-                       .output         = ip6_pkt_discard_out,
+                       .input          = ip6_pkt_blk_hole,
+                       .output         = ip6_pkt_blk_hole,
                        .ops            = &ip6_dst_ops,
                        .path           = (struct dst_entry*)&ip6_blk_hole_entry,
                }
@@ -326,6 +330,8 @@ static int inline rt6_check_neigh(struct rt6_info *rt)
                read_lock_bh(&neigh->lock);
                if (neigh->nud_state & NUD_VALID)
                        m = 2;
+               else if (!(neigh->nud_state & NUD_FAILED))
+                       m = 1;
                read_unlock_bh(&neigh->lock);
        }
        return m;
@@ -343,9 +349,7 @@ static int rt6_score_route(struct rt6_info *rt, int oif,
        m |= IPV6_DECODE_PREF(IPV6_EXTRACT_PREF(rt->rt6i_flags)) << 2;
 #endif
        n = rt6_check_neigh(rt);
-       if (n > 1)
-               m |= 16;
-       else if (!n && strict & RT6_LOOKUP_F_REACHABLE)
+       if (!n && (strict & RT6_LOOKUP_F_REACHABLE))
                return -1;
        return m;
 }
@@ -376,10 +380,11 @@ static struct rt6_info *rt6_select(struct rt6_info **head, int oif,
                        continue;
 
                if (m > mpri) {
-                       rt6_probe(match);
+                       if (strict & RT6_LOOKUP_F_REACHABLE)
+                               rt6_probe(match);
                        match = rt;
                        mpri = m;
-               } else {
+               } else if (strict & RT6_LOOKUP_F_REACHABLE) {
                        rt6_probe(rt);
                }
        }
@@ -484,7 +489,7 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,
 do { \
        if (rt == &ip6_null_entry) { \
                struct fib6_node *pn; \
-               while (fn) { \
+               while (1) { \
                        if (fn->fn_flags & RTN_TL_ROOT) \
                                goto out; \
                        pn = fn->parent; \
@@ -618,8 +623,6 @@ static struct rt6_info *rt6_alloc_clone(struct rt6_info *ort, struct in6_addr *d
                ipv6_addr_copy(&rt->rt6i_dst.addr, daddr);
                rt->rt6i_dst.plen = 128;
                rt->rt6i_flags |= RTF_CACHE;
-               if (rt->rt6i_flags & RTF_REJECT)
-                       rt->u.dst.error = ort->u.dst.error;
                rt->u.dst.flags |= DST_HOST;
                rt->rt6i_nexthop = neigh_clone(ort->rt6i_nexthop);
        }
@@ -634,7 +637,7 @@ static struct rt6_info *ip6_pol_route_input(struct fib6_table *table,
        int strict = 0;
        int attempts = 3;
        int err;
-       int reachable = RT6_LOOKUP_F_REACHABLE;
+       int reachable = ipv6_devconf.forwarding ? 0 : RT6_LOOKUP_F_REACHABLE;
 
        strict |= flags & RT6_LOOKUP_F_IFACE;
 
@@ -711,7 +714,7 @@ void ip6_route_input(struct sk_buff *skb)
 #ifdef CONFIG_IPV6_ROUTE_FWMARK
                                .fwmark = skb->nfmark,
 #endif
-                               .flowlabel = (* (u32 *) iph)&IPV6_FLOWINFO_MASK,
+                               .flowlabel = (* (__be32 *) iph)&IPV6_FLOWINFO_MASK,
                        },
                },
                .proto = iph->nexthdr,
@@ -731,7 +734,7 @@ static struct rt6_info *ip6_pol_route_output(struct fib6_table *table,
        int strict = 0;
        int attempts = 3;
        int err;
-       int reachable = RT6_LOOKUP_F_REACHABLE;
+       int reachable = ipv6_devconf.forwarding ? 0 : RT6_LOOKUP_F_REACHABLE;
 
        strict |= flags & RT6_LOOKUP_F_IFACE;
 
@@ -1540,6 +1543,7 @@ static struct rt6_info * ip6_rt_copy(struct rt6_info *ort)
                rt->u.dst.output = ort->u.dst.output;
 
                memcpy(rt->u.dst.metrics, ort->u.dst.metrics, RTAX_MAX*sizeof(u32));
+               rt->u.dst.error = ort->u.dst.error;
                rt->u.dst.dev = ort->u.dst.dev;
                if (rt->u.dst.dev)
                        dev_hold(rt->u.dst.dev);
@@ -1743,24 +1747,50 @@ int ipv6_route_ioctl(unsigned int cmd, void __user *arg)
  *     Drop the packet on the floor
  */
 
-static int ip6_pkt_discard(struct sk_buff *skb)
+static inline int ip6_pkt_drop(struct sk_buff *skb, int code)
 {
        int type = ipv6_addr_type(&skb->nh.ipv6h->daddr);
        if (type == IPV6_ADDR_ANY || type == IPV6_ADDR_RESERVED)
                IP6_INC_STATS(IPSTATS_MIB_INADDRERRORS);
 
        IP6_INC_STATS(IPSTATS_MIB_OUTNOROUTES);
-       icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_NOROUTE, 0, skb->dev);
+       icmpv6_send(skb, ICMPV6_DEST_UNREACH, code, 0, skb->dev);
        kfree_skb(skb);
        return 0;
 }
 
+static int ip6_pkt_discard(struct sk_buff *skb)
+{
+       return ip6_pkt_drop(skb, ICMPV6_NOROUTE);
+}
+
 static int ip6_pkt_discard_out(struct sk_buff *skb)
 {
        skb->dev = skb->dst->dev;
        return ip6_pkt_discard(skb);
 }
 
+#ifdef CONFIG_IPV6_MULTIPLE_TABLES
+
+static int ip6_pkt_prohibit(struct sk_buff *skb)
+{
+       return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED);
+}
+
+static int ip6_pkt_prohibit_out(struct sk_buff *skb)
+{
+       skb->dev = skb->dst->dev;
+       return ip6_pkt_prohibit(skb);
+}
+
+static int ip6_pkt_blk_hole(struct sk_buff *skb)
+{
+       kfree_skb(skb);
+       return 0;
+}
+
+#endif
+
 /*
  *     Allocate a dst for local (unicast / anycast) address.
  */