samples: pktgen: fix append mode failed issue
Subsystems (2)
PATCH 1/1 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.
--- samples/pktgen/functions.sh | 13 +++++++------ .../pktgen/pktgen_bench_xmit_mode_netif_receive.sh | 4 ++++ samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh | 4 ++++ samples/pktgen/pktgen_sample01_simple.sh | 4 ++++ samples/pktgen/pktgen_sample02_multiqueue.sh | 3 +++ samples/pktgen/pktgen_sample03_burst_single_flow.sh | 4 ++++ samples/pktgen/pktgen_sample04_many_flows.sh | 4 ++++ samples/pktgen/pktgen_sample05_flow_per_thread.sh | 4 ++++ ...ktgen_sample06_numa_awared_queue_irq_affinity.sh | 3 +++ 9 files changed, 37 insertions(+), 6 deletions(-)
samples/pktgen/functions.sh +7 -6
@@ -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 --
samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh +4 -0
@@ -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
samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh +4 -0
@@ -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
samples/pktgen/pktgen_sample01_simple.sh +4 -0
@@ -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
samples/pktgen/pktgen_sample02_multiqueue.sh +3 -0
@@ -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
samples/pktgen/pktgen_sample03_burst_single_flow.sh +4 -0
@@ -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"
samples/pktgen/pktgen_sample04_many_flows.sh +4 -0
@@ -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"
samples/pktgen/pktgen_sample05_flow_per_thread.sh +4 -0
@@ -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"
samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh +3 -0
@@ -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"
Signature · 1 line
2.39.2 (Apple Git-143)
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 9 lines · On Sat, 1 Jul 2023 22:37:37 +0800 you wrote:
Each sample script sources
functions.shbeforeparameters.shwhich 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.shand trap EXIT explicitly.[...]
Here is the summary with links:
- samples: pktgen: fix append mode failed issue
https://git.kernel.org/netdev/net/c/a27ac5390922
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html