[PATCH] fsstack: Remove inode copy
[powerpc.git] / net / ipv6 / fib6_rules.c
index 2c4fbc8..0862809 100644 (file)
@@ -13,7 +13,6 @@
  *     Ville Nuorvala          <vnuorval@tcs.hut.fi>
  */
 
-#include <linux/config.h>
 #include <linux/netdevice.h>
 
 #include <net/fib_rules.h>
@@ -64,7 +63,7 @@ struct dst_entry *fib6_rule_lookup(struct flowi *fl, int flags,
                fib_rule_put(arg.rule);
 
        if (arg.result)
-               return (struct dst_entry *) arg.result;
+               return arg.result;
 
        dst_hold(&ip6_null_entry.u.dst);
        return &ip6_null_entry.u.dst;
@@ -114,22 +113,26 @@ static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
 {
        struct fib6_rule *r = (struct fib6_rule *) rule;
 
-       if (!ipv6_prefix_equal(&fl->fl6_dst, &r->dst.addr, r->dst.plen))
+       if (r->dst.plen &&
+           !ipv6_prefix_equal(&fl->fl6_dst, &r->dst.addr, r->dst.plen))
                return 0;
 
-       if ((flags & RT6_F_HAS_SADDR) &&
-           !ipv6_prefix_equal(&fl->fl6_src, &r->src.addr, r->src.plen))
+       if (r->src.plen) {
+               if (!(flags & RT6_LOOKUP_F_HAS_SADDR) ||
+                   !ipv6_prefix_equal(&fl->fl6_src, &r->src.addr, r->src.plen))
+                       return 0;
+       }
+
+       if (r->tclass && r->tclass != ((ntohl(fl->fl6_flowlabel) >> 20) & 0xff))
                return 0;
 
        return 1;
 }
 
-static struct nla_policy fib6_rule_policy[RTA_MAX+1] __read_mostly = {
-       [FRA_IFNAME]    = { .type = NLA_STRING },
-       [FRA_PRIORITY]  = { .type = NLA_U32 },
-       [FRA_SRC]       = { .minlen = sizeof(struct in6_addr) },
-       [FRA_DST]       = { .minlen = sizeof(struct in6_addr) },
-       [FRA_TABLE]     = { .type = NLA_U32 },
+static struct nla_policy fib6_rule_policy[FRA_MAX+1] __read_mostly = {
+       FRA_GENERIC_POLICY,
+       [FRA_SRC]       = { .len = sizeof(struct in6_addr) },
+       [FRA_DST]       = { .len = sizeof(struct in6_addr) },
 };
 
 static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
@@ -139,8 +142,7 @@ static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
        int err = -EINVAL;
        struct fib6_rule *rule6 = (struct fib6_rule *) rule;
 
-       if (frh->src_len > 128 || frh->dst_len > 128 ||
-           (frh->tos & ~IPV6_FLOWINFO_MASK))
+       if (frh->src_len > 128 || frh->dst_len > 128)
                goto errout;
 
        if (rule->action == FR_ACT_TO_TBL) {
@@ -229,6 +231,12 @@ static u32 fib6_rule_default_pref(void)
        return 0x3FFF;
 }
 
+static size_t fib6_rule_nlmsg_payload(struct fib_rule *rule)
+{
+       return nla_total_size(16) /* dst */
+              + nla_total_size(16); /* src */
+}
+
 static struct fib_rules_ops fib6_rules_ops = {
        .family                 = AF_INET6,
        .rule_size              = sizeof(struct fib6_rule),
@@ -238,6 +246,7 @@ static struct fib_rules_ops fib6_rules_ops = {
        .compare                = fib6_rule_compare,
        .fill                   = fib6_rule_fill,
        .default_pref           = fib6_rule_default_pref,
+       .nlmsg_payload          = fib6_rule_nlmsg_payload,
        .nlgroup                = RTNLGRP_IPV6_RULE,
        .policy                 = fib6_rule_policy,
        .rules_list             = &fib6_rules,