From: Matt Corallo Date: Wed, 8 Dec 2021 20:14:50 +0000 (+0000) Subject: Use best instruction set that the local kernel supports X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=flowspec-xdp;a=commitdiff_plain;h=3e73d6020b9ff96340085e9c669b7d5cd0109e4b Use best instruction set that the local kernel supports --- diff --git a/install.sh b/install.sh index b791d8e..2a47a1d 100755 --- a/install.sh +++ b/install.sh @@ -21,9 +21,9 @@ STATS_RULES="$(echo "$RULES" | ./genrules.py --8021q=drop-vlan --v6frag=ignore-p clang $CLANG_ARGS -g -std=c99 -pedantic -Wall -Wextra -Wno-pointer-arith -Wno-unused-variable -Wno-unused-function -O3 -emit-llvm -c xdp.c -o xdp.bc if [ "$2" != "" ]; then clang $4 -g -std=c99 -pedantic -Wall -Wextra -Wno-pointer-arith -O3 -emit-llvm -c "$2" -o wrapper.bc - llvm-link xdp.bc wrapper.bc | llc -O3 -march=bpf -filetype=obj -o xdp + llvm-link xdp.bc wrapper.bc | llc -O3 -march=bpf -mcpu=probe -filetype=obj -o xdp else - cat xdp.bc | llc -O3 -march=bpf -filetype=obj -o xdp + cat xdp.bc | llc -O3 -march=bpf -mcpu=probe -filetype=obj -o xdp fi echo "Before unload drop count was:" diff --git a/xdp.c b/xdp.c index f59019a..187c220 100644 --- a/xdp.c +++ b/xdp.c @@ -273,9 +273,9 @@ static int check_v##IPV##_persrc_ratelimit(IP_TYPE key, void *map, size_t map_li struct persrc_rate##IPV##_entry *first_bucket = &buckets->entries[(hash % map_limit) & (~(SRC_HASH_BUCKET_COUNT - 1))]; \ bpf_spin_lock(&buckets->lock); \ \ - int min_sent_idx = 0; \ + uint64_t min_sent_idx = 0; /* Must be uint64_t or BPF verifier gets lost and thinks it can be any value */ \ uint64_t min_sent_time = UINT64_MAX; \ - for (int i = 0; i < SRC_HASH_BUCKET_COUNT; i++) { \ + for (uint64_t i = 0; i < SRC_HASH_BUCKET_COUNT; i++) { \ if (first_bucket[i].srcip == key) { \ min_sent_idx = i; \ break; \