Management Data of Socket Buffers

The socket buffer structure contains not only the above pointers, but also other elements that are used to handle the associated data and to manage the socket buffer itself.

The less common elements are dicsussed in this chapter when they are needed. The most important elements are listed below.

□ tstamp stores the time the packet arrived.

□ dev specifies the network device on which the packet is processed. dev may change in the course of processing the packet — for instance, when it will leave the computer on another device at some point.

□ The interface index number of the input device is always preserved in iif. Section 12.7.1 explains how to use this number.

□ sk is a link to the socket instance (see Section 12.10.1) of the socket used to process the packet.

□ dst indicates the further route of the packet through the network implementation. A special format is used (this is discussed in Section 12.8.5).

□ next and prev hold socket buffers in a doubly linked list. The standard list implementation of the kernel is not used here but is replaced by a manual version.

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;

qlen specifies the length of the wait queue; that is, the number of elements in the queue. next and prev of sk_buff_head and sk_buff are used to create a cyclic doubly linked list, and the list element of the socket buffer points back to the list head, as illustrated in Figure 12-8.

sk_buff_head sk_buff sk_buff next prev len=2

next prev list next prev list

Continue reading here: Network Access Layer

Was this article helpful?

0 0