Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 12: Networks


__u16 csum_offset;
};
};
__u32 priority;
__u8 local_df:1,
cloned:1,
ip_summed:2,
nohdr:1,
nfctinfo:3;
__u8 pkt_type:3,
fclone:2,
ipvs_property:1;
nf_trace:1;
__be16 protocol;
...
void (*destructor)(struct sk_buff *skb);
...
int iif;
...
sk_buff_data_t transport_header;
sk_buff_data_t network_header;
sk_buff_data_t mac_header;

/* These elements must be at the end, see alloc_skb() for details. */
sk_buff_data_t tail;
sk_buff_data_t end;
unsigned char *head,
*data;
unsigned int truesize;
atomic_t users;
};

Socket buffers are used to exchange data between the network implementation levels without having to
copy packet data to and fro — this delivers considerable speed gains. The socket structure is one of the
cornerstones of the network layer because it is processed on all levels both when packets are analyzed
and generated.

12.6.1 Data Management Using Socket Buffers


Socket buffers are linked by means of the various pointers they contain with an area in memory where
the data of a network packet reside, as shown in Figure 12-6. The figure assumes that we are working on
a 32-bit system (the organization of a socket buffer is slightly different on a 64-bit machine, as you will
see in a moment).

The basic idea of a socket buffer is to add and remove protocol headers by manipulating pointers.

❑ headandendpoint to the start and end of the area in memory where the data reside.

This area may be larger than actually needed because it is not clear how big packets
will be when they are synthesized.

❑ dataandtailpoint to the start and end of the protocol data area.
Free download pdf