The Socket Buffers
We’ve now discussed most of the issues related to network interfaces.
The next few sections explain in more detail how the
is designed. They introduce both the main fields of the structure and
the functions used to act on the socket buffers.
Although there is no strict need to understand the internals of
sk_buff, the ability to look at its contents can be helpful when
you are tracking down problems and when you are trying to optimize the
code. For example, if
you look in
loopback.c, you’ll find an optimization based on
knowledge of the
I’m not going to describe the whole structure here, just the
fields that might be used from within a driver. If you want to see more,
you can look at
<linux/skbuff.h>, where the structure is defined
and the functions are prototyped. Additional details about how the fields and
functions are used can be easily retrieved by grepping in the kernel
The Important Fields
For our purposes, the important fields in the structure are those a driver writer might need. They are listed here in no particular order.
struct device *dev;
The device receiving or sending this buffer.
Source address, destination address, and router address, used by the IP protocol.
raddris the first hop the packet must take to reach its destination. These fields are set before the packet is transmitted and need not be assigned when it is received. An outgoing packet reaching ...