Skip to content

Commit

Permalink
tapsetup: add --delay option
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Nov 11, 2022
1 parent 0eaa6ed commit 1bbf4a7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions dist/tools/tapsetup/tapsetup
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ usage() {
echo " (ignored on OSX and FreeBSD)" >&2
echo " --loss: Optional loss %" >&2
echo " (ignored on OSX and FreeBSD)" >&2
echo " --delay: Optional delay ms" >&2
echo " (ignored on OSX and FreeBSD)" >&2
echo " -h, --help: Prints this text" >&2
}

Expand Down Expand Up @@ -322,9 +324,7 @@ create_iface() {
if [ -z "${TUNNAME}" ]; then
ip link set dev ${NAME}${N} master ${BRNAME} || exit 1
fi
if [ -n "${LOSS}" ]; then
tc qdisc add dev ${NAME}${N} root netem loss ${LOSS}
fi
tc qdisc add dev ${NAME}${N} root netem ${DELAY} ${LOSS}
ip link set ${NAME}${N} up || exit 1 ;;
OSX)
chown ${SUDO_USER} /dev/${NAME}${N} || exit 1
Expand Down Expand Up @@ -487,7 +487,16 @@ while true ; do
usage
exit 2 ;;
*)
LOSS="$2"
LOSS="loss random $2"
shift 2 ;;
esac ;;
--delay)
case "$2" in
"")
usage
exit 2 ;;
*)
DELAY="delay $2"
shift 2 ;;
esac ;;
-t|--tap)
Expand Down

0 comments on commit 1bbf4a7

Please sign in to comment.