diff options
| author | Petr Machata <petrm@mellanox.com> | 2018-05-03 06:36:59 -0400 |
|---|---|---|
| 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) | |
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() | |||
| 381 | echo $((ageing_time / 100)) | 381 | echo $((ageing_time / 100)) |
| 382 | } | 382 | } |
| 383 | 383 | ||
| 384 | declare -A SYSCTL_ORIG | ||
| 385 | sysctl_set() | ||
| 386 | { | ||
| 387 | local key=$1; shift | ||
| 388 | local value=$1; shift | ||
| 389 | |||
| 390 | SYSCTL_ORIG[$key]=$(sysctl -n $key) | ||
| 391 | sysctl -qw $key=$value | ||
| 392 | } | ||
| 393 | |||
| 394 | sysctl_restore() | ||
| 395 | { | ||
| 396 | local key=$1; shift | ||
| 397 | |||
| 398 | sysctl -qw $key=${SYSCTL_ORIG["$key"]} | ||
| 399 | } | ||
| 400 | |||
| 384 | forwarding_enable() | 401 | forwarding_enable() |
| 385 | { | 402 | { |
| 386 | ipv4_fwd=$(sysctl -n net.ipv4.conf.all.forwarding) | 403 | ipv4_fwd=$(sysctl -n net.ipv4.conf.all.forwarding) |
