Skip to content

Commit c99d57d

Browse files
Geliang Tangdavem330
authored andcommitted
selftests: mptcp: use pm_nl endpoint ops
Use those newly added pm_nl endpoint ops helpers to replace all 'pm_nl_ctl' commands with 'limits', 'add', 'del', 'flush', 'show' and 'set' arguments in scripts mptcp_sockopt.sh and simult_flows.sh. In pm_netlink.sh, add wrappers of there helpers to make the function names shorter. Then use the wrappers to replace all 'pm_nl_ctl' commands. Signed-off-by: Geliang Tang <[email protected]> Reviewed-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 441c6be commit c99d57d

File tree

3 files changed

+89
-61
lines changed

3 files changed

+89
-61
lines changed

tools/testing/selftests/net/mptcp/mptcp_sockopt.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ init()
5858
# let $ns2 reach any $ns1 address from any interface
5959
ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i
6060

61-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.$i.1 flags signal
62-
ip netns exec $ns1 ./pm_nl_ctl add dead:beef:$i::1 flags signal
61+
mptcp_lib_pm_nl_add_endpoint "${ns1}" "10.0.${i}.1" flags signal
62+
mptcp_lib_pm_nl_add_endpoint "${ns1}" "dead:beef:${i}::1" flags signal
6363

64-
ip netns exec $ns2 ./pm_nl_ctl add 10.0.$i.2 flags signal
65-
ip netns exec $ns2 ./pm_nl_ctl add dead:beef:$i::2 flags signal
64+
mptcp_lib_pm_nl_add_endpoint "${ns2}" "10.0.${i}.2" flags signal
65+
mptcp_lib_pm_nl_add_endpoint "${ns2}" "dead:beef:${i}::2" flags signal
6666
done
6767

68-
ip netns exec $ns1 ./pm_nl_ctl limits 8 8
69-
ip netns exec $ns2 ./pm_nl_ctl limits 8 8
68+
mptcp_lib_pm_nl_set_limits "${ns1}" 8 8
69+
mptcp_lib_pm_nl_set_limits "${ns2}" 8 8
7070

7171
add_mark_rules $ns1 1
7272
add_mark_rules $ns2 2

tools/testing/selftests/net/mptcp/pm_netlink.sh

Lines changed: 80 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,36 @@ change_address() {
8686
fi
8787
}
8888

89+
set_limits()
90+
{
91+
mptcp_lib_pm_nl_set_limits "${ns1}" "${@}"
92+
}
93+
94+
add_endpoint()
95+
{
96+
mptcp_lib_pm_nl_add_endpoint "${ns1}" "${@}"
97+
}
98+
99+
del_endpoint()
100+
{
101+
mptcp_lib_pm_nl_del_endpoint "${ns1}" "${@}"
102+
}
103+
104+
flush_endpoint()
105+
{
106+
mptcp_lib_pm_nl_flush_endpoint "${ns1}"
107+
}
108+
109+
show_endpoints()
110+
{
111+
mptcp_lib_pm_nl_show_endpoints "${ns1}"
112+
}
113+
114+
change_endpoint()
115+
{
116+
mptcp_lib_pm_nl_change_endpoint "${ns1}" "${@}"
117+
}
118+
89119
check()
90120
{
91121
local cmd="$1"
@@ -107,47 +137,47 @@ check()
107137
fi
108138
}
109139

110-
check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "defaults addr list"
140+
check "show_endpoints" "" "defaults addr list"
111141

112142
default_limits="$(get_limits)"
113143
if mptcp_lib_expect_all_features; then
114144
check "get_limits" "$(format_limits 0 2)" "defaults limits"
115145
fi
116146

117-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1
118-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.2 flags subflow dev lo
119-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 flags signal,backup
147+
add_endpoint 10.0.1.1
148+
add_endpoint 10.0.1.2 flags subflow dev lo
149+
add_endpoint 10.0.1.3 flags signal,backup
120150
check "get_endpoint 1" "$(format_endpoints "1,10.0.1.1")" "simple add/get addr"
121151

122-
check "ip netns exec $ns1 ./pm_nl_ctl dump" \
152+
check "show_endpoints" \
123153
"$(format_endpoints "1,10.0.1.1" \
124154
"2,10.0.1.2,subflow,lo" \
125155
"3,10.0.1.3,signal backup")" "dump addrs"
126156

127-
ip netns exec $ns1 ./pm_nl_ctl del 2
157+
del_endpoint 2
128158
check "get_endpoint 2" "" "simple del addr"
129-
check "ip netns exec $ns1 ./pm_nl_ctl dump" \
159+
check "show_endpoints" \
130160
"$(format_endpoints "1,10.0.1.1" \
131161
"3,10.0.1.3,signal backup")" "dump addrs after del"
132162

133-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 2>/dev/null
163+
add_endpoint 10.0.1.3 2>/dev/null
134164
check "get_endpoint 4" "" "duplicate addr"
135165

136-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.4 flags signal
166+
add_endpoint 10.0.1.4 flags signal
137167
check "get_endpoint 4" "$(format_endpoints "4,10.0.1.4,signal")" "id addr increment"
138168

139169
for i in $(seq 5 9); do
140-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.$i flags signal >/dev/null 2>&1
170+
add_endpoint "10.0.1.${i}" flags signal >/dev/null 2>&1
141171
done
142172
check "get_endpoint 9" "$(format_endpoints "9,10.0.1.9,signal")" "hard addr limit"
143173
check "get_endpoint 10" "" "above hard addr limit"
144174

145-
ip netns exec $ns1 ./pm_nl_ctl del 9
175+
del_endpoint 9
146176
for i in $(seq 10 255); do
147-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.9 id $i
148-
ip netns exec $ns1 ./pm_nl_ctl del $i
177+
add_endpoint 10.0.0.9 id "${i}"
178+
del_endpoint "${i}"
149179
done
150-
check "ip netns exec $ns1 ./pm_nl_ctl dump" \
180+
check "show_endpoints" \
151181
"$(format_endpoints "1,10.0.1.1" \
152182
"3,10.0.1.3,signal backup" \
153183
"4,10.0.1.4,signal" \
@@ -156,28 +186,28 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" \
156186
"7,10.0.1.7,signal" \
157187
"8,10.0.1.8,signal")" "id limit"
158188

159-
ip netns exec $ns1 ./pm_nl_ctl flush
160-
check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "flush addrs"
189+
flush_endpoint
190+
check "show_endpoints" "" "flush addrs"
161191

162-
ip netns exec $ns1 ./pm_nl_ctl limits 9 1 2>/dev/null
192+
set_limits 9 1 2>/dev/null
163193
check "get_limits" "${default_limits}" "rcv addrs above hard limit"
164194

165-
ip netns exec $ns1 ./pm_nl_ctl limits 1 9 2>/dev/null
195+
set_limits 1 9 2>/dev/null
166196
check "get_limits" "${default_limits}" "subflows above hard limit"
167197

168-
ip netns exec $ns1 ./pm_nl_ctl limits 8 8
198+
set_limits 8 8
169199
check "get_limits" "$(format_limits 8 8)" "set limits"
170200

171-
ip netns exec $ns1 ./pm_nl_ctl flush
172-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1
173-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.2
174-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 id 100
175-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.4
176-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.5 id 254
177-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.6
178-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.7
179-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.8
180-
check "ip netns exec $ns1 ./pm_nl_ctl dump" \
201+
flush_endpoint
202+
add_endpoint 10.0.1.1
203+
add_endpoint 10.0.1.2
204+
add_endpoint 10.0.1.3 id 100
205+
add_endpoint 10.0.1.4
206+
add_endpoint 10.0.1.5 id 254
207+
add_endpoint 10.0.1.6
208+
add_endpoint 10.0.1.7
209+
add_endpoint 10.0.1.8
210+
check "show_endpoints" \
181211
"$(format_endpoints "1,10.0.1.1" \
182212
"2,10.0.1.2" \
183213
"3,10.0.1.7" \
@@ -187,16 +217,16 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" \
187217
"254,10.0.1.5" \
188218
"255,10.0.1.6")" "set ids"
189219

190-
ip netns exec $ns1 ./pm_nl_ctl flush
191-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.1
192-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.2 id 254
193-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.3
194-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.4
195-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.5 id 253
196-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.6
197-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.7
198-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.8
199-
check "ip netns exec $ns1 ./pm_nl_ctl dump" \
220+
flush_endpoint
221+
add_endpoint 10.0.0.1
222+
add_endpoint 10.0.0.2 id 254
223+
add_endpoint 10.0.0.3
224+
add_endpoint 10.0.0.4
225+
add_endpoint 10.0.0.5 id 253
226+
add_endpoint 10.0.0.6
227+
add_endpoint 10.0.0.7
228+
add_endpoint 10.0.0.8
229+
check "show_endpoints" \
200230
"$(format_endpoints "1,10.0.0.1" \
201231
"2,10.0.0.4" \
202232
"3,10.0.0.6" \
@@ -206,28 +236,26 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" \
206236
"254,10.0.0.2" \
207237
"255,10.0.0.3")" "wrap-around ids"
208238

209-
ip netns exec $ns1 ./pm_nl_ctl flush
210-
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 flags subflow
239+
flush_endpoint
240+
add_endpoint 10.0.1.1 flags subflow
211241
change_address 10.0.1.1 backup
212-
check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow backup")" \
242+
check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow backup")" \
213243
"set flags (backup)"
214244
change_address 10.0.1.1 nobackup
215-
check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow")" \
245+
check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow")" \
216246
" (nobackup)"
217247

218248
# fullmesh support has been added later
219-
ip netns exec $ns1 ./pm_nl_ctl set id 1 flags fullmesh 2>/dev/null
220-
if ip netns exec $ns1 ./pm_nl_ctl dump | grep -q "fullmesh" ||
249+
change_endpoint 1 fullmesh 2>/dev/null
250+
if show_endpoints | grep -q "fullmesh" ||
221251
mptcp_lib_expect_all_features; then
222-
check "ip netns exec $ns1 ./pm_nl_ctl dump" \
223-
"$(format_endpoints "1,10.0.1.1,subflow fullmesh")" \
252+
check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow fullmesh")" \
224253
" (fullmesh)"
225-
ip netns exec $ns1 ./pm_nl_ctl set id 1 flags nofullmesh
226-
check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow")" \
254+
change_endpoint 1 nofullmesh
255+
check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow")" \
227256
" (nofullmesh)"
228-
ip netns exec $ns1 ./pm_nl_ctl set id 1 flags backup,fullmesh
229-
check "ip netns exec $ns1 ./pm_nl_ctl dump" \
230-
"$(format_endpoints "1,10.0.1.1,subflow backup fullmesh")" \
257+
change_endpoint 1 backup,fullmesh
258+
check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow backup fullmesh")" \
231259
" (backup,fullmesh)"
232260
else
233261
for st in fullmesh nofullmesh backup,fullmesh; do

tools/testing/selftests/net/mptcp/simult_flows.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ setup()
8585
ip -net "$ns1" route add default via 10.0.2.2 metric 101
8686
ip -net "$ns1" route add default via dead:beef:2::2 metric 101
8787

88-
ip netns exec "$ns1" ./pm_nl_ctl limits 1 1
89-
ip netns exec "$ns1" ./pm_nl_ctl add 10.0.2.1 dev ns1eth2 flags subflow
88+
mptcp_lib_pm_nl_set_limits "${ns1}" 1 1
89+
mptcp_lib_pm_nl_add_endpoint "${ns1}" 10.0.2.1 dev ns1eth2 flags subflow
9090

9191
ip -net "$ns2" addr add 10.0.1.2/24 dev ns2eth1
9292
ip -net "$ns2" addr add dead:beef:1::2/64 dev ns2eth1 nodad
@@ -108,7 +108,7 @@ setup()
108108
ip -net "$ns3" route add default via 10.0.3.2
109109
ip -net "$ns3" route add default via dead:beef:3::2
110110

111-
ip netns exec "$ns3" ./pm_nl_ctl limits 1 1
111+
mptcp_lib_pm_nl_set_limits "${ns3}" 1 1
112112

113113
# debug build can slow down measurably the test program
114114
# we use quite tight time limit on the run-time, to ensure

0 commit comments

Comments
 (0)