Message ID | 20210618183017.3340769-2-olteanv@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Improvement for DSA cross-chip setups | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | success | CCed 7 of 7 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 13 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
On 6/18/2021 11:30 AM, Vladimir Oltean wrote: > From: Vladimir Oltean <vladimir.oltean@nxp.com> > > The cross-chip notifiers work by comparing each ds->index against the > info->sw_index value from the notifier. The ds->index is retrieved from > the device tree dsa,member property. > > If a single tree cross-chip topology does not declare unique switch IDs, > this will result in hard-to-debug issues/voodoo effects such as the > cross-chip notifier for one switch port also matching the port with the > same number from another switch. > > Check in dsa_switch_parse_member_of() whether the DSA switch tree > contains a DSA switch with the index we're preparing to add, before > actually adding it. > > Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
On Fri, Jun 18, 2021 at 09:30:12PM +0300, Vladimir Oltean wrote: > From: Vladimir Oltean <vladimir.oltean@nxp.com> > > The cross-chip notifiers work by comparing each ds->index against the > info->sw_index value from the notifier. The ds->index is retrieved from > the device tree dsa,member property. > > If a single tree cross-chip topology does not declare unique switch IDs, > this will result in hard-to-debug issues/voodoo effects such as the > cross-chip notifier for one switch port also matching the port with the > same number from another switch. > > Check in dsa_switch_parse_member_of() whether the DSA switch tree > contains a DSA switch with the index we're preparing to add, before > actually adding it. > > Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Andrew
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index b71e87909f0e..ba244fbd9646 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -1259,6 +1259,13 @@ static int dsa_switch_parse_member_of(struct dsa_switch *ds, if (!ds->dst) return -ENOMEM; + if (dsa_switch_find(ds->dst->index, ds->index)) { + dev_err(ds->dev, + "A DSA switch with index %d already exists in tree %d\n", + ds->index, ds->dst->index); + return -EEXIST; + } + return 0; }