net_device Structure
The net_device data structure stores all
information specifically regarding a network device. There is one such structure for each
device, both real ones (such as Ethernet NICs) and virtual ones (such as bonding[1] or VLAN[†]). In this section, I will use the words interface and
device interchangeably, even though the difference between them is
important in other contexts.
The net_device structures for all devices are put
into a global list to which the global variable dev_base points. The data structure is defined in include/linux/netdevice.h. The registration of network devices is described
in Chapter 8. In that chapter, you can find
details on how and when most of the net_device fields
are initialized.
Like sk_buff, this structure is quite big and
includes many feature-specific parameters, along with parameters from many different
layers. For this reason, the overall organization of the structure will probably see some
changes soon for optimization reasons.
Network devices can be classified into types such as Ethernet
cards and Token Ring cards. While certain fields of the net_device structure are set to the same value for all devices of the same type, some fields must be set differently by each model of device. Thus, for almost every type, Linux provides a general function that initializes the parameters whose values stay the same across all models. Each device driver invokes this function in addition to setting those fields that have unique values for its ...
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