---
name: "drbr"
section: "9freebsd"
platform: "linux"
package: "freebsd-manpages"
version: "12.2-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/drbr/9freebsd"
---

# drbr(9freebsd)

network driver interface to buf\_ring

## 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)](/buf_ring/9.md) 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.

The **drbr\_free**() function frees all the enqueued mbufs and then frees the buf\_ring.

The **drbr\_enqueue**() function is used to enqueue an mbuf to a buf\_ring, falling back to the ifnet's IFQ if [ALTQ(4)](/ALTQ/4.md) is enabled.

The **drbr\_dequeue**() function is used to dequeue an mbuf from a buf\_ring or, if [ALTQ(4)](/ALTQ/4.md) is enabled, from the ifnet's IFQ.

The **drbr\_dequeue\_cond**() function is used to conditionally dequeue an mbuf from a buf\_ring based on whether *func* returns TRUE or FALSE.

The **drbr\_flush**() function frees all mbufs enqueued in the buf\_ring and the ifnet's IFQ.

The **drbr\_empty**() function returns TRUE if there are no mbufs enqueued, FALSE otherwise.

The **drbr\_inuse**() function returns the number of mbufs enqueued. Note to users that 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.

## RETURN VALUES

The **drbr\_enqueue**() function returns ENOBUFS if there are no slots available in the buf\_ring and 0 on success.

The **drbr\_dequeue**() and **drbr\_dequeue\_cond**() functions return an mbuf on success and NULL if the buf\_ring is empty.

## HISTORY

These functions were introduced in FreeBSD 8.0.
