Multipath Caching
The concepts behind this feature are introduced in the section "Cache Support for Multipath" in Chapter 31. When the kernel is compiled with support for multipath caching, the lookup code adds multiple routes to the cache, as shown in the section "Multipath Caching" in Chapter 35. In this section, we will examine the key routines used to implement this feature, and the interface provided by caching algorithms.
Registering a Caching Algorithm
Caching algorithms are
defined with an instance of the ip_mp_alg_ops data
structure, which consists of function pointers. Depending on the needs of the caching
algorithm, not all function pointers may be initialized, but one is mandatory: mp_alg_select_route.
Algorithms register and unregister with the kernel, respectively, using multipath_alg_register and multipath_alg_unregister. All the algorithms are implemented as modules in
the net/ipv4/ directory.
Interface Between the Routing Cache and Multipath
For each function pointer of the ip_mp_alg_ops
data structure, the kernel defines a wrapper in include/net/ip_mp_alg.h. Here is when each one is called:
-
multipath_select_route This is the most important routine. It selects the right route from the ones in the cache that satisfy a given lookup (because they are associated with the same multipath route). This routine is called by
_ _ip_route_output_key, the lookup function we saw earlier.-
multipath_flush Clears any state kept by the algorithm when the cache is flushed. It is called ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access