Playing with mbuf in userland
Bosko Milekic
bmilekic at FreeBSD.org
Sun Aug 22 07:12:53 PDT 2004
I wrote:
Another option to look into would be to implement a sysctl(8)-exported
handler that iterates over the mbuf chain and prints out the mbuf chains
in something like XML, which your userland application can then more or less
easily parse, and reproduce the chain ("fake it up") in userland. This
solution is rather attractive because you can do all sorts of things
with the intermediate-parsing-language right from the kernel, as well
as from userland (at the parsing stages). To see an example of a sysctl(8)
handler, refer to src/sys/vm/uma_core.c (the bottom) in FreeBSD 5.x.
I should also add: you should have various sysctl OIDs that call this
handler passing, say, the mbuf chain as an argument (a reference to the
top mbuf). This way certain OIDs can send out a snapshot of an mbuf
chain at a particular point in the stack, and others can send snapshots
from the socket buffer and driver entry-points (you can get some perception
of how the chain changes as it makes its way up-and-down the layers).
-Bosko
More information about the freebsd-hackers
mailing list