Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 12: Networks


A list head is used to implement wait queues with socket buffers. Its structure is defined as follows:

<skbuff.h>
struct sk_buff_head {
/* These two members must be first. */
struct sk_buff *next;
struct sk_buff *prev;

__u32 qlen;
spinlock_t lock;
};

qlenspecifies the length of the wait queue; that is, the number of elements in the queue.nextandprev
ofsk_buff_headandsk_buffare used to create a cyclic doubly linked list, and thelistelement of the
socket buffer points back to the list head, as illustrated in Figure 12-8.

next
prev
len=2

sk_buff_head

list

next
prev

sk_buff

list

next
prev

sk_buff

Figure 12-8: Managing socket buffers in a doubly linked
list.

Packets are often placed on wait queues, for example, when they are awaiting processing or when packets
that have been fragmented are reassembled.

12.7 Network Access Layer


Now that we have examined the structure of the network subsystem in the Linux kernel, we turn our
attention to the first layer of the network implementation — the network access layer. This layer is pri-
marily responsible for transferring information between computers and collaborates directly with the
device drivers of network cards.

It is not my intention to discuss the implementation of the card drivers and the associated problems^9
because the techniques employed are only slightly different from those described in Chapter 6. I am
much more interested in theinterfacemade available by each card driver and used by the network code
to provide an abstract view of the hardware.

By reference to Ethernet frames, I explain how dataare represented ‘‘on the cable‘‘ and describe the
steps taken between receiving a packet and passing it on to a higher layer. I also describe the steps in the
reverse direction when generated packets leave the computer via a network interface.

(^9) Even though this may be quite interesting — unfortunately not for technical reasons but for product policy reasons.

Free download pdf