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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -z "$APPEND" ]]; then
|
function trap_exit()
|
||||||
if [[ $EUID -eq 0 ]]; then
|
{
|
||||||
# Cleanup pktgen setup on exit if thats not "append mode"
|
# Cleanup pktgen setup on exit if thats not "append mode"
|
||||||
|
if [[ -z "$APPEND" ]] && [[ $EUID -eq 0 ]]; then
|
||||||
trap 'pg_ctrl "reset"' EXIT
|
trap 'pg_ctrl "reset"' EXIT
|
||||||
fi
|
fi
|
||||||
fi
|
}
|
||||||
|
|
||||||
## -- General shell tricks --
|
## -- General shell tricks --
|
||||||
|
|
||||||
|
@ -33,6 +33,10 @@ root_check_run_with_sudo "$@"
|
|||||||
|
|
||||||
# Parameter parsing via include
|
# Parameter parsing via include
|
||||||
source ${basedir}/parameters.sh
|
source ${basedir}/parameters.sh
|
||||||
|
|
||||||
|
# Trap EXIT first
|
||||||
|
trap_exit
|
||||||
|
|
||||||
# Using invalid DST_MAC will cause the packets to get dropped in
|
# Using invalid DST_MAC will cause the packets to get dropped in
|
||||||
# ip_rcv() which is part of the test
|
# ip_rcv() which is part of the test
|
||||||
if [ -z "$DEST_IP" ]; then
|
if [ -z "$DEST_IP" ]; then
|
||||||
|
@ -14,6 +14,10 @@ root_check_run_with_sudo "$@"
|
|||||||
|
|
||||||
# Parameter parsing via include
|
# Parameter parsing via include
|
||||||
source ${basedir}/parameters.sh
|
source ${basedir}/parameters.sh
|
||||||
|
|
||||||
|
# Trap EXIT first
|
||||||
|
trap_exit
|
||||||
|
|
||||||
if [ -z "$DEST_IP" ]; then
|
if [ -z "$DEST_IP" ]; then
|
||||||
[ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
|
[ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
|
||||||
fi
|
fi
|
||||||
|
@ -13,6 +13,10 @@ root_check_run_with_sudo "$@"
|
|||||||
# - go look in parameters.sh to see which setting are avail
|
# - go look in parameters.sh to see which setting are avail
|
||||||
# - required param is the interface "-i" stored in $DEV
|
# - required param is the interface "-i" stored in $DEV
|
||||||
source ${basedir}/parameters.sh
|
source ${basedir}/parameters.sh
|
||||||
|
|
||||||
|
# Trap EXIT first
|
||||||
|
trap_exit
|
||||||
|
|
||||||
#
|
#
|
||||||
# Set some default params, if they didn't get set
|
# Set some default params, if they didn't get set
|
||||||
if [ -z "$DEST_IP" ]; then
|
if [ -z "$DEST_IP" ]; then
|
||||||
|
@ -14,6 +14,9 @@ root_check_run_with_sudo "$@"
|
|||||||
# Required param: -i dev in $DEV
|
# Required param: -i dev in $DEV
|
||||||
source ${basedir}/parameters.sh
|
source ${basedir}/parameters.sh
|
||||||
|
|
||||||
|
# Trap EXIT first
|
||||||
|
trap_exit
|
||||||
|
|
||||||
[ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely
|
[ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely
|
||||||
|
|
||||||
# Base Config
|
# Base Config
|
||||||
|
@ -25,6 +25,10 @@ root_check_run_with_sudo "$@"
|
|||||||
|
|
||||||
# Parameter parsing via include
|
# Parameter parsing via include
|
||||||
source ${basedir}/parameters.sh
|
source ${basedir}/parameters.sh
|
||||||
|
|
||||||
|
# Trap EXIT first
|
||||||
|
trap_exit
|
||||||
|
|
||||||
# Set some default params, if they didn't get set
|
# Set some default params, if they didn't get set
|
||||||
if [ -z "$DEST_IP" ]; then
|
if [ -z "$DEST_IP" ]; then
|
||||||
[ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
|
[ -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
|
# Parameter parsing via include
|
||||||
source ${basedir}/parameters.sh
|
source ${basedir}/parameters.sh
|
||||||
|
|
||||||
|
# Trap EXIT first
|
||||||
|
trap_exit
|
||||||
|
|
||||||
# Set some default params, if they didn't get set
|
# Set some default params, if they didn't get set
|
||||||
if [ -z "$DEST_IP" ]; then
|
if [ -z "$DEST_IP" ]; then
|
||||||
[ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
|
[ -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
|
# Parameter parsing via include
|
||||||
source ${basedir}/parameters.sh
|
source ${basedir}/parameters.sh
|
||||||
|
|
||||||
|
# Trap EXIT first
|
||||||
|
trap_exit
|
||||||
|
|
||||||
# Set some default params, if they didn't get set
|
# Set some default params, if they didn't get set
|
||||||
if [ -z "$DEST_IP" ]; then
|
if [ -z "$DEST_IP" ]; then
|
||||||
[ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
|
[ -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
|
# Required param: -i dev in $DEV
|
||||||
source ${basedir}/parameters.sh
|
source ${basedir}/parameters.sh
|
||||||
|
|
||||||
|
# Trap EXIT first
|
||||||
|
trap_exit
|
||||||
|
|
||||||
# Base Config
|
# Base Config
|
||||||
[ -z "$COUNT" ] && COUNT="20000000" # Zero means indefinitely
|
[ -z "$COUNT" ] && COUNT="20000000" # Zero means indefinitely
|
||||||
[ -z "$CLONE_SKB" ] && CLONE_SKB="0"
|
[ -z "$CLONE_SKB" ] && CLONE_SKB="0"
|
||||||
|
Loading…
Reference in New Issue
Block a user