-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'unified-tunnel-dst-caching'
Paolo Abeni says: ==================== net: unify dst caching for tunnel devices This patch series try to unify the dst cache implementations currently present in the kernel, namely in ip_tunnel.c and ip6_tunnel.c, introducing a new generic implementation, replacing the existing ones, and then using the new implementation in other tunnel devices which currently lack it. The new dst implementation is compiled, as built-in, only if any device using it is enabled. Caching the dst for the tunnel remote address gives small, but measurable, performance improvement when tunneling over ipv4 (in the 2%-4% range) and significant ones when tunneling over ipv6 (roughly 60% when no fragmentation/segmentation take place and the tunnel local address is not specified). v2: - move the vxlan dst_cache usage inside the device lookup functions - fix usage after free for lwt tunnel moving the dst cache storage inside the dst_metadata, - sparse codying style cleanup ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Showing
21 changed files
with
429 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#ifndef _NET_DST_CACHE_H | ||
#define _NET_DST_CACHE_H | ||
|
||
#include <linux/jiffies.h> | ||
#include <net/dst.h> | ||
#if IS_ENABLED(CONFIG_IPV6) | ||
#include <net/ip6_fib.h> | ||
#endif | ||
|
||
struct dst_cache { | ||
struct dst_cache_pcpu __percpu *cache; | ||
unsigned long reset_ts; | ||
}; | ||
|
||
/** | ||
* dst_cache_get - perform cache lookup | ||
* @dst_cache: the cache | ||
* | ||
* The caller should use dst_cache_get_ip4() if it need to retrieve the | ||
* source address to be used when xmitting to the cached dst. | ||
* local BH must be disabled. | ||
*/ | ||
struct dst_entry *dst_cache_get(struct dst_cache *dst_cache); | ||
|
||
/** | ||
* dst_cache_get_ip4 - perform cache lookup and fetch ipv4 source address | ||
* @dst_cache: the cache | ||
* @saddr: return value for the retrieved source address | ||
* | ||
* local BH must be disabled. | ||
*/ | ||
struct rtable *dst_cache_get_ip4(struct dst_cache *dst_cache, __be32 *saddr); | ||
|
||
/** | ||
* dst_cache_set_ip4 - store the ipv4 dst into the cache | ||
* @dst_cache: the cache | ||
* @dst: the entry to be cached | ||
* @saddr: the source address to be stored inside the cache | ||
* | ||
* local BH must be disabled. | ||
*/ | ||
void dst_cache_set_ip4(struct dst_cache *dst_cache, struct dst_entry *dst, | ||
__be32 saddr); | ||
|
||
#if IS_ENABLED(CONFIG_IPV6) | ||
|
||
/** | ||
* dst_cache_set_ip6 - store the ipv6 dst into the cache | ||
* @dst_cache: the cache | ||
* @dst: the entry to be cached | ||
* @saddr: the source address to be stored inside the cache | ||
* | ||
* local BH must be disabled. | ||
*/ | ||
void dst_cache_set_ip6(struct dst_cache *dst_cache, struct dst_entry *dst, | ||
const struct in6_addr *addr); | ||
|
||
/** | ||
* dst_cache_get_ip6 - perform cache lookup and fetch ipv6 source address | ||
* @dst_cache: the cache | ||
* @saddr: return value for the retrieved source address | ||
* | ||
* local BH must be disabled. | ||
*/ | ||
struct dst_entry *dst_cache_get_ip6(struct dst_cache *dst_cache, | ||
struct in6_addr *saddr); | ||
#endif | ||
|
||
/** | ||
* dst_cache_reset - invalidate the cache contents | ||
* @dst_cache: the cache | ||
* | ||
* This do not free the cached dst to avoid races and contentions. | ||
* the dst will be freed on later cache lookup. | ||
*/ | ||
static inline void dst_cache_reset(struct dst_cache *dst_cache) | ||
{ | ||
dst_cache->reset_ts = jiffies; | ||
} | ||
|
||
/** | ||
* dst_cache_init - initialize the cache, allocating the required storage | ||
* @dst_cache: the cache | ||
* @gfp: allocation flags | ||
*/ | ||
int dst_cache_init(struct dst_cache *dst_cache, gfp_t gfp); | ||
|
||
/** | ||
* dst_cache_destroy - empty the cache and free the allocated storage | ||
* @dst_cache: the cache | ||
* | ||
* No synchronization is enforced: it must be called only when the cache | ||
* is unsed. | ||
*/ | ||
void dst_cache_destroy(struct dst_cache *dst_cache); | ||
|
||
#endif |
Oops, something went wrong.