Skip to content

Commit

Permalink
selftests: forwarding: lib: Add mtu_set(), mtu_restore()
Browse files Browse the repository at this point in the history
Some selftests need to tweak MTU of an interface, and naturally should
at teardown restore the MTU back to the original value. Add two
functions to facilitate this MTU handling: mtu_set() to change MTU
value, and mtu_reset() to change it back to what it was before.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Petr Machata authored and David S. Miller committed Sep 20, 2018
1 parent 3136a36 commit a381ed1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tools/testing/selftests/net/forwarding/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,23 @@ forwarding_restore()
sysctl_restore net.ipv4.conf.all.forwarding
}

declare -A MTU_ORIG
mtu_set()
{
local dev=$1; shift
local mtu=$1; shift

MTU_ORIG["$dev"]=$(ip -j link show dev $dev | jq -e '.[].mtu')
ip link set dev $dev mtu $mtu
}

mtu_restore()
{
local dev=$1; shift

ip link set dev $dev mtu ${MTU_ORIG["$dev"]}
}

tc_offload_check()
{
local num_netifs=${1:-$NUM_NETIFS}
Expand Down

0 comments on commit a381ed1

Please sign in to comment.