aboutsummaryrefslogtreecommitdiff
path: root/include/net/ip_fib.h
diff options
context:
space:
mode:
authorDavid S. Miller2011-03-07 20:54:48 -0800
committerDavid S. Miller2011-03-07 20:54:48 -0800
commit1fc050a13473348f5c439de2bb41c8e92dba5588 (patch)
treeb2cecf15f5de87997fb44b4a1025b48d473cd038 /include/net/ip_fib.h
parent6118e35a7126c1062b1a0f6737b84b4fe4d5c8d4 (diff)
ipv4: Cache source address in nexthop entries.
When doing output route lookups, we have to select the source address if the user has not specified an explicit one. First, if the route has an explicit preferred source address specified, then we use that. Otherwise we search the route's outgoing interface for a suitable address. This search can be precomputed and cached at route insertion time. The only missing part is that we have to refresh this precomputed value any time addresses are added or removed from the interface, and this is accomplished by fib_update_nh_saddrs(). Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/ip_fib.h')
-rw-r--r--include/net/ip_fib.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 523a170b0ecb..0e140830b85a 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -60,6 +60,7 @@ struct fib_nh {
#endif
int nh_oif;
__be32 nh_gw;
+ __be32 nh_saddr;
};
/*
@@ -139,11 +140,13 @@ struct fib_result_nl {
#endif /* CONFIG_IP_ROUTE_MULTIPATH */
-#define FIB_RES_PREFSRC(res) ((res).fi->fib_prefsrc ? : __fib_res_prefsrc(&res))
+#define FIB_RES_SADDR(res) (FIB_RES_NH(res).nh_saddr)
#define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
#define FIB_RES_DEV(res) (FIB_RES_NH(res).nh_dev)
#define FIB_RES_OIF(res) (FIB_RES_NH(res).nh_oif)
+#define FIB_RES_PREFSRC(res) ((res).fi->fib_prefsrc ? : FIB_RES_SADDR(res))
+
struct fib_table {
struct hlist_node tb_hlist;
u32 tb_id;
@@ -224,8 +227,8 @@ extern void fib_select_default(struct fib_result *res);
extern int ip_fib_check_default(__be32 gw, struct net_device *dev);
extern int fib_sync_down_dev(struct net_device *dev, int force);
extern int fib_sync_down_addr(struct net *net, __be32 local);
+extern void fib_update_nh_saddrs(struct net_device *dev);
extern int fib_sync_up(struct net_device *dev);
-extern __be32 __fib_res_prefsrc(struct fib_result *res);
extern void fib_select_multipath(const struct flowi *flp, struct fib_result *res);
/* Exported by fib_trie.c */