Initializing the Device Handling Layer: net_dev_init
An important part of initialization for the networking code,
including Traffic Control and per-CPU ingress queues, is performed at boot time by
net_dev_init, defined in net/core/dev.c:
static int _ _init net_dev_init(void)
{
...
}
subsys_initcall(net_dev_init);See Chapter 7 for how the subsys_initcall macros ensure that net_dev_init runs before any NIC device drivers register themselves, and why
this is important. You also will see why net_dev_init
is tagged with the _ _init macro.
Let's walk through the main parts of net_dev_init:
The per-CPU data structures used by the two networking software interrupts (softirqs) are initialized. In Chapter 9, we will see what a softirq is and go into detail on how the networking code uses softirqs.
When the kernel is compiled with support for the /proc filesystem (which is the default configuration), a few files are added to /proc with
dev_proc_initanddev_mcast_init. See the later section "Tuning via /proc Filesystem" for more details.netdev_sysfs_initregisters thenetclass with sysfs. This creates the directory /sys/class/net, under which you will find a subdirectory for each registered network device. These directories include lots of files, some of which used to be in /proc.net_random_initinitializes a per-CPU vector of seeds that will be used when generating random numbers with thenet_randomroutine.net_randomis used in different contexts, described later in this section.The protocol-independent ...
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