Skip to content

Commit 6182c5c

Browse files
troglobitdavem330
authored andcommitted
selftests: forwarding: multiple instances in tcpdump helper
Extend tcpdump_start() & C:o to handle multiple instances. Useful when observing bridge operation, e.g., unicast learning/flooding, and any case of multicast distribution (to these ports but not that one ...). This means the interface argument is now a mandatory argument to all tcpdump_*() functions, hence the changes to the ocelot flower test. Signed-off-by: Joachim Wiberg <troglobit@gmail.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent fe32dff commit 6182c5c

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,15 @@ test_vlan_pop()
215215

216216
sleep 1
217217

218-
tcpdump_stop
218+
tcpdump_stop $eth2
219219

220-
if tcpdump_show | grep -q "$eth3_mac > $eth2_mac, ethertype IPv4"; then
220+
if tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, ethertype IPv4"; then
221221
echo "OK"
222222
else
223223
echo "FAIL"
224224
fi
225225

226-
tcpdump_cleanup
226+
tcpdump_cleanup $eth2
227227
}
228228

229229
test_vlan_push()
@@ -236,15 +236,15 @@ test_vlan_push()
236236

237237
sleep 1
238238

239-
tcpdump_stop
239+
tcpdump_stop $eth3.100
240240

241-
if tcpdump_show | grep -q "$eth2_mac > $eth3_mac"; then
241+
if tcpdump_show $eth3.100 | grep -q "$eth2_mac > $eth3_mac"; then
242242
echo "OK"
243243
else
244244
echo "FAIL"
245245
fi
246246

247-
tcpdump_cleanup
247+
tcpdump_cleanup $eth3.100
248248
}
249249

250250
test_vlan_ingress_modify()
@@ -267,15 +267,15 @@ test_vlan_ingress_modify()
267267

268268
sleep 1
269269

270-
tcpdump_stop
270+
tcpdump_stop $eth2
271271

272-
if tcpdump_show | grep -q "$eth3_mac > $eth2_mac, .* vlan 300"; then
272+
if tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, .* vlan 300"; then
273273
echo "OK"
274274
else
275275
echo "FAIL"
276276
fi
277277

278-
tcpdump_cleanup
278+
tcpdump_cleanup $eth2
279279

280280
tc filter del dev $eth0 ingress chain $(IS1 2) pref 3
281281

@@ -305,15 +305,15 @@ test_vlan_egress_modify()
305305

306306
sleep 1
307307

308-
tcpdump_stop
308+
tcpdump_stop $eth2
309309

310-
if tcpdump_show | grep -q "$eth3_mac > $eth2_mac, .* vlan 300"; then
310+
if tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, .* vlan 300"; then
311311
echo "OK"
312312
else
313313
echo "FAIL"
314314
fi
315315

316-
tcpdump_cleanup
316+
tcpdump_cleanup $eth2
317317

318318
tc filter del dev $eth1 egress chain $(ES0) pref 3
319319
tc qdisc del dev $eth1 clsact

tools/testing/selftests/net/forwarding/lib.sh

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,13 +1386,17 @@ stop_traffic()
13861386
{ kill %% && wait %%; } 2>/dev/null
13871387
}
13881388

1389+
declare -A cappid
1390+
declare -A capfile
1391+
declare -A capout
1392+
13891393
tcpdump_start()
13901394
{
13911395
local if_name=$1; shift
13921396
local ns=$1; shift
13931397

1394-
capfile=$(mktemp)
1395-
capout=$(mktemp)
1398+
capfile[$if_name]=$(mktemp)
1399+
capout[$if_name]=$(mktemp)
13961400

13971401
if [ -z $ns ]; then
13981402
ns_cmd=""
@@ -1407,26 +1411,34 @@ tcpdump_start()
14071411
fi
14081412

14091413
$ns_cmd tcpdump $TCPDUMP_EXTRA_FLAGS -e -n -Q in -i $if_name \
1410-
-s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 &
1411-
cappid=$!
1414+
-s 65535 -B 32768 $capuser -w ${capfile[$if_name]} \
1415+
> "${capout[$if_name]}" 2>&1 &
1416+
cappid[$if_name]=$!
14121417

14131418
sleep 1
14141419
}
14151420

14161421
tcpdump_stop()
14171422
{
1418-
$ns_cmd kill $cappid
1423+
local if_name=$1
1424+
local pid=${cappid[$if_name]}
1425+
1426+
$ns_cmd kill "$pid" && wait "$pid"
14191427
sleep 1
14201428
}
14211429

14221430
tcpdump_cleanup()
14231431
{
1424-
rm $capfile $capout
1432+
local if_name=$1
1433+
1434+
rm ${capfile[$if_name]} ${capout[$if_name]}
14251435
}
14261436

14271437
tcpdump_show()
14281438
{
1429-
tcpdump -e -n -r $capfile 2>&1
1439+
local if_name=$1
1440+
1441+
tcpdump -e -n -r ${capfile[$if_name]} 2>&1
14301442
}
14311443

14321444
# return 0 if the packet wasn't seen on host2_if or 1 if it was

0 commit comments

Comments
 (0)