diff options
author | melifaro <melifaro@FreeBSD.org> | 2012-04-06 06:55:21 +0000 |
---|---|---|
committer | melifaro <melifaro@FreeBSD.org> | 2012-04-06 06:55:21 +0000 |
commit | 85ccef88d3440944ee1c97a3fba3e8718d05fb8e (patch) | |
tree | 9ef2a8c79325381d2620c436f7de019ef62c053f /sys/net/bpfdesc.h | |
parent | 8b1d10268c8ffd28f6c4b0da1e3906b139fc94cf (diff) | |
download | FreeBSD-src-85ccef88d3440944ee1c97a3fba3e8718d05fb8e.zip FreeBSD-src-85ccef88d3440944ee1c97a3fba3e8718d05fb8e.tar.gz |
- Improve performace for writer-only BPF users.
Linux and Solaris (at least OpenSolaris) has PF_PACKET socket families to send
raw ethernet frames. The only FreeBSD interface that can be used to send raw frames
is BPF. As a result, many programs like cdpd, lldpd, various dhcp stuff uses
BPF only to send data. This leads us to the situation when software like cdpd,
being run on high-traffic-volume interface significantly reduces overall performance
since we have to acquire additional locks for every packet.
Here we add sysctl that changes BPF behavior in the following way:
If program came and opens BPF socket without explicitly specifyin read filter we
assume it to be write-only and add it to special writer-only per-interface list.
This makes bpf_peers_present() return 0, so no additional overhead is introduced.
After filter is supplied, descriptor is added to original per-interface list permitting
packets to be captured.
Unfortunately, pcap_open_live() sets catch-all filter itself for the purpose of
setting snap length.
Fortunately, most programs explicitly sets (event catch-all) filter after that.
tcpdump(1) is a good example.
So a bit hackis approach is taken: we upgrade description only after second
BIOCSETF is received.
Sysctl is named net.bpf.optimize_writers and is turned off by default.
- While here, document all sysctl variables in bpf.4
Sponsored by Yandex LLC
Reviewed by: glebius (previous version)
Reviewed by: silence on -net@
Approved by: (mentor)
MFC after: 4 weeks
Diffstat (limited to 'sys/net/bpfdesc.h')
-rw-r--r-- | sys/net/bpfdesc.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/sys/net/bpfdesc.h b/sys/net/bpfdesc.h index 170e1b3..f01a0e1 100644 --- a/sys/net/bpfdesc.h +++ b/sys/net/bpfdesc.h @@ -79,6 +79,7 @@ struct bpf_d { u_char bd_promisc; /* true if listening promiscuously */ u_char bd_state; /* idle, waiting, or timed out */ u_char bd_immediate; /* true to return on packet arrival */ + u_char bd_writer; /* non-zero if d is writer-only */ int bd_hdrcmplt; /* false to fill in src lladdr automatically */ int bd_direction; /* select packet direction */ int bd_tstamp; /* select time stamping function */ |