diff options
author | J.J. Martzki <mars14850@gmail.com> | 2023-07-01 17:37:37 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-07-03 11:15:26 +0300 |
commit | a27ac5390922059867f645eefd978e533d7af902 (patch) | |
tree | cc707a1806e2f0e82b1bc8cd9d088dd9e0838ae2 | |
parent | f56d1eeaeabf3aa613157b26aa07215fcd2c5719 (diff) | |
download | linux-a27ac5390922059867f645eefd978e533d7af902.tar.xz |
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>
-rw-r--r-- | samples/pktgen/functions.sh | 13 | ||||
-rwxr-xr-x | samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh | 4 | ||||
-rwxr-xr-x | samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh | 4 | ||||
-rwxr-xr-x | samples/pktgen/pktgen_sample01_simple.sh | 4 | ||||
-rwxr-xr-x | samples/pktgen/pktgen_sample02_multiqueue.sh | 3 | ||||
-rwxr-xr-x | samples/pktgen/pktgen_sample03_burst_single_flow.sh | 4 | ||||
-rwxr-xr-x | samples/pktgen/pktgen_sample04_many_flows.sh | 4 | ||||
-rwxr-xr-x | samples/pktgen/pktgen_sample05_flow_per_thread.sh | 4 | ||||
-rwxr-xr-x | samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh | 3 |
9 files changed, 37 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 -- diff --git a/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh b/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh index 99ec0688b044..b4328db4a164 100755 --- a/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh +++ b/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh @@ -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 diff --git a/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh b/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh index 04b0dd0c36d6..f2beb512c5cd 100755 --- a/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh +++ b/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh @@ -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 diff --git a/samples/pktgen/pktgen_sample01_simple.sh b/samples/pktgen/pktgen_sample01_simple.sh index 09a92ea963f9..cdb9f497f87d 100755 --- a/samples/pktgen/pktgen_sample01_simple.sh +++ b/samples/pktgen/pktgen_sample01_simple.sh @@ -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 diff --git a/samples/pktgen/pktgen_sample02_multiqueue.sh b/samples/pktgen/pktgen_sample02_multiqueue.sh index 7fa41c84c32f..93f33d7d0a81 100755 --- a/samples/pktgen/pktgen_sample02_multiqueue.sh +++ b/samples/pktgen/pktgen_sample02_multiqueue.sh @@ -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 diff --git a/samples/pktgen/pktgen_sample03_burst_single_flow.sh b/samples/pktgen/pktgen_sample03_burst_single_flow.sh index 8bf2fdffba16..8f8ed1ac46a0 100755 --- a/samples/pktgen/pktgen_sample03_burst_single_flow.sh +++ b/samples/pktgen/pktgen_sample03_burst_single_flow.sh @@ -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" diff --git a/samples/pktgen/pktgen_sample04_many_flows.sh b/samples/pktgen/pktgen_sample04_many_flows.sh index cff51f861506..65ed486ce4f1 100755 --- a/samples/pktgen/pktgen_sample04_many_flows.sh +++ b/samples/pktgen/pktgen_sample04_many_flows.sh @@ -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" diff --git a/samples/pktgen/pktgen_sample05_flow_per_thread.sh b/samples/pktgen/pktgen_sample05_flow_per_thread.sh index 3578d0aa4ac5..bcbc386b2284 100755 --- a/samples/pktgen/pktgen_sample05_flow_per_thread.sh +++ b/samples/pktgen/pktgen_sample05_flow_per_thread.sh @@ -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" diff --git a/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh b/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh index 264cc5db9c49..0c5409cb5bab 100755 --- a/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh +++ b/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh @@ -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" |