Commit d51d10aa authored by Petr Machata's avatar Petr Machata Committed by David S. Miller
Browse files

selftests: forwarding: Use sysctl_set(), sysctl_restore()



Instead of hand-managing the sysctl set and restore, use the wrappers
sysctl_set() and sysctl_restore() to do the bookkeeping automatically.

Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
Reviewed-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f5ae5778
Loading
Loading
Loading
Loading
+4 −7
Original line number Original line Diff line number Diff line
@@ -400,17 +400,14 @@ sysctl_restore()


forwarding_enable()
forwarding_enable()
{
{
       ipv4_fwd=$(sysctl -n net.ipv4.conf.all.forwarding)
	sysctl_set net.ipv4.conf.all.forwarding 1
       ipv6_fwd=$(sysctl -n net.ipv6.conf.all.forwarding)
	sysctl_set net.ipv6.conf.all.forwarding 1

       sysctl -q -w net.ipv4.conf.all.forwarding=1
       sysctl -q -w net.ipv6.conf.all.forwarding=1
}
}


forwarding_restore()
forwarding_restore()
{
{
       sysctl -q -w net.ipv6.conf.all.forwarding=$ipv6_fwd
	sysctl_restore net.ipv6.conf.all.forwarding
       sysctl -q -w net.ipv4.conf.all.forwarding=$ipv4_fwd
	sysctl_restore net.ipv4.conf.all.forwarding
}
}


tc_offload_check()
tc_offload_check()
+2 −5
Original line number Original line Diff line number Diff line
@@ -36,9 +36,7 @@ setup_prepare()


	# This test downs $swp3, which deletes the configured IPv6 address
	# This test downs $swp3, which deletes the configured IPv6 address
	# unless this sysctl is set.
	# unless this sysctl is set.
	local key=net.ipv6.conf.$swp3.keep_addr_on_down
	sysctl_set net.ipv6.conf.$swp3.keep_addr_on_down 1
	SWP3_KEEP_ADDR_ON_DOWN=$(sysctl -n $key)
	sysctl -qw $key=1


	ip address add dev $swp3 192.0.2.129/28
	ip address add dev $swp3 192.0.2.129/28
	ip address add dev $h3 192.0.2.130/28
	ip address add dev $h3 192.0.2.130/28
@@ -57,8 +55,7 @@ cleanup()
	ip address del dev $h3 192.0.2.130/28
	ip address del dev $h3 192.0.2.130/28
	ip address del dev $swp3 192.0.2.129/28
	ip address del dev $swp3 192.0.2.129/28


	local key=net.ipv6.conf.$swp3.keep_addr_on_down
	sysctl_restore net.ipv6.conf.$swp3.keep_addr_on_down
	sysctl -qw $key=$SWP3_KEEP_ADDR_ON_DOWN


	mirror_gre_topo_destroy
	mirror_gre_topo_destroy
	vrf_cleanup
	vrf_cleanup
+4 −8
Original line number Original line Diff line number Diff line
@@ -205,13 +205,11 @@ multipath4_test()
       local weight_rp13=$3
       local weight_rp13=$3
       local t0_rp12 t0_rp13 t1_rp12 t1_rp13
       local t0_rp12 t0_rp13 t1_rp12 t1_rp13
       local packets_rp12 packets_rp13
       local packets_rp12 packets_rp13
       local hash_policy


       # Transmit multiple flows from h1 to h2 and make sure they are
       # Transmit multiple flows from h1 to h2 and make sure they are
       # distributed between both multipath links (rp12 and rp13)
       # distributed between both multipath links (rp12 and rp13)
       # according to the configured weights.
       # according to the configured weights.
       hash_policy=$(sysctl -n net.ipv4.fib_multipath_hash_policy)
       sysctl_set net.ipv4.fib_multipath_hash_policy 1
       sysctl -q -w net.ipv4.fib_multipath_hash_policy=1
       ip route replace 198.51.100.0/24 vrf vrf-r1 \
       ip route replace 198.51.100.0/24 vrf vrf-r1 \
               nexthop via 169.254.2.22 dev $rp12 weight $weight_rp12 \
               nexthop via 169.254.2.22 dev $rp12 weight $weight_rp12 \
               nexthop via 169.254.3.23 dev $rp13 weight $weight_rp13
               nexthop via 169.254.3.23 dev $rp13 weight $weight_rp13
@@ -233,7 +231,7 @@ multipath4_test()
       ip route replace 198.51.100.0/24 vrf vrf-r1 \
       ip route replace 198.51.100.0/24 vrf vrf-r1 \
               nexthop via 169.254.2.22 dev $rp12 \
               nexthop via 169.254.2.22 dev $rp12 \
               nexthop via 169.254.3.23 dev $rp13
               nexthop via 169.254.3.23 dev $rp13
       sysctl -q -w net.ipv4.fib_multipath_hash_policy=$hash_policy
       sysctl_restore net.ipv4.fib_multipath_hash_policy
}
}


multipath6_l4_test()
multipath6_l4_test()
@@ -243,13 +241,11 @@ multipath6_l4_test()
       local weight_rp13=$3
       local weight_rp13=$3
       local t0_rp12 t0_rp13 t1_rp12 t1_rp13
       local t0_rp12 t0_rp13 t1_rp12 t1_rp13
       local packets_rp12 packets_rp13
       local packets_rp12 packets_rp13
       local hash_policy


       # Transmit multiple flows from h1 to h2 and make sure they are
       # Transmit multiple flows from h1 to h2 and make sure they are
       # distributed between both multipath links (rp12 and rp13)
       # distributed between both multipath links (rp12 and rp13)
       # according to the configured weights.
       # according to the configured weights.
       hash_policy=$(sysctl -n net.ipv6.fib_multipath_hash_policy)
       sysctl_set net.ipv6.fib_multipath_hash_policy 1
       sysctl -q -w net.ipv6.fib_multipath_hash_policy=1


       ip route replace 2001:db8:2::/64 vrf vrf-r1 \
       ip route replace 2001:db8:2::/64 vrf vrf-r1 \
	       nexthop via fe80:2::22 dev $rp12 weight $weight_rp12 \
	       nexthop via fe80:2::22 dev $rp12 weight $weight_rp12 \
@@ -272,7 +268,7 @@ multipath6_l4_test()
	       nexthop via fe80:2::22 dev $rp12 \
	       nexthop via fe80:2::22 dev $rp12 \
	       nexthop via fe80:3::23 dev $rp13
	       nexthop via fe80:3::23 dev $rp13


       sysctl -q -w net.ipv6.fib_multipath_hash_policy=$hash_policy
       sysctl_restore net.ipv6.fib_multipath_hash_policy
}
}


multipath6_test()
multipath6_test()