Skip to content

Commit 2379795

Browse files
vladimirolteandavem330
authored andcommitted
selftests: net: local_termination: add PTP frames to the mix
A breakage in the felix DSA driver shows we do not have enough test coverage. More generally, it is sufficiently special that it is likely drivers will treat it differently. This is not meant to be a full PTP test, it just makes sure that PTP packets sent to the different addresses corresponding to their profiles are received correctly. The local_termination selftest seemed like the most appropriate place for this addition. PTP RX/TX in some cases makes no sense (over a bridge) and this is why $skip_ptp exists. And in others - PTP over a bridge port - the IP stack needs convincing through the available bridge netfilter hooks to leave the PTP packets alone and not stolen by the bridge rx_handler. It is safe to assume that users have that figured out already. This is a driver level test, and by using tcpdump, all that extra setup is out of scope here. send_non_ip() was an unfinished idea; written but never used. Replace it with a more generic send_raw(), and send 3 PTP packet types times 3 transports. Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9aa3749 commit 2379795

File tree

1 file changed

+148
-13
lines changed

1 file changed

+148
-13
lines changed

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

Lines changed: 148 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,84 @@ UNKNOWN_MACV6_MC_ADDR1="33:33:01:02:03:05"
3939
UNKNOWN_MACV6_MC_ADDR2="33:33:01:02:03:06"
4040
UNKNOWN_MACV6_MC_ADDR3="33:33:01:02:03:07"
4141

42-
NON_IP_MC="01:02:03:04:05:06"
43-
NON_IP_PKT="00:04 48:45:4c:4f"
44-
BC="ff:ff:ff:ff:ff:ff"
42+
PTP_1588_L2_SYNC=" \
43+
01:1b:19:00:00:00 00:00:de:ad:be:ef 88:f7 00 02 \
44+
00 2c 00 00 02 00 00 00 00 00 00 00 00 00 00 00 \
45+
00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 00 00 \
46+
00 00 00 00 00 00 00 00 00 00"
47+
PTP_1588_L2_FOLLOW_UP=" \
48+
01:1b:19:00:00:00 00:00:de:ad:be:ef 88:f7 08 02 \
49+
00 2c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
50+
00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 02 00 \
51+
00 00 66 83 c5 f1 17 97 ed f0"
52+
PTP_1588_L2_PDELAY_REQ=" \
53+
01:80:c2:00:00:0e 00:00:de:ad:be:ef 88:f7 02 02 \
54+
00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
55+
00 00 3e 37 63 ff fe cf 17 0e 00 01 00 06 05 7f \
56+
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
57+
00 00 00 00"
58+
PTP_1588_IPV4_SYNC=" \
59+
01:00:5e:00:01:81 00:00:de:ad:be:ef 08:00 45 00 \
60+
00 48 0a 9a 40 00 01 11 cb 88 c0 00 02 01 e0 00 \
61+
01 81 01 3f 01 3f 00 34 a3 c8 00 02 00 2c 00 00 \
62+
02 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 37 \
63+
63 ff fe cf 17 0e 00 01 00 00 00 00 00 00 00 00 \
64+
00 00 00 00 00 00"
65+
PTP_1588_IPV4_FOLLOW_UP="
66+
01:00:5e:00:01:81 00:00:de:ad:be:ef 08:00 45 00 \
67+
00 48 0a 9b 40 00 01 11 cb 87 c0 00 02 01 e0 00 \
68+
01 81 01 40 01 40 00 34 a3 c8 08 02 00 2c 00 00 \
69+
00 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 37 \
70+
63 ff fe cf 17 0e 00 01 00 00 02 00 00 00 66 83 \
71+
c6 0f 1d 9a 61 87"
72+
PTP_1588_IPV4_PDELAY_REQ=" \
73+
01:00:5e:00:00:6b 00:00:de:ad:be:ef 08:00 45 00 \
74+
00 52 35 a9 40 00 01 11 a1 85 c0 00 02 01 e0 00 \
75+
00 6b 01 3f 01 3f 00 3e a2 bc 02 02 00 36 00 00 \
76+
00 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 37 \
77+
63 ff fe cf 17 0e 00 01 00 01 05 7f 00 00 00 00 \
78+
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
79+
PTP_1588_IPV6_SYNC=" \
80+
33:33:00:00:01:81 00:00:de:ad:be:ef 86:dd 60 06 \
81+
7c 2f 00 36 11 01 20 01 0d b8 00 01 00 00 00 00 \
82+
00 00 00 00 00 01 ff 0e 00 00 00 00 00 00 00 00 \
83+
00 00 00 00 01 81 01 3f 01 3f 00 36 2e 92 00 02 \
84+
00 2c 00 00 02 00 00 00 00 00 00 00 00 00 00 00 \
85+
00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 00 00 \
86+
00 00 00 00 00 00 00 00 00 00 00 00"
87+
PTP_1588_IPV6_FOLLOW_UP=" \
88+
33:33:00:00:01:81 00:00:de:ad:be:ef 86:dd 60 0a \
89+
00 bc 00 36 11 01 20 01 0d b8 00 01 00 00 00 00 \
90+
00 00 00 00 00 01 ff 0e 00 00 00 00 00 00 00 00 \
91+
00 00 00 00 01 81 01 40 01 40 00 36 2e 92 08 02 \
92+
00 2c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
93+
00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 02 00 \
94+
00 00 66 83 c6 2a 32 09 bd 74 00 00"
95+
PTP_1588_IPV6_PDELAY_REQ=" \
96+
33:33:00:00:00:6b 00:00:de:ad:be:ef 86:dd 60 0c \
97+
5c fd 00 40 11 01 fe 80 00 00 00 00 00 00 3c 37 \
98+
63 ff fe cf 17 0e ff 02 00 00 00 00 00 00 00 00 \
99+
00 00 00 00 00 6b 01 3f 01 3f 00 40 b4 54 02 02 \
100+
00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
101+
00 00 3e 37 63 ff fe cf 17 0e 00 01 00 01 05 7f \
102+
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
103+
00 00 00 00 00 00"
45104

46105
# Disable promisc to ensure we don't receive unknown MAC DA packets
47106
export TCPDUMP_EXTRA_FLAGS="-pl"
48107

49108
h1=${NETIFS[p1]}
50109
h2=${NETIFS[p2]}
51110

52-
send_non_ip()
111+
send_raw()
53112
{
54-
local if_name=$1
55-
local smac=$2
56-
local dmac=$3
113+
local if_name=$1; shift
114+
local pkt="$1"; shift
115+
local smac=$(mac_get $if_name)
57116

58-
$MZ -q $if_name "$dmac $smac $NON_IP_PKT"
117+
pkt="${pkt/00:00:de:ad:be:ef/$smac}"
118+
119+
$MZ -q $if_name "$pkt"
59120
}
60121

61122
send_uc_ipv4()
@@ -109,6 +170,7 @@ run_test()
109170
{
110171
local send_if_name=$1; shift
111172
local rcv_if_name=$1; shift
173+
local skip_ptp=$1; shift
112174
local no_unicast_flt=$1; shift
113175
local test_name="$1"; shift
114176
local smac=$(mac_get $send_if_name)
@@ -150,6 +212,35 @@ run_test()
150212
mc_route_destroy $rcv_if_name
151213
mc_route_destroy $send_if_name
152214

215+
if [ $skip_ptp = false ]; then
216+
ip maddress add 01:1b:19:00:00:00 dev $rcv_if_name
217+
send_raw $send_if_name "$PTP_1588_L2_SYNC"
218+
send_raw $send_if_name "$PTP_1588_L2_FOLLOW_UP"
219+
ip maddress del 01:1b:19:00:00:00 dev $rcv_if_name
220+
221+
ip maddress add 01:80:c2:00:00:0e dev $rcv_if_name
222+
send_raw $send_if_name "$PTP_1588_L2_PDELAY_REQ"
223+
ip maddress del 01:80:c2:00:00:0e dev $rcv_if_name
224+
225+
mc_join $rcv_if_name 224.0.1.129
226+
send_raw $send_if_name "$PTP_1588_IPV4_SYNC"
227+
send_raw $send_if_name "$PTP_1588_IPV4_FOLLOW_UP"
228+
mc_leave
229+
230+
mc_join $rcv_if_name 224.0.0.107
231+
send_raw $send_if_name "$PTP_1588_IPV4_PDELAY_REQ"
232+
mc_leave
233+
234+
mc_join $rcv_if_name ff0e::181
235+
send_raw $send_if_name "$PTP_1588_IPV6_SYNC"
236+
send_raw $send_if_name "$PTP_1588_IPV6_FOLLOW_UP"
237+
mc_leave
238+
239+
mc_join $rcv_if_name ff02::6b
240+
send_raw $send_if_name "$PTP_1588_IPV6_PDELAY_REQ"
241+
mc_leave
242+
fi
243+
153244
sleep 1
154245

155246
tcpdump_stop $rcv_if_name
@@ -212,6 +303,44 @@ run_test()
212303
"$smac > $UNKNOWN_MACV6_MC_ADDR3, ethertype IPv6 (0x86dd)" \
213304
true "$test_name"
214305

306+
if [ $skip_ptp = false ]; then
307+
check_rcv $rcv_if_name "1588v2 over L2 transport, Sync" \
308+
"ethertype PTP (0x88f7).* PTPv2.* msg type : sync msg" \
309+
true "$test_name"
310+
311+
check_rcv $rcv_if_name "1588v2 over L2 transport, Follow-Up" \
312+
"ethertype PTP (0x88f7).* PTPv2.* msg type : follow up msg" \
313+
true "$test_name"
314+
315+
check_rcv $rcv_if_name "1588v2 over L2 transport, Peer Delay Request" \
316+
"ethertype PTP (0x88f7).* PTPv2.* msg type : peer delay req msg" \
317+
true "$test_name"
318+
319+
check_rcv $rcv_if_name "1588v2 over IPv4, Sync" \
320+
"ethertype IPv4 (0x0800).* PTPv2.* msg type : sync msg" \
321+
true "$test_name"
322+
323+
check_rcv $rcv_if_name "1588v2 over IPv4, Follow-Up" \
324+
"ethertype IPv4 (0x0800).* PTPv2.* msg type : follow up msg" \
325+
true "$test_name"
326+
327+
check_rcv $rcv_if_name "1588v2 over IPv4, Peer Delay Request" \
328+
"ethertype IPv4 (0x0800).* PTPv2.* msg type : peer delay req msg" \
329+
true "$test_name"
330+
331+
check_rcv $rcv_if_name "1588v2 over IPv6, Sync" \
332+
"ethertype IPv6 (0x86dd).* PTPv2.* msg type : sync msg" \
333+
true "$test_name"
334+
335+
check_rcv $rcv_if_name "1588v2 over IPv6, Follow-Up" \
336+
"ethertype IPv6 (0x86dd).* PTPv2.* msg type : follow up msg" \
337+
true "$test_name"
338+
339+
check_rcv $rcv_if_name "1588v2 over IPv6, Peer Delay Request" \
340+
"ethertype IPv6 (0x86dd).* PTPv2.* msg type : peer delay req msg" \
341+
true "$test_name"
342+
fi
343+
215344
tcpdump_cleanup $rcv_if_name
216345
}
217346

@@ -293,6 +422,7 @@ macvlan_destroy()
293422
standalone()
294423
{
295424
local no_unicast_flt=true
425+
local skip_ptp=false
296426

297427
if [ $(has_unicast_flt $h2) = yes ]; then
298428
no_unicast_flt=false
@@ -302,7 +432,7 @@ standalone()
302432
h2_create
303433
macvlan_create $h2
304434

305-
run_test $h1 $h2 $no_unicast_flt "$h2"
435+
run_test $h1 $h2 $skip_ptp $no_unicast_flt "$h2"
306436

307437
macvlan_destroy
308438
h2_destroy
@@ -313,13 +443,15 @@ test_bridge()
313443
{
314444
local no_unicast_flt=true
315445
local vlan_filtering=$1
446+
local skip_ptp=true
316447

317448
h1_create
318449
bridge_create $vlan_filtering
319450
simple_if_init br0 $H2_IPV4/24 $H2_IPV6/64
320451
macvlan_create br0
321452

322-
run_test $h1 br0 $no_unicast_flt "vlan_filtering=$vlan_filtering bridge"
453+
run_test $h1 br0 $skip_ptp $no_unicast_flt \
454+
"vlan_filtering=$vlan_filtering bridge"
323455

324456
macvlan_destroy
325457
simple_if_fini br0 $H2_IPV4/24 $H2_IPV6/64
@@ -340,6 +472,7 @@ vlan_aware_bridge()
340472
test_vlan()
341473
{
342474
local no_unicast_flt=true
475+
local skip_ptp=false
343476

344477
if [ $(has_unicast_flt $h2) = yes ]; then
345478
no_unicast_flt=false
@@ -349,7 +482,7 @@ test_vlan()
349482
h2_vlan_create
350483
macvlan_create $h2.100
351484

352-
run_test $h1.100 $h2.100 $no_unicast_flt "VLAN upper"
485+
run_test $h1.100 $h2.100 $skip_ptp $no_unicast_flt "VLAN upper"
353486

354487
macvlan_destroy
355488
h2_vlan_destroy
@@ -360,6 +493,7 @@ vlan_over_bridged_port()
360493
{
361494
local no_unicast_flt=true
362495
local vlan_filtering=$1
496+
local skip_ptp=false
363497

364498
# br_manage_promisc() will not force a single vlan_filtering port to
365499
# promiscuous mode, so we should still expect unicast filtering to take
@@ -373,7 +507,7 @@ vlan_over_bridged_port()
373507
bridge_create $vlan_filtering
374508
macvlan_create $h2.100
375509

376-
run_test $h1.100 $h2.100 $no_unicast_flt \
510+
run_test $h1.100 $h2.100 $skip_ptp $no_unicast_flt \
377511
"VLAN over vlan_filtering=$vlan_filtering bridged port"
378512

379513
macvlan_destroy
@@ -396,6 +530,7 @@ vlan_over_bridge()
396530
{
397531
local no_unicast_flt=true
398532
local vlan_filtering=$1
533+
local skip_ptp=true
399534

400535
h1_vlan_create
401536
bridge_create $vlan_filtering
@@ -408,7 +543,7 @@ vlan_over_bridge()
408543
bridge vlan add dev br0 vid 100 self
409544
fi
410545

411-
run_test $h1.100 br0.100 $no_unicast_flt \
546+
run_test $h1.100 br0.100 $skip_ptp $no_unicast_flt \
412547
"VLAN over vlan_filtering=$vlan_filtering bridge"
413548

414549
if [ $vlan_filtering = 1 ]; then

0 commit comments

Comments
 (0)