]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
samples: pktgen: fix append mode failed issue
authorJ.J. Martzki <mars14850@gmail.com>
Sat, 1 Jul 2023 14:37:37 +0000 (22:37 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 3 Jul 2023 08:15:26 +0000 (09:15 +0100)
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>
samples/pktgen/functions.sh
samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh
samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh
samples/pktgen/pktgen_sample01_simple.sh
samples/pktgen/pktgen_sample02_multiqueue.sh
samples/pktgen/pktgen_sample03_burst_single_flow.sh
samples/pktgen/pktgen_sample04_many_flows.sh
samples/pktgen/pktgen_sample05_flow_per_thread.sh
samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh

index dd4e53ae9b734ed3f48ebd7662ab8f625b8cc2bf..c08cefb8eb1f5ad8a6eb177440c525e33a9037f9 100644 (file)
@@ -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 --
 
index 99ec0688b04453dc55f31290f75043d4bc1d8569..b4328db4a1640b5bc697f0ddfb428d79283b8fbe 100755 (executable)
@@ -33,6 +33,10 @@ root_check_run_with_sudo "$@"
 
 # Parameter parsing via include
 source ${basedir}/parameters.sh
+
+# Trap EXIT first
+trap_exit
+
 # Using invalid DST_MAC will cause the packets to get dropped in
 # ip_rcv() which is part of the test
 if [ -z "$DEST_IP" ]; then
index 04b0dd0c36d6552de1cfc2b733820facedafd5c5..f2beb512c5cd7d5b18c7a81d77c9be96305e2bac 100755 (executable)
@@ -14,6 +14,10 @@ root_check_run_with_sudo "$@"
 
 # Parameter parsing via include
 source ${basedir}/parameters.sh
+
+# Trap EXIT first
+trap_exit
+
 if [ -z "$DEST_IP" ]; then
     [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
 fi
index 09a92ea963f98b40431fc99079096215088ae0ab..cdb9f497f87da73a7f80abdcd5370f371acf67ef 100755 (executable)
@@ -13,6 +13,10 @@ root_check_run_with_sudo "$@"
 # - go look in parameters.sh to see which setting are avail
 # - required param is the interface "-i" stored in $DEV
 source ${basedir}/parameters.sh
+
+# Trap EXIT first
+trap_exit
+
 #
 # Set some default params, if they didn't get set
 if [ -z "$DEST_IP" ]; then
index 7fa41c84c32f77525cca9ea1eb2c5d51eec24673..93f33d7d0a81d10581008df93e104ce1d5a7d615 100755 (executable)
@@ -14,6 +14,9 @@ root_check_run_with_sudo "$@"
 # Required param: -i dev in $DEV
 source ${basedir}/parameters.sh
 
+# Trap EXIT first
+trap_exit
+
 [ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely
 
 # Base Config
index 8bf2fdffba16e64ef802dfda0ba093bec21d2ffa..8f8ed1ac46a0b640ae6c5806410c50e10e1c5292 100755 (executable)
@@ -25,6 +25,10 @@ root_check_run_with_sudo "$@"
 
 # Parameter parsing via include
 source ${basedir}/parameters.sh
+
+# Trap EXIT first
+trap_exit
+
 # Set some default params, if they didn't get set
 if [ -z "$DEST_IP" ]; then
     [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
index cff51f861506d12aeb3d08f75c7329a811518d84..65ed486ce4f1d2d7fa4336faecf40d077d8a1252 100755 (executable)
@@ -12,6 +12,10 @@ root_check_run_with_sudo "$@"
 
 # Parameter parsing via include
 source ${basedir}/parameters.sh
+
+# Trap EXIT first
+trap_exit
+
 # Set some default params, if they didn't get set
 if [ -z "$DEST_IP" ]; then
     [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
index 3578d0aa4ac55222e519e6c786f66842e30f4553..bcbc386b228483ce8fe10bbd673d153ffe88c63b 100755 (executable)
@@ -16,6 +16,10 @@ root_check_run_with_sudo "$@"
 
 # Parameter parsing via include
 source ${basedir}/parameters.sh
+
+# Trap EXIT first
+trap_exit
+
 # Set some default params, if they didn't get set
 if [ -z "$DEST_IP" ]; then
     [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
index 264cc5db9c4965fd5bcf12a27e8cddf09c1264a5..0c5409cb5bab811432825e2237e2c3e10914ab0d 100755 (executable)
@@ -14,6 +14,9 @@ root_check_run_with_sudo "$@"
 # Required param: -i dev in $DEV
 source ${basedir}/parameters.sh
 
+# Trap EXIT first
+trap_exit
+
 # Base Config
 [ -z "$COUNT" ]     && COUNT="20000000"   # Zero means indefinitely
 [ -z "$CLONE_SKB" ] && CLONE_SKB="0"