X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=install.sh;h=b791d8ee5c0b98c692e14e9102cecd149b3b8a04;hb=f14e8156a096aaa3ba97498b90e028019aa3252a;hp=d77a8b0a66a5dd941fa78fdb39e14488da44e2cd;hpb=31c91503a07f942531da55ac861630bfdf8d00fb;p=flowspec-xdp diff --git a/install.sh b/install.sh index d77a8b0..b791d8e 100755 --- a/install.sh +++ b/install.sh @@ -15,10 +15,12 @@ fi RULES="$(birdc show route table flowspec4 primary all) $(birdc show route table flowspec6 primary all)" -echo "$RULES" | ./genrules.py --8021q=drop-vlan --v6frag=ignore-parse-if-rule --ihl=parse-options -clang $CLANG_ARGS -g -std=c99 -pedantic -Wall -Wextra -Wno-pointer-arith -Wno-unused-variable -O3 -emit-llvm -c xdp.c -o xdp.bc +echo "const uint8_t COMPILE_TIME_RAND[] = { $(dd if=/dev/urandom of=/dev/stdout bs=1 count=8 2>/dev/null | hexdump -e '4/1 "0x%02x, "') };" > rand.h + +STATS_RULES="$(echo "$RULES" | ./genrules.py --8021q=drop-vlan --v6frag=ignore-parse-if-rule --ihl=parse-options)" +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 -Wno-unused-variable -O3 -emit-llvm -c "$2" -o wrapper.bc + 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 else cat xdp.bc | llc -O3 -march=bpf -filetype=obj -o xdp @@ -27,12 +29,10 @@ fi echo "Before unload drop count was:" ./dropcount.sh || echo "Not loaded" -ip link set "$1" xdp off -ip link set "$1" xdpgeneric off # Note that sometimes the automated fallback does not work properly so we have to || generic here -ip link set "$1" xdpoffload obj xdp sec $XDP_SECTION || ( - echo "Failed to install in NIC, testing in driver..." && ip link set "$1" xdpdrv obj xdp sec $XDP_SECTION || ( - echo "Failed to install in driver, using generic..." && ip link set "$1" xdpgeneric obj xdp sec $XDP_SECTION +ip -force link set "$1" xdpoffload obj xdp sec $XDP_SECTION || ( + echo "Failed to install in NIC, testing in driver..." && ip -force link set "$1" xdpdrv obj xdp sec $XDP_SECTION || ( + echo "Failed to install in driver, using generic..." && ip -force link set "$1" xdpgeneric obj xdp sec $XDP_SECTION ) ) -echo "$RULES" | grep "^flow. {" > installed-rules.txt +echo "$STATS_RULES" > installed-rules.txt