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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'fix-ptp-received-on-wrong-port-with-bridged-sja1105-dsa'

Vladimir Oltean says:

====================
Fix PTP received on wrong port with bridged SJA1105 DSA

Since the changes were made to tag_8021q to support imprecise RX for
bridged ports, the tag_sja1105 driver still prefers the source port
information deduced from the VLAN headers for link-local traffic, even
though the switch can theoretically do better and report the precise
source port.

The problem is that the tagger doesn't know when to trust one source of
information over another, because the INCL_SRCPT option (to "tag" link
local frames) is sometimes enabled and sometimes it isn't.

The first patch makes the switch provide the hardware tag for link local
traffic under all circumstances, and the second patch makes the tagger
always use that hardware tag as primary source of information for link
local packets.
====================

Link: https://lore.kernel.org/r/20230627094207.3385231-1-vladimir.oltean@nxp.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

+32 -17
+2 -7
drivers/net/dsa/sja1105/sja1105_main.c
··· 866 866 .hostprio = 7, 867 867 .mac_fltres1 = SJA1105_LINKLOCAL_FILTER_A, 868 868 .mac_flt1 = SJA1105_LINKLOCAL_FILTER_A_MASK, 869 - .incl_srcpt1 = false, 869 + .incl_srcpt1 = true, 870 870 .send_meta1 = false, 871 871 .mac_fltres0 = SJA1105_LINKLOCAL_FILTER_B, 872 872 .mac_flt0 = SJA1105_LINKLOCAL_FILTER_B_MASK, 873 - .incl_srcpt0 = false, 873 + .incl_srcpt0 = true, 874 874 .send_meta0 = false, 875 875 /* Default to an invalid value */ 876 876 .mirr_port = priv->ds->num_ports, ··· 2405 2405 general_params->tpid = tpid; 2406 2406 /* EtherType used to identify outer tagged (S-tag) VLAN traffic */ 2407 2407 general_params->tpid2 = tpid2; 2408 - /* When VLAN filtering is on, we need to at least be able to 2409 - * decode management traffic through the "backup plan". 2410 - */ 2411 - general_params->incl_srcpt1 = enabled; 2412 - general_params->incl_srcpt0 = enabled; 2413 2408 2414 2409 for (port = 0; port < ds->num_ports; port++) { 2415 2410 if (dsa_is_unused_port(ds, port))
+30 -10
net/dsa/tag_sja1105.c
··· 545 545 is_link_local = sja1105_is_link_local(skb); 546 546 is_meta = sja1105_is_meta_frame(skb); 547 547 548 - if (sja1105_skb_has_tag_8021q(skb)) { 549 - /* Normal traffic path. */ 550 - sja1105_vlan_rcv(skb, &source_port, &switch_id, &vbid, &vid); 551 - } else if (is_link_local) { 548 + if (is_link_local) { 552 549 /* Management traffic path. Switch embeds the switch ID and 553 550 * port ID into bytes of the destination MAC, courtesy of 554 551 * the incl_srcpt options. ··· 559 562 sja1105_meta_unpack(skb, &meta); 560 563 source_port = meta.source_port; 561 564 switch_id = meta.switch_id; 562 - } else { 565 + } 566 + 567 + /* Normal data plane traffic and link-local frames are tagged with 568 + * a tag_8021q VLAN which we have to strip 569 + */ 570 + if (sja1105_skb_has_tag_8021q(skb)) { 571 + int tmp_source_port = -1, tmp_switch_id = -1; 572 + 573 + sja1105_vlan_rcv(skb, &tmp_source_port, &tmp_switch_id, &vbid, 574 + &vid); 575 + /* Preserve the source information from the INCL_SRCPT option, 576 + * if available. This allows us to not overwrite a valid source 577 + * port and switch ID with zeroes when receiving link-local 578 + * frames from a VLAN-unaware bridged port (non-zero vbid) or a 579 + * VLAN-aware bridged port (non-zero vid). 580 + */ 581 + if (source_port == -1) 582 + source_port = tmp_source_port; 583 + if (switch_id == -1) 584 + switch_id = tmp_switch_id; 585 + } else if (source_port == -1 && switch_id == -1) { 586 + /* Packets with no source information have no chance of 587 + * getting accepted, drop them straight away. 588 + */ 563 589 return NULL; 564 590 } 565 591 566 - if (vbid >= 1) 567 - skb->dev = dsa_tag_8021q_find_port_by_vbid(netdev, vbid); 568 - else if (source_port == -1 || switch_id == -1) 569 - skb->dev = dsa_find_designated_bridge_port_by_vid(netdev, vid); 570 - else 592 + if (source_port != -1 && switch_id != -1) 571 593 skb->dev = dsa_master_find_slave(netdev, switch_id, source_port); 594 + else if (vbid >= 1) 595 + skb->dev = dsa_tag_8021q_find_port_by_vbid(netdev, vbid); 596 + else 597 + skb->dev = dsa_find_designated_bridge_port_by_vid(netdev, vid); 572 598 if (!skb->dev) { 573 599 netdev_warn(netdev, "Couldn't decode source port\n"); 574 600 return NULL;