Network stack overview

Basic definitions

Common structures


Routing overview

Drivers & ifnet

Ingress caps

Egress caps



Netisr(9) is generic network dispatch service. It allows you to determine how exactly packets for given L3 protocol are processed in terms of flow grouping and queuing to different queues (to enable parallel processing on SMP). Since every network forwarding element should avoid reordering for the packets inside single flow (for example, TCP session) we need some way to determine which flow packets belongs to. Typically this is done using some kind of hashing function that uses L3+L4 headers to make u16 value which is the same for single unidirectional flow. Different protocols require different flow handling techniques, so, quoting manual:

     netisr supports multi-processor execution of handlers, and relies on a
     combination of source ordering and protocol-specific ordering and work-
     placement policies to decide how do distribute work across one or more
     worker threads.  Registering protocols will declare one of three poli‐

     NETISR_POLICY_SOURCE  netisr should maintain source ordering without
                           advice from the protocol.  netisr will ignore any
                           flow IDs present on mbuf headers for the purposes
                           of work placement.

     NETISR_POLICY_FLOW    netisr should maintain flow ordering as defined by
                           the mbuf header flow ID field.  If the protocol
                           implements nh_m2flow, then netisr will query the
                           protocol in the event that the mbuf doesn't have a
                           flow ID, falling back on source ordering.

     NETISR_POLICY_CPU     netisr will entirely delegate all work placement
                           decisions to the protocol, querying nh_m2cpuid for
                           each packet.

Netisr supports 2 (3) different dispatch models: "direct" (e.g.

Base netisr entry point lives in net/if_ethersubr.c:ether_demux() function. However, many places on stack need to perform packet recirculation (various tunneling, etc..) so they call netisr directly using netisr_dispatch(_ETHERTYPE_, ..) function.


Software interrupts, SWI_NET. Used by netisr(9) and pf(4).




Routing socket

Lookup trie


Address management

IPv4 address assignment

IPv6 address assignment

AlexanderChernikov/NetworkStack (last edited 2014-01-18 12:25:51 by AlexanderChernikov)