DRBR(9)
π DRBR(9) β network driver interface to buf_ring
okay bestie, welcome to the DRBR(9) page from the Kernel Developer's Manual β¨ this one is all about the drbr squad and how network drivers use buf_ring(9) for enqueueing and dequeueing packets. stay with me, itβs actually iconic.
πΈ NAME πΈ
drbr, drbr_free, drbr_enqueue, drbr_dequeue, drbr_dequeue_cond, drbr_flush, drbr_empty, drbr_inuse β network driver interface to buf_ring
β¨ SYNOPSIS β¨
#include <sys/param.h>
#include <net/if.h>
#include <net/if_var.h>
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 π
The drbr functions provide an API to network drivers for using buf_ring(9) for enqueueing and dequeueing packets. This is meant as a replacement for the IFQ interface for packet queuing. It allows a packet to be enqueued with a single atomic and packet dequeue to be done without any per-packet atomics as it is protected by the driver's tx queue lock. If INVARIANTS is enabled, drbr_dequeue() will assert that the tx queue lock is held when it is called.
π«Ά lowkey important: that INVARIANTS assert is your vibe check for lock discipline, bestie.
drbr_free()β frees all the enqueued mbufs and then frees thebuf_ring.drbr_enqueue()β used to enqueue an mbuf to abuf_ring, falling back to the ifnet'sIFQifALTQ(4)is enabled.drbr_dequeue()β used to dequeue an mbuf from abuf_ringor, ifALTQ(4)is enabled, from the ifnet'sIFQ.drbr_dequeue_cond()β used to conditionally dequeue an mbuf from abuf_ringbased on whetherfuncreturnsTRUEorFALSE.drbr_flush()β frees all mbufs enqueued in thebuf_ringand the ifnet'sIFQ.drbr_empty()β returnsTRUEif there are no mbufs enqueued,FALSEotherwise.drbr_inuse()β returns the number of mbufs enqueued.
π aboutdrbr_inuse(): note to users that this is intrinsically racy as there is no guarantee that there will not be more mbufs whendrbr_dequeue()is actually called. Provided the tx queue lock is held there will not be less.
π₯ RETURN VALUES π₯
drbr_enqueue()returnsENOBUFSif there are no slots available in thebuf_ringand0on success. slay.drbr_dequeue()anddrbr_dequeue_cond()return an mbuf on success andNULLif thebuf_ringis empty. no mbufs, no problem β you getNULL.
π¦ HISTORY π¦
These functions were introduced in FreeBSD 8.0. π
π source/version: Debian Β· date: September 27, 2012 Β· page: DRBR(9) β byeee bestie, go forth and queue responsibly ππ«Άβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2009 Bitgravity Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms