Chapter 2. Critical Data Structures
A few key data structures are referenced throughout the Linux networking code. Both when reading this book and when studying the source code directly, you’ll need to understand the fields in these data structures. To be sure, going over data structures field by field is less fun than unraveling functions, but it’s an important foundation to have. “Show me your data,” said the legendary software engineer, Frederick P. Brooks.
This chapter introduces the following data structures, and mentions some of the functions and macros that manipulate them:
-
struct sk_buff
This is where a packet is stored. The structure is used by all the network layers to store their headers, information about the user data (the payload), and other information needed internally for coordinating their work.
-
struct net_device
Each network device is represented in the Linux kernel by this data structure, which contains information about both its hardware and its software configuration. See Chapter 8 for details on when and how
net_device
data structures are allocated.
Another critical data structure for Linux networking is struct
sock
, which stores the networking information for sockets. Because this book
does not cover sockets, I have not included sock
in this
chapter.
The Socket Buffer: sk_buff Structure
This is probably the most important data structure in the Linux networking code, representing the headers for data that has been received or is about to be transmitted. Defined ...
Get Understanding Linux Network Internals now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.