]> err.no Git - linux-2.6/blobdiff - net/decnet/dn_rules.c
Merge mulgrave-w:git/linux-2.6
[linux-2.6] / net / decnet / dn_rules.c
index 977bb56c3ce4920e9c34f01a139619d164cd6c62..3e0c882c90bfa28a662540e21c97c333a17d4bc6 100644 (file)
@@ -47,6 +47,7 @@ struct dn_fib_rule
        u8                      flags;
 #ifdef CONFIG_DECNET_ROUTE_FWMARK
        u32                     fwmark;
+       u32                     fwmask;
 #endif
 };
 
@@ -75,8 +76,8 @@ int dn_fib_lookup(struct flowi *flp, struct dn_fib_res *res)
        return err;
 }
 
-int dn_fib_rule_action(struct fib_rule *rule, struct flowi *flp, int flags,
-                      struct fib_lookup_arg *arg)
+static int dn_fib_rule_action(struct fib_rule *rule, struct flowi *flp,
+                             int flags, struct fib_lookup_arg *arg)
 {
        int err = -EAGAIN;
        struct dn_fib_table *tbl;
@@ -111,11 +112,12 @@ errout:
 }
 
 static struct nla_policy dn_fib_rule_policy[FRA_MAX+1] __read_mostly = {
-       [FRA_IFNAME]    = { .type = NLA_STRING },
+       [FRA_IFNAME]    = { .type = NLA_STRING, .len = IFNAMSIZ - 1 },
        [FRA_PRIORITY]  = { .type = NLA_U32 },
        [FRA_SRC]       = { .type = NLA_U16 },
        [FRA_DST]       = { .type = NLA_U16 },
        [FRA_FWMARK]    = { .type = NLA_U32 },
+       [FRA_FWMASK]    = { .type = NLA_U32 },
        [FRA_TABLE]     = { .type = NLA_U32 },
 };
 
@@ -130,7 +132,7 @@ static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
                return 0;
 
 #ifdef CONFIG_DECNET_ROUTE_FWMARK
-       if (r->fwmark && (r->fwmark != fl->fld_fwmark))
+       if ((r->fwmark ^ fl->fld_fwmark) & r->fwmask)
                return 0;
 #endif
 
@@ -168,8 +170,17 @@ static int dn_fib_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
                r->dst = nla_get_u16(tb[FRA_DST]);
 
 #ifdef CONFIG_DECNET_ROUTE_FWMARK
-       if (tb[FRA_FWMARK])
+       if (tb[FRA_FWMARK]) {
                r->fwmark = nla_get_u32(tb[FRA_FWMARK]);
+               if (r->fwmark)
+                       /* compatibility: if the mark value is non-zero all bits
+                        * are compared unless a mask is explicitly specified.
+                        */
+                       r->fwmask = 0xFFFFFFFF;
+       }
+
+       if (tb[FRA_FWMASK])
+               r->fwmask = nla_get_u32(tb[FRA_FWMASK]);
 #endif
 
        r->src_len = frh->src_len;
@@ -195,6 +206,9 @@ static int dn_fib_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
 #ifdef CONFIG_DECNET_ROUTE_FWMARK
        if (tb[FRA_FWMARK] && (r->fwmark != nla_get_u32(tb[FRA_FWMARK])))
                return 0;
+
+       if (tb[FRA_FWMASK] && (r->fwmask != nla_get_u32(tb[FRA_FWMASK])))
+               return 0;
 #endif
 
        if (tb[FRA_SRC] && (r->src != nla_get_u16(tb[FRA_SRC])))
@@ -237,6 +251,8 @@ static int dn_fib_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
 #ifdef CONFIG_DECNET_ROUTE_FWMARK
        if (r->fwmark)
                NLA_PUT_U32(skb, FRA_FWMARK, r->fwmark);
+       if (r->fwmask || r->fwmark)
+               NLA_PUT_U32(skb, FRA_FWMASK, r->fwmask);
 #endif
        if (r->dst_len)
                NLA_PUT_U16(skb, FRA_DST, r->dst);