From: Simon Horman <simon.horman@corigine.com>
To: Wojciech Drewek <wojciech.drewek@intel.com>
Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
alexandr.lobakin@intel.com, david.m.ertman@intel.com,
michal.swiatkowski@linux.intel.com,
marcin.szycik@linux.intel.com, pawel.chmielewski@intel.com,
sridhar.samudrala@intel.com,
Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: [PATCH iwl-next v3 03/10] ice: Implement basic eswitch bridge setup
Date: Mon, 22 May 2023 13:22:37 +0200 [thread overview]
Message-ID: <ZGtQffLjYdt14Lpg@corigine.com> (raw)
In-Reply-To: <20230522090542.45679-4-wojciech.drewek@intel.com>
+Dan Carpenter
On Mon, May 22, 2023 at 11:05:35AM +0200, Wojciech Drewek wrote:
> With this patch, ice driver is able to track if the port
> representors or uplink port were added to the linux bridge in
> switchdev mode. Listen for NETDEV_CHANGEUPPER events in order to
> detect this. ice_esw_br data structure reflects the linux bridge
> and stores all the ports of the bridge (ice_esw_br_port) in
> xarray, it's created when the first port is added to the bridge and
> freed once the last port is removed. Note that only one bridge is
> supported per eswitch.
>
> Bridge port (ice_esw_br_port) can be either a VF port representor
> port or uplink port (ice_esw_br_port_type). In both cases bridge port
> holds a reference to the VSI, VF's VSI in case of the PR and uplink
> VSI in case of the uplink. VSI's index is used as an index to the
> xarray in which ports are stored.
>
> Add a check which prevents configuring switchdev mode if uplink is
> already added to any bridge. This is needed because we need to listen
> for NETDEV_CHANGEUPPER events to record if the uplink was added to
> the bridge. Netdevice notifier is registered after eswitch mode
> is changed top switchdev.
>
> Signed-off-by: Wojciech Drewek <wojciech.drewek@intel.com>
...
> +static void
> +ice_eswitch_br_port_deinit(struct ice_esw_br *bridge,
> + struct ice_esw_br_port *br_port)
> +{
> + struct ice_vsi *vsi = br_port->vsi;
> +
> + if (br_port->type == ICE_ESWITCH_BR_UPLINK_PORT && vsi->back)
> + vsi->back->br_port = NULL;
> + else if (vsi->vf)
> + vsi->vf->repr->br_port = NULL;
> +
> + xa_erase(&bridge->ports, br_port->vsi_idx);
> + kfree(br_port);
> +}
...
> +static int
> +ice_eswitch_br_port_unlink(struct ice_esw_br_offloads *br_offloads,
> + struct net_device *dev, int ifindex,
> + struct netlink_ext_ack *extack)
> +{
> + struct ice_esw_br_port *br_port = ice_eswitch_br_netdev_to_port(dev);
> +
> + if (!br_port) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Port representor is not attached to any bridge");
> + return -EINVAL;
> + }
> +
> + if (br_port->bridge->ifindex != ifindex) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Port representor is attached to another bridge");
> + return -EINVAL;
> + }
> +
> + ice_eswitch_br_port_deinit(br_port->bridge, br_port);
Hi Wojciech,
According to Smatch, ice_eswitch_br_port_deinit() will free br_port.
> + ice_eswitch_br_verify_deinit(br_offloads, br_port->bridge);
But br_port is dereferenced here.
.../ice_eswitch_br.c:207 ice_eswitch_br_port_unlink() error: dereferencing freed memory 'br_port'
> +
> + return 0;
> +}
...
--
pw-bot: cr
next prev parent reply other threads:[~2023-05-22 11:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-22 9:05 [PATCH iwl-next v3 00/10] ice: switchdev bridge offload Wojciech Drewek
2023-05-22 9:05 ` [PATCH iwl-next v3 01/10] ice: Minor switchdev fixes Wojciech Drewek
2023-05-22 10:05 ` [Intel-wired-lan] " Paul Menzel
2023-05-23 9:20 ` Drewek, Wojciech
2023-05-22 9:05 ` [PATCH iwl-next v3 02/10] ice: Unset src prune on uplink VSI Wojciech Drewek
2023-05-22 9:05 ` [PATCH iwl-next v3 03/10] ice: Implement basic eswitch bridge setup Wojciech Drewek
2023-05-22 11:22 ` Simon Horman [this message]
2023-05-23 10:09 ` Drewek, Wojciech
2023-05-22 9:05 ` [PATCH iwl-next v3 04/10] ice: Switchdev FDB events support Wojciech Drewek
2023-05-22 9:05 ` [PATCH iwl-next v3 05/10] ice: Add guard rule when creating FDB in switchdev Wojciech Drewek
2023-05-22 9:05 ` [PATCH iwl-next v3 06/10] ice: Accept LAG netdevs in bridge offloads Wojciech Drewek
2023-05-22 9:05 ` [PATCH iwl-next v3 07/10] ice: Add VLAN FDB support in switchdev mode Wojciech Drewek
2023-05-22 9:05 ` [PATCH iwl-next v3 08/10] ice: implement bridge port vlan Wojciech Drewek
2023-05-22 11:27 ` Simon Horman
2023-05-23 10:10 ` Drewek, Wojciech
2023-05-22 9:05 ` [PATCH iwl-next v3 09/10] ice: implement static version of ageing Wojciech Drewek
2023-05-22 10:13 ` [Intel-wired-lan] " Paul Menzel
2023-05-23 10:00 ` Drewek, Wojciech
2023-05-22 9:05 ` [PATCH iwl-next v3 10/10] ice: add tracepoints for the switchdev bridge Wojciech Drewek
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=ZGtQffLjYdt14Lpg@corigine.com \
--to=simon.horman@corigine.com \
--cc=alexandr.lobakin@intel.com \
--cc=dan.carpenter@linaro.org \
--cc=david.m.ertman@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=marcin.szycik@linux.intel.com \
--cc=michal.swiatkowski@linux.intel.com \
--cc=netdev@vger.kernel.org \
--cc=pawel.chmielewski@intel.com \
--cc=sridhar.samudrala@intel.com \
--cc=wojciech.drewek@intel.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).