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

net: dsa: tag_ocelot: avoid accessing ds->priv in ocelot_rcv

Taggers should be written to do something valid irrespective of the
switch driver that they are attached to. This is even more true now,
because since the introduction of the .change_tag_protocol method, a
certain tagger is not necessarily strictly associated with a driver any
longer, and I would like to be able to test all taggers with dsa_loop in
the future.

In the case of ocelot, it needs to move the classified VLAN from the DSA
tag into the skb if the port is VLAN-aware. We can allow it to do that
by looking at the dp->vlan_filtering property, no need to invoke
structures which are specific to ocelot.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vladimir Oltean and committed by
David S. Miller
8a678bb2 137ffbc4

+3 -4
+3 -4
net/dsa/tag_ocelot.c
··· 177 177 struct net_device *netdev, 178 178 struct packet_type *pt) 179 179 { 180 - struct dsa_port *cpu_dp = netdev->dsa_ptr; 181 - struct dsa_switch *ds = cpu_dp->ds; 182 - struct ocelot *ocelot = ds->priv; 183 180 u64 src_port, qos_class; 184 181 u64 vlan_tci, tag_type; 185 182 u8 *start = skb->data; 183 + struct dsa_port *dp; 186 184 u8 *extraction; 187 185 u16 vlan_tpid; 188 186 ··· 241 243 * equal to the pvid of the ingress port and should not be used for 242 244 * processing. 243 245 */ 246 + dp = dsa_slave_to_port(skb->dev); 244 247 vlan_tpid = tag_type ? ETH_P_8021AD : ETH_P_8021Q; 245 248 246 - if (ocelot->ports[src_port]->vlan_aware && 249 + if (dsa_port_is_vlan_filtering(dp) && 247 250 eth_hdr(skb)->h_proto == htons(vlan_tpid)) { 248 251 u16 dummy_vlan_tci; 249 252