Netdev List
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	"olteanv@gmail.com" <olteanv@gmail.com>,
	"nikolay@nvidia.com" <nikolay@nvidia.com>
Subject: Re: [PATCH net-next 1/2] net: dsa: untag the bridge pvid from rx skbs
Date: Wed, 23 Sep 2020 08:14:51 +0000	[thread overview]
Message-ID: <20200923081450.2ghr6am4vjci6cd4@skbuf> (raw)
In-Reply-To: <20200923031155.2832348-2-f.fainelli@gmail.com>

On Tue, Sep 22, 2020 at 08:11:54PM -0700, Florian Fainelli wrote:
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index d16057c5987a..b539241a7533 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -301,6 +301,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.
>  	 */
> diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
> index 5c18c0214aac..dec4ab59b7c4 100644
> --- a/net/dsa/dsa.c
> +++ b/net/dsa/dsa.c
> @@ -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++;

I was thinking a lot simpler. Maybe you could just tail-call
dsa_untag_bridge_pvid(skb) at the end of your .rcv function instead of
putting it in the common receive path. I specifically wrote it to look
at hdr->h_vlan_proto instead of skb->protocol, so it wouldn't depend on
eth_type_trans().

Something like:

diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c
index 9c6c30649d13..118d253af5a7 100644
--- a/net/dsa/tag_brcm.c
+++ b/net/dsa/tag_brcm.c
@@ -192,7 +192,7 @@ static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev,
 		nskb->data - ETH_HLEN - BRCM_TAG_LEN,
 		2 * ETH_ALEN);
 
-	return nskb;
+	return dsa_untag_bridge_pvid(nskb);
 }
 
 static const struct dsa_device_ops brcm_netdev_ops = {
@@ -220,8 +220,14 @@ static struct sk_buff *brcm_tag_rcv_prepend(struct sk_buff *skb,
 					    struct net_device *dev,
 					    struct packet_type *pt)
 {
+	struct sk_buff *nskb;
+
 	/* tag is prepended to the packet */
-	return brcm_tag_rcv_ll(skb, dev, pt, ETH_HLEN);
+	nskb = brcm_tag_rcv_ll(skb, dev, pt, ETH_HLEN);
+	if (!nskb)
+		return nskb;
+
+	return dsa_untag_bridge_pvid(nskb);
 }
 
 static const struct dsa_device_ops brcm_prepend_netdev_ops = {

Thanks,
-Vladimir

  reply	other threads:[~2020-09-23  8:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-23  3:11 [PATCH net-next 0/2] net: dsa: b53: Configure VLANs while not filtering Florian Fainelli
2020-09-23  3:11 ` [PATCH net-next 1/2] net: dsa: untag the bridge pvid from rx skbs Florian Fainelli
2020-09-23  8:14   ` Vladimir Oltean [this message]
2020-09-23 17:06     ` Florian Fainelli
2020-09-23  3:11 ` [PATCH net-next 2/2] net: dsa: b53: Configure VLANs while not filtering Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200923081450.2ghr6am4vjci6cd4@skbuf \
    --to=vladimir.oltean@nxp.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@nvidia.com \
    --cc=olteanv@gmail.com \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox