Skip to content

Commit

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

Expand Down Expand Up @@ -320,6 +322,9 @@ 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
ip link set ${NAME}${N} up || exit 1 ;;
OSX)
chown ${SUDO_USER} /dev/${NAME}${N} || exit 1
Expand Down Expand Up @@ -476,6 +481,15 @@ while true ; do
UPLINK="$2"
shift 2 ;;
esac ;;
--loss)
case "$2" in
"")
usage
exit 2 ;;
*)
LOSS="$2"
shift 2 ;;
esac ;;
-t|--tap)
case "$2" in
"")
Expand Down

0 comments on commit 0eaa6ed

Please sign in to comment.