Alexander V. Chernikov 51ec1eb70d - 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
2012-04-06 06:55:21 +00:00
..
2012-03-24 13:37:57 +00:00
2011-05-22 14:03:30 +00:00
2008-11-29 18:09:50 +00:00
2011-12-09 19:17:51 +00:00
2012-03-26 15:18:14 +00:00
2012-01-05 21:43:33 +00:00
2012-03-24 13:37:57 +00:00
2010-10-08 12:40:16 +00:00
2012-03-26 15:18:14 +00:00
2012-03-24 13:37:57 +00:00
2010-10-08 12:40:16 +00:00
2011-02-06 11:39:51 +00:00
2011-06-02 09:56:53 +00:00
2012-03-24 13:37:57 +00:00
2012-03-26 15:18:14 +00:00
2010-01-15 16:01:22 +00:00
2010-10-08 12:40:16 +00:00
2010-08-06 14:33:42 +00:00
2011-12-20 17:44:25 +00:00
2010-09-09 21:39:06 +00:00
2012-02-25 15:21:43 +00:00
2012-03-24 13:37:57 +00:00
2012-02-09 04:37:30 +00:00
2011-12-16 11:52:33 +00:00
2010-10-08 12:40:16 +00:00
2010-10-08 12:40:16 +00:00
2012-03-24 13:37:57 +00:00
2012-03-24 13:37:57 +00:00
2012-03-04 16:59:45 +00:00
2012-03-24 13:37:57 +00:00
2011-11-06 21:54:27 +00:00
2011-12-09 19:17:51 +00:00
2012-03-13 10:54:14 +00:00
2012-03-24 13:37:57 +00:00
2011-12-20 17:44:25 +00:00
2012-03-24 13:37:57 +00:00
2012-03-24 13:37:57 +00:00
2012-03-24 13:37:57 +00:00
2012-03-24 13:37:57 +00:00
2010-10-08 12:40:16 +00:00
2010-08-07 08:31:32 +00:00
2012-03-24 13:37:57 +00:00
2012-03-24 13:37:57 +00:00
2012-03-04 15:22:03 +00:00
2010-10-08 12:40:16 +00:00
2010-10-08 12:40:16 +00:00
2010-01-15 16:01:22 +00:00
2012-03-26 15:18:14 +00:00
2012-01-27 08:46:32 +00:00
2010-10-08 12:40:16 +00:00
2012-02-25 14:31:25 +00:00
2010-10-08 12:40:16 +00:00
2010-05-12 17:12:38 +00:00
2008-10-22 09:11:35 +00:00
2007-03-11 15:20:04 +00:00
2010-03-14 15:49:04 +00:00
2011-01-26 01:07:56 +00:00
2010-08-15 21:34:50 +00:00
2010-10-08 12:40:16 +00:00
2012-03-24 13:37:57 +00:00
2011-02-24 18:08:23 +00:00
2010-03-04 11:09:49 +00:00
2009-03-18 20:03:33 +00:00
2010-08-06 14:33:42 +00:00
2010-10-08 12:40:16 +00:00
2012-03-24 13:37:57 +00:00
2011-05-22 14:03:30 +00:00
2010-10-08 12:40:16 +00:00
2010-10-08 12:40:16 +00:00
2011-11-06 20:37:17 +00:00
2011-01-26 21:59:59 +00:00
2011-01-26 06:07:24 +00:00
2010-10-08 12:40:16 +00:00
2010-11-29 15:08:18 +00:00
2010-03-04 11:09:49 +00:00
2012-02-09 04:37:30 +00:00
2010-03-04 10:59:21 +00:00
2010-10-08 12:40:16 +00:00
2010-10-08 12:40:16 +00:00
2010-10-08 12:40:16 +00:00
2012-03-19 19:27:43 +00:00
2011-04-08 12:46:47 +00:00
2010-10-08 12:40:16 +00:00
2010-10-08 12:40:16 +00:00
2010-01-15 16:01:22 +00:00
2007-05-12 06:33:52 +00:00
2012-03-24 13:37:57 +00:00
2007-05-12 06:41:41 +00:00
2008-11-05 15:04:03 +00:00
2010-10-08 12:40:16 +00:00
2010-10-08 12:40:16 +00:00
2008-01-22 19:16:09 +00:00
2012-03-26 15:18:14 +00:00
2011-11-14 22:16:12 +00:00
2011-12-20 17:44:25 +00:00
2010-10-08 12:40:16 +00:00
2009-12-28 09:41:13 +00:00
2010-10-08 12:40:16 +00:00
2012-03-24 13:37:57 +00:00
2011-11-20 12:18:21 +00:00
2009-05-16 21:38:55 +00:00
2011-11-20 12:18:21 +00:00
2011-11-20 12:18:21 +00:00
2011-11-20 12:18:21 +00:00
2010-01-15 16:01:22 +00:00
2011-06-02 09:56:53 +00:00
2010-03-06 05:57:24 +00:00
2011-11-20 12:18:21 +00:00
2011-02-24 18:08:23 +00:00
2011-08-20 14:21:32 +00:00
2012-03-29 17:04:04 +00:00
2011-11-20 12:18:21 +00:00
2011-11-20 12:18:21 +00:00
2011-11-20 12:18:21 +00:00
2010-10-08 12:40:16 +00:00
2010-03-15 20:25:28 +00:00
2010-10-08 12:40:16 +00:00
2012-02-09 04:37:30 +00:00
2012-02-28 15:47:39 +00:00
2011-11-20 12:18:21 +00:00
2011-11-20 12:18:21 +00:00
2011-11-20 12:18:21 +00:00
2011-04-14 08:53:04 +00:00
2012-01-22 10:16:24 +00:00
2012-01-22 10:16:24 +00:00
2012-02-25 14:31:25 +00:00
2010-12-31 21:52:51 +00:00
2012-01-22 10:16:24 +00:00
2010-10-08 12:40:16 +00:00
2012-02-22 22:40:20 +00:00
2010-10-08 12:40:16 +00:00