]> git.bitcoin.ninja Git - flowspec-xdp/commitdiff
Add default installer script
authorMatt Corallo <git@bluematt.me>
Sun, 4 Apr 2021 02:14:43 +0000 (22:14 -0400)
committerMatt Corallo <git@bluematt.me>
Sun, 4 Apr 2021 03:49:06 +0000 (23:49 -0400)
dropcount.sh [new file with mode: 0755]
install.sh [new file with mode: 0755]

diff --git a/dropcount.sh b/dropcount.sh
new file mode 100755 (executable)
index 0000000..f67abf7
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+KEY=""
+CNT=0
+bpftool map dump id "$(bpftool map show | grep drop_cnt_map | awk '{ print $1 }' | tr -d ':')" | while read LINE; do
+       case "$LINE" in
+               "key:") ;;
+               "value"*)
+                       CNT=$(( $CNT + $(echo "$LINE" | awk '{ print "0x" $11 $10 $9 $8 $7 $6 $5 $4 }') ))
+                       ;;
+               "Found "*) ;;
+               *)
+                       if [ "$KEY" != "" ]; then
+                               echo "$KEY: $CNT"
+                       fi
+                       KEY=$(echo "$LINE" | awk '{ print "0x" $4 $3 $2 $1 }')
+                       CNT=0
+                       ;;
+       esac
+done
diff --git a/install.sh b/install.sh
new file mode 100755 (executable)
index 0000000..d93664c
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+set -e
+
+RULES="$(birdc show route table flowspec4)
+$(birdc show route table flowspec6)"
+
+echo "$RULES" | ./genrules.py --8021q=drop-vlan --v6frag=ignore-parse-if-rule --ihl=drop-options
+clang -std=c99 -pedantic -Wall -Wextra -Wno-pointer-arith -Wno-unused-variable -Os -emit-llvm -c xdp.c -o - | llc -march=bpf -filetype=obj -o xdp
+
+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" xdp obj xdp sec xdp_drop || ip link set "$1" xdpgeneric obj xdp sec xdp_drop