DRBR(9)
π DRBR(9) β the network driver interface to buf_ring, bestie π
okay so this is a page from the Kernel Developer's Manual and it's literally about how network drivers talk to buf_ring. buckle up, it's giving β¨kernel internalsβ¨ but make it cute.
πΈ NAME πΈ
drbr, drbr_free, drbr_enqueue, drbr_dequeue, drbr_dequeue_cond, drbr_flush, drbr_empty, drbr_inuse β the network driver interface to buf_ring. that's the whole squad π«Ά
β¨ SYNOPSIS β¨
first you gotta bring the headers in, no cap:
#include <sys/param.h>
#include <net/if.h>
#include <net/if_var.h>
and here's every single function, exactly as it is, don't @ me:
void
drbr_free(struct buf_ring *br, struct malloc_type *type);
int
drbr_enqueue(struct ifnet *ifp, struct buf_ring *br, struct mbuf *m);
struct mbuf *
drbr_dequeue(struct ifnet *ifp, struct buf_ring *br);
struct mbuf *
drbr_dequeue_cond(struct ifnet *ifp, struct buf_ring *br,
int (*func) (struct mbuf *, void *), void *arg);
void
drbr_flush(struct ifnet *ifp, struct buf_ring *br);
int
drbr_empty(struct ifnet *ifp, struct buf_ring *br);
int
drbr_inuse(struct ifnet *ifp, struct buf_ring *br);
π DESCRIPTION π
so the drbr functions hand network drivers an API for using buf_ring(9) to enqueue and dequeue packets. it's meant as a replacement for the IFQ interface for packet queuing, which is a glow-up fr fr. the way it works: a packet can be enqueued with a single atomic</>, and packet dequeue gets done without any per-packet atomics</> because it's protected by the driver's tx queue lock. efficient queen behavior π
ngl, ifINVARIANTSis enabled,drbr_dequeue()will assert that the tx queue lock is held when it is called. so hold that lock, bestie. π
drbr_free()β frees all the enqueued mbufs, and then frees thebuf_ring. clean sweep, iconic. π§Ήdrbr_enqueue()β used to enqueue an mbuf to abuf_ring, falling back to the ifnet'sIFQif ALTQ(4) is enabled. it's got a backup plan, we love a prepared queen. πdrbr_dequeue()β used to dequeue an mbuf from abuf_ringor, if ALTQ(4) is enabled, from the ifnet'sIFQ. πdrbr_dequeue_cond()β used to conditionally dequeue an mbuf from abuf_ring, based on whetherfuncreturnsTRUEorFALSE. conditional queen behavior β¨drbr_flush()β frees all mbufs enqueued in thebuf_ringand the ifnet'sIFQ. everything. gone. periodt. πdrbr_empty()β returnsTRUEif there are no mbufs enqueued,FALSEotherwise. simple. gorgeous. π¦drbr_inuse()β returns the number of mbufs enqueued. ok but heads up, bestie:
β οΈ note to users: this is intrinsically racy as there is no guarantee that there will not be more mbufs when drbr_dequeue() is actually called. provided the tx queue lock is held there will not be less. so likeβ¦ it's a vibe check, not a promise. π
π RETURN VALUES π
drbr_enqueue()returnsENOBUFSif there are no slots available in thebuf_ring, and0on success. slay βdrbr_dequeue()anddrbr_dequeue_cond()return an mbuf on success andNULLif thebuf_ringis empty. no mbufs, no problem, justNULLπ«Ά
π HISTORY π
these functions were introduced in FreeBSD 8.0. vintage, but make it nostalgic π
okay that's the whole page, you ate that reading session fr fr π β¨
this lil manual page came from Debian, dated September 27, 2012 β so if you ever need to cite it, that's the tea. mwah, go enqueue something π¦π
π¦ 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 Bitgravity Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms