NETISR(9)
π
NETISR(9) β netisr, the Kernel network dispatch service π
okay bestie, gather round, because this is the manual page for netisr, aka the Kernel network dispatch service. It's giving kernel plumbing but make it iconic. β¨
β¨ NAME β¨
netisr β Kernel network dispatch service. No cap, that's the whole vibe: it's the kernel's little dispatch service for network packets. π
π¦ SYNOPSIS π¦
Here's the include and the function squad, exactly as they show up:
#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);
With optional virtual network stack support enabled via the following kernel compile option:
options VIMAGE
void
netisr_register_vnet(const struct netisr_handler *nhp);
void
netisr_unregister_vnet(const struct netisr_handler *nhp);
πΈ DESCRIPTION πΈ
The netisr kernel interface suite allows device drivers (and other packet sources) to direct packets to protocols for directly dispatched or deferred processing. Protocol registration and work stream statistics may be monitored using netstat(1). slay.
π Protocol registration π
Protocols register and unregister handlers using netisr_register() and netisr_unregister(), and may also manage queue limits and statistics using netisr_clearqdrops(), netisr_getqdrops(), netisr_getqlimit(), and netisr_setqlimit(). Cute little lifecycle, fr fr.
In case of VIMAGE kernels each 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. Disabling will also purge any outstanding packet from the protocol queue. purge? yes bestie, it means what it means.
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 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 onmbufheaders for the purposes of work placement.NETISR_POLICY_FLOWβnetisrshould maintain flow ordering as defined by thembufheader flow ID field. If the protocol implementsnh_m2flow, thennetisrwill query the protocol in the event that thembufdoesn'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 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 greater 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. twice, bestie!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 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.
π’ Protocol number constants π’
The following protocol numbers are currently defined:
NETISR_IPβ IPv4NETISR_IGMPβ IGMPv3 loopbackNETISR_ROUTEβ Routing socket loopbackNETISR_ARPβ ARPNETISR_IPV6β IPv6
π AUTHORS π
This manual page and the netisr implementation were written by Robert N. M. Watson. iconic behavior, honestly.
okay bestie, that's the whole page β it's from Debian, dated April 12, 2023, and it's the NETISR(9) manual. mwah π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2009 Robert N. M. Watson
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms