Routing Cache
Routing Cache
The routing cache is also known as the forwarding information base (FIB).
The routing cache stores recently used routing entries in a fast and convenient hash lookup table,
and are consulted before the routing tables. If the kernel finds a matching entry during route
cache lookup, it will forward the packet immediately and stop traversing the routing tables.
Because the routing cache is maintained by the kernel separately from the routing tables,
manipulating the routing tables may not have an immediate effect on the kernel's choice of path
for a given packet. To avoid a non-deterministic lag between the time that a new route is entered
into the kernel routing tables and the time that a new lookup in those route tables is performed,
use ip route flush cache. Once the route cache has been emptied, new route lookups will result
in a new lookup to the kernel routing tables.
The following is a listing of the hash lookup keys in the routing cache and a description of each
key.
The destination IP address of the packet. This is the destination address on the packet at
the time of the route lookup. The address is a host address. All 32 bits are significant
during this lookup.
The source IP address of the packet. This is the source address on the packet at the time
of the route lookup. The address is a host address. All 32 bits are significant during this
lookup.
The ToS marking on the packet. If there is no ToS marking on the packet (tos == 0), this
lookup key is unused. If there is a ToS marking, the kernel will search for a match with
this ToS value. If no matching (dst, src, tos) is found, the kernel will continue the search
for a route by traversing the RPDB.
fwmark
The mark on a packet added administratively by the packet filtering engine (ipchains or
iptables). This mark is not part of the physical IP packet, and only exists as part of the
data structure held in memory on the routing device to represent the IP packet. If there is
no fwmark on the packet, this lookup key is unused. When present, the kernel will search
for a matching (dst, src, tos?, fwmark) entry. If no matching entry is found, the kernel
will continue the search for a route by traversing the RPDB.