Bridge--using Packet Capture Library(libpcap.a) -- efficiency ?????

Robert Watson rwatson at freebsd.org
Sun Oct 31 01:44:59 PST 2004


On Sun, 31 Oct 2004, kamal kc wrote:

> I have made a bridge using the Packet Capture Library I set the two nics
> to promiscous mode and transfer packet between the two packet capture
> handles A piece of the code I use for initializing the packet capture

Copying every packet into and out of user space along with the at least
two system calls to do each packet will necessarily be expensive.
However, 3ms sounds far to high to me, do you have other processes running
(such as tcpdump) that might result in additional context switches?

I have used BPF to do bridging previously with a lot of success; I have
some sample code bridging over a tap interface and a TCP socket -- the
source (functional but not pretty) is at:

    http://www.watson.org/~robert/freebsd/netbridge/

The only complicated bit is walking through the BPF buffer, where sample
code is invaluable.  Everything else is very straight forward.  If you're
doing a bridge, you probably want to set the BPF flag so you don't loop
any packets.

Robert N M Watson             FreeBSD Core Team, TrustedBSD Projects
robert at fledge.watson.org      Principal Research Scientist, McAfee Research



More information about the freebsd-net mailing list