Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 12: Networks


only its own queue and cannot therefore interfere with the work of the other CPUs. Below, I ignore the
multiprocessor aspect and refer only to a single ‘‘softnet_datawait queue‘‘ so as not to overcomplicate
matters.

Only one element of the data structure is of interest for our purposes right now:

<netdevice.h>
struct softnet_data
{
...
struct sk_buff_head input_pkt_queue;
...
};

input_pkt_queueuses thesk_buff_headlist head mentioned above to build a linked list of all incoming
packets.

netif_rxmarks the soft interruptNET_RX_SOFTIRQfor execution (refer to Chapter 14 for more informa-
tion) before it finishes its work and exits the interrupt context.

net_rx_actionis used as the handler function of the softIRQ. Its code flow diagram is shown in
Figure 12-11. Keep in mind that a simplified version is described here. The full story — which includes
the new methods introduced for high-speed network adapters — follows below.

for example: ip_rcv
Iterate over all packet

types

net_rx_action

process_backlog

_ _skb_dequeue

netif_receive_skb

deliver_skb packet_type->func

Figure 12-11: Code flow diagram fornet_rx_action.

After a few preparatory tasks, work is passed toprocess_backlog, which performs the following steps in
a loop. To simplify matters, assume that the loop iterates until all pending packets have been processed
and is not interrupted by any other condition.


  1. __skb_dequeueremoves a socket buffer that is managing a received packet from the wait
    queue.

  2. The packet type is analyzed by thenetif_receive_skbfunction so that it can be delivered
    to the receive function of the network layer (i.e., to a higher layer of the network system). For
    this, it iterates over all network layer functions that feel responsible for the current type and
    callsdeliver_skbfor each of them.

Free download pdf