Introduce parameter --remove

Need an easy way to move the setup again.

Signed-off-by: Jesper Dangaard Brouer <netoptimizer@brouer.com>
This commit is contained in:
Jesper Dangaard Brouer
2020-11-08 13:12:02 +01:00
parent 72d3bba6d9
commit 91a8e78a12
2 changed files with 20 additions and 6 deletions

View File

@@ -18,6 +18,15 @@ BPF_OBJ=edt_pacer01.o
info "Applying TC-BPF egress setup on device: $DEV with object file: $BPF_OBJ" info "Applying TC-BPF egress setup on device: $DEV with object file: $BPF_OBJ"
function tc_remove_clsact()
{
local device=${1:-$DEV}
shift
# Removing qdisc clsact, also deletes all filters
call_tc_allow_fail qdisc del dev "$device" clsact 2> /dev/null
}
function tc_init_clsact() function tc_init_clsact()
{ {
local device=${1:-$DEV} local device=${1:-$DEV}
@@ -50,6 +59,11 @@ function tc_egress_list()
call_tc filter show dev "$device" egress call_tc filter show dev "$device" egress
} }
if [[ -n $REMOVE ]]; then
tc_remove_clsact $DEV
exit 0
fi
tc_init_clsact $DEV tc_init_clsact $DEV
tc_egress_bpf_attach $DEV $BPF_OBJ tc_egress_bpf_attach $DEV $BPF_OBJ

View File

@@ -7,10 +7,10 @@
function usage() { function usage() {
echo "" echo ""
echo "Usage: $0 [-vfh] --dev ethX" echo "Usage: $0 [-vh] --dev ethX"
echo " -d | --dev : (\$DEV) Ingress interface/device (required)" echo " -d | --dev : (\$DEV) Ingress interface/device (required)"
echo " -v | --verbose : (\$VERBOSE) verbose" echo " -v | --verbose : (\$VERBOSE) verbose"
echo " --flush : (\$FLUSH) Only flush (remove TC drop rules)" echo " --remove : (\$REMOVE) Remove the TC rules"
echo " --dry-run : (\$DRYRUN) Dry-run only (echo tc commands)" echo " --dry-run : (\$DRYRUN) Dry-run only (echo tc commands)"
echo " -s | --stats : (\$STATS_ONLY) Call TC statistics command" echo " -s | --stats : (\$STATS_ONLY) Call TC statistics command"
echo " -l | --list : (\$LIST) List TC filter setup after setup" echo " -l | --list : (\$LIST) List TC filter setup after setup"
@@ -18,8 +18,8 @@ function usage() {
} }
# Using external program "getopt" to get --long-options # Using external program "getopt" to get --long-options
OPTIONS=$(getopt -o vfshd:l \ OPTIONS=$(getopt -o vshd:l \
--long verbose,dry-run,flush,stats,list,help,dev: -- "$@") --long verbose,dry-run,remove,stats,list,help,dev: -- "$@")
if (( $? != 0 )); then if (( $? != 0 )); then
usage usage
err 2 "Error calling getopt" err 2 "Error calling getopt"
@@ -45,8 +45,8 @@ while true; do
info "Dry-run mode: enable VERBOSE and don't call TC" >&2 info "Dry-run mode: enable VERBOSE and don't call TC" >&2
shift shift
;; ;;
-f | --flush ) --remove )
export FLUSH=yes export REMOVE=yes
shift shift
;; ;;
-s | --stats ) -s | --stats )