From: Sabrina Dubroca <sd@queasysnail.net>
To: Cosmin Ratiu <cratiu@nvidia.com>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Dragos Tatulea <dtatulea@nvidia.com>
Subject: Re: [PATCH net-next v2 1/3] nsim: Add support for VLAN filters
Date: Sat, 28 Feb 2026 12:21:42 +0100 [thread overview]
Message-ID: <aaLPxrqoWsVC7PkB@krikkit> (raw)
In-Reply-To: <20260227090227.1552512-2-cratiu@nvidia.com>
2026-02-27, 11:02:25 +0200, Cosmin Ratiu wrote:
> Add support for storing the list of VLANs in nsim devices, together with
> ops for adding/removing them and a debug file to show them.
>
> This will be used in upcoming tests.
>
> Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
> ---
> drivers/net/netdevsim/netdev.c | 59 +++++++++++++++++++++++++++++--
> drivers/net/netdevsim/netdevsim.h | 8 +++++
> 2 files changed, 65 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
> index 6285fbefe38a..7177711cf9fc 100644
> --- a/drivers/net/netdevsim/netdev.c
> +++ b/drivers/net/netdevsim/netdev.c
> @@ -602,6 +602,36 @@ static int nsim_stop(struct net_device *dev)
> return 0;
> }
>
> +static int nsim_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
> +{
> + struct netdevsim *ns = netdev_priv(dev);
> +
> + if (vid >= VLAN_N_VID)
> + return -EINVAL;
> +
> + if (proto == htons(ETH_P_8021Q))
> + set_bit(vid, ns->vlan.ctag);
Maybe
DEBUG_NET_WARN_ON_ONCE(test_and_set_bit(vid, ns->vlan.ctag));
> + else if (proto == htons(ETH_P_8021AD))
> + set_bit(vid, ns->vlan.stag);
> +
> + return 0;
> +}
> +
> +static int nsim_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid)
> +{
> + struct netdevsim *ns = netdev_priv(dev);
> +
> + if (vid >= VLAN_N_VID)
> + return -EINVAL;
> +
> + if (proto == htons(ETH_P_8021Q))
> + clear_bit(vid, ns->vlan.ctag);
and
DEBUG_NET_WARN_ON_ONCE(!test_and_clear_bit(vid, ns->vlan.ctag));
> + else if (proto == htons(ETH_P_8021AD))
> + clear_bit(vid, ns->vlan.stag);
> +
> + return 0;
> +}
and in nsim_destroy, something like:
for_each_set_bit(vid, ns->vlan.ctag, VLAN_N_VID)
DEBUG_NET_WARN_ON_ONCE(1);
for_each_set_bit(vid, ns->vlan.stag, VLAN_N_VID)
DEBUG_NET_WARN_ON_ONCE(1);
just to make sure that we did all the accounting correctly?
This last one would catch problems like the error handling spotted by
AI (just add 3 offloaded devices + one non-offloaded, then try to
offload the last one, netdevsim accepts only 3 secys so mdo_add_secy
will fail):
# echo 1 > /sys/bus/netdevsim/new_device
# ip link add link eni1np1 type macsec port 5 offload mac
# ip link add link eni1np1 type macsec port 6 offload mac
# ip link add link eni1np1 type macsec port 7 offload mac
# ip link add macsec_H link eni1np1 type macsec offload off
# ip link add link macsec_H type vlan id 20
# cat /sys/kernel/debug/netdevsim/netdevsim1/ports/0/vlan
# ip link set macsec_H type macsec offload mac
RTNETLINK answers: No space left on device
# cat /sys/kernel/debug/netdevsim/netdevsim1/ports/0/vlan
ctag 20
# echo 1 > /sys/bus/netdevsim/del_device
<splat>
--
Sabrina
next prev parent reply other threads:[~2026-02-28 11:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 9:02 [PATCH net-next v2 0/3] macsec: Add support for VLAN filtering in offload mode Cosmin Ratiu
2026-02-27 9:02 ` [PATCH net-next v2 1/3] nsim: Add support for VLAN filters Cosmin Ratiu
2026-02-28 11:21 ` Sabrina Dubroca [this message]
2026-02-27 9:02 ` [PATCH net-next v2 2/3] selftests: Add macsec offload VLAN tests Cosmin Ratiu
2026-02-27 14:58 ` Jakub Kicinski
2026-03-06 15:01 ` Cosmin Ratiu
2026-03-06 20:04 ` Jakub Kicinski
2026-02-27 9:02 ` [PATCH net-next v2 3/3] macsec: Support VLAN-filtering lower devices Cosmin Ratiu
2026-02-27 14:59 ` Jakub Kicinski
2026-02-28 11:27 ` Sabrina Dubroca
2026-03-06 15:02 ` Cosmin Ratiu
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=aaLPxrqoWsVC7PkB@krikkit \
--to=sd@queasysnail.net \
--cc=andrew+netdev@lunn.ch \
--cc=cratiu@nvidia.com \
--cc=davem@davemloft.net \
--cc=dtatulea@nvidia.com \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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