Commit a27ac539 authored by J.J. Martzki's avatar J.J. Martzki Committed by David S. Miller

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: default avatarJ.J. Martzki <mars14850@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f56d1eea
......@@ -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 --
......
......@@ -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"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment