Alexei Starovoitov 27b29f6305 bpf: add bpf_redirect() helper
Existing bpf_clone_redirect() helper clones skb before redirecting
it to RX or TX of destination netdev.
Introduce bpf_redirect() helper that does that without cloning.

Benchmarked with two hosts using 10G ixgbe NICs.
One host is doing line rate pktgen.
Another host is configured as:
$ tc qdisc add dev $dev ingress
$ tc filter add dev $dev root pref 10 u32 match u32 0 0 flowid 1:2 \
   action bpf run object-file tcbpf1_kern.o section clone_redirect_xmit drop
so it receives the packet on $dev and immediately xmits it on $dev + 1
The section 'clone_redirect_xmit' in tcbpf1_kern.o file has the program
that does bpf_clone_redirect() and performance is 2.0 Mpps

$ tc filter add dev $dev root pref 10 u32 match u32 0 0 flowid 1:2 \
   action bpf run object-file tcbpf1_kern.o section redirect_xmit drop
which is using bpf_redirect() - 2.4 Mpps

and using cls_bpf with integrated actions as:
$ tc filter add dev $dev root pref 10 \
  bpf run object-file tcbpf1_kern.o section redirect_xmit integ_act classid 1
performance is 2.5 Mpps

To summarize:
u32+act_bpf using clone_redirect - 2.0 Mpps
u32+act_bpf using redirect - 2.4 Mpps
cls_bpf using redirect - 2.5 Mpps

For comparison linux bridge in this setup is doing 2.1 Mpps
and ixgbe rx + drop in ip_rcv - 7.8 Mpps

Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-09-17 21:09:07 -07:00
..
2014-10-20 10:30:15 +08:00
2014-09-23 23:15:46 -07:00
2015-05-23 10:49:55 +01:00
2015-04-21 16:16:02 -04:00
2015-02-23 09:59:07 -06:00
2015-09-15 21:53:24 -07:00
2013-04-26 16:08:16 +10:00
2015-09-17 21:09:07 -07:00
2014-07-01 10:48:05 -06:00
2014-03-20 14:55:18 +01:00
2015-08-25 14:41:50 -05:00
2014-11-19 14:48:02 -06:00
2012-10-16 18:49:15 -07:00
2014-08-08 15:57:31 -07:00
2015-04-12 21:25:13 -04:00
2015-07-01 16:26:08 +02:00
2014-05-14 10:04:34 +01:00
2013-12-11 12:57:55 -08:00
2013-08-13 15:10:22 -07:00
2014-12-22 16:12:36 -05:00
2015-05-25 13:25:35 -04:00
2015-09-04 16:54:41 -07:00
2014-12-02 13:52:53 -07:00
2015-02-17 14:34:51 -08:00
2015-08-22 14:57:59 -07:00
2015-02-03 12:48:40 -05:00
2015-08-03 17:30:00 -07:00
2014-08-08 15:57:31 -07:00
2015-07-21 10:39:05 -07:00
2015-01-20 13:51:06 +01:00
2014-12-13 12:42:52 -08:00
2015-05-05 13:40:44 -06:00
2015-02-02 18:46:51 -08:00
2015-08-27 19:44:53 -04:00
2015-04-23 15:16:14 -04:00
2015-07-20 14:58:46 -04:00
2015-08-18 11:56:13 -06:00
2012-11-16 10:15:35 -08:00
2015-08-04 10:16:57 +02:00
2015-09-17 21:09:07 -07:00
2015-09-04 16:54:41 -07:00
2014-03-21 14:21:13 -04:00
2014-12-10 17:41:10 -08:00
2014-12-09 14:10:41 +08:00
2013-03-22 16:19:59 -07:00
2015-03-05 22:08:42 -05:00
2014-04-26 12:13:24 -04:00
2015-05-24 12:49:16 -07:00
2015-06-11 23:37:37 +02:00
2015-06-03 14:17:38 +02:00
2015-03-29 12:13:52 +10:30
2014-12-09 12:05:24 +02:00
2015-03-31 13:58:35 -04:00