diff options
author | Stefan Tomanek <stefan.tomanek@wertarbyte.de> | 2013-07-31 20:17:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-07-31 20:27:17 -0400 |
commit | 7764a45a8f1fe74d4f7d301eaca2e558e7e2831a (patch) | |
tree | 39e20aa1dd22859d315da33b858074651efed7b9 /net/ipv6 | |
parent | 5c15257f93234aaa9775291a041b49eeb38fd95a (diff) |
fib_rules: add .suppress operation
This change adds a new operation to the fib_rules_ops struct; it allows the
suppression of routing decisions if certain criteria are not met by its
results.
The first implemented constraint is a minimum prefix length added to the
structures of routing rules. If a rule is added with a minimum prefix length
>0, only routes meeting this threshold will be considered. Any other (more
general) routing table entries will be ignored.
When configuring a system with multiple network uplinks and default routes, it
is often convinient to reference the main routing table multiple times - but
omitting the default route. Using this patch and a modified "ip" utility, this
can be achieved by using the following command sequence:
$ ip route add table secuplink default via 10.42.23.1
$ ip rule add pref 100 table main prefixlength 1
$ ip rule add pref 150 fwmark 0xA table secuplink
With this setup, packets marked 0xA will be processed by the additional routing
table "secuplink", but only if no suitable route in the main routing table can
be found. By using a minimal prefixlength of 1, the default route (/0) of the
table "main" is hidden to packets processed by rule 100; packets traveling to
destinations with more specific routing entries are processed as usual.
Signed-off-by: Stefan Tomanek <stefan.tomanek@wertarbyte.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/fib6_rules.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index 2e1a432867c0..e64e6a55fc4a 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c | |||
@@ -111,6 +111,18 @@ out: | |||
111 | return rt == NULL ? -EAGAIN : 0; | 111 | return rt == NULL ? -EAGAIN : 0; |
112 | } | 112 | } |
113 | 113 | ||
114 | static bool fib6_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg) | ||
115 | { | ||
116 | struct rt6_info *rt = (struct rt6_info *) arg->result; | ||
117 | /* do not accept result if the route does | ||
118 | * not meet the required prefix length | ||
119 | */ | ||
120 | if (rt->rt6i_dst.plen < rule->table_prefixlen_min) { | ||
121 | ip6_rt_put(rt); | ||
122 | return true; | ||
123 | } | ||
124 | return false; | ||
125 | } | ||
114 | 126 | ||
115 | static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags) | 127 | static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags) |
116 | { | 128 | { |
@@ -244,6 +256,7 @@ static const struct fib_rules_ops __net_initconst fib6_rules_ops_template = { | |||
244 | .addr_size = sizeof(struct in6_addr), | 256 | .addr_size = sizeof(struct in6_addr), |
245 | .action = fib6_rule_action, | 257 | .action = fib6_rule_action, |
246 | .match = fib6_rule_match, | 258 | .match = fib6_rule_match, |
259 | .suppress = fib6_rule_suppress, | ||
247 | .configure = fib6_rule_configure, | 260 | .configure = fib6_rule_configure, |
248 | .compare = fib6_rule_compare, | 261 | .compare = fib6_rule_compare, |
249 | .fill = fib6_rule_fill, | 262 | .fill = fib6_rule_fill, |