Routing Subsystem Initialization
The
initialization of the
IPv4 routing code starts in net/ipv4/route.c with
ip_rt_init, which is called by the IP subsystem when
it is initialized with ip_init in net/ipv4/ip_output.c at boot time. ip_init is described in Chapter
19; here we will see ip_rt_init.
[*]
Figure 32-4 shows how the main routing
initialization routines are invoked.

Figure 32-4. Sequence of calls for the main routing initialization functions
In ip_rt_init, the IPv4 routing code initializes
its data structures and global variables. Among other things, the function:
Defines the size of the routing cache based on the available RAM.
Creates the memory pool that will be used to allocate elements of the routing cache.
Initializes the routing cache
Defines the
gc_threshthreshold used by the garbage collection algorithm (see the section "rt_garbage_collect Function" in Chapter 33).Starts the timer
rt_periodic_timer(see the section "Garbage Collection" in Chapter 33).Starts the
rt_secret_timertimer (see the section "Flushing the Routing Cache" in Chapter 33).Adds a few files to the /proc filesystem (see the section "Tuning via /proc Filesystem" in Chapter 36).
Two routines are of particular interest:
-
ip_fib_init Initializes the default routing tables and registers two handlers with the two notification chains[*]
netdev_chainandinetaddr_chain(see the section "External Events").-
devinet_init ...
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