Understanding Linux Network Subsystem: Layers, Interrupt Handling, and Driver Initialization
This article explains the layered architecture of the Linux network stack, maps the TCP/IP model to Linux implementation, and details how hardware and soft interrupts, ksoftirqd threads, and NAPI cooperate with driver initialization to process packet reception and transmission.
Linux network subsystem is organized in layered architecture separating link, network and transport layers, providing protocol‑independent socket API and supporting multiple protocol families and devices.
The TCP/IP model maps to Linux implementation where the link layer is handled by NIC drivers, the network layer by the IP stack, and the transport layer by TCP/UDP.
Packet reception involves hardware (hard) interrupts that trigger the NIC driver, which quickly disables further NIC interrupts and raises a soft interrupt (NET_RX_SOFTIRQ). The soft interrupt is processed by the ksoftirqd kernel threads.
During kernel initialization softirq_init() registers soft‑irq handlers such as NET_RX_SOFTIRQ with open_softirq(NET_RX_SOFTIRQ, net_rx_action) . The net_rx_action function walks the per‑CPU softnet_data poll list and invokes NAPI poll functions.
Network drivers (e.g., e1000, igb) allocate TX/RX descriptor rings, register interrupt handlers via request_irq() (or MSI‑X), and set up NAPI with netif_napi_add() . The NAPI poll routine (e.g., igb_poll ) processes received descriptors, builds sk_buff structures, and hands them to the stack via netif_receive_skb() .
Sending follows the reverse path: the socket layer creates an sk_buff , the driver places it in the TX ring, DMA moves the packet to the NIC FIFO, and the NIC generates a completion interrupt.
Top Architect
Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.