summaryrefslogtreecommitdiffstats
path: root/samples/pktgen/functions.sh
diff options
context:
space:
mode:
authorJ.J. Martzki <mars14850@gmail.com>2023-07-01 16:37:37 +0200
committerDavid S. Miller <davem@davemloft.net>2023-07-03 10:15:26 +0200
commita27ac5390922059867f645eefd978e533d7af902 (patch)
treecc707a1806e2f0e82b1bc8cd9d088dd9e0838ae2 /samples/pktgen/functions.sh
parentselftests/net: Add xt_policy config for xfrm_policy test (diff)
downloadlinux-a27ac5390922059867f645eefd978e533d7af902.tar.xz
linux-a27ac5390922059867f645eefd978e533d7af902.zip
samples: pktgen: fix append mode failed issue
Each sample script sources functions.sh before parameters.sh which makes $APPEND undefined when trapping EXIT no matter in append mode or not. Due to this when sample scripts finished they always do "pgctrl reset" which resets pktgen config. So move trap to each script after sourcing parameters.sh and trap EXIT explicitly. Signed-off-by: J.J. Martzki <mars14850@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples/pktgen/functions.sh')
-rw-r--r--samples/pktgen/functions.sh13
1 files changed, 7 insertions, 6 deletions
diff --git a/samples/pktgen/functions.sh b/samples/pktgen/functions.sh
index dd4e53ae9b73..c08cefb8eb1f 100644
--- a/samples/pktgen/functions.sh
+++ b/samples/pktgen/functions.sh
@@ -108,12 +108,13 @@ function pgset() {
fi
}
-if [[ -z "$APPEND" ]]; then
- if [[ $EUID -eq 0 ]]; then
- # Cleanup pktgen setup on exit if thats not "append mode"
- trap 'pg_ctrl "reset"' EXIT
- fi
-fi
+function trap_exit()
+{
+ # Cleanup pktgen setup on exit if thats not "append mode"
+ if [[ -z "$APPEND" ]] && [[ $EUID -eq 0 ]]; then
+ trap 'pg_ctrl "reset"' EXIT
+ fi
+}
## -- General shell tricks --