ML_INIT(9)
π ML_INIT(9) β mbuf list API π
Okay so this is ML_INIT(9), straight from the Kernel Developer's Manual, bestie. It's the mbuf list API page, and it's giving very useful data-structure realness for managing lists of mbufs between contexts. Slay.
β¨ NAME β¨
The whole icon squad is ml_init, ml_enqueue, ml_dequeue, ml_enlist, ml_dechain, ml_len, ml_empty, ml_hdatalen, ml_purge, MBUF_LIST_INITIALIZER, MBUF_LIST_FIRST, MBUF_LIST_NEXT, and MBUF_LIST_FOREACH β aka the mbuf list API.
πΈ SYNOPSIS πΈ
#include <sys/mbuf.h>
void
ml_init(struct mbuf_list *ml);
void
ml_enqueue(struct mbuf_list *ml, struct mbuf *m);
struct mbuf *
ml_dequeue(struct mbuf_list *ml);
void
ml_enlist(struct mbuf_list *ml, struct mbuf_list *src);
struct mbuf *
ml_dechain(struct mbuf_list *ml);
unsigned int
ml_len(struct mbuf_list *ml);
int
ml_empty(struct mbuf_list *ml);
unsigned int
ml_hdatalen(struct mbuf_list *ml);
unsigned int
ml_purge(struct mbuf_list *ml);
struct mbuf_list
MBUF_LIST_INITIALIZER();
struct mbuf *
MBUF_LIST_FIRST(struct mbuf_list *ml);
struct mbuf *
MBUF_LIST_NEXT(struct mbuf *m);
MBUF_LIST_FOREACH(struct mbuf_list *ml, VARNAME);
π¦ DESCRIPTION π¦
The mbuf list API provides implementations of data structures and operations for managing lists of mbufs between contexts. mbuf_list structures support the following functionality:
- Insertion of a new mbuf at the end of the list.
- Removal of an mbuf from the head of the list.
Here's the full cast, no skips, no cuts:
ml_init(struct mbuf_list *ml)β Initialise themlmbuf_liststructure.MBUF_LIST_INITIALIZER()β An initialiser for anmbuf_liststructure declaration.ml_enqueue(struct mbuf_list *ml, struct mbuf *m)β Enqueue mbufmon the end of themlmbuf list.ml_dequeue(struct mbuf_list *ml)β Dequeue an mbuf from the front of themlmbuf list.ml_enlist(struct mbuf_list *ml, struct mbuf_list *src)β Enqueue all the mbufs on thesrcmbuf list on to the end of themlmbuf list.ml_dechain(struct mbuf_list *ml)β Dequeues all mbufs from themlmbuf list.ml_len(struct mbuf_list *ml)β Return the number of mbufs on themlmbuf list.ml_empty(struct mbuf_list *ml)β Return if themlmbuf list is empty.ml_hdatalen(struct mbuf_list *ml)β Return the number of bytes in the packet at the head of themlmbuf list.ml_purge(struct mbuf_list *ml)β Free all the mbufs on themlmbuf list.MBUF_LIST_FIRST(struct mbuf_list *ml)β Access the first mbuf in themlmbuf list for traversal.MBUF_LIST_NEXT(struct mbuf *m)β Access the next mbuf in the mbuf list afterm.MBUF_LIST_FOREACH(struct mbuf_list *ml, VARNAME)β A convenience macro that can be used to iterate over the contents of themlmbuf list.VARNAMEidentifies the name (not the address) of an mbuf pointer that will be set to each entry on the list. Note that it is unsafe to modify the list while iterating over it.
π¨ Bestie, for real: it is unsafe to modify the list while iterating over it. The page says it, I'm saying it, we're all saying it. Do not do the chaotic thing.
β CONTEXT β
These specific ones can be called during autoconf, from process context, or from interrupt context:
ml_init()ml_enqueue()ml_dequeue()ml_enlist()ml_dechain()ml_len()ml_empty()ml_purge()MBUF_LIST_INITIALIZER()MBUF_LIST_FIRST()MBUF_LIST_NEXT()MBUF_LIST_FOREACH()
π RETURN VALUES π
ml_dequeue()β returns the mbuf that was at the head of its list. If the list was empty,NULLis returned.ml_dechain()β returns all the mbufs that were on the list via a pointer to an mbuf with the chain accessible viam_nextpktmembers. If the list was empty,NULLis returned.ml_len()β returns the number of mbufs on the list.ml_empty()β returns a non-zero value if the list is empty, otherwise0.ml_hdatalen()β returns the size of a packet on the list, or0if the list is empty.ml_purge()β returns the number of mbufs that were freed.MBUF_LIST_FIRST()β returns the first mbuf in the mbuf list, orNULLif the list is empty.MBUF_LIST_NEXT()β returns the next mbuf in the mbuf list, orNULLif the end of the list has been reached.
π SEE ALSO π
This page is from Debian, dated January 23, 2020 β mwah, and good luck out there π β¨
π¦ where this page comes from
- nixpkgs unstable: cvs-export
- Copyright (c) 2015 David Gwynne <dlg@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms