mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
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>
This commit is contained in:
parent
f56d1eeaea
commit
a27ac53909
@ -108,12 +108,13 @@ function pgset() {
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ -z "$APPEND" ]]; then
|
||||
if [[ $EUID -eq 0 ]]; then
|
||||
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
|
||||
fi
|
||||
}
|
||||
|
||||
## -- General shell tricks --
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user