Default to parse-options because some people like `ping -R`
[flowspec-xdp] / install.sh
1 #!/bin/bash
2 set -e
3
4 RULES="$(birdc show route table flowspec4 primary all)
5 $(birdc show route table flowspec6 primary all)"
6
7 echo "$RULES" | ./genrules.py --8021q=drop-vlan --v6frag=ignore-parse-if-rule --ihl=parse-options
8 clang -g -std=c99 -pedantic -Wall -Wextra -Wno-pointer-arith -Wno-unused-variable -O3 -emit-llvm -c xdp.c -o - | llc -O3 -march=bpf -filetype=obj -o xdp
9
10 echo "Before unload drop count was:"
11 ./dropcount.sh || echo "Not loaded"
12
13 ip link set "$1" xdp off
14 ip link set "$1" xdpgeneric off
15 # Note that sometimes the automated fallback does not work properly so we have to || generic here
16 ip link set "$1" xdpoffload obj xdp sec xdp_drop || (
17         echo "Failed to install in NIC, testing in driver..." && ip link set "$1" xdpdrv obj xdp sec xdp_drop || (
18                 echo "Failed to install in driver, using generic..." && ip link set "$1" xdpgeneric obj xdp sec xdp_drop
19         )
20 )
21 echo "$RULES" | grep "^flow. {" > installed-rules.txt