]> git.ipfire.org Git - thirdparty/suricata.git/commit
ebpf: improve xdp-cpu-redirect distribution in xdp_filter.c
authorJesper Dangaard Brouer <netoptimizer@brouer.com>
Thu, 25 Jan 2018 19:24:38 +0000 (20:24 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 6 Feb 2018 16:48:03 +0000 (17:48 +0100)
commit796ec08dd7a6311b108b5352ab66653b10f2aff9
tree55f869eefb3b4622e6d7fcf62927ab7ffe386777
parent460a0a6977614a521ebb17cc8e531c6528ff8c69
ebpf: improve xdp-cpu-redirect distribution in xdp_filter.c

The XDP CPU destination array/set, configured via xdp-cpu-redirect,
will always be fairly small.  My different benchmarking showed that
the current modulo hashing into the CPU array can easily result in bad
distribution, expecially if the number of CPU is an even number.

This patch uses a proper hashing function on the input key. The key
used for hashing is inspired by the ippair hashing code in
src/tmqh-flow.c, and is based on the IP src + dst.

An important property is that the hashing is flow symmetric, meaning
that if the source and destintation gets swapped then the selected CPU
will remain the same.  This is important for Suricate.

That hashing INITVAL (15485863 the 10^6th prime number) was fairly
arbitrary choosen, but experiments with kernel tree pktgen scripts
(pktgen_sample04_many_flows.sh +pktgen_sample05_flow_per_thread.sh)
showed this improved the distribution.

Signed-off-by: Jesper Dangaard Brouer <netoptimizer@brouer.com>
ebpf/xdp_filter.c