mirror of https://github.com/OISF/suricata
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>pull/3223/head
parent
460a0a6977
commit
796ec08dd7
Loading…
Reference in New Issue