NETISR(9) | Kernel Developer's Manual | NETISR(9) |
netisr
— Kernel
network dispatch service
#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
netisr_register_vnet
(const
struct netisr_handler *nhp);
void
netisr_unregister_vnet
(const
struct netisr_handler *nhp);
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).
Protocols register and unregister handlers using
netisr_register
()
and
netisr_unregister
(),
and may also manage queue limits and statistics using the
netisr_clearqdrops
(),
netisr_getqdrops
(),
netisr_getqlimit
(),
and
netisr_setqlimit
().
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.
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
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
will entirely delegate all work placement
decisions to the protocol, querying nh_m2cpuid for
each packet.Registration is declared using struct netisr_handler, whose fields are defined as follows:
netisr
with
M_HASHTYPE_GET(m)
equal to
M_HASHTYPE_NONE
. Will be used only with
NETISR_POLICY_FLOW
.NETISR_POLICY_CPU
.netisr
, 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.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.
The follow protocol numbers are currently defined:
NETISR_IP
NETISR_IGMP
NETISR_ROUTE
NETISR_ARP
NETISR_IPV6
NETISR_EPAIR
This manual page and the netisr
implementation were written by Robert N. M.
Watson.
April 25, 2017 | Debian |