General Packet Handling
The rest of this chapter covers some general considerations that the kernel has to take into account when handling ingress IP packets, such as checksumming and options. Subsequent chapters go into detail about how they are forwarded, transmitted, and fragmented/defragmented.
Protocol Initialization
The IPv4 protocol
is initialized by ip_init, defined in net/ipv4/ip_output.c. Because IPv4 support cannot be
removed from the kernel (i.e., it cannot be compiled as a module), there is no ip_uninit function.
Here are the main tasks accomplished by ip_init:
Register the handler for IP packets with the
dev_add_packfunction (see Chapter 13). This handler is a function namedip_rcv.Initialize the routing subsystem, including the protocol-independent cache (see Chapter 32).
Initialize the infrastructure used to manage IP peers (see the section "Long-Living IP Peer Information" in Chapter 23.
ip_init is invoked at boot time by inet_init, which takes care of the initialization of all the
subsystems related to IPv4, including the L4 protocols.
Interaction with Netfilter
We will not examine the Netfilter firewalling subsystem in this book, but we can examine its main working principles now, particularly its relationship to the aspects of the IPv4 implementation we discuss in this part of the book.
Firewalling, essentially, hooks into certain places in the network stack code that packets always pass through when the packets or the kernel meet certain conditions; at those points, ...
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