]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net: dsa: Call dsa_untag_bridge_pvid() from dsa_switch_rcv()
authorFlorian Fainelli <f.fainelli@gmail.com>
Fri, 2 Oct 2020 02:42:12 +0000 (19:42 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 2 Oct 2020 20:36:07 +0000 (13:36 -0700)
When a DSA switch driver needs to call dsa_untag_bridge_pvid(), it can
set dsa_switch::untag_brige_pvid to indicate this is necessary.

This is a pre-requisite to making sure that we are always calling
dsa_untag_bridge_pvid() after eth_type_trans() has been called.

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

index b502a63d196e12e1f163774bae0a0ae9f824dc3e..8b0696e08cac8e9e1a5b8ec0c810e3fe1b18a2ec 100644 (file)
@@ -308,6 +308,14 @@ struct dsa_switch {
         */
        bool                    configure_vlan_while_not_filtering;
 
+       /* If the switch driver always programs the CPU port as egress tagged
+        * despite the VLAN configuration indicating otherwise, then setting
+        * @untag_bridge_pvid will force the DSA receive path to pop the bridge's
+        * default_pvid VLAN tagged frames to offer a consistent behavior
+        * between a vlan_filtering=0 and vlan_filtering=1 bridge device.
+        */
+       bool                    untag_bridge_pvid;
+
        /* In case vlan_filtering_is_global is set, the VLAN awareness state
         * should be retrieved from here and not from the per-port settings.
         */
index 5c18c0214aac9c99dea6889aa9b0b39e60f6c952..dec4ab59b7c43c21b386679828a26cbfa46e28f1 100644 (file)
@@ -225,6 +225,15 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
        skb->pkt_type = PACKET_HOST;
        skb->protocol = eth_type_trans(skb, skb->dev);
 
+       if (unlikely(cpu_dp->ds->untag_bridge_pvid)) {
+               nskb = dsa_untag_bridge_pvid(skb);
+               if (!nskb) {
+                       kfree_skb(skb);
+                       return 0;
+               }
+               skb = nskb;
+       }
+
        s = this_cpu_ptr(p->stats64);
        u64_stats_update_begin(&s->syncp);
        s->rx_packets++;