NETISR(9)
πΈ NETISR(9) πΈ
okay bestie, gather round, because we're about to talk about netisr β the kernel network dispatch service, from the Kernel Developer's Manual. yes it's a (9) page, yes it's kernel-land, yes it's iconic. sit down, hydrate, let's go π
β¨ NAME β¨
netisr β Kernel network dispatch service π«Ά
π SYNOPSIS π
#include <net/netisr.h>
void
netisr_register(const struct netisr_handler *nhp);
void
netisr_unregister(const struct netisr_handler *nhp);
int
netisr_dispatch(u_int proto, struct mbuf *m);
int
netisr_dispatch_src(u_int proto, uintptr_t source, struct mbuf *m);
int
netisr_queue(u_int proto, struct mbuf *m);
int
netisr_queue_src(u_int proto, uintptr_t source, struct mbuf *m);
void
netisr_clearqdrops(const struct netisr_handler *nhp);
void
netisr_getqdrops(const struct netisr_handler *nhp, uint64_t *qdropsp);
void
netisr_getqlimit(const struct netisr_handler *nhp, u_int *qlimitp);
int
netisr_setqlimit(const struct netisr_handler *nhp, u_int qlimit);
u_int
netisr_default_flow2cpu(u_int flowid);
u_int
netisr_get_cpucount(void);
u_int
netisr_get_cpuid(u_int cpunumber);
and if you've got the optional virtual network stack support turned on via this kernel compile option:
options VIMAGE
then you ALSO get these two:
void
netisr_register_vnet(const struct netisr_handler *nhp);
void
netisr_unregister_vnet(const struct netisr_handler *nhp);
π DESCRIPTION π
so the netisr kernel interface suite is literally the whole group chat between device drivers (and other packet sources) and protocols β it lets them hand packets off for either directly dispatched or deferred processing. and the way that you can keep an eye on protocol registration and work stream statistics? that's netstat(1). no cap π₯
π Protocol registration
protocols register and unregister their handlers with netisr_register() and netisr_unregister(), and they can also manage queue limits and stats using netisr_clearqdrops(), netisr_getqdrops(), netisr_getqlimit(), and netisr_setqlimit().
in case of VIMAGE kernels, every virtual network stack (vnet) that is not the default base system network stack calls netisr_register_vnet() and netisr_unregister_vnet() to enable or disable packet processing by the netisr for each protocol. and heads up β disabling will also purge any outstanding packet from the protocol queue. bye bye packet π
netisr supports multi-processor execution of handlers, and it relies on a combination of source ordering and protocol-specific ordering and work-placement policies to decide how to distribute work across one or more worker threads. registering protocols will declare one of three policies:
NETISR_POLICY_SOURCEβnetisrshould maintain source ordering without advice from the protocol.netisrwill ignore any flow IDs present on mbuf headers for the purposes of work placement.NETISR_POLICY_FLOWβnetisrshould maintain flow ordering as defined by the mbuf header flow ID field. if the protocol implementsnh_m2flow, thennetisrwill query the protocol in the event that the mbuf doesn't have a flow ID, falling back on source ordering.NETISR_POLICY_CPUβnetisrwill entirely delegate all work placement decisions to the protocol, queryingnh_m2cpuidfor each packet.
registration is declared using struct netisr_handler, whose fields are defined as follows:
const char * nh_nameβ unique character string name of the protocol, which may be included insysctl(3)MIB names, so it should not contain whitespace.netisr_handler_t nh_handlerβ protocol handler function that will be invoked on each packet received for the protocol.netisr_m2flow_t nh_m2flowβ optional protocol function to generate a flow ID and set a valid hashtype for packets that enter thenetisrwithM_HASHTYPE_GET(m)equal toM_HASHTYPE_NONE. will be used only withNETISR_POLICY_FLOW.netisr_m2cpuid_t nh_m2cpuidβ protocol function to determine what CPU a packet should be processed on. will be used only withNETISR_POLICY_CPU.netisr_drainedcpu_t nh_drainedcpuβ optional callback function that will be invoked when a per-CPU queue was drained. it will never fire for directly dispatched packets. unless fully understood, this special-purpose function should not be used. π«£u_int nh_protoβ protocol number used by both protocols to identify themselves tonetisr, and by packet sources to select what handler will be used to process packets. a table of supported protocol numbers appears below. for implementation reasons, protocol numbers great than 15 are currently unsupported.u_int nh_qlimitβ the maximum per-CPU queue depth for the protocol; due to internal implementation details, the effective queue depth may be as much as twice this number.u_int nh_policyβ the ordering and work placement policy for the protocol, as described earlier.
π¦ Packet source interface
packet sources, such as network interfaces, may request protocol processing using the netisr_dispatch() and netisr_queue() interfaces. both accept a protocol number and mbuf argument, but here's the tea β β while netisr_queue() will always execute the protocol handler asynchronously in a deferred context, netisr_dispatch() will optionally direct dispatch if permitted by global and per-protocol policy.
in order to provide additional load balancing and flow information, packet sources may also specify an opaque source identifier β which in practice might be a network interface number or socket pointer β using the netisr_dispatch_src() and netisr_queue_src() variants. slay β¨
β Protocol number constants
the follow protocol numbers are currently defined:
NETISR_IPβ IPv4NETISR_IGMPβ IGMPv3 loopbackNETISR_ROUTEβ Routing socket loopbackNETISR_ARPβ ARPNETISR_IPV6β IPv6NETISR_EPAIRβnetstat(1),epair(4)
π AUTHORS π
this manual page and the netisr implementation were written by Robert N. M. Watson. legend behaviour, honestly π
and that's the whole page, bestie!! this one came from the Debian crew and it's dated April 25, 2017, living in section NETISR(9) of the Kernel Developer's Manual. go forth and dispatch responsibly π§π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2009 Robert N. M. Watson
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms