lkml.org 
[lkml]   [2019]   [Apr]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 net-next 12/24] net: dsa: Copy the vlan_filtering setting on the CPU port if it's global
Date
The current behavior is not as obvious as one would assume (which is
that, if the driver set vlan_filtering_is_global = 1, then checking any
dp->vlan_filtering would yield the same result). Only the ports which
are actively enslaved into a bridge would have vlan_filtering set.

This makes it tricky for drivers to check what the global state is.
Moreover, the most obvious place to check for this setting, the CPU
port, is not populated since it's not being enslaved to the bridge.
So fix this and make the CPU port hold the global state of VLAN
filtering on this switch.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
---
Changes in v3:
Patch is new.

net/dsa/port.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/net/dsa/port.c b/net/dsa/port.c
index c8eb2cbcea6e..acb4ed1f9929 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -190,6 +190,8 @@ static bool dsa_port_can_apply_vlan_filtering(struct dsa_port *dp,
int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering,
struct switchdev_trans *trans)
{
+ /* Violate a const pointer here */
+ struct dsa_port *cpu_dp = (struct dsa_port *)dp->cpu_dp;
struct dsa_switch *ds = dp->ds;
int err;

@@ -209,6 +211,12 @@ int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering,
return err;

dp->vlan_filtering = vlan_filtering;
+ /* In case of switches where VLAN filtering is not per-port,
+ * also put the setting in the most unambiguous place to
+ * retrieve it from.
+ */
+ if (ds->vlan_filtering_is_global)
+ cpu_dp->vlan_filtering = vlan_filtering;
return 0;
}

--
2.17.1
\
 
 \ /
  Last update: 2019-04-13 03:29    [W:0.238 / U:1.808 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site