From 91a8e78a123507c4e178096124dfac5e2becb401 Mon Sep 17 00:00:00 2001 From: Jesper Dangaard Brouer Date: Sun, 8 Nov 2020 13:12:02 +0100 Subject: [PATCH] Introduce parameter --remove Need an easy way to move the setup again. Signed-off-by: Jesper Dangaard Brouer --- traffic-pacing-edt/bpf_egress_loader.sh | 14 ++++++++++++++ traffic-pacing-edt/parameters.sh | 12 ++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/traffic-pacing-edt/bpf_egress_loader.sh b/traffic-pacing-edt/bpf_egress_loader.sh index 2988061..30ec823 100755 --- a/traffic-pacing-edt/bpf_egress_loader.sh +++ b/traffic-pacing-edt/bpf_egress_loader.sh @@ -18,6 +18,15 @@ BPF_OBJ=edt_pacer01.o 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() { local device=${1:-$DEV} @@ -50,6 +59,11 @@ function tc_egress_list() call_tc filter show dev "$device" egress } +if [[ -n $REMOVE ]]; then + tc_remove_clsact $DEV + exit 0 +fi + tc_init_clsact $DEV tc_egress_bpf_attach $DEV $BPF_OBJ diff --git a/traffic-pacing-edt/parameters.sh b/traffic-pacing-edt/parameters.sh index a2f1f20..2e8b7eb 100644 --- a/traffic-pacing-edt/parameters.sh +++ b/traffic-pacing-edt/parameters.sh @@ -7,10 +7,10 @@ function usage() { echo "" - echo "Usage: $0 [-vfh] --dev ethX" + echo "Usage: $0 [-vh] --dev ethX" echo " -d | --dev : (\$DEV) Ingress interface/device (required)" 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 " -s | --stats : (\$STATS_ONLY) Call TC statistics command" echo " -l | --list : (\$LIST) List TC filter setup after setup" @@ -18,8 +18,8 @@ function usage() { } # Using external program "getopt" to get --long-options -OPTIONS=$(getopt -o vfshd:l \ - --long verbose,dry-run,flush,stats,list,help,dev: -- "$@") +OPTIONS=$(getopt -o vshd:l \ + --long verbose,dry-run,remove,stats,list,help,dev: -- "$@") if (( $? != 0 )); then usage err 2 "Error calling getopt" @@ -45,8 +45,8 @@ while true; do info "Dry-run mode: enable VERBOSE and don't call TC" >&2 shift ;; - -f | --flush ) - export FLUSH=yes + --remove ) + export REMOVE=yes shift ;; -s | --stats )