Routing Table Initialization
Routing tables are initialized with fib_hash_init,
defined in net/ipv4/fib_hash.c. It is called by
ip_fib_init, which initializes the IP routing
subsystem, to create the ip_fib_main_table and ip_fib_local_table tables (see the section "Routing Subsystem Initialization" in Chapter 32).
The first time fib_hash_init is called, it creates
the memory pool fn_hash_kmem that will be used to
allocate fib_node data structures.
fib_hash_init first allocates a fib_table data structure and then initializes its virtual
functions to the routines shown in Table
34-1. The function also clears the content of the bottom part of the structure
(fn_hash), which, as shown in Figure 34-1, is used to distribute the
routing entries on different hash tables based on their netmask lengths.
Table 34-1. Initialization of the fib_table's virtual functions
|
Method |
Routine used |
|---|---|
|
tb_lookup |
fn_hash_lookup |
|
tb_insert |
fn_hash_insert |
|
tb_delete |
fn_hash_delete |
|
tb_flush |
fn_hash_flush |
|
tb_select_default |
fn_hash_select_default |
|
tb_dump |
fn_hash_dump |
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