]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - include/net/ip_fib.h
ipv4: Cache output routes in fib_info nexthops.
[mirror_ubuntu-zesty-kernel.git] / include / net / ip_fib.h
index 539c6721f810154c992d23426eba6f1f11e3c3c5..fb62c590360ed289a4534f02fe01c6962308168f 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <net/flow.h>
 #include <linux/seq_file.h>
+#include <linux/rcupdate.h>
 #include <net/fib_rules.h>
 #include <net/inetpeer.h>
 
@@ -45,6 +46,23 @@ struct fib_config {
  };
 
 struct fib_info;
+struct rtable;
+
+struct fib_nh_exception {
+       struct fib_nh_exception __rcu   *fnhe_next;
+       __be32                          fnhe_daddr;
+       u32                             fnhe_pmtu;
+       __be32                          fnhe_gw;
+       unsigned long                   fnhe_expires;
+       unsigned long                   fnhe_stamp;
+};
+
+struct fnhe_hash_bucket {
+       struct fib_nh_exception __rcu   *chain;
+};
+
+#define FNHE_HASH_SIZE         2048
+#define FNHE_RECLAIM_DEPTH     5
 
 struct fib_nh {
        struct net_device       *nh_dev;
@@ -63,6 +81,8 @@ struct fib_nh {
        __be32                  nh_gw;
        __be32                  nh_saddr;
        int                     nh_saddr_genid;
+       struct rtable           *nh_rth_output;
+       struct fnhe_hash_bucket *nh_exceptions;
 };
 
 /*
@@ -106,12 +126,10 @@ struct fib_result {
        unsigned char   nh_sel;
        unsigned char   type;
        unsigned char   scope;
+       u32             tclassid;
        struct fib_info *fi;
        struct fib_table *table;
        struct list_head *fa_head;
-#ifdef CONFIG_IP_MULTIPLE_TABLES
-       struct fib_rule *r;
-#endif
 };
 
 struct fib_result_nl {
@@ -162,7 +180,6 @@ struct fib_table {
        u32                     tb_id;
        int                     tb_default;
        int                     tb_num_default;
-       struct inet_peer_base   tb_peers;
        unsigned long           tb_data[0];
 };
 
@@ -216,10 +233,6 @@ static inline int fib_lookup(struct net *net, const struct flowi4 *flp,
 extern int __net_init fib4_rules_init(struct net *net);
 extern void __net_exit fib4_rules_exit(struct net *net);
 
-#ifdef CONFIG_IP_ROUTE_CLASSID
-extern u32 fib_rules_tclass(const struct fib_result *res);
-#endif
-
 extern struct fib_table *fib_new_table(struct net *net, u32 id);
 extern struct fib_table *fib_get_table(struct net *net, u32 id);
 
@@ -230,6 +243,7 @@ static inline int fib_lookup(struct net *net, struct flowi4 *flp,
                             struct fib_result *res)
 {
        if (!net->ipv4.fib_has_custom_rules) {
+               res->tclassid = 0;
                if (net->ipv4.fib_local &&
                    !fib_table_lookup(net->ipv4.fib_local, flp, res,
                                      FIB_LOOKUP_NOREF))
@@ -289,7 +303,7 @@ static inline void fib_combine_itag(u32 *itag, const struct fib_result *res)
 #endif
        *itag = FIB_RES_NH(*res).nh_tclassid<<16;
 #ifdef CONFIG_IP_MULTIPLE_TABLES
-       rtag = fib_rules_tclass(res);
+       rtag = res->tclassid;
        if (*itag == 0)
                *itag = (rtag<<16);
        *itag |= (rtag>>16);