From: Simon Horman <simon.horman@corigine.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 2/2] net: dsa: tag_sja1105: always prefer source port information from INCL_SRCPT
Date: Tue, 27 Jun 2023 13:15:03 +0200 [thread overview]
Message-ID: <ZJrEtw15g3a7nyLN@corigine.com> (raw)
In-Reply-To: <20230626221828.qzjeo6dedjnyme6k@skbuf>
On Tue, Jun 27, 2023 at 01:18:28AM +0300, Vladimir Oltean wrote:
> Hi Simon,
>
> On Mon, Jun 26, 2023 at 08:11:53PM +0200, Simon Horman wrote:
> > Hi Vladimir,
> >
> > A similar comment to that made for [1], though the code is somewhat
> > different to that case: are you sure vid is initialised here?
> > GCC 12 and Smatch seem unsure about it.
> >
> > [1] Re: [PATCH net-next v2 4/7] net: dsa: vsc73xx: Add dsa tagging based on 8021q
> > https://lore.kernel.org/all/ZJg2M+Qvg3Fv73CH@corigine.com/
>
> "vid" can be uninitialized if the tagger is fed a junk packet (a
> non-link-local, non-meta packet that also has no tag_8021q header).
>
> The immediate answer that comes to mind is: it depends on how the driver
> configures the hardware to send packets to the CPU (and it will never
> configure the switch in that way).
>
> But, between the sja1105 driver configuring the switch in a certain way
> and the tag_sja1105 driver seeing the results of that, there's also the
> DSA master driver (can be any net_device) which can alter the packet in
> a nonsensical way, like remove the VLAN header for some reason.
>
> Considering the fact that the DSA master can have tc rules on its
> ingress path which do just that, it would probably be wise to be
> defensive about this. So I can probably add:
>
> if (sja1105_skb_has_tag_8021q(skb)) {
> ... // existing call to sja1105_vlan_rcv() here
> } else if (source_port == -1 && switch_id == -1) {
> /* Packets with no source information have no chance of
> * getting accepted, drop them straight away.
> */
> return NULL;
> }
>
> This "else if" block should ensure that when "vid" is uninitialized,
> either "source_port" and "switch_id", or "vbid", always have valid values.
This is kind of complex :)
Can I clarify that either:
1. Both source_port and switch_id are -1; or
2. Neither source_port nor switch_id are -1
If so, I agree with your proposal.
next prev parent reply other threads:[~2023-06-27 11:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-26 15:51 [PATCH net 0/2] Fix PTP received on wrong port with bridged SJA1105 DSA Vladimir Oltean
2023-06-26 15:51 ` [PATCH net 1/2] net: dsa: sja1105: always enable the INCL_SRCPT option Vladimir Oltean
2023-06-26 15:51 ` [PATCH net 2/2] net: dsa: tag_sja1105: always prefer source port information from INCL_SRCPT Vladimir Oltean
2023-06-26 18:11 ` Simon Horman
2023-06-26 22:18 ` Vladimir Oltean
2023-06-27 11:15 ` Simon Horman [this message]
2023-06-27 11:41 ` Vladimir Oltean
2023-06-27 11:59 ` Simon Horman
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=ZJrEtw15g3a7nyLN@corigine.com \
--to=simon.horman@corigine.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@nxp.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;
as well as URLs for NNTP newsgroup(s).