diff mbox series

[net] net: dsa: tag_sja1105: fix source port decoding in vlan_filtering=0 bridge mode

Message ID 20230630222010.1691671-1-vladimir.oltean@nxp.com (mailing list archive)
State Accepted
Commit a398b9ea0c3b791b7a0f4c6029a62cf628f97f22
Delegated to: Netdev Maintainers
Headers show
Series [net] net: dsa: tag_sja1105: fix source port decoding in vlan_filtering=0 bridge mode | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang fail Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Vladimir Oltean June 30, 2023, 10:20 p.m. UTC
There was a regression introduced by the blamed commit, where pinging to
a VLAN-unaware bridge would fail with the repeated message "Couldn't
decode source port" coming from the tagging protocol driver.

When receiving packets with a bridge_vid as determined by
dsa_tag_8021q_bridge_join(), dsa_8021q_rcv() will decode:
- source_port = 0 (which isn't really valid, more like "don't know")
- switch_id = 0 (which isn't really valid, more like "don't know")
- vbid = value in range 1-7

Since the blamed patch has reversed the order of the checks, we are now
going to believe that source_port != -1 and switch_id != -1, so they're
valid, but they aren't.

The minimal solution to the problem is to only populate source_port and
switch_id with what dsa_8021q_rcv() came up with, if the vbid is zero,
i.e. the source port information is trustworthy.

Fixes: c1ae02d87689 ("net: dsa: tag_sja1105: always prefer source port information from INCL_SRCPT")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 net/dsa/tag_sja1105.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Simon Horman July 1, 2023, 7:38 p.m. UTC | #1
On Sat, Jul 01, 2023 at 01:20:10AM +0300, Vladimir Oltean wrote:
> There was a regression introduced by the blamed commit, where pinging to
> a VLAN-unaware bridge would fail with the repeated message "Couldn't
> decode source port" coming from the tagging protocol driver.
> 
> When receiving packets with a bridge_vid as determined by
> dsa_tag_8021q_bridge_join(), dsa_8021q_rcv() will decode:
> - source_port = 0 (which isn't really valid, more like "don't know")
> - switch_id = 0 (which isn't really valid, more like "don't know")
> - vbid = value in range 1-7
> 
> Since the blamed patch has reversed the order of the checks, we are now
> going to believe that source_port != -1 and switch_id != -1, so they're
> valid, but they aren't.
> 
> The minimal solution to the problem is to only populate source_port and
> switch_id with what dsa_8021q_rcv() came up with, if the vbid is zero,
> i.e. the source port information is trustworthy.
> 
> Fixes: c1ae02d87689 ("net: dsa: tag_sja1105: always prefer source port information from INCL_SRCPT")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Simon Horman <simon.horman@corigine.com>
patchwork-bot+netdevbpf@kernel.org July 3, 2023, 8:20 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Sat,  1 Jul 2023 01:20:10 +0300 you wrote:
> There was a regression introduced by the blamed commit, where pinging to
> a VLAN-unaware bridge would fail with the repeated message "Couldn't
> decode source port" coming from the tagging protocol driver.
> 
> When receiving packets with a bridge_vid as determined by
> dsa_tag_8021q_bridge_join(), dsa_8021q_rcv() will decode:
> - source_port = 0 (which isn't really valid, more like "don't know")
> - switch_id = 0 (which isn't really valid, more like "don't know")
> - vbid = value in range 1-7
> 
> [...]

Here is the summary with links:
  - [net] net: dsa: tag_sja1105: fix source port decoding in vlan_filtering=0 bridge mode
    https://git.kernel.org/netdev/net/c/a398b9ea0c3b

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c
index 796e4b88f63b..f480ffffa8c3 100644
--- a/net/dsa/tag_sja1105.c
+++ b/net/dsa/tag_sja1105.c
@@ -531,11 +531,14 @@  static struct sk_buff *sja1105_rcv(struct sk_buff *skb,
 		 * if available. This allows us to not overwrite a valid source
 		 * port and switch ID with zeroes when receiving link-local
 		 * frames from a VLAN-unaware bridged port (non-zero vbid) or a
-		 * VLAN-aware bridged port (non-zero vid).
+		 * VLAN-aware bridged port (non-zero vid). Furthermore, the
+		 * tag_8021q source port information is only of trust when the
+		 * vbid is 0 (precise port). Otherwise, tmp_source_port and
+		 * tmp_switch_id will be zeroes.
 		 */
-		if (source_port == -1)
+		if (vbid == 0 && source_port == -1)
 			source_port = tmp_source_port;
-		if (switch_id == -1)
+		if (vbid == 0 && switch_id == -1)
 			switch_id = tmp_switch_id;
 	} else if (source_port == -1 && switch_id == -1) {
 		/* Packets with no source information have no chance of