411 REFERENCE · Wikibooks
The Linux Kernel/Networking
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
networkingsockets accessaddress families: inet, unix, ...network storageprotocolsnetwork interfacesnetwork drivers
Linux kernel network functionality spans from sockets interface through protocols to network cards.
⚲ Shell interfaces:
8 netstat prints network connections, routing tables, interface statistics and other details
8 ip shows and configures routing, network devices, interfaces and tunnels
8 ss - socket statistics utility
Sockets
⚲ API:
sys/socket.h – main user mode sockets header
Basic common and client side interface:
2 socket ↪ __sys_socket creates an endpoint for communication
struct sockaddr - abstract socket address
2 connect ↪ __sys_connect;
2 shutdown shuts down part of a full-duplex connection
2 send ↪ __sys_sendto sends a message on a socket
2 recv ↪ __sys_recvfrom, __sys_recvmsg receives a message from a socket
2 setsockopt, 2 getsockopt ↪ __sys_setsockopt – set/get socket options
2 socketpair ↪ __sys_socketpair – create a pair of connected sockets
Additional server side interface:
2 bind ↪ __sys_bind - binds a sockaddr to a socket
2 listen ↪ __sys_listen - listens for connections on a socket
2 accept ↪ __sys_accept4 - accepts a connection on a socket
⚙️ Internals
struct socket @ linux/net.h contains
struct proto_ops - abstract protocols interface
struct sock - network layer representation of sockets net/sock.h
__sys_socket ↯ call hierarchy:
sock_create
__sock_create
security_socket_create
sock_alloc
net_proto_family->create.
for example inet_create. See Address families for other options.
__sys_connect ↯ call hierarchy:
move_addr_to_kernel
audit_sockaddr
__sys_connect_file
sock_from_file
security_socket_connect
proto_ops->connect.
for example inet_stream_connect. See Protocols for other options.
net/socket.c – socket system calls implementation
net/core/sock.c – sock core: allocation, options, buffer management
📚 References
7 socket
linux/socket.h
Berkeley sockets
🔨 stress-ng --sock,
--sockpair
Network storage
🚀 advanced topic
🔧 TODO
⚲ API:
2 sendfile ↪ do_sendfile.
See also Zero-copy between file descriptors
Application layer Application layer: Network File System
NFS filesystems/nfs, linux/nfs_fs.h, fs/nfs
init_nfs_fs, nfs4_fs_type, nfs_fs_type,
init_nfsd, nfsd_fs_type
CIFS admin-guide/cifs
init_cifs
cifs_fs_type, smb3_fs_type cifs_smb3_do_mount
target and iSCSI Interfaces Guide driver-api/target.html
📚 Further reading
https://deepwiki.com/torvalds/linux/4.3-network-filesystems-(cifssmb)
Transport and Network
Names
⚲ API: 2 uname, 2 sethostname, 2 gethostname, 2 setdomainname 2 getdomainname
↪ utsname
⚙️ Details
utsname returns writable pointer to new_utsname from uts_namespace from nsproxy from current task_struct.
CLONE_NEWUTS, setns
kernel/utsname.c – UTS namespace management
📚 References:
7 namespaces
7 network_namespaces
7 uts_namespaces
Address families
⚲ API
2 getsockname
2 getpeername
Address Family (AF) domain defines address format and address length socklen_t.
3 inet_ntop, 3 inet_pton (derive socklen_t from AF)
Common AF: AF_UNIX, AF_INET, AF_NETLINK.
PF - Protocol Family index (PF_MAX) actually is the same as Address Family index (AF).
⚙️ Internals of some AF
7 unix ↪ unix_family_ops - sockets for local IPC, net/unix
unix_create
7 ip ↪ inet_family_ops - IPv4
inet_create
7 netlink ↪ netlink_family_ops - communication between kernel and user space, net/netlink
linux/netlink.h, linux/rtnetlink.h – netlink and routing netlink messages
netlink_create
🔨 stress-ng --netlink-proc
7 vsock ↪ vsock_family_ops - communication between VM and hypervisor
vsock_create
7 packet ↪ packet_family_ops - device level interface
packet_create
bt_sock_family_ops - Bluetooth
bt_sock_create
There are more than 40 AFs in total (see AF_MAX)
⚙️ Internals
sock_register - registers net_proto_family. See references to this identifiers to find more than 30 protocol families.
__sock_create
📚 Further reading
8 ip-address – protocol address management
Internet layer
7 address_families
Protocols
Each Protocol Family (PF, same index as Address Family AF) consists of several protocol implementations.
Directory /proc/net contains various files and subdirectories containing information about the networking layer.
File /proc/net/protocols lists available and used protocols.
In each PF protocols are classified to different types sock_type, for example stream, datagram and raw socket.
TCP is type of stream, UDP is type of datagram, raw and ping are type of raw.
proto_register - registers struct proto - protocol implementations:
In inet_init initcall, inetsw_array, proto_ops and proto :
inet_stream_ops & tcp_prot tcp_sendmsg ...
inet_dgram_ops & udp_prot udp_sendmsg ...
inet_sockraw_ops
raw_prot raw_sendmsg ...
ping_prot ping_v4_sendmsg ...
In af_unix_init initcall:
unix_family_ops
unix_create
unix_stream_ops unix_stream_sendmsg ...
unix_dgram_ops unix_dgram_sendmsg ...
unix_seqpacket_ops unix_seqpacket_sendmsg ...
⚙️ Internals:
linux/in.h, linux/ip.h – IPv4 address, protocol and header definitions
net/ipv4 – IPv4 protocol stack
net/ipv4/af_inet.c – PF_INET socket family (inet_family_ops, inet_init)
net/ipv4/protocol.c – IPv4 protocol handler registration (inet_add_protocol)
net/ipv4/ip_input.c – IPv4 receive path (ip_rcv, ip_local_deliver)
net/ipv4/ip_output.c – IPv4 transmit path (ip_output, ip_queue_xmit)
net/ipv4/ip_forward.c – IPv4 packet forwarding (ip_forward)
net/ipv4/ip_fragment.c – fragmentation and reassembly (ip_do_fragment)
net/ipv4/ip_options.c – IP options parsing and building
net/ipv4/ip_sockglue.c – IP socket options (ip_setsockopt)
Addressing:
net/ipv4/devinet.c – per-device IPv4 address management (inetdev_init)
net/ipv4/arp.c – Address Resolution Protocol (arp_rcv, arp_send)
Routing:
net/ipv4/route.c – IPv4 route lookup and cache (ip_route_output_key, rtable)
net/ipv4/fib_frontend.c – FIB user interface: netlink and ioctl (fib_table_lookup)
net/ipv4/fib_trie.c – LC-trie FIB implementation (fib_trie_table)
net/ipv4/fib_semantics.c – FIB entry semantics: nexthop, scope, metrics
net/ipv4/fib_rules.c – IPv4 routing policy rules (ip rule)
net/ipv4/nexthop.c – generic nexthop objects (since 5.3, nexthop_find_by_id)
net/ipv4/inetpeer.c – peer storage for per-destination state (inet_getpeer)
ICMP / IGMP:
net/ipv4/icmp.c – ICMPv4 (icmp_rcv, icmp_send)
net/ipv4/igmp.c – Internet Group Management Protocol, MLDv1 (ip_mc_join_group)
net/ipv4/ipmr.c – IPv4 multicast routing (ipmr_mfc_add)
Transport protocols:
net/tcp.h, net/ipv4/tcp.c – TCP core (connect, send, recv, close)
tcp_sock – per-connection TCP state, tcp_sk – cast from sock
tcphdr – TCP header struct
tcp_congestion_ops – pluggable congestion control (TCP congestion control cubic, bbr, reno)
net/ipv4/tcp_ipv4.c – TCP over IPv4 (tcp_v4_rcv, tcp_prot)
net/ipv4/tcp_input.c – TCP receive processing (tcp_rcv_established, ACK, SACK)
net/ipv4/tcp_output.c – TCP transmit: segment building, retransmit (tcp_write_xmit)
net/ipv4/tcp_timer.c – TCP timers: retransmit, keepalive, TIME_WAIT (tcp_retransmit_timer)
net/ipv4/tcp_minisocks.c – TIME_WAIT and SYN_RECV mini sockets (tcp_time_wait)
net/ipv4/tcp_fastopen.c – TCP Fast Open (tcp_fastopen_cookie, since 3.6)
net/ipv4/tcp_ao.c – TCP Authentication Option (RFC 5925, since 6.7)
net/ipv4/tcp_metrics.c – per-destination TCP metrics cache
net/ipv4/tcp_cong.c – congestion control framework (tcp_register_congestion_control)
net/ipv4/tcp_cubic.c – CUBIC congestion control (default)
net/ipv4/tcp_bbr.c – BBR congestion control (since 4.9)
net/ipv4/syncookies.c – TCP SYN cookies (cookie_v4_check)
net/ipv4/udp.c – UDP (udp_rcv, udp_prot)
net/ipv4/raw.c – raw IP sockets (raw_prot)
net/ipv4/ping.c – ping socket / ICMP echo (ping_prot)
net/ipv4/datagram.c – common UDP/RAW datagram helpers (ip4_datagram_connect)
Socket infrastructure:
net/ipv4/inet_connection_sock.c – connection-oriented socket base (inet_csk_accept)
net/ipv4/inet_hashtables.c – TCP/UDP socket hash table lookup (inet_lookup_established)
net/ipv4/inet_timewait_sock.c – TIME_WAIT socket recycling
net/ipv4/inet_fragment.c – generic IP fragment queue management
net/ipv4/inet_diag.c – socket diagnostics via netlink (ss, inet_diag_handler)
Tunnels:
net/ipv4/ip_tunnel.c – generic IP tunnel framework (ip_tunnel_xmit)
net/ipv4/ip_gre.c – GRE over IPv4 (gre, gretap)
net/ipv4/ipip.c – IP-in-IP tunnel (ipip)
net/ipv4/ip_vti.c – virtual tunnel interface (vti, IPsec-aware)
net/ipv4/fou_core.c – Foo-over-UDP encapsulation (since 3.18)
net/ipv4/gre_demux.c – GRE protocol demultiplexer
net/ipv4/tunnel4.c – IPv4 tunnel protocol registration
IPsec / XFRM:
net/ipv4/xfrm4_policy.c – IPv4 IPsec policy (xfrm4_dst_ops)
net/ipv4/xfrm4_state.c – IPv4 IPsec state management
net/ipv4/xfrm4_input.c – IPv4 IPsec inbound processing
net/ipv4/xfrm4_output.c – IPv4 IPsec outbound processing
net/ipv4/ah4.c – Authentication Header (AH) for IPv4
net/ipv4/esp4.c – Encapsulating Security Payload (ESP) for IPv4
net/ipv4/ipcomp.c – IP Payload Compression (IPComp, RFC 3173)
Security:
net/ipv4/cipso_ipv4.c – CIPSO Commercial IP Security Option (cipso_v4_validate)
sysctl / proc:
net/ipv4/sysctl_net_ipv4.c – /proc/sys/net/ipv4/ tunables
net/ipv4/proc.c – /proc/net/snmp and /proc/net/netstat statistics
net/ipv4/netfilter – IPv4 netfilter hooks (see Netfilter)
linux/ipv6.h – IPv6 definitions
net/ipv6 – IPv6 protocol stack
net/ipv6/af_inet6.c – PF_INET6 socket family (inet6_family_ops, inet6_init)
net/ipv6/protocol.c – IPv6 protocol handler registration (inet6_add_protocol)
net/ipv6/ip6_input.c – IPv6 receive path (ipv6_rcv, ip6_forward)
net/ipv6/ip6_output.c – IPv6 transmit path (ip6_output, ip6_xmit)
net/ipv6/ip6_checksum.c – UDP/TCP checksum over IPv6
net/ipv6/ila – IPv6 address Identifier Locator Addressing (ILA): address translation for scalable IPv6 overlays
net/ipv6/netfilter – IPv6 netfilter hooks (see Netfilter)
Addressing:
net/ipv6/addrconf.c – address autoconfiguration: SLAAC, DAD, RA handling (addrconf_notify)
net/ipv6/addrconf_core.c – address scope helpers for static builds (no full IPv6 module)
net/ipv6/ndisc.c – Neighbor Discovery Protocol (Neighbor Discovery Protocol NDP, RFC 4861)
net/ipv6/anycast.c – anycast address support
net/ipv6/addrlabel.c – address label subsystem for source address selection (RFC 6724)
Routing:
net/ipv6/route.c – IPv6 routing table lookup and route management (ip6_route_output, rt6_info)
net/ipv6/ip6_fib.c – IPv6 FIB trie (fib6_table, fib6_info)
net/ipv6/fib6_rules.c – IPv6 routing policy rules (ip rule)
net/ipv6/ip6_flowlabel.c – flow label manager (ip6_flowlabel)
Extension headers:
net/ipv6/exthdrs.c – extension header processing (hop-by-hop, routing, destination)
Transport protocols:
net/ipv6/tcp_ipv6.c – TCP over IPv6 (tcp_v6_rcv, tcpv6_prot, tcp_v6_syn_recv_sock)
net/ipv6/udp.c – UDP over IPv6 (udpv6_prot, udpv6_rcv)
net/ipv6/raw.c – raw sockets over IPv6
net/ipv6/ping.c – ping socket (ICMPv6 echo) over IPv6
net/ipv6/datagram.c – common UDP/RAW datagram helpers (ip6_datagram_connect)
net/ipv6/syncookies.c – TCP SYN cookie support for IPv6
net/ipv6/reassembly.c – fragment reassembly (ipv6_frag_rcv)
ICMPv6:
net/ipv6/icmp.c – ICMPv6 (RFC 4443): error messages, echo, icmpv6_send
Multicast:
net/ipv6/mcast.c – multicast group management, MLDv1/v2 (ipv6_dev_mc_inc)
net/ipv6/ip6mr.c – IPv6 multicast routing (ip6mr_table)
net/ipv6/mcast_snoop.c – MLD snooping for bridge integration
Tunnels:
net/ipv6/ip6_tunnel.c – IPv6-in-IPv6 tunnel (ip6tnl)
net/ipv6/ip6_gre.c – GRE over IPv6 (ip6gre, ip6gretap)
net/ipv6/sit.c – IPv4-in-IPv6 Simple Internet Transition tunnel (sit)
net/ipv6/ip6_vti.c – virtual tunnel interface over IPv6 (vti6, IPsec-aware)
net/ipv6/ip6_udp_tunnel.c – UDP encapsulation helpers for IPv6 tunnels
net/ipv6/fou6.c – Foo-over-UDP encapsulation for IPv6
IPsec / XFRM:
net/ipv6/xfrm6_policy.c – IPv6 IPsec policy lookup (xfrm6_dst_ops)
net/ipv6/xfrm6_state.c – IPv6 IPsec state management
net/ipv6/xfrm6_input.c – IPv6 IPsec inbound processing
net/ipv6/xfrm6_output.c – IPv6 IPsec outbound processing
net/ipv6/ah6.c – Authentication Header (AH) transform for IPv6
net/ipv6/esp6.c – Encapsulating Security Payload (ESP) transform for IPv6
net/ipv6/ipcomp6.c – IP Payload Compression (IPComp) for IPv6 (RFC 3173)
net/ipv6/mip6.c – Mobile IPv6 extension header handling
Segment Routing:
net/ipv6/seg6.c – Segment Routing IPv6 (SRv6) core: genl API, encap helpers
net/ipv6/seg6_local.c – SRv6 local endpoint behaviors (End, End.DX4, End.DT6, …)
net/ipv6/seg6_iptunnel.c – SRv6 tunnel encapsulation via lwtunnel
net/ipv6/seg6_hmac.c – SRv6 HMAC integrity verification (RFC 8754)
net/ipv6/rpl.c – RPL source routing header
IOAM:
net/ipv6/ioam6.c – In-situ OAM for IPv6 (RFC 9197): namespace and schema management
net/ipv6/ioam6_iptunnel.c – IOAM insertion via lwtunnel encapsulation
Security:
net/ipv6/calipso.c – CALIPSO Mandatory Access Control option (RFC 5570)
sysctl / proc:
net/ipv6/sysctl_net_ipv6.c – /proc/sys/net/ipv6/ tunables
net/ipv6/proc.c – /proc/net/snmp6 and /proc/net/dev_snmp6 statistics
net/tls – kernel TLS (since 4.13)
net/xdp – Express Data Path fast packet processing (since 4.8)
net/sched – traffic control and QoS
A Qdisc (queuing discipline) sits on each netdev_queue and controls packet scheduling on the TX path.
struct Qdisc_ops – enqueue / dequeue / peek callbacks, registered via register_qdisc
net/sched/sch_generic.c – default pfifo_fast qdisc, qdisc_run, dev_watchdog
net/sched/sch_api.c – tc netlink API: qdisc/class/filter CRUD
Common qdiscs:
net/sched/sch_fifo.c – pfifo / bfifo - simple FIFO, default fallback
net/sched/sch_fq.c – FQ - per-flow fair queue with pacing (fq_sched_data)
net/sched/sch_fq_codel.c – FQ-CoDel - fair queue + CoDel AQM (default on many distros)
net/sched/sch_htb.c – HTB - Hierarchical Token Bucket, bandwidth allocation
net/sched/sch_cake.c – CAKE - combined AQM + shaper + flow isolation (since 4.19)
net/sched/sch_codel.c – CoDel - Controlled Delay AQM
net/sched/sch_tbf.c – TBF - Token Bucket Filter, rate limiter
net/sch_generic.h – Qdisc, Qdisc_ops, tcf_proto definitions
Socket performance options:
TCP_NODELAY – disable Nagle's algorithm for low-latency sends
TCP_CORK – accumulate small writes into full-size segments
Network determinism tips, RHEL RT
Reducing TCP performance spikes – TCP timestamp tuning
📚 References:
7 tcp
7 udp
7 raw
8 tc – traffic control
Transport layer and Transmission_Control_Protocol TCP
🔨 stress-ng --udp,
--udp-flood,
--sctp
RDMA
🚀 advanced topic
🗝️ Acronyms:
IB — InfiniBand, an interconnect standard, competes with Ethernet, Fibre Channel
IPoIB — IP network emulation layer over InfiniBand networks
SRP — SCSI RDMA Protocol
ULP — Upper-layer protocols
iSER — iSCSI Extensions for RDMA
⚲ Interfaces:
https://github.com/linux-rdma/rdma-core
8 rdma
7 rdma_cm — RDMA communication manager
include/uapi/rdma – user-space RDMA API definitions
include/rdma – kernel RDMA API definitions
⚙️ Internals:
drivers/infiniband – InfiniBand core and drivers
drivers/infiniband/ulp — Upper-layer protocols
drivers/infiniband/sw — software drivers
drivers/infiniband/hw — hardware device drivers
📚 References:
InfiniBand infiniband
InfiniBand and RDMA Interfaces driver-api/infiniband.html
Netfilter
Netfilter is the kernel’s packet filtering and manipulation framework.
It provides hook points in the network stack where modules can inspect, modify, drop, or redirect packets.
nftables is the current user-facing interface, replacing the legacy iptables/ip6tables/ebtables/arptables tools.
Netfilter#Connection_tracking connection tracking (conntrack) tracks network connections for stateful filtering and NAT.
⚲ API
8 nft – nftables rule management
8 iptables, 8 ip6tables – legacy packet filter
8 ebtables, 8 arptables – bridge and ARP filtering
8 ebtables-nft, 8 arptables-nft, 8 xtables-nft – nftables-backed compatibility
ipset – IP set management
8 conntrack – conntrack table management
/proc/net/nf_conntrack – active connections
/proc/sys/net/netfilter/ – conntrack tunables
linux/netfilter.h – hook API
nf_hook_state, nf_register_net_hook
uapi/linux/netfilter, linux/netfilter
net/netfilter, net/netns/netfilter.h
linux/netfilter/x_tables.h – xtables match/target registration
⚙️ Internals
net/netfilter – packet filtering framework
net/netfilter/core.c – hook registration and dispatch
net/netfilter/nf_tables_api.c – nftables kernel API
net/netfilter/nf_tables_core.c – nftables rule evaluation
net/netfilter/nf_conntrack_core.c – connection tracking core
net/netfilter/nf_nat_core.c – Network address translation NAT core
net/netfilter/nf_flow_table_core.c – hardware offload flowtable
📖 References
Netfilter Sysfs variables networking/netfilter-sysctl.html
Netfilter Conntrack Sysfs variables networking/nf_conntrack-sysctl.html
Netfilter’s flowtable infrastructure networking/nf_flowtable.html
nftables, https://wiki.nftables.org/
https://lwn.net/Kernel/Index/#Networking-Packet_filtering
Network device Network interface interfaces
⚲ Interfaces
ip -brief link show
ls -l /sys/class/net
devm_register_netdev registers net_device, net_device_ops
dev_queue_xmit queues socket buffers into transmit queue
linux/netdevice.h
linux/skbuff.h
sk_buff socket buffer (skb)
/sys/class/net/*/statistics/ – per-interface packet and byte counters
8 devlink – manage switchdev, eswitch, shared buffers and firmware of network devices
8 bridge – show/manipulate bridge forwarding, MAC and VLAN tables
sos networking plugin – diagnostics collection for network subsystem
👁 Example: drivers/net/loopback.c - the most famous and simple interface lo
⚙️ Internals
net/core – core networking infrastructure
Device:
net/core/dev.c – network device operations core: xmit, receive, register/unregister (__dev_queue_xmit, netif_receive_skb)
⚙️ Internals:
softnet_data – per-CPU: poll_list, input_pkt_queue, completion queue
net_dev_init – registers NET_RX_SOFTIRQ / NET_TX_SOFTIRQ handlers
net_tx_action – TX softirq handler:
frees completed skbs from softnet_data→completion_queue
drains softnet_data→output_queue of pending qdiscs (qdisc_run → driver ndo_start_xmit)
net_rx_action – RX softirq handler; drains up to netdev_budget (300) packets
napi_poll → driver napi->poll()
netif_receive_skb → __netif_receive_skb_core → ip_rcv / ipv6_rcv …
Legacy (pre-NAPI): netif_rx → input_pkt_queue → backlog napi (same drain)
net/neighbour.h, net/core/neighbour.c – generic neighbour (ARP/NDP) cache (neigh_lookup, neighbour)
net/core/rtnetlink.c – rtnetlink: netlink interface for routing and device config (__rtnl_register_many)
net/core/net-sysfs.c – /sys/class/net/ device attributes
net/core/sysctl_net_core.c – /proc/sys/net/core/ tunables
Sockets:
net/sock.h, net/core/sock.c – sock core: allocation, options, buffer management
linux/skbuff.h, net/core/skbuff.c – sk_buff allocation, cloning, manipulation (alloc_skb, skb_clone)
net/core/datagram.c – generic datagram recv helpers (skb_recv_datagram)
net/core/stream.c – generic stream socket helpers (sk_stream_wait_connect)
net/core/scm.c – socket control message (ancillary data) handling
net/sock_reuseport.h, net/core/sock_reuseport.c – SO_REUSEPORT socket selection (reuseport_add_sock)
linux/filter.h, net/core/filter.c – socket filtering: BPF/cBPF/eBPF attach to sockets (sk_filter_trim_cap)
Routing / forwarding:
net/dst.h, net/core/dst.c – destination cache (dst_entry, dst_alloc)
net/flow_dissector.h, net/core/flow_dissector.c – packet field extraction for hashing and steering (skb_flow_dissector_init, skb_flow_get_ports)
net/lwtunnel.h, net/core/lwtunnel.c – lightweight tunnel infrastructure (lwtunnel_build_state)
net/net_namespace.h, net/core/net_namespace.c – network namespace lifecycle (copy_net_ns, net_ns_ops)
Offload:
net/core/gro.c – Generic Receive Offload (gro_receive_skb, dev_gro_receive)
net/core/gso.c – Generic Segmentation Offload (__skb_gso_segment, skb_mac_gso_segment)
net/xdp.h, net/core/xdp.c – XDP buffer and memory model (xdp_rxq_info, xdp_buff)
net/page_pool/types.h, net/core/page_pool.c – page pool allocator for zero-copy RX (page_pool_create)
Diagnostics / tools:
net/core/secure_seq.c – ISN and port randomization (secure_tcp_seq_and_ts_off, secure_ipv4_port_ephemeral)
net/core/netpoll.c – network console / crash dump transport (netpoll_send_skb)
net/core/drop_monitor.c – kfree_skb drop event monitor (send_dm_alert, net_dm_alert_summary_ops)
net/core/pktgen.c – in-kernel packet generator (8 pktgen)
net/core/timestamping.c – SO_TIMESTAMPING and PHY timestamping helpers
function loopback_xmit receives skb and passes it back with netif_rx
🔨 stress-ng --rawsock,
--icmp-flood
📚 Further reading
8 ip-link – network device configuration
8 ip-stats – manage and show interface statistics
7 netdevice – low-level access to Linux network devices
7 packet – packet interface on device level
Queueing in the Linux Network Stack
💾 Historical
LDP TLK Chapter 10 Networks
Network drivers
linux/if_ether.h – IEEE 802.3 Ethernet constants and header
linux/etherdevice.h
New_API NAPI
NAPI Driver design
⚲ API:
netif_napi_add – registers napi_struct, stores driver poll_fn as napi->poll
napi_schedule – raises NET_RX_SOFTIRQ from IRQ handler
netif_receive_skb – delivers skb to protocol handlers
napi_complete_done – signals poll() exhausted its quota
⚙️ Internals:
net_dev_init – registers softirq handlers, sets up per-CPU softnet_data
napi_poll – calls driver napi->poll(), enforces budget
👁 example
e1000_intr → __napi_schedule
e1000e_poll (napi->poll()) → napi_complete_done
ether_setup setups Ethernet network device
👁 An example of Ethernet driver: e1000_probe
⚙️ Internals:
drivers/net – network device drivers
drivers/net/wireless – wireless drivers
drivers/net/ethernet – Ethernet drivers
net/wireless – cfg80211, wireless configuration API and userspace interface via 8 iw
net/mac80211 – mac80211, software 802.11 MAC layer used by most WiFi drivers
net/bluetooth – Bluetooth protocol stack
net/bridge – Ethernet bridging networking/bridge.html
📚 References:
8 ethtool – query or control network driver and hardware settings
Data link layer: Ethernet
GRO - Generic Receive Offload
Segmentation Offloads networking/segmentation-offloads.html
https://wireless.wiki.kernel.org
📚 Further reading
LKMPG: Network Drivers
💾 Historical:
LDD2:Network Drivers
LDD3:Network Drivers
Kernel Analysis: Networking, 2003
network_overview
📖 Further reading about networking
Networking interfaces subsystem-apis.html#networking-interfaces
Networking networking
https://lwn.net/Kernel/Index/#Networking
https://lartc.org/ – Linux Advanced Routing & Traffic Control
8 ip – show / manipulate routing, network devices, interfaces and tunnels
8 tc – show / manipulate traffic control settings
bcc/ebpf networking tools
eBPF-based Networking, Security, and Observability
Retis – tracing packets in the Linux networking stack & friends