aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/fib_rules.h
diff options
context:
space:
mode:
authorStefan Tomanek <stefan.tomanek@wertarbyte.de>2013-07-31 20:17:15 -0400
committerDavid S. Miller <davem@davemloft.net>2013-07-31 20:27:17 -0400
commit7764a45a8f1fe74d4f7d301eaca2e558e7e2831a (patch)
tree39e20aa1dd22859d315da33b858074651efed7b9 /include/net/fib_rules.h
parent5c15257f93234aaa9775291a041b49eeb38fd95a (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 'include/net/fib_rules.h')
-rw-r--r--include/net/fib_rules.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index e361f4882426..2f286dce9259 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -18,6 +18,7 @@ struct fib_rule {
18 u32 pref; 18 u32 pref;
19 u32 flags; 19 u32 flags;
20 u32 table; 20 u32 table;
21 u8 table_prefixlen_min;
21 u8 action; 22 u8 action;
22 u32 target; 23 u32 target;
23 struct fib_rule __rcu *ctarget; 24 struct fib_rule __rcu *ctarget;
@@ -46,6 +47,8 @@ struct fib_rules_ops {
46 int (*action)(struct fib_rule *, 47 int (*action)(struct fib_rule *,
47 struct flowi *, int, 48 struct flowi *, int,
48 struct fib_lookup_arg *); 49 struct fib_lookup_arg *);
50 bool (*suppress)(struct fib_rule *,
51 struct fib_lookup_arg *);
49 int (*match)(struct fib_rule *, 52 int (*match)(struct fib_rule *,
50 struct flowi *, int); 53 struct flowi *, int);
51 int (*configure)(struct fib_rule *, 54 int (*configure)(struct fib_rule *,
@@ -80,6 +83,7 @@ struct fib_rules_ops {
80 [FRA_FWMARK] = { .type = NLA_U32 }, \ 83 [FRA_FWMARK] = { .type = NLA_U32 }, \
81 [FRA_FWMASK] = { .type = NLA_U32 }, \ 84 [FRA_FWMASK] = { .type = NLA_U32 }, \
82 [FRA_TABLE] = { .type = NLA_U32 }, \ 85 [FRA_TABLE] = { .type = NLA_U32 }, \
86 [FRA_TABLE_PREFIXLEN_MIN] = { .type = NLA_U8 }, \
83 [FRA_GOTO] = { .type = NLA_U32 } 87 [FRA_GOTO] = { .type = NLA_U32 }
84 88
85static inline void fib_rule_get(struct fib_rule *rule) 89static inline void fib_rule_get(struct fib_rule *rule)