]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
ebpf: don't use nexthdr to build hash
authorEric Leblond <eric@regit.org>
Sat, 1 Jun 2019 15:04:40 +0000 (17:04 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 18 Jun 2019 05:07:02 +0000 (07:07 +0200)
As pointed by Victor Julien, it is not a good idea to use the
nexthdr value, as init key for the hash as it could contain some
other headers and can be changed for a session.

ebpf/xdp_filter.c

index 076ed4d55184500fc5d750ef1052956628eabfb8..229a912e6b5cc8d1e54175626dc4e5c499a6e411 100644 (file)
@@ -446,7 +446,7 @@ static int __always_inline filter_ipv6(struct xdp_md *ctx, void *data, __u64 nh_
     cpu_hash += tuple.src[1] + tuple.dst[1];
     cpu_hash += tuple.src[2] + tuple.dst[2];
     cpu_hash += tuple.src[3] + tuple.dst[3];
-    cpu_hash = SuperFastHash((char *)&cpu_hash, 4, ip6h->nexthdr);
+    cpu_hash = SuperFastHash((char *)&cpu_hash, 4, INITVAL);
 
     if (cpu_max && *cpu_max) {
         cpu_dest = cpu_hash % *cpu_max;
@@ -465,7 +465,7 @@ static int __always_inline filter_ipv6(struct xdp_md *ctx, void *data, __u64 nh_
     xdp_hash += tuple.src[1] + tuple.dst[1];
     xdp_hash += tuple.src[2] + tuple.dst[2];
     xdp_hash += tuple.src[3] + tuple.dst[3];
-    xdp_hash = SuperFastHash((char *)&xdp_hash, 4, ip6h->nexthdr);
+    xdp_hash = SuperFastHash((char *)&xdp_hash, 4, INITVAL);
     ctx->rx_queue_index = xdp_hash % RSS_QUEUE_NUMBERS;
 #endif