Synopses & Reviews
If you've ever wondered how Linux carries out the complicated tasks assigned to it by the IP protocols -- or if you just want to learn about modern networking through real-life examples -- Understanding Linux Network Internals is for you.
Like the popular O'Reilly book, Understanding the Linux Kernel, this book clearly explains the underlying concepts and teaches you how to follow the actual C code that implements it. Although some background in the TCP/IP protocols is helpful, you can learn a great deal from this text about the protocols themselves and their uses. And if you already have a base knowledge of C, you can use the book's code walkthroughs to figure out exactly what this sophisticated part of the Linux kernel is doing.
Part of the difficulty in understanding networks -- and implementing them -- is that the tasks are broken up and performed at many different times by different pieces of code. One of the strengths of this book is to integrate the pieces and reveal the relationships between far-flung functions and data structures. Understanding Linux Network Internals is both a big-picture discussion and a no-nonsense guide to the details of Linux networking. Topics include:
- Key problems with networking
- Network interface card (NIC) device drivers
- System initialization
- Layer 2 (link-layer) tasks and implementation
- Layer 3 (IPv4) tasks and implementation
- Neighbor infrastructure and protocols (ARP)
Author Christian Benvenuti, an operating system designer specializing in networking, explains much more than how Linux code works. He shows the purposes of major networking features and the trade-offs involved in choosing one solution over another. A large number of flowcharts and other diagrams enhance the book's understandability.
Benvenuti describes the relationship between the Internet's TCP/IP implementation and the Linux Kernel so that programmers and advanced administrators can modify and fine-tune their network environment.
About the Author
Christian Benvenuti received his masters degree in Computer Science at the University of Bologna in Italy. He collaborated for a few years with the International Center for Theoretical Physics (ICTP) in Trieste, where he developed ad-hoc software based on the Linux kernel, was a scientific consultant for a project on remote collaboration, and served as an instructor for several training sessions on networking. The trainings, held mainly in Europe, Africa, and South America wereall based on Linux systems and addressed to scientists from developing countries, where the ICTP has been promoting Linux for many years. He occasionally collaborates with a non-profit organization founded by ICTP members, Collaborium.org, to continue promoting Linux on developing countries.In the past few years he worked as a software engineer for Cisco Systems in the Silicon Valley, where he focused on Layer two switching, high availability, and network security.
Table of Contents
Preface; The Audience for This Book; Background Information; Organization of the Material; Conventions Used in This Book; Using Code Examples; We'd Like to Hear from You; Safari Enabled; Acknowledgments; Part I: General Background; Chapter 1: Introduction; 1.1 Basic Terminology; 1.2 Common Coding Patterns; 1.3 User-Space Tools; 1.4 Browsing the Source Code; 1.5 When a Feature Is Offered as a Patch; Chapter 2: Critical Data Structures; 2.1 The Socket Buffer: sk_buff Structure; 2.2 net_device Structure; 2.3 Files Mentioned in This Chapter; Chapter 3: User-Space-to-Kernel Interface; 3.1 Overview; 3.2 procfs Versus sysctl; 3.3 ioctl; 3.4 Netlink; 3.5 Serializing Configuration Changes; Part II: System Initialization; Chapter 4: Notification Chains; 4.1 Reasons for Notification Chains; 4.2 Overview; 4.3 Defining a Chain; 4.4 Registering with a Chain; 4.5 Notifying Events on a Chain; 4.6 Notification Chains for the Networking Subsystems; 4.7 Tuning via /proc Filesystem; 4.8 Functions and Variables Featured in This Chapter; 4.9 Files and Directories Featured in This Chapter; Chapter 5: Network Device Initialization; 5.1 System Initialization Overview; 5.2 Device Registration and Initialization; 5.3 Basic Goals of NIC Initialization; 5.4 Interaction Between Devices and Kernel; 5.5 Initialization Options; 5.6 Module Options; 5.7 Initializing the Device Handling Layer: net_dev_init; 5.8 User-Space Helpers; 5.9 Virtual Devices; 5.10 Tuning via /proc Filesystem; 5.11 Functions and Variables Featured in This Chapter; 5.12 Files and Directories Featured in This Chapter; Chapter 6: The PCI Layer and Network Interface Cards; 6.1 Data Structures Featured in This Chapter; 6.2 Registering a PCI NIC Device Driver; 6.3 Power Management and Wake-on-LAN; 6.4 Example of PCI NIC Driver Registration; 6.5 The Big Picture; 6.6 Tuning via /proc Filesystem; 6.7 Functions and Variables Featured in This Chapter; 6.8 Files and Directories Featured in This Chapter; Chapter 7: Kernel Infrastructure for Component Initialization; 7.1 Boot-Time Kernel Options; 7.2 Module Initialization Code; 7.3 Optimized Macro-Based Tagging; 7.4 Boot-Time Initialization Routines; 7.5 Memory Optimizations; 7.6 Tuning via /proc Filesystem; 7.7 Functions and Variables Featured in This Chapter; 7.8 Files and Directories Featured in This Chapter; Chapter 8: Device Registration and Initialization; 8.1 When a Device Is Registered; 8.2 When a Device Is Unregistered; 8.3 Allocating net_device Structures; 8.4 Skeleton of NIC Registration and Unregistration; 8.5 Device Initialization; 8.6 Organization of net_device Structures; 8.7 Device State; 8.8 Registering and Unregistering Devices; 8.9 Device Registration; 8.10 Device Unregistration; 8.11 Enabling and Disabling a Network Device; 8.12 Updating the Device Queuing Discipline State; 8.13 Configuring Device-Related Information from User Space; 8.14 Virtual Devices; 8.15 Locking; 8.16 Tuning via /proc Filesystem; 8.17 Functions and Variables Featured in This Chapter; 8.18 Files and Directories Featured in This Chapter; Part III: Transmission and Reception; Chapter 9: Interrupts and Network Drivers; 9.1 Decisions and Traffic Direction; 9.2 Notifying Drivers When Frames Are Received; 9.3 Interrupt Handlers; 9.4 softnet_data Structure; Chapter 10: Frame Reception; 10.1 Interactions with Other Features; 10.2 Enabling and Disabling a Device; 10.3 Queues; 10.4 Notifying the Kernel of Frame Reception: NAPI and netif_rx; 10.5 Old Interface Between Device Drivers and Kernel: First Part of netif_rx; 10.6 Congestion Management; 10.7 Processing the NET_RX_SOFTIRQ: net_rx_action; Chapter 11: Frame Transmission; 11.1 Enabling and Disabling Transmissions; Chapter 12: General and Reference Material About Interrupts; 12.1 Statistics; 12.2 Tuning via /proc and sysfs Filesystems; 12.3 Functions and Variables Featured in This Part of the Book; 12.4 Files and Directories Featured in This Part of the Book; Chapter 13: Protocol Handlers; 13.1 Overview of Network Stack; 13.2 Executing the Right Protocol Handler; 13.3 Protocol Handler Organization; 13.4 Protocol Handler Registration; 13.5 Ethernet Versus IEEE 802.3 Frames; 13.6 Tuning via /proc Filesystem; 13.7 Functions and Variables Featured in This Chapter; 13.8 Files and Directories Featured in This Chapter; Part IV: Bridging; Chapter 14: Bridging: Concepts; 14.1 Repeaters, Bridges, and Routers; 14.2 Bridges Versus Switches; 14.3 Hosts; 14.4 Merging LANs with Bridges; 14.5 Bridging Different LAN Technologies; 14.6 Address Learning; 14.7 Multiple Bridges; Chapter 15: Bridging: The Spanning Tree Protocol; 15.1 Basic Terminology; 15.2 Example of Hierarchical Switched L2 Topology; 15.3 Basic Elements of the Spanning Tree Protocol; 15.4 Bridge and Port IDs; 15.5 Bridge Protocol Data Units (BPDUs); 15.6 Defining the Active Topology; 15.7 Timers; 15.8 Topology Changes; 15.9 BPDU Encapsulation; 15.10 Transmitting Configuration BPDUs; 15.11 Processing Ingress Frames; 15.12 Convergence Time; 15.13 Overview of Newer Spanning Tree Protocols; Chapter 16: Bridging: Linux Implementation; 16.1 Bridge Device Abstraction; 16.2 Important Data Structures; 16.3 Initialization of Bridging Code; 16.4 Creating Bridge Devices and Bridge Ports; 16.5 Creating a New Bridge Device; 16.6 Bridge Device Setup Routine; 16.7 Deleting a Bridge; 16.8 Adding Ports to a Bridge; 16.9 Enabling and Disabling a Bridge Device; 16.10 Enabling and Disabling a Bridge Port; 16.11 Changing State on a Bridge Port; 16.12 The Big Picture; 16.13 Forwarding Database; 16.14 Handling Ingress Traffic; 16.15 Transmitting on a Bridge Device; 16.16 Spanning Tree Protocol (STP); 16.17 netdevice Notification Chain; Chapter 17: Bridging: Miscellaneous Topics; 17.1 User-Space Configuration Tools; 17.2 Tuning via /proc Filesystem; 17.3 Tuning via /sys Filesystem; 17.4 Statistics; 17.5 Data Structures Featured in This Part of the Book; 17.6 Functions and Variables Featured in This Part of the Book; 17.7 Files and Directories Featured in This Part of the Book; Part V: Internet Protocol Version 4 (IPv4); Chapter 18: Internet Protocol Version 4 (IPv4): Concepts; 18.1 IP Protocol: The Big Picture; 18.2 IP Header; 18.3 IP Options; 18.4 Packet Fragmentation/Defragmentation; 18.5 Checksums; Chapter 19: Internet Protocol Version 4 (IPv4): Linux Foundations and Features; 19.1 Main IPv4 Data Structures; 19.2 General Packet Handling; 19.3 IP Options; Chapter 20: Internet Protocol Version 4 (IPv4): Forwarding and Local Delivery; 20.1 Forwarding; 20.2 Local Delivery; Chapter 21: Internet Protocol Version 4 (IPv4): Transmission; 21.1 Key Functions That Perform Transmission; 21.2 Interface to the Neighboring Subsystem; Chapter 22: Internet Protocol Version 4 (IPv4): Handling Fragmentation; 22.1 IP Fragmentation; 22.2 IP Defragmentation; Chapter 23: Internet Protocol Version 4 (IPv4): Miscellaneous Topics; 23.1 Long-Living IP Peer Information; 23.2 Selecting the IP Header's ID Field; 23.3 IP Statistics; 23.4 IP Configuration; 23.5 IP-over-IP; 23.6 IPv4: What's Wrong with It?; 23.7 Tuning via /proc Filesystem; 23.8 Data Structures Featured in This Part of the Book; 23.9 Functions and Variables Featured in This Part of the Book; 23.10 Files and Directories Featured in This Part of the Book; Chapter 24: Layer Four Protocol and Raw IP Handling; 24.1 Available L4 Protocols; 24.2 L4 Protocol Registration; 24.3 L3 to L4 Delivery: ip_local_deliver_finish; 24.4 IPv4 Versus IPv6; 24.5 Tuning via /proc Filesystem; 24.6 Functions and Variables Featured in This Chapter; 24.7 Files and Directories Featured in This Chapter; Chapter 25: Internet Control Message Protocol (ICMPv4); 25.1 ICMP Header; 25.2 ICMP Payload; 25.3 ICMP Types; 25.4 Applications of the ICMP Protocol; 25.5 The Big Picture; 25.6 Protocol Initialization; 25.7 Data Structures Featured in This Chapter; 25.8 Transmitting ICMP Messages; 25.9 ICMP Statistics; 25.10 Passing Error Notifications to the Transport Layer; 25.11 Tuning via /proc Filesystem; 25.12 Functions and Variables Featured in This Chapter; 25.13 Files and Directories Featured in This Chapter; Part VI: Neighboring Subsystem; Chapter 26: Neighboring Subsystem: Concepts; 26.1 What Is a Neighbor?; 26.2 Reasons That Neighboring Protocols Are Needed; 26.3 Linux Implementation; 26.4 Proxying the Neighboring Protocol; 26.5 When Solicitation Requests Are Transmitted and Processed; 26.6 Neighbor States and Network Unreachability Detection (NUD); Chapter 27: Neighboring Subsystem: Infrastructure; 27.1 Main Data Structures; 27.2 Common Interface Between L3 Protocols and Neighboring Protocols; 27.3 General Tasks of the Neighboring Infrastructure; 27.4 Reference Counts on neighbour Structures; 27.5 Creating a neighbour Entry; 27.6 Neighbor Deletion; 27.7 Acting As a Proxy; 27.8 L2 Header Caching; 27.9 Protocol Initialization and Cleanup; 27.10 Interaction with Other Subsystems; 27.11 Interaction Between Neighboring Protocols and L3 Transmission Functions; 27.12 Queuing; Chapter 28: Neighboring Subsystem: Address Resolution Protocol (ARP); 28.1 ARP Packet Format; 28.2 Example of an ARP Transaction; 28.3 Gratuitous ARP; 28.4 Responding from Multiple Interfaces; 28.5 Tunable ARP Options; 28.6 ARP Protocol Initialization; 28.7 Initialization of a neighbour Structure; 28.8 Transmitting and Receiving ARP Packets; 28.9 Processing Ingress ARP Packets; 28.10 Proxy ARP; 28.11 Examples; 28.12 External Events; 28.13 ARPD; 28.14 Reverse Address Resolution Protocol (RARP); 28.15 Improvements in ND (IPv6) over ARP (IPv4); Chapter 29: Neighboring Subsystem: Miscellaneous Topics; 29.1 System Administration of Neighbors; 29.2 Tuning via /proc Filesystem; 29.3 Data Structures Featured in This Part of the Book; 29.4 Files and Directories Featured in This Part of the Book; Part VII: Routing; Chapter 30: Routing: Concepts; 30.1 Routers, Routes, and Routing Tables; 30.2 Essential Elements of Routing; 30.3 Routing Table; 30.4 Lookups; 30.5 Packet Reception Versus Packet Transmission; Chapter 31: Routing: Advanced; 31.1 Concepts Behind Policy Routing; 31.2 Concepts Behind Multipath Routing; 31.3 Interactions with Other Kernel Subsystems; 31.4 Routing Protocol Daemons; 31.5 Verbose Monitoring; 31.6 ICMP_REDIRECT Messages; 31.7 Reverse Path Filtering; Chapter 32: Routing: Li nux Implementation; 32.1 Kernel Options; 32.2 Main Data Structures; 32.3 Route and Address Scopes; 32.4 Primary and Secondary IP Addresses; 32.5 Generic Helper Routines and Macros; 32.6 Global Locks; 32.7 Routing Subsystem Initialization; 32.8 External Events; 32.9 Interactions with Other Subsystems; Chapter 33: Routing: The Routing Cache; 33.1 Routing Cache Initialization; 33.2 Hash Table Organization; 33.3 Major Cache Operations; 33.4 Multipath Caching; 33.5 Interface Between the DST and Calling Protocols; 33.6 Flushing the Routing Cache; 33.7 Garbage Collection; 33.8 Egress ICMP REDIRECT Rate Limiting; Chapter 34: Routing: Routing Tables; 34.1 Organization of Routing Hash Tables; 34.2 Routing Table Initialization; 34.3 Adding and Removing Routes; 34.4 Policy Routing and Its Effects on Routing Table Definitions; Chapter 35: Routing: Lookups; 35.1 High-Level View of Lookup Functions; 35.2 Helper Routines; 35.3 The Table Lookup: fn_hash_lookup; 35.4 fib_lookup Function; 35.5 Setting Functions for Reception and Transmission; 35.6 General Structure of the Input and Output Routing Routines; 35.7 Input Routing; 35.8 Output Routing; 35.9 Effects of Multipath on Next Hop Selection; 35.10 Policy Routing; 35.11 Source Routing; 35.12 Policy Routing and Routing Table Based Classifier; Chapter 36: Routing: Miscellaneous Topics; 36.1 User-Space Configuration Tools; 36.2 Statistics; 36.3 Tuning via /proc Filesystem; 36.4 Enabling and Disabling Forwarding; 36.5 Data Structures Featured in This Part of the Book; 36.6 Functions and Variables Featured in This Part of the Book; 36.7 Files and Directories Featured in This Part of the Book; Colophon;