mirror of
https://github.com/torvalds/linux.git
synced 2026-11-27 17:02:17 +00:00
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 <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
committed by
David S. Miller
parent
41f405460a
commit
f5ae57784b
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user