From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Ansuel Smith <ansuelsmth@gmail.com>,
Tobias Waldekranz <tobias@waldekranz.com>,
DENG Qingfang <dqfext@gmail.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
"UNGLinuxDriver@microchip.com" <UNGLinuxDriver@microchip.com>,
Jiri Pirko <jiri@resnulli.us>, Ivan Vecera <ivecera@redhat.com>
Subject: Re: [PATCH v2 net-next 11/12] net: dsa: support FDB events on offloaded LAG interfaces
Date: Fri, 11 Feb 2022 23:14:22 +0000 [thread overview]
Message-ID: <20220211231421.erqojnturtnmtfvo@skbuf> (raw)
In-Reply-To: <20220211150352.548530ae@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
On Fri, Feb 11, 2022 at 03:03:52PM -0800, Jakub Kicinski wrote:
> On Thu, 10 Feb 2022 14:52:00 +0200 Vladimir Oltean wrote:
> > +static int
> > +dsa_lag_fdb_event(struct net_device *lag_dev, struct net_device *orig_dev,
> > + unsigned long event, const void *ctx,
> > + const struct switchdev_notifier_fdb_info *fdb_info)
> > +{
> > + struct dsa_switchdev_event_work *switchdev_work;
> > + bool host_addr = fdb_info->is_local;
> > + struct net_device *slave;
> > + struct dsa_switch *ds;
> > + struct dsa_port *dp;
> > +
> > + /* Skip dynamic FDB entries, since the physical ports beneath the LAG
> > + * should have learned it too.
> > + */
> > + if (netif_is_lag_master(orig_dev) &&
> > + switchdev_fdb_is_dynamically_learned(fdb_info))
> > + return 0;
> > +
> > + /* FDB entries learned by the software bridge should be installed as
> > + * host addresses only if the driver requests assisted learning.
> > + */
> > + if (switchdev_fdb_is_dynamically_learned(fdb_info) &&
> > + !ds->assisted_learning_on_cpu_port)
> > + return 0;
> > +
> > + /* Get a handle to any DSA interface beneath the LAG */
> > + slave = switchdev_lower_dev_find(lag_dev, dsa_slave_dev_check,
> > + dsa_foreign_dev_check);
> > + dp = dsa_slave_to_port(slave);
> > + ds = dp->ds;
>
> clang says:
>
> net/dsa/slave.c:2650:7: warning: variable 'ds' is uninitialized when used here [-Wuninitialized]
> !ds->assisted_learning_on_cpu_port)
> ^~
>
> It also suggests:
>
> net/dsa/slave.c:2636:23: note: initialize the variable 'ds' to silence this warning
> struct dsa_switch *ds;
> ^
> = NULL
>
> but that's perhaps for comedic purposes.
Yes, that's "how not to fix a bug".
In this case the second "if" condition needs to be moved past the "ds = ..."
assignment.
The reason why I didn't get a dereference of an invalid pointer during
my testing is that I didn't test bridging between a DSA-offloaded LAG
and a foreign (non-DSA) interface - that's the kind of dynamic FDB entry
that check is for.
I saw that the patches aren't active in patchwork anymore and I have
this already fixed, but I'd wait for some feedback until I resend.
Maybe I'll resend on Monday or so.
next prev parent reply other threads:[~2022-02-11 23:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-10 12:51 [PATCH v2 net-next 00/12] FDB entries on DSA LAG interfaces Vladimir Oltean
2022-02-10 12:51 ` [PATCH v2 net-next 01/12] net: dsa: rename references to "lag" as "lag_dev" Vladimir Oltean
2022-02-10 12:51 ` [PATCH v2 net-next 02/12] net: dsa: mv88e6xxx: " Vladimir Oltean
2022-02-10 12:51 ` [PATCH v2 net-next 03/12] net: dsa: qca8k: " Vladimir Oltean
2022-02-10 12:51 ` [PATCH v2 net-next 04/12] net: dsa: make LAG IDs one-based Vladimir Oltean
2022-02-10 12:51 ` [PATCH v2 net-next 05/12] net: dsa: mv88e6xxx: use dsa_switch_for_each_port in mv88e6xxx_lag_sync_masks Vladimir Oltean
2022-02-10 12:51 ` [PATCH v2 net-next 06/12] net: dsa: create a dsa_lag structure Vladimir Oltean
2022-02-10 12:51 ` [PATCH v2 net-next 07/12] net: switchdev: export switchdev_lower_dev_find Vladimir Oltean
2022-02-10 12:51 ` [PATCH v2 net-next 08/12] net: dsa: remove "ds" and "port" from struct dsa_switchdev_event_work Vladimir Oltean
2022-02-10 12:51 ` [PATCH v2 net-next 09/12] net: dsa: move dsa_foreign_dev_check above dsa_slave_switchdev_event_work Vladimir Oltean
2022-02-10 12:51 ` [PATCH v2 net-next 10/12] net: dsa: refactor FDB event work for user ports to separate function Vladimir Oltean
2022-02-10 12:52 ` [PATCH v2 net-next 11/12] net: dsa: support FDB events on offloaded LAG interfaces Vladimir Oltean
2022-02-11 23:03 ` Jakub Kicinski
2022-02-11 23:14 ` Vladimir Oltean [this message]
2022-02-10 12:52 ` [PATCH v2 net-next 12/12] net: dsa: felix: support FDB entries " 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=20220211231421.erqojnturtnmtfvo@skbuf \
--to=vladimir.oltean@nxp.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=dqfext@gmail.com \
--cc=f.fainelli@gmail.com \
--cc=ivecera@redhat.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=tobias@waldekranz.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