diff options
author | Stefan Tomanek <stefan.tomanek@wertarbyte.de> | 2013-08-03 08:14:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-08-03 13:40:23 -0400 |
commit | 73f5698e77219bfc3ea1903759fe8e20ab5b285e (patch) | |
tree | f3b64e87cc6ce4d7749ddfd9e993421b0c53a02c | |
parent | 0c0667a8548ef2985038a5a1d0fa0f64e2774694 (diff) |
fib_rules: fix suppressor names and default values
This change brings the suppressor attribute names into line; it also changes
the data types to provide a more consistent interface.
While -1 indicates that the suppressor is not enabled, values >= 0 for
suppress_prefixlen or suppress_ifgroup reject routing decisions violating the
constraint.
This changes the previously presented behaviour of suppress_prefixlen, where a
prefix length _less_ than the attribute value was rejected. After this change,
a prefix length less than *or* equal to the value is considered a violation of
the rule constraint.
It also changes the default values for default and newly added rules (disabling
any suppression for those).
Signed-off-by: Stefan Tomanek <stefan.tomanek@wertarbyte.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/fib_rules.h | 4 | ||||
-rw-r--r-- | include/uapi/linux/fib_rules.h | 2 | ||||
-rw-r--r-- | net/core/fib_rules.c | 15 | ||||
-rw-r--r-- | net/ipv4/fib_rules.c | 2 | ||||
-rw-r--r-- | net/ipv6/fib6_rules.c | 2 |
5 files changed, 16 insertions, 9 deletions
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h index d13c461b4b59..9d0fcbaa9cbb 100644 --- a/include/net/fib_rules.h +++ b/include/net/fib_rules.h | |||
@@ -19,7 +19,7 @@ struct fib_rule { | |||
19 | u32 flags; | 19 | u32 flags; |
20 | u32 table; | 20 | u32 table; |
21 | int suppress_ifgroup; | 21 | int suppress_ifgroup; |
22 | u8 table_prefixlen_min; | 22 | int suppress_prefixlen; |
23 | u8 action; | 23 | u8 action; |
24 | u32 target; | 24 | u32 target; |
25 | struct fib_rule __rcu *ctarget; | 25 | struct fib_rule __rcu *ctarget; |
@@ -84,7 +84,7 @@ struct fib_rules_ops { | |||
84 | [FRA_FWMARK] = { .type = NLA_U32 }, \ | 84 | [FRA_FWMARK] = { .type = NLA_U32 }, \ |
85 | [FRA_FWMASK] = { .type = NLA_U32 }, \ | 85 | [FRA_FWMASK] = { .type = NLA_U32 }, \ |
86 | [FRA_TABLE] = { .type = NLA_U32 }, \ | 86 | [FRA_TABLE] = { .type = NLA_U32 }, \ |
87 | [FRA_TABLE_PREFIXLEN_MIN] = { .type = NLA_U8 }, \ | 87 | [FRA_SUPPRESS_PREFIXLEN] = { .type = NLA_U32 }, \ |
88 | [FRA_SUPPRESS_IFGROUP] = { .type = NLA_U32 }, \ | 88 | [FRA_SUPPRESS_IFGROUP] = { .type = NLA_U32 }, \ |
89 | [FRA_GOTO] = { .type = NLA_U32 } | 89 | [FRA_GOTO] = { .type = NLA_U32 } |
90 | 90 | ||
diff --git a/include/uapi/linux/fib_rules.h b/include/uapi/linux/fib_rules.h index 63e31166e85b..2b82d7e30974 100644 --- a/include/uapi/linux/fib_rules.h +++ b/include/uapi/linux/fib_rules.h | |||
@@ -45,7 +45,7 @@ enum { | |||
45 | FRA_FLOW, /* flow/class id */ | 45 | FRA_FLOW, /* flow/class id */ |
46 | FRA_UNUSED6, | 46 | FRA_UNUSED6, |
47 | FRA_SUPPRESS_IFGROUP, | 47 | FRA_SUPPRESS_IFGROUP, |
48 | FRA_TABLE_PREFIXLEN_MIN, | 48 | FRA_SUPPRESS_PREFIXLEN, |
49 | FRA_TABLE, /* Extended table id */ | 49 | FRA_TABLE, /* Extended table id */ |
50 | FRA_FWMASK, /* mask for netfilter mark */ | 50 | FRA_FWMASK, /* mask for netfilter mark */ |
51 | FRA_OIFNAME, | 51 | FRA_OIFNAME, |
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c index 5040a61bf28a..2e654138433c 100644 --- a/net/core/fib_rules.c +++ b/net/core/fib_rules.c | |||
@@ -33,6 +33,9 @@ int fib_default_rule_add(struct fib_rules_ops *ops, | |||
33 | r->flags = flags; | 33 | r->flags = flags; |
34 | r->fr_net = hold_net(ops->fro_net); | 34 | r->fr_net = hold_net(ops->fro_net); |
35 | 35 | ||
36 | r->suppress_prefixlen = -1; | ||
37 | r->suppress_ifgroup = -1; | ||
38 | |||
36 | /* The lock is not required here, the list in unreacheable | 39 | /* The lock is not required here, the list in unreacheable |
37 | * at the moment this function is called */ | 40 | * at the moment this function is called */ |
38 | list_add_tail(&r->list, &ops->rules_list); | 41 | list_add_tail(&r->list, &ops->rules_list); |
@@ -340,11 +343,15 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh) | |||
340 | rule->action = frh->action; | 343 | rule->action = frh->action; |
341 | rule->flags = frh->flags; | 344 | rule->flags = frh->flags; |
342 | rule->table = frh_get_table(frh, tb); | 345 | rule->table = frh_get_table(frh, tb); |
343 | if (tb[FRA_TABLE_PREFIXLEN_MIN]) | 346 | if (tb[FRA_SUPPRESS_PREFIXLEN]) |
344 | rule->table_prefixlen_min = nla_get_u8(tb[FRA_TABLE_PREFIXLEN_MIN]); | 347 | rule->suppress_prefixlen = nla_get_u32(tb[FRA_SUPPRESS_PREFIXLEN]); |
348 | else | ||
349 | rule->suppress_prefixlen = -1; | ||
345 | 350 | ||
346 | if (tb[FRA_SUPPRESS_IFGROUP]) | 351 | if (tb[FRA_SUPPRESS_IFGROUP]) |
347 | rule->suppress_ifgroup = nla_get_u32(tb[FRA_SUPPRESS_IFGROUP]); | 352 | rule->suppress_ifgroup = nla_get_u32(tb[FRA_SUPPRESS_IFGROUP]); |
353 | else | ||
354 | rule->suppress_ifgroup = -1; | ||
348 | 355 | ||
349 | if (!tb[FRA_PRIORITY] && ops->default_pref) | 356 | if (!tb[FRA_PRIORITY] && ops->default_pref) |
350 | rule->pref = ops->default_pref(ops); | 357 | rule->pref = ops->default_pref(ops); |
@@ -531,7 +538,7 @@ static inline size_t fib_rule_nlmsg_size(struct fib_rules_ops *ops, | |||
531 | + nla_total_size(IFNAMSIZ) /* FRA_OIFNAME */ | 538 | + nla_total_size(IFNAMSIZ) /* FRA_OIFNAME */ |
532 | + nla_total_size(4) /* FRA_PRIORITY */ | 539 | + nla_total_size(4) /* FRA_PRIORITY */ |
533 | + nla_total_size(4) /* FRA_TABLE */ | 540 | + nla_total_size(4) /* FRA_TABLE */ |
534 | + nla_total_size(1) /* FRA_TABLE_PREFIXLEN_MIN */ | 541 | + nla_total_size(4) /* FRA_SUPPRESS_PREFIXLEN */ |
535 | + nla_total_size(4) /* FRA_SUPPRESS_IFGROUP */ | 542 | + nla_total_size(4) /* FRA_SUPPRESS_IFGROUP */ |
536 | + nla_total_size(4) /* FRA_FWMARK */ | 543 | + nla_total_size(4) /* FRA_FWMARK */ |
537 | + nla_total_size(4); /* FRA_FWMASK */ | 544 | + nla_total_size(4); /* FRA_FWMASK */ |
@@ -558,7 +565,7 @@ static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule, | |||
558 | frh->table = rule->table; | 565 | frh->table = rule->table; |
559 | if (nla_put_u32(skb, FRA_TABLE, rule->table)) | 566 | if (nla_put_u32(skb, FRA_TABLE, rule->table)) |
560 | goto nla_put_failure; | 567 | goto nla_put_failure; |
561 | if (nla_put_u8(skb, FRA_TABLE_PREFIXLEN_MIN, rule->table_prefixlen_min)) | 568 | if (nla_put_u32(skb, FRA_SUPPRESS_PREFIXLEN, rule->suppress_prefixlen)) |
562 | goto nla_put_failure; | 569 | goto nla_put_failure; |
563 | frh->res1 = 0; | 570 | frh->res1 = 0; |
564 | frh->res2 = 0; | 571 | frh->res2 = 0; |
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c index b78fd28970c9..523be38e37de 100644 --- a/net/ipv4/fib_rules.c +++ b/net/ipv4/fib_rules.c | |||
@@ -109,7 +109,7 @@ static bool fib4_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg | |||
109 | /* do not accept result if the route does | 109 | /* do not accept result if the route does |
110 | * not meet the required prefix length | 110 | * not meet the required prefix length |
111 | */ | 111 | */ |
112 | if (result->prefixlen < rule->table_prefixlen_min) | 112 | if (result->prefixlen <= rule->suppress_prefixlen) |
113 | goto suppress_route; | 113 | goto suppress_route; |
114 | 114 | ||
115 | /* do not accept result if the route uses a device | 115 | /* do not accept result if the route uses a device |
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index 36283267e2f8..a6c58ce43d34 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c | |||
@@ -126,7 +126,7 @@ static bool fib6_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg | |||
126 | /* do not accept result if the route does | 126 | /* do not accept result if the route does |
127 | * not meet the required prefix length | 127 | * not meet the required prefix length |
128 | */ | 128 | */ |
129 | if (rt->rt6i_dst.plen < rule->table_prefixlen_min) | 129 | if (rt->rt6i_dst.plen <= rule->suppress_prefixlen) |
130 | goto suppress_route; | 130 | goto suppress_route; |
131 | 131 | ||
132 | /* do not accept result if the route uses a device | 132 | /* do not accept result if the route uses a device |