mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
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:
@@ -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
|
||||
|
||||
|
@@ -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 )
|
||||
|
Reference in New Issue
Block a user