6 if [ "$2" != "" ]; then
7 CLANG_ARGS="-DHAVE_WRAPPER"
9 if [ ! -f "$2" -o "$3" = "" ]; then
10 echo "To use a wrapper C file, call as $0 interface path/to/wrapper.c xdp_section wrapper-clang-args"
15 RULES="$(birdc show route table flowspec4 primary all)
16 $(birdc show route table flowspec6 primary all)"
18 echo "$RULES" | ./genrules.py --8021q=drop-vlan --v6frag=ignore-parse-if-rule --ihl=parse-options
19 clang $CLANG_ARGS -g -std=c99 -pedantic -Wall -Wextra -Wno-pointer-arith -Wno-unused-variable -O3 -emit-llvm -c xdp.c -o xdp.bc
20 if [ "$2" != "" ]; then
21 clang $4 -g -std=c99 -pedantic -Wall -Wextra -Wno-pointer-arith -Wno-unused-variable -O3 -emit-llvm -c "$2" -o wrapper.bc
22 llvm-link xdp.bc wrapper.bc | llc -O3 -march=bpf -filetype=obj -o xdp
24 cat xdp.bc | llc -O3 -march=bpf -filetype=obj -o xdp
27 echo "Before unload drop count was:"
28 ./dropcount.sh || echo "Not loaded"
30 ip link set "$1" xdp off
31 ip link set "$1" xdpgeneric off
32 # Note that sometimes the automated fallback does not work properly so we have to || generic here
33 ip link set "$1" xdpoffload obj xdp sec $XDP_SECTION || (
34 echo "Failed to install in NIC, testing in driver..." && ip link set "$1" xdpdrv obj xdp sec $XDP_SECTION || (
35 echo "Failed to install in driver, using generic..." && ip link set "$1" xdpgeneric obj xdp sec $XDP_SECTION
38 echo "$RULES" | grep "^flow. {" > installed-rules.txt