Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vladimir Oltean and committed by
David S. Miller
23797950 9aa3749c

+148 -13
+148 -13
tools/testing/selftests/net/forwarding/local_termination.sh
··· 39 39 UNKNOWN_MACV6_MC_ADDR2="33:33:01:02:03:06" 40 40 UNKNOWN_MACV6_MC_ADDR3="33:33:01:02:03:07" 41 41 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" 45 104 46 105 # Disable promisc to ensure we don't receive unknown MAC DA packets 47 106 export TCPDUMP_EXTRA_FLAGS="-pl" ··· 108 49 h1=${NETIFS[p1]} 109 50 h2=${NETIFS[p2]} 110 51 111 - send_non_ip() 52 + send_raw() 112 53 { 113 - local if_name=$1 114 - local smac=$2 115 - local dmac=$3 54 + local if_name=$1; shift 55 + local pkt="$1"; shift 56 + local smac=$(mac_get $if_name) 116 57 117 - $MZ -q $if_name "$dmac $smac $NON_IP_PKT" 58 + pkt="${pkt/00:00:de:ad:be:ef/$smac}" 59 + 60 + $MZ -q $if_name "$pkt" 118 61 } 119 62 120 63 send_uc_ipv4() ··· 170 109 { 171 110 local send_if_name=$1; shift 172 111 local rcv_if_name=$1; shift 112 + local skip_ptp=$1; shift 173 113 local no_unicast_flt=$1; shift 174 114 local test_name="$1"; shift 175 115 local smac=$(mac_get $send_if_name) ··· 211 149 212 150 mc_route_destroy $rcv_if_name 213 151 mc_route_destroy $send_if_name 152 + 153 + if [ $skip_ptp = false ]; then 154 + ip maddress add 01:1b:19:00:00:00 dev $rcv_if_name 155 + send_raw $send_if_name "$PTP_1588_L2_SYNC" 156 + send_raw $send_if_name "$PTP_1588_L2_FOLLOW_UP" 157 + ip maddress del 01:1b:19:00:00:00 dev $rcv_if_name 158 + 159 + ip maddress add 01:80:c2:00:00:0e dev $rcv_if_name 160 + send_raw $send_if_name "$PTP_1588_L2_PDELAY_REQ" 161 + ip maddress del 01:80:c2:00:00:0e dev $rcv_if_name 162 + 163 + mc_join $rcv_if_name 224.0.1.129 164 + send_raw $send_if_name "$PTP_1588_IPV4_SYNC" 165 + send_raw $send_if_name "$PTP_1588_IPV4_FOLLOW_UP" 166 + mc_leave 167 + 168 + mc_join $rcv_if_name 224.0.0.107 169 + send_raw $send_if_name "$PTP_1588_IPV4_PDELAY_REQ" 170 + mc_leave 171 + 172 + mc_join $rcv_if_name ff0e::181 173 + send_raw $send_if_name "$PTP_1588_IPV6_SYNC" 174 + send_raw $send_if_name "$PTP_1588_IPV6_FOLLOW_UP" 175 + mc_leave 176 + 177 + mc_join $rcv_if_name ff02::6b 178 + send_raw $send_if_name "$PTP_1588_IPV6_PDELAY_REQ" 179 + mc_leave 180 + fi 214 181 215 182 sleep 1 216 183 ··· 302 211 check_rcv $rcv_if_name "Multicast IPv6 to unknown group, allmulti" \ 303 212 "$smac > $UNKNOWN_MACV6_MC_ADDR3, ethertype IPv6 (0x86dd)" \ 304 213 true "$test_name" 214 + 215 + if [ $skip_ptp = false ]; then 216 + check_rcv $rcv_if_name "1588v2 over L2 transport, Sync" \ 217 + "ethertype PTP (0x88f7).* PTPv2.* msg type : sync msg" \ 218 + true "$test_name" 219 + 220 + check_rcv $rcv_if_name "1588v2 over L2 transport, Follow-Up" \ 221 + "ethertype PTP (0x88f7).* PTPv2.* msg type : follow up msg" \ 222 + true "$test_name" 223 + 224 + check_rcv $rcv_if_name "1588v2 over L2 transport, Peer Delay Request" \ 225 + "ethertype PTP (0x88f7).* PTPv2.* msg type : peer delay req msg" \ 226 + true "$test_name" 227 + 228 + check_rcv $rcv_if_name "1588v2 over IPv4, Sync" \ 229 + "ethertype IPv4 (0x0800).* PTPv2.* msg type : sync msg" \ 230 + true "$test_name" 231 + 232 + check_rcv $rcv_if_name "1588v2 over IPv4, Follow-Up" \ 233 + "ethertype IPv4 (0x0800).* PTPv2.* msg type : follow up msg" \ 234 + true "$test_name" 235 + 236 + check_rcv $rcv_if_name "1588v2 over IPv4, Peer Delay Request" \ 237 + "ethertype IPv4 (0x0800).* PTPv2.* msg type : peer delay req msg" \ 238 + true "$test_name" 239 + 240 + check_rcv $rcv_if_name "1588v2 over IPv6, Sync" \ 241 + "ethertype IPv6 (0x86dd).* PTPv2.* msg type : sync msg" \ 242 + true "$test_name" 243 + 244 + check_rcv $rcv_if_name "1588v2 over IPv6, Follow-Up" \ 245 + "ethertype IPv6 (0x86dd).* PTPv2.* msg type : follow up msg" \ 246 + true "$test_name" 247 + 248 + check_rcv $rcv_if_name "1588v2 over IPv6, Peer Delay Request" \ 249 + "ethertype IPv6 (0x86dd).* PTPv2.* msg type : peer delay req msg" \ 250 + true "$test_name" 251 + fi 305 252 306 253 tcpdump_cleanup $rcv_if_name 307 254 } ··· 422 293 standalone() 423 294 { 424 295 local no_unicast_flt=true 296 + local skip_ptp=false 425 297 426 298 if [ $(has_unicast_flt $h2) = yes ]; then 427 299 no_unicast_flt=false ··· 432 302 h2_create 433 303 macvlan_create $h2 434 304 435 - run_test $h1 $h2 $no_unicast_flt "$h2" 305 + run_test $h1 $h2 $skip_ptp $no_unicast_flt "$h2" 436 306 437 307 macvlan_destroy 438 308 h2_destroy ··· 443 313 { 444 314 local no_unicast_flt=true 445 315 local vlan_filtering=$1 316 + local skip_ptp=true 446 317 447 318 h1_create 448 319 bridge_create $vlan_filtering 449 320 simple_if_init br0 $H2_IPV4/24 $H2_IPV6/64 450 321 macvlan_create br0 451 322 452 - run_test $h1 br0 $no_unicast_flt "vlan_filtering=$vlan_filtering bridge" 323 + run_test $h1 br0 $skip_ptp $no_unicast_flt \ 324 + "vlan_filtering=$vlan_filtering bridge" 453 325 454 326 macvlan_destroy 455 327 simple_if_fini br0 $H2_IPV4/24 $H2_IPV6/64 ··· 472 340 test_vlan() 473 341 { 474 342 local no_unicast_flt=true 343 + local skip_ptp=false 475 344 476 345 if [ $(has_unicast_flt $h2) = yes ]; then 477 346 no_unicast_flt=false ··· 482 349 h2_vlan_create 483 350 macvlan_create $h2.100 484 351 485 - run_test $h1.100 $h2.100 $no_unicast_flt "VLAN upper" 352 + run_test $h1.100 $h2.100 $skip_ptp $no_unicast_flt "VLAN upper" 486 353 487 354 macvlan_destroy 488 355 h2_vlan_destroy ··· 493 360 { 494 361 local no_unicast_flt=true 495 362 local vlan_filtering=$1 363 + local skip_ptp=false 496 364 497 365 # br_manage_promisc() will not force a single vlan_filtering port to 498 366 # promiscuous mode, so we should still expect unicast filtering to take ··· 507 373 bridge_create $vlan_filtering 508 374 macvlan_create $h2.100 509 375 510 - run_test $h1.100 $h2.100 $no_unicast_flt \ 376 + run_test $h1.100 $h2.100 $skip_ptp $no_unicast_flt \ 511 377 "VLAN over vlan_filtering=$vlan_filtering bridged port" 512 378 513 379 macvlan_destroy ··· 530 396 { 531 397 local no_unicast_flt=true 532 398 local vlan_filtering=$1 399 + local skip_ptp=true 533 400 534 401 h1_vlan_create 535 402 bridge_create $vlan_filtering ··· 543 408 bridge vlan add dev br0 vid 100 self 544 409 fi 545 410 546 - run_test $h1.100 br0.100 $no_unicast_flt \ 411 + run_test $h1.100 br0.100 $skip_ptp $no_unicast_flt \ 547 412 "VLAN over vlan_filtering=$vlan_filtering bridge" 548 413 549 414 if [ $vlan_filtering = 1 ]; then