2 # SPDX-License-Identifier: GPL-2.0
8 [ $cpus -gt 2 ] ||
exit $ksft_skip
10 readonly INITIAL_RPS_DEFAULT_MASK
=$
(cat /proc
/sys
/net
/core
/rps_default_mask
)
11 readonly TAG
="$(mktemp -u XXXXXX)"
12 readonly VETH
="veth${TAG}"
13 readonly NETNS
="ns-${TAG}"
16 ip netns add
"${NETNS}"
17 ip
-netns "${NETNS}" link
set lo up
21 echo $INITIAL_RPS_DEFAULT_MASK > /proc
/sys
/net
/core
/rps_default_mask
26 local rps_mask expected_rps_mask
=$4
32 [ -n "$netns" ] && cmd
="ip netns exec $netns $cmd"
34 rps_mask
=$
($cmd /sys
/class
/net
/$dev_name/queues
/rx-
0/rps_cpus
)
37 # In case there is more than 32 CPUs we need to remove commas from masks
38 rps_mask
=${rps_mask//,}
39 expected_rps_mask
=${expected_rps_mask//,}
40 if [ $rps_mask -eq $expected_rps_mask ]; then
43 echo "[fail] expected $expected_rps_mask found $rps_mask"
50 echo 0 > /proc
/sys
/net
/core
/rps_default_mask
52 chk_rps
"empty rps_default_mask" $NETNS lo
0
55 echo 1 > /proc
/sys
/net
/core
/rps_default_mask
57 chk_rps
"changing rps_default_mask dont affect existing devices" "" lo
$INITIAL_RPS_DEFAULT_MASK
59 echo 3 > /proc
/sys
/net
/core
/rps_default_mask
60 chk_rps
"changing rps_default_mask dont affect existing netns" $NETNS lo
0
62 ip link add name
$VETH type veth peer netns
$NETNS name
$VETH
63 ip link
set dev
$VETH up
64 ip
-n $NETNS link
set dev
$VETH up
65 chk_rps
"changing rps_default_mask affect newly created devices" "" $VETH 3
66 chk_rps
"changing rps_default_mask don't affect newly child netns[II]" $NETNS $VETH 0
71 chk_rps
"rps_default_mask is 0 by default in child netns" "$NETNS" lo
0
73 ip netns
exec $NETNS sysctl
-qw net.core.rps_default_mask
=1
74 ip link add name
$VETH type veth peer netns
$NETNS name
$VETH
75 chk_rps
"changing rps_default_mask in child ns don't affect the main one" "" lo
$INITIAL_RPS_DEFAULT_MASK
76 chk_rps
"changing rps_default_mask in child ns affects new childns devices" $NETNS $VETH 1
77 chk_rps
"changing rps_default_mask in child ns don't affect existing devices" $NETNS lo
0