diff options
author | Petr Machata <petrm@mellanox.com> | 2018-05-03 12:36:59 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-05-03 13:37:02 -0400 |
commit | f5ae57784ba805d0e8b11db1a7b2c17c5a07dd70 (patch) | |
tree | 1f6bed8d18e8db4b03b25662e2f85b7f5c66f1e8 /tools/testing/selftests/net/forwarding/lib.sh | |
parent | 41f405460a0471e2183a6d4149608a964f6dc63f (diff) | |
download | linux-f5ae57784ba805d0e8b11db1a7b2c17c5a07dd70.tar.gz |
selftests: forwarding: lib: Add sysctl_set(), sysctl_restore()
Add two helper functions: sysctl_set() to change the value of a given
sysctl setting, and sysctl_restore() to change it back to what it was.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/net/forwarding/lib.sh')
-rw-r--r-- | tools/testing/selftests/net/forwarding/lib.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 061c87bbf77c..e49e78b5cd3d 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -381,6 +381,23 @@ bridge_ageing_time_get() echo $((ageing_time / 100)) } +declare -A SYSCTL_ORIG +sysctl_set() +{ + local key=$1; shift + local value=$1; shift + + SYSCTL_ORIG[$key]=$(sysctl -n $key) + sysctl -qw $key=$value +} + +sysctl_restore() +{ + local key=$1; shift + + sysctl -qw $key=${SYSCTL_ORIG["$key"]} +} + forwarding_enable() { ipv4_fwd=$(sysctl -n net.ipv4.conf.all.forwarding) |