Policy Routing
A routing lookup in a kernel that has support for Policy
Routing has to take into account the possible presence of multiple tables. The next two
sections show how the Policy Routing versions of fib_lookup and fib_select_default differ
from the basic versions we saw earlier in this chapter.
fib_lookup with Policy Routing
When Policy Routing is configured, this function contains an extra step: it needs to find out what routing table to use based on the configured policies.
We saw in the section "Main Data
Structures" in Chapter 32 that
routing policies are defined with fib_rule data
structures. All the fib_rule instances are linked
together with the global list fib_rules. The list is
kept sorted in increasing order as indicated by the priority field. This allows the configuration to define the order in which
the rules should be checked, therefore reducing lookup time. The more commonly matched
rules or most important rules (as defined by the administrator, depending on the
context) are closer to the head of the list. The priority is a 32-bit field, which means a host can theoretically have up to
232 policies. Of course, because policies are stored in a
sorted, flat list, a high number of policies can decrease routing performance
significantly.
Without any user configuration, fib_rules
includes the three default instances defined in net/ipv4/fib_rules.c, as shown in Figure 35-11:
-
local_rule This is the highest-priority rule and is therefore at the head of the list. It always ...
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