mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Vladimir Oltean <olteanv@gmail.com>,
	vivien.didelot@gmail.com, andrew@lunn.ch, davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 3/9] net: dsa: Allow drivers to filter packets they can decode source port from
Date: Fri, 3 May 2019 19:00:52 -0700	[thread overview]
Message-ID: <dcf251bc-ace1-4a3e-d500-54c916fcfdbb@gmail.com> (raw)
In-Reply-To: <20190504011826.30477-4-olteanv@gmail.com>



On 5/3/2019 6:18 PM, Vladimir Oltean wrote:
> Frames get processed by DSA and redirected to switch port net devices
> based on the ETH_P_XDSA multiplexed packet_type handler found by the
> network stack when calling eth_type_trans().
> 
> The running assumption is that once the DSA .rcv function is called, DSA
> is always able to decode the switch tag in order to change the skb->dev
> from its master.
> 
> However there are tagging protocols (such as the new DSA_TAG_PROTO_SJA1105,
> user of DSA_TAG_PROTO_8021Q) where this assumption is not completely
> true, since switch tagging piggybacks on the absence of a vlan_filtering
> bridge. Moreover, management traffic (BPDU, PTP) for this switch doesn't
> rely on switch tagging, but on a different mechanism. So it would make
> sense to at least be able to terminate that.
> 
> Having DSA receive traffic it can't decode would put it in an impossible
> situation: the eth_type_trans() function would invoke the DSA .rcv(),
> which could not change skb->dev, then eth_type_trans() would be invoked
> again, which again would call the DSA .rcv, and the packet would never
> be able to exit the DSA filter and would spiral in a loop until the
> whole system dies.
> 
> This happens because eth_type_trans() doesn't actually look at the skb
> (so as to identify a potential tag) when it deems it as being
> ETH_P_XDSA. It just checks whether skb->dev has a DSA private pointer
> installed (therefore it's a DSA master) and that there exists a .rcv
> callback (everybody except DSA_TAG_PROTO_NONE has that). This is
> understandable as there are many switch tags out there, and exhaustively
> checking for all of them is far from ideal.
> 
> The solution lies in introducing a filtering function for each tagging
> protocol. In the absence of a filtering function, all traffic is passed
> to the .rcv DSA callback. The tagging protocol should see the filtering
> function as a pre-validation that it can decode the incoming skb. The
> traffic that doesn't match the filter will bypass the DSA .rcv callback
> and be left on the master netdevice, which wasn't previously possible.

I can't come up with a different solution either:

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

Maybe one day we will have in-kernel BPF filter for parsing DSA tags
(similar to PTP) and then we can preserve the layering while leveraging
the power of BPF!
-- 
Florian

  reply	other threads:[~2019-05-04  2:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-04  1:18 [PATCH net-next 0/9] Traffic support for SJA1105 DSA driver Vladimir Oltean
2019-05-04  1:18 ` [PATCH net-next 1/9] net: dsa: Call driver's setup callback after setting up its switchdev notifier Vladimir Oltean
2019-05-04  1:18 ` [PATCH net-next 2/9] net: dsa: Optional VLAN-based port separation for switches without tagging Vladimir Oltean
2019-05-04  1:18 ` [PATCH net-next 3/9] net: dsa: Allow drivers to filter packets they can decode source port from Vladimir Oltean
2019-05-04  2:00   ` Florian Fainelli [this message]
2019-05-04  1:18 ` [PATCH net-next 4/9] net: dsa: Keep private info in the skb->cb Vladimir Oltean
2019-05-04  2:04   ` Florian Fainelli
2019-05-04  2:23     ` Vladimir Oltean
2019-05-04  1:18 ` [PATCH net-next 5/9] net: dsa: Add support for deferred xmit Vladimir Oltean
2019-05-04  2:07   ` Florian Fainelli
2019-05-04  2:10     ` Vladimir Oltean
2019-05-04  1:18 ` [PATCH net-next 6/9] net: dsa: Add a private structure pointer to dsa_port Vladimir Oltean
2019-05-04  2:08   ` Florian Fainelli
2019-05-04  1:18 ` [PATCH net-next 7/9] net: dsa: sja1105: Add support for traffic through standalone ports Vladimir Oltean
2019-05-04  1:18 ` [PATCH net-next 8/9] net: dsa: sja1105: Add support for Spanning Tree Protocol Vladimir Oltean
2019-05-04  2:10   ` Florian Fainelli
2019-05-04  1:18 ` [PATCH net-next 9/9] Documentation: net: dsa: sja1105: Add info about supported traffic modes Vladimir Oltean
2019-05-04  2:17   ` Florian Fainelli
2019-05-04  2:36     ` Vladimir Oltean

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=dcf251bc-ace1-4a3e-d500-54c916fcfdbb@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --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

Powered by JetHome