Skip to content

Commit

Permalink
selftests: forwarding: lib: Split sysctl_save() out of sysctl_set()
Browse files Browse the repository at this point in the history
In order to be able to save the current value of a sysctl without changing
it, split the relevant bit out of sysctl_set() into a new helper.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20240607151357.421181-5-petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Petr Machata authored and Jakub Kicinski committed Jun 12, 2024
1 parent 60bcfed commit 6f51aed
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/testing/selftests/net/forwarding/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1134,12 +1134,19 @@ bridge_ageing_time_get()
}

declare -A SYSCTL_ORIG
sysctl_save()
{
local key=$1; shift

SYSCTL_ORIG[$key]=$(sysctl -n $key)
}

sysctl_set()
{
local key=$1; shift
local value=$1; shift

SYSCTL_ORIG[$key]=$(sysctl -n $key)
sysctl_save "$key"
sysctl -qw $key="$value"
}

Expand Down

0 comments on commit 6f51aed

Please sign in to comment.