netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@corigine.com>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: Vladimir Oltean <vladimir.oltean@nxp.com>,
	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:59:07 +0200	[thread overview]
Message-ID: <ZJrPC7dqsGPZ5b1C@corigine.com> (raw)
In-Reply-To: <20230627114148.lpyopy6ttuvvciww@skbuf>

On Tue, Jun 27, 2023 at 02:41:48PM +0300, Vladimir Oltean wrote:
> On Tue, Jun 27, 2023 at 01:15:03PM +0200, Simon Horman wrote:
> > 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.
> 
> They are integers assigned from the same code blocks in all cases,
> starting with -1 and later being assigned rvalues either from u64 fields
> limited to 0-255 (meta->source_port, meta->switch_id) or from unsigned
> char fields (hdr->h_dest[3], hdr->h_dest[4]), or from
> dsa_8021q_rx_source_port() and dsa_8021q_rx_switch_id() which return
> limited-size positive integers due to their implementation.

Thanks, in that case I think we are good.

      reply	other threads:[~2023-06-27 11:59 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
2023-06-27 11:41         ` Vladimir Oltean
2023-06-27 11:59           ` Simon Horman [this message]

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=ZJrPC7dqsGPZ5b1C@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=olteanv@gmail.com \
    --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).