Commit 1f6c9557 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

[NET] rules: Share common attribute validation policy

Move the attribute policy for the non-specific attributes into
net/fib_rules.h and include it in the respective protocols.
Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b8964ed9
...@@ -59,6 +59,13 @@ struct fib_rules_ops ...@@ -59,6 +59,13 @@ struct fib_rules_ops
struct module *owner; struct module *owner;
}; };
#define FRA_GENERIC_POLICY \
[FRA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, \
[FRA_PRIORITY] = { .type = NLA_U32 }, \
[FRA_FWMARK] = { .type = NLA_U32 }, \
[FRA_FWMASK] = { .type = NLA_U32 }, \
[FRA_TABLE] = { .type = NLA_U32 }
static inline void fib_rule_get(struct fib_rule *rule) static inline void fib_rule_get(struct fib_rule *rule)
{ {
atomic_inc(&rule->refcnt); atomic_inc(&rule->refcnt);
......
...@@ -108,13 +108,9 @@ static int dn_fib_rule_action(struct fib_rule *rule, struct flowi *flp, ...@@ -108,13 +108,9 @@ static int dn_fib_rule_action(struct fib_rule *rule, struct flowi *flp,
} }
static struct nla_policy dn_fib_rule_policy[FRA_MAX+1] __read_mostly = { static struct nla_policy dn_fib_rule_policy[FRA_MAX+1] __read_mostly = {
[FRA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, FRA_GENERIC_POLICY,
[FRA_PRIORITY] = { .type = NLA_U32 },
[FRA_SRC] = { .type = NLA_U16 }, [FRA_SRC] = { .type = NLA_U16 },
[FRA_DST] = { .type = NLA_U16 }, [FRA_DST] = { .type = NLA_U16 },
[FRA_FWMARK] = { .type = NLA_U32 },
[FRA_FWMASK] = { .type = NLA_U32 },
[FRA_TABLE] = { .type = NLA_U32 },
}; };
static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags) static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
......
...@@ -170,14 +170,10 @@ static struct fib_table *fib_empty_table(void) ...@@ -170,14 +170,10 @@ static struct fib_table *fib_empty_table(void)
} }
static struct nla_policy fib4_rule_policy[FRA_MAX+1] __read_mostly = { static struct nla_policy fib4_rule_policy[FRA_MAX+1] __read_mostly = {
[FRA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, FRA_GENERIC_POLICY,
[FRA_PRIORITY] = { .type = NLA_U32 },
[FRA_SRC] = { .type = NLA_U32 }, [FRA_SRC] = { .type = NLA_U32 },
[FRA_DST] = { .type = NLA_U32 }, [FRA_DST] = { .type = NLA_U32 },
[FRA_FWMARK] = { .type = NLA_U32 },
[FRA_FWMASK] = { .type = NLA_U32 },
[FRA_FLOW] = { .type = NLA_U32 }, [FRA_FLOW] = { .type = NLA_U32 },
[FRA_TABLE] = { .type = NLA_U32 },
}; };
static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb, static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
......
...@@ -130,13 +130,9 @@ static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags) ...@@ -130,13 +130,9 @@ static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
} }
static struct nla_policy fib6_rule_policy[FRA_MAX+1] __read_mostly = { static struct nla_policy fib6_rule_policy[FRA_MAX+1] __read_mostly = {
[FRA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, FRA_GENERIC_POLICY,
[FRA_PRIORITY] = { .type = NLA_U32 },
[FRA_SRC] = { .len = sizeof(struct in6_addr) }, [FRA_SRC] = { .len = sizeof(struct in6_addr) },
[FRA_DST] = { .len = sizeof(struct in6_addr) }, [FRA_DST] = { .len = sizeof(struct in6_addr) },
[FRA_FWMARK] = { .type = NLA_U32 },
[FRA_FWMASK] = { .type = NLA_U32 },
[FRA_TABLE] = { .type = NLA_U32 },
}; };
static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb, static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment