Switchdev is an in-kernel Linux driver model that offloads the data-plane forwarding of Ethernet switch ASICs (and similar devices) from the kernel to hardware. Each physical front-panel port is represented by a port netdev registered with register_netdev(), which serves as the control conduit, exposes PHY/link stats and supports higher-level constructs (bridges, bonds, VLANs, tunnels, L3 routing). There is no separate kernel switch object; drivers must implement ndo_get_port_parent_id to provide a unique switch ID per box, and udev-based naming (e.g., phys_port_name) is recommended rather than hard-coded kernel names. Management ports are handled outside switchdev. Drivers can set netns_immutable if the device cannot be partitioned across network namespaces, and they must monitor NETDEV_CHANGEUPPER events to track port topology (bond/bridge membership).
L2 forwarding is offloaded by mirroring bridge FDB entries to hardware and by receiving device-learned/forgotten MAC/VLAN notifications via SWITCHDEV_FDB_ADD/DEL. Drivers that implement ndo_fdb_add/ndo_fdb_del/ndo_fdb_dump support static FDB programming, but static entries should be added via the bridge “master” path to keep software and hardware consistent (avoid bypassing the bridge). The bridge marks offloaded entries NTF_EXT_LEARNED and skips ageing; hardware/drivers are responsible for ageing and must notify the bridge on expiry. Learning should be disabled on the bridge and enabled on the device with learning_sync to synchronize learned entries. Drivers implement switchdev_port_attr_set for pre-bridge flags and may implement ndo_fdb_dump only to visualize hardware tables when device notifications are absent.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.