Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 12: Networks


After an individual device has been polled, the kernel checks if the number of processed packets is
identical with the allowed local budget. If this is the case, then the device could not obtain all waiting
packets as represented bywork == weightin the code flow diagram. The kernel moves it to the end of
the poll list and will continue to poll the device after all other devices on the list have been processed.
Clearly, this implements round robin scheduling between the network devices.

Implementation of the Old API on Top of NAPI


Finally, note how the old API is implemented on top of NAPI. The normal behavior of the kernel is
controlled by a dummy network device linked with the softnet queue; theprocess_backlogstandard
function innet/core/dev.cis used as the poll method. If no network adapters add themselves to the
poll list of the queue, it contains only the dummy adapter, and the behavior ofnet_rx_actionthere-
fore corresponds to a single call ofprocess_backlogin which the packets in the queue are processed
regardless of the device from which they originate.

12.7.3 Sending Packets


A finished packet is sent when a protocol-specific function of the network layer instructs the network
access layer to process a packet defined by a socket buffer.

What must be noted when messages are sent from the computer? In addition to complete headers
and the checksums required by the particular protocol and already generated by the higher instances,
the route to be taken by the packet is of prime importance. (Even if the computer has only one net-
work card, the kernel still has to distinguish between packets for external destinations and for the
loopback link.)

Because this question can only be clarified by higher protocol instances (particularly if there is a choice
of routes to the desired destination), the device driver assumes that the decision has already been made.

Before a packet can be sent to the next correct computer (normally not the same as the target computer
because IP packets are usually sent via gateways unless there is a direct hardware connection), it is neces-
sary to establish the hardware address of the receiving network card. This is a complicated process looked
at more closely in Section 12.8.5. At this point, simply assume that the receiving MAC address is known.
A further header for the network access layer is normally generated by protocol-specific functions.

dev_queue_xmitfromnet/core/dev.cis used to place the packet on the queue for outgoing packets. I
ignore the implementation of the device-specific queue mechanism because it reveals little of interest on
how the network layer functions. It is sufficient to know that the packet is sent a certain length of time
after it has been placed on the wait queue. This is done by the adapter-specifichard_start_xmitfunction
that is present as a function pointer in eachnet_devicestructure and is implemented by the hardware
device drivers.

12.8 Network Layer


The network access layer is still quite strongly influenced by the properties of the transmission medium
and the device drivers of the associated adapters. The network layer (and therefore specifically the IP
Internet protocol) is almost totally divorced from the hardware properties of the network adapters. Why
only almost? As you will see shortly, the layer is responsible not only for sending and receiving data, but
Free download pdf