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_devicedata 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access