aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@redhat.com>2015-03-06 16:47:00 -0500
committerDavid S. Miller <davem@davemloft.net>2015-03-11 16:22:14 -0400
commit0ddcf43d5d4a03ded1ee3f6b3b72a0cbed4e90b1 (patch)
tree28c93b0c6eb9389182f60736103b6bfc0b61cedc /include
parent169bf9121b19dd6029e0a354d33513f61bfbe3d3 (diff)
ipv4: FIB Local/MAIN table collapse
This patch is meant to collapse local and main into one by converting tb_data from an array to a pointer. Doing this allows us to point the local table into the main while maintaining the same variables in the table. As such the tb_data was converted from an array to a pointer, and a new array called data is added in order to still provide an object for tb_data to point to. In order to track the origin of the fib aliases a tb_id value was added in a hole that existed on 64b systems. Using this we can also reverse the merge in the event that custom FIB rules are enabled. With this patch I am seeing an improvement of 20ns to 30ns for routing lookups as long as custom rules are not enabled, with custom rules enabled we fall back to split tables and the original behavior. Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/fib_rules.h2
-rw-r--r--include/net/ip_fib.h26
2 files changed, 10 insertions, 18 deletions
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index e584de16e4c3..88d2ae526961 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -58,7 +58,7 @@ struct fib_rules_ops {
58 struct sk_buff *, 58 struct sk_buff *,
59 struct fib_rule_hdr *, 59 struct fib_rule_hdr *,
60 struct nlattr **); 60 struct nlattr **);
61 void (*delete)(struct fib_rule *); 61 int (*delete)(struct fib_rule *);
62 int (*compare)(struct fib_rule *, 62 int (*compare)(struct fib_rule *,
63 struct fib_rule_hdr *, 63 struct fib_rule_hdr *,
64 struct nlattr **); 64 struct nlattr **);
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 1657604c5dd3..54271ed0ed45 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -186,7 +186,8 @@ struct fib_table {
186 int tb_default; 186 int tb_default;
187 int tb_num_default; 187 int tb_num_default;
188 struct rcu_head rcu; 188 struct rcu_head rcu;
189 unsigned long tb_data[0]; 189 unsigned long *tb_data;
190 unsigned long __data[0];
190}; 191};
191 192
192int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp, 193int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
@@ -196,11 +197,10 @@ int fib_table_delete(struct fib_table *, struct fib_config *);
196int fib_table_dump(struct fib_table *table, struct sk_buff *skb, 197int fib_table_dump(struct fib_table *table, struct sk_buff *skb,
197 struct netlink_callback *cb); 198 struct netlink_callback *cb);
198int fib_table_flush(struct fib_table *table); 199int fib_table_flush(struct fib_table *table);
200struct fib_table *fib_trie_unmerge(struct fib_table *main_tb);
199void fib_table_flush_external(struct fib_table *table); 201void fib_table_flush_external(struct fib_table *table);
200void fib_free_table(struct fib_table *tb); 202void fib_free_table(struct fib_table *tb);
201 203
202
203
204#ifndef CONFIG_IP_MULTIPLE_TABLES 204#ifndef CONFIG_IP_MULTIPLE_TABLES
205 205
206#define TABLE_LOCAL_INDEX (RT_TABLE_LOCAL & (FIB_TABLE_HASHSZ - 1)) 206#define TABLE_LOCAL_INDEX (RT_TABLE_LOCAL & (FIB_TABLE_HASHSZ - 1))
@@ -229,18 +229,13 @@ static inline int fib_lookup(struct net *net, const struct flowi4 *flp,
229 struct fib_result *res) 229 struct fib_result *res)
230{ 230{
231 struct fib_table *tb; 231 struct fib_table *tb;
232 int err; 232 int err = -ENETUNREACH;
233 233
234 rcu_read_lock(); 234 rcu_read_lock();
235 235
236 for (err = 0; !err; err = -ENETUNREACH) { 236 tb = fib_get_table(net, RT_TABLE_MAIN);
237 tb = fib_get_table(net, RT_TABLE_LOCAL); 237 if (tb && !fib_table_lookup(tb, flp, res, FIB_LOOKUP_NOREF))
238 if (tb && !fib_table_lookup(tb, flp, res, FIB_LOOKUP_NOREF)) 238 err = 0;
239 break;
240 tb = fib_get_table(net, RT_TABLE_MAIN);
241 if (tb && !fib_table_lookup(tb, flp, res, FIB_LOOKUP_NOREF))
242 break;
243 }
244 239
245 rcu_read_unlock(); 240 rcu_read_unlock();
246 241
@@ -270,10 +265,6 @@ static inline int fib_lookup(struct net *net, struct flowi4 *flp,
270 res->tclassid = 0; 265 res->tclassid = 0;
271 266
272 for (err = 0; !err; err = -ENETUNREACH) { 267 for (err = 0; !err; err = -ENETUNREACH) {
273 tb = rcu_dereference_rtnl(net->ipv4.fib_local);
274 if (tb && !fib_table_lookup(tb, flp, res, FIB_LOOKUP_NOREF))
275 break;
276
277 tb = rcu_dereference_rtnl(net->ipv4.fib_main); 268 tb = rcu_dereference_rtnl(net->ipv4.fib_main);
278 if (tb && !fib_table_lookup(tb, flp, res, FIB_LOOKUP_NOREF)) 269 if (tb && !fib_table_lookup(tb, flp, res, FIB_LOOKUP_NOREF))
279 break; 270 break;
@@ -309,6 +300,7 @@ static inline int fib_num_tclassid_users(struct net *net)
309 return 0; 300 return 0;
310} 301}
311#endif 302#endif
303int fib_unmerge(struct net *net);
312void fib_flush_external(struct net *net); 304void fib_flush_external(struct net *net);
313 305
314/* Exported by fib_semantics.c */ 306/* Exported by fib_semantics.c */
@@ -320,7 +312,7 @@ void fib_select_multipath(struct fib_result *res);
320 312
321/* Exported by fib_trie.c */ 313/* Exported by fib_trie.c */
322void fib_trie_init(void); 314void fib_trie_init(void);
323struct fib_table *fib_trie_table(u32 id); 315struct fib_table *fib_trie_table(u32 id, struct fib_table *alias);
324 316
325static inline void fib_combine_itag(u32 *itag, const struct fib_result *res) 317static inline void fib_combine_itag(u32 *itag, const struct fib_result *res)
326{ 318{