[NETLINK]: Do precise netlink message allocations where possible
[safe/jmp/linux-2.6] / net / decnet / dn_rules.c
index 977bb56..b7dfd04 100644 (file)
@@ -45,9 +45,6 @@ struct dn_fib_rule
        __le16                  dstmask;
        __le16                  srcmap;
        u8                      flags;
-#ifdef CONFIG_DECNET_ROUTE_FWMARK
-       u32                     fwmark;
-#endif
 };
 
 static struct dn_fib_rule default_rule = {
@@ -75,8 +72,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,29 +108,21 @@ errout:
 }
 
 static struct nla_policy dn_fib_rule_policy[FRA_MAX+1] __read_mostly = {
-       [FRA_IFNAME]    = { .type = NLA_STRING },
-       [FRA_PRIORITY]  = { .type = NLA_U32 },
+       FRA_GENERIC_POLICY,
        [FRA_SRC]       = { .type = NLA_U16 },
        [FRA_DST]       = { .type = NLA_U16 },
-       [FRA_FWMARK]    = { .type = NLA_U32 },
-       [FRA_TABLE]     = { .type = NLA_U32 },
 };
 
 static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
 {
        struct dn_fib_rule *r = (struct dn_fib_rule *)rule;
-       u16 daddr = fl->fld_dst;
-       u16 saddr = fl->fld_src;
+       __le16 daddr = fl->fld_dst;
+       __le16 saddr = fl->fld_src;
 
        if (((saddr ^ r->src) & r->srcmask) ||
            ((daddr ^ r->dst) & r->dstmask))
                return 0;
 
-#ifdef CONFIG_DECNET_ROUTE_FWMARK
-       if (r->fwmark && (r->fwmark != fl->fld_fwmark))
-               return 0;
-#endif
-
        return 1;
 }
 
@@ -167,11 +156,6 @@ static int dn_fib_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
        if (tb[FRA_DST])
                r->dst = nla_get_u16(tb[FRA_DST]);
 
-#ifdef CONFIG_DECNET_ROUTE_FWMARK
-       if (tb[FRA_FWMARK])
-               r->fwmark = nla_get_u32(tb[FRA_FWMARK]);
-#endif
-
        r->src_len = frh->src_len;
        r->srcmask = dnet_make_mask(r->src_len);
        r->dst_len = frh->dst_len;
@@ -192,11 +176,6 @@ static int dn_fib_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
        if (frh->dst_len && (r->dst_len != frh->dst_len))
                return 0;
 
-#ifdef CONFIG_DECNET_ROUTE_FWMARK
-       if (tb[FRA_FWMARK] && (r->fwmark != nla_get_u32(tb[FRA_FWMARK])))
-               return 0;
-#endif
-
        if (tb[FRA_SRC] && (r->src != nla_get_u16(tb[FRA_SRC])))
                return 0;
 
@@ -234,10 +213,6 @@ static int dn_fib_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
        frh->src_len = r->src_len;
        frh->tos = 0;
 
-#ifdef CONFIG_DECNET_ROUTE_FWMARK
-       if (r->fwmark)
-               NLA_PUT_U32(skb, FRA_FWMARK, r->fwmark);
-#endif
        if (r->dst_len)
                NLA_PUT_U16(skb, FRA_DST, r->dst);
        if (r->src_len)
@@ -266,6 +241,12 @@ static u32 dn_fib_rule_default_pref(void)
        return 0;
 }
 
+static size_t dn_fib_rule_nlmsg_payload(struct fib_rule *rule)
+{
+       return nla_total_size(2) /* dst */
+              + nla_total_size(2); /* src */
+}
+
 int dn_fib_dump_rules(struct sk_buff *skb, struct netlink_callback *cb)
 {
        return fib_rules_dump(skb, cb, AF_DECnet);