aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorDavid Ahern <dsa@cumulusnetworks.com>2016-06-08 13:55:39 -0400
committerDavid S. Miller <davem@davemloft.net>2016-06-08 14:36:02 -0400
commit96c63fa7393d0a346acfe5a91e0c7d4c7782641b (patch)
tree0dcc6d3f3e5ccb788347399c9a63059f8ad8b5df /include/net
parent6278e03dc667b611cc9ebbd8f455d859f18f8e11 (diff)
net: Add l3mdev rule
Currently, VRFs require 1 oif and 1 iif rule per address family per VRF. As the number of VRF devices increases it brings scalability issues with the increasing rule list. All of the VRF rules have the same format with the exception of the specific table id to direct the lookup. Since the table id is available from the oif or iif in the loopup, the VRF rules can be consolidated to a single rule that pulls the table from the VRF device. This patch introduces a new rule attribute l3mdev. The l3mdev rule means the table id used for the lookup is pulled from the L3 master device (e.g., VRF) rather than being statically defined. With the l3mdev rule all of the basic VRF FIB rules are reduced to 1 l3mdev rule per address family (IPv4 and IPv6). If an admin wishes to insert higher priority rules for specific VRFs those rules will co-exist with the l3mdev rule. This capability means current VRF scripts will co-exist with this new simpler implementation. Currently, the rules list for both ipv4 and ipv6 look like this: $ ip ru ls 1000: from all oif vrf1 lookup 1001 1000: from all iif vrf1 lookup 1001 1000: from all oif vrf2 lookup 1002 1000: from all iif vrf2 lookup 1002 1000: from all oif vrf3 lookup 1003 1000: from all iif vrf3 lookup 1003 1000: from all oif vrf4 lookup 1004 1000: from all iif vrf4 lookup 1004 1000: from all oif vrf5 lookup 1005 1000: from all iif vrf5 lookup 1005 1000: from all oif vrf6 lookup 1006 1000: from all iif vrf6 lookup 1006 1000: from all oif vrf7 lookup 1007 1000: from all iif vrf7 lookup 1007 1000: from all oif vrf8 lookup 1008 1000: from all iif vrf8 lookup 1008 ... 32765: from all lookup local 32766: from all lookup main 32767: from all lookup default With the l3mdev rule the list is just the following regardless of the number of VRFs: $ ip ru ls 1000: from all lookup [l3mdev table] 32765: from all lookup local 32766: from all lookup main 32767: from all lookup default (Note: the above pretty print of the rule is based on an iproute2 prototype. Actual verbage may change) Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/fib_rules.h24
-rw-r--r--include/net/l3mdev.h12
2 files changed, 34 insertions, 2 deletions
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index 59160de702b6..456e4a6006ab 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -17,7 +17,8 @@ struct fib_rule {
17 u32 flags; 17 u32 flags;
18 u32 table; 18 u32 table;
19 u8 action; 19 u8 action;
20 /* 3 bytes hole, try to use */ 20 u8 l3mdev;
21 /* 2 bytes hole, try to use */
21 u32 target; 22 u32 target;
22 __be64 tun_id; 23 __be64 tun_id;
23 struct fib_rule __rcu *ctarget; 24 struct fib_rule __rcu *ctarget;
@@ -36,6 +37,7 @@ struct fib_lookup_arg {
36 void *lookup_ptr; 37 void *lookup_ptr;
37 void *result; 38 void *result;
38 struct fib_rule *rule; 39 struct fib_rule *rule;
40 u32 table;
39 int flags; 41 int flags;
40#define FIB_LOOKUP_NOREF 1 42#define FIB_LOOKUP_NOREF 1
41#define FIB_LOOKUP_IGNORE_LINKSTATE 2 43#define FIB_LOOKUP_IGNORE_LINKSTATE 2
@@ -89,7 +91,8 @@ struct fib_rules_ops {
89 [FRA_TABLE] = { .type = NLA_U32 }, \ 91 [FRA_TABLE] = { .type = NLA_U32 }, \
90 [FRA_SUPPRESS_PREFIXLEN] = { .type = NLA_U32 }, \ 92 [FRA_SUPPRESS_PREFIXLEN] = { .type = NLA_U32 }, \
91 [FRA_SUPPRESS_IFGROUP] = { .type = NLA_U32 }, \ 93 [FRA_SUPPRESS_IFGROUP] = { .type = NLA_U32 }, \
92 [FRA_GOTO] = { .type = NLA_U32 } 94 [FRA_GOTO] = { .type = NLA_U32 }, \
95 [FRA_L3MDEV] = { .type = NLA_U8 }
93 96
94static inline void fib_rule_get(struct fib_rule *rule) 97static inline void fib_rule_get(struct fib_rule *rule)
95{ 98{
@@ -102,6 +105,20 @@ static inline void fib_rule_put(struct fib_rule *rule)
102 kfree_rcu(rule, rcu); 105 kfree_rcu(rule, rcu);
103} 106}
104 107
108#ifdef CONFIG_NET_L3_MASTER_DEV
109static inline u32 fib_rule_get_table(struct fib_rule *rule,
110 struct fib_lookup_arg *arg)
111{
112 return rule->l3mdev ? arg->table : rule->table;
113}
114#else
115static inline u32 fib_rule_get_table(struct fib_rule *rule,
116 struct fib_lookup_arg *arg)
117{
118 return rule->table;
119}
120#endif
121
105static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla) 122static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla)
106{ 123{
107 if (nla[FRA_TABLE]) 124 if (nla[FRA_TABLE])
@@ -117,4 +134,7 @@ int fib_rules_lookup(struct fib_rules_ops *, struct flowi *, int flags,
117 struct fib_lookup_arg *); 134 struct fib_lookup_arg *);
118int fib_default_rule_add(struct fib_rules_ops *, u32 pref, u32 table, 135int fib_default_rule_add(struct fib_rules_ops *, u32 pref, u32 table,
119 u32 flags); 136 u32 flags);
137
138int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh);
139int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh);
120#endif 140#endif
diff --git a/include/net/l3mdev.h b/include/net/l3mdev.h
index 374388dc01c8..34f33eb96a5e 100644
--- a/include/net/l3mdev.h
+++ b/include/net/l3mdev.h
@@ -11,6 +11,8 @@
11#ifndef _NET_L3MDEV_H_ 11#ifndef _NET_L3MDEV_H_
12#define _NET_L3MDEV_H_ 12#define _NET_L3MDEV_H_
13 13
14#include <net/fib_rules.h>
15
14/** 16/**
15 * struct l3mdev_ops - l3mdev operations 17 * struct l3mdev_ops - l3mdev operations
16 * 18 *
@@ -41,6 +43,9 @@ struct l3mdev_ops {
41 43
42#ifdef CONFIG_NET_L3_MASTER_DEV 44#ifdef CONFIG_NET_L3_MASTER_DEV
43 45
46int l3mdev_fib_rule_match(struct net *net, struct flowi *fl,
47 struct fib_lookup_arg *arg);
48
44int l3mdev_master_ifindex_rcu(const struct net_device *dev); 49int l3mdev_master_ifindex_rcu(const struct net_device *dev);
45static inline int l3mdev_master_ifindex(struct net_device *dev) 50static inline int l3mdev_master_ifindex(struct net_device *dev)
46{ 51{
@@ -236,6 +241,13 @@ struct sk_buff *l3mdev_ip6_rcv(struct sk_buff *skb)
236{ 241{
237 return skb; 242 return skb;
238} 243}
244
245static inline
246int l3mdev_fib_rule_match(struct net *net, struct flowi *fl,
247 struct fib_lookup_arg *arg)
248{
249 return 1;
250}
239#endif 251#endif
240 252
241#endif /* _NET_L3MDEV_H_ */ 253#endif /* _NET_L3MDEV_H_ */