Kernel module advice for bandwidth monitor

Gerry Weaver gerryw at
Mon Jun 23 03:14:11 UTC 2008

Hello All,

I am just starting to dig into FreeBSD kernel development and the pfil interface in particular. I am in need of some advice and possibly some pointers to relevant documentation. I want to develop a bandwidth control driver and the associated monitoring code. It seems that the bandwidth control part of the equation is fairly straight forward with regard to the pfil framework. However, my current dilemma centers around the best way to implement monitoring. There seem to be several approaches to doing this. There is the bandwidth control driver itself, the bpf interface and the pcap library. My question concerns performance and network latency. It would be a given that any approach to monitoring is going to add some overhead in these areas, but I'm interested in minimizing this as much as possible. This is precisely where I was hoping to get some advice from the kernel gurus out there. I assume that it is possible for a kernel driver to communicate over the network. If, so it would seem that no context switch to user space would be necessary  to transmit stats to another monitor machine. If the bpf or pcap mechanisms were employed, user space would become involved. Given the various methods of accessing packet data, and the fact that I want to send stats to another machine, which approach would require the least overhead? Also, are there any good docs or possibly some code that I could look at that would illustrate the requirements/details of network communication from within a kernel driver? I searched the relevant lists for this, but was not able to find anything that looked like what I needed. I apologize if I have missed something. Please forgive my newbness as I'm just starting out. Hopefully my questions are not too foolish ;)


More information about the freebsd-hackers mailing list