Global Locks
The routing code uses a few locks for protection against race conditions. The following list includes only global locks; those that are embedded in the data structure (i.e., applied to single entries) will be addressed in the associated data structure descriptions.
-
fib_hash_lock This read-write spin lock (rwlock) protects all the routing tables. For instance, the insertion of a new
fib_nodeinstance requires the lock to be taken in exclusive mode, and a routing table lookup requires the lock to be acquired just in shared mode. Since there is only one lock for all the routing tables, it means that it is not possible to add two routing entries to two distinct routing tables at the same time. However, this does not really represent a bottleneck, because configuration changes are rare events and the user can live with a shared lock without any major impact on router performance.-
fib_info_lock This
rwlockprotects all thefib_infodata structures. It is used, for instance, when accessingfib_infostructures through the hash tables described in the section "Organization of fib_info Structures" in Chapter 34.-
fib_rules_lock This rwlock protects the
fib_rulesglobal list offib_ruledata structures.-
rt_flush_lock This spin lock is used by
rt_cache_flushto protect the manipulation of thert_deadlineglobal variable and thert_flush_timertimer. The cache is protected by the per-bucket locks. See Figure 33-1 and the section "Flushing the Routing Cache," both in Chapter 33.
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