From: Paolo Abeni <pabeni@redhat.com>
To: michael.dege@renesas.com
Cc: paul@pbarker.dev, niklas.soderlund@ragnatech.se, kuba@kernel.org,
yoshihiro.shimoda.uh@renesas.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, edumazet@google.com,
pabeni@redhat.com, linux-renesas-soc@vger.kernel.org,
andrew+netdev@lunn.ch, davem@davemloft.net
Subject: Re: [net-next,v3,13/13] net: renesas: rswitch: add vlan aware switching
Date: Thu, 2 Apr 2026 14:59:46 +0200 [thread overview]
Message-ID: <20260402125946.234499-1-pabeni@redhat.com> (raw)
In-Reply-To: <20260331-rswitch_add_vlans-v3-13-c37f41b1c556@renesas.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: renesas: rswitch: add vlan aware switching
This commit adds vlan support to the L2 HW bridge, with limited support
on R-Car S4 (not fully 802.1Q compliant).
> diff --git a/drivers/net/ethernet/renesas/Kconfig b/drivers/net/ethernet/renesas/Kconfig
> index 9b7559c88bee..2494ff60e8c2 100644
> --- a/drivers/net/ethernet/renesas/Kconfig
> +++ b/drivers/net/ethernet/renesas/Kconfig
[ ... ]
> diff --git a/drivers/net/ethernet/renesas/rswitch_l2.c b/drivers/net/ethernet/renesas/rswitch_l2.c
> index ea95a87ed234..b7d0e7f94ecd 100644
> --- a/drivers/net/ethernet/renesas/rswitch_l2.c
> +++ b/drivers/net/ethernet/renesas/rswitch_l2.c
[ ... ]
> @@ -212,61 +197,397 @@ static int rswitch_netdevice_event(struct notifier_block *nb,
[ ... ]
> +static int rswitch_handle_port_obj_add(struct net_device *ndev,
> + struct notifier_block *nb,
> + struct switchdev_notifier_port_obj_info *info)
> +{
> + struct switchdev_obj_port_vlan *p_vlan = SWITCHDEV_OBJ_PORT_VLAN(info->obj);
> + struct rswitch_private *priv;
> + int err;
> +
> + priv = container_of(nb, struct rswitch_private, rswitch_switchdev_blocking_nb);
> +
> + if ((p_vlan->flags & BRIDGE_VLAN_INFO_MASTER) ||
> + (p_vlan->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) ||
> + (p_vlan->flags & BRIDGE_VLAN_INFO_RANGE_END) ||
> + (p_vlan->flags & BRIDGE_VLAN_INFO_ONLY_OPTS))
> + return NOTIFY_DONE;
> +
> + switch (info->obj->id) {
> + case SWITCHDEV_OBJ_ID_PORT_VLAN:
Can the flag checks access the wrong memory? The code casts info->obj to
switchdev_obj_port_vlan before checking info->obj->id. When the notifier
delivers a non-VLAN object (such as SWITCHDEV_OBJ_ID_PORT_MDB for multicast
group changes), SWITCHDEV_OBJ_PORT_VLAN() performs an incorrect container_of
cast, and p_vlan->flags reads bytes from a different struct type.
For switchdev_obj_port_mdb, the p_vlan->flags field overlaps with the first
2 bytes of the addr[ETH_ALEN] MAC address field. Multicast MAC addresses
always have bit 0 of the first byte set, which matches BRIDGE_VLAN_INFO_MASTER
(1<<0), causing the function to return NOTIFY_DONE instead of falling through
to the default case that returns -EOPNOTSUPP.
Other switchdev drivers (lan966x, mlxsw, cpsw) perform the
SWITCHDEV_OBJ_PORT_VLAN cast inside the SWITCHDEV_OBJ_ID_PORT_VLAN case,
not before the type switch.
The same issue exists in rswitch_handle_port_obj_del().
> + if (!is_rdev(ndev))
> + err = rswitch_port_obj_do_add_gwca(ndev, priv, p_vlan);
> + else
> + err = rswitch_port_obj_do_add(ndev, p_vlan);
> +
> + if (err < 0)
> + return err;
> +
> + break;
> + default:
> + return -EOPNOTSUPP;
> + }
> +
> + info->handled = true;
> +
> + return NOTIFY_DONE;
> +}
> +
> +static int rswitch_handle_port_obj_del(struct net_device *ndev,
> + struct notifier_block *nb,
> + struct switchdev_notifier_port_obj_info *info)
> +{
> + struct switchdev_obj_port_vlan *p_vlan = SWITCHDEV_OBJ_PORT_VLAN(info->obj);
> + struct rswitch_private *priv;
> + int err;
> +
> + priv = container_of(nb, struct rswitch_private, rswitch_switchdev_blocking_nb);
> +
> + if ((p_vlan->flags & BRIDGE_VLAN_INFO_MASTER) ||
> + (p_vlan->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) ||
> + (p_vlan->flags & BRIDGE_VLAN_INFO_RANGE_END) ||
> + (p_vlan->flags & BRIDGE_VLAN_INFO_ONLY_OPTS))
> + return NOTIFY_DONE;
> +
> + switch (info->obj->id) {
> + case SWITCHDEV_OBJ_ID_PORT_VLAN:
> + if (!is_rdev(ndev))
> + err = rswitch_port_obj_do_del_gwca(ndev, priv, p_vlan);
> + else
> + err = rswitch_port_obj_do_del(ndev, p_vlan);
> +
> + if (err < 0)
> + return err;
> +
> + break;
> + default:
> + return -EOPNOTSUPP;
> + }
> +
> + info->handled = true;
> +
> + return NOTIFY_DONE;
> +}
[ ... ]
prev parent reply other threads:[~2026-04-02 13:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 10:03 [net-next PATCH v3 00/13] net: renesas: rswitch: R-Car S4 add VLAN aware switching Michael Dege
2026-03-31 10:03 ` [PATCH net-next v3 01/13] net: renesas: rswitch: improve port change mode functions Michael Dege
2026-04-02 12:59 ` [net-next,v3,01/13] " Paolo Abeni
2026-03-31 10:03 ` [PATCH net-next v3 02/13] net: renesas: rswitch: use device instead of net_device Michael Dege
2026-03-31 10:03 ` [PATCH net-next v3 03/13] net: renesas: rswitch: fix FWPC2 register access macros Michael Dege
2026-03-31 10:03 ` [PATCH net-next v3 04/13] net: renesas: rswitch: add register definitions for vlan support Michael Dege
2026-04-02 12:59 ` [net-next,v3,04/13] " Paolo Abeni
2026-04-02 13:02 ` [PATCH net-next v3 04/13] " Paolo Abeni
2026-03-31 10:03 ` [PATCH net-next v3 05/13] net: renesas: rswitch: add exception path for packets with unknown dst MAC Michael Dege
2026-04-02 12:59 ` [net-next,v3,05/13] " Paolo Abeni
2026-03-31 10:04 ` [PATCH net-next v3 06/13] net: renesas: rswitch: add forwarding rules for gwca Michael Dege
2026-04-02 12:59 ` [net-next,v3,06/13] " Paolo Abeni
2026-03-31 10:04 ` [PATCH net-next v3 07/13] net: renesas: rswitch: make helper functions available to whole driver Michael Dege
2026-03-31 10:04 ` [PATCH net-next v3 08/13] net: renesas: rswitch: add basic vlan init to rswitch_fwd_init Michael Dege
2026-03-31 10:04 ` [PATCH net-next v3 09/13] net: renesas: rswitch: update port HW init Michael Dege
2026-03-31 10:04 ` [PATCH net-next v3 10/13] net: renesas: rswitch: clean up is_rdev rswitch_device checking Michael Dege
2026-03-31 10:04 ` [PATCH net-next v3 11/13] net: renesas: rswitch: add passing of rswitch_private into notifiers Michael Dege
2026-03-31 10:04 ` [PATCH net-next v3 12/13] net: renesas: rswitch: add handler for FDB notification Michael Dege
2026-04-02 12:59 ` [net-next,v3,12/13] " Paolo Abeni
2026-04-02 13:06 ` [PATCH net-next v3 12/13] " Paolo Abeni
2026-03-31 10:04 ` [PATCH net-next v3 13/13] net: renesas: rswitch: add vlan aware switching Michael Dege
2026-04-02 12:59 ` Paolo Abeni [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=20260402125946.234499-1-pabeni@redhat.com \
--to=pabeni@redhat.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=michael.dege@renesas.com \
--cc=netdev@vger.kernel.org \
--cc=niklas.soderlund@ragnatech.se \
--cc=paul@pbarker.dev \
--cc=yoshihiro.shimoda.uh@renesas.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