Ethernet Bridge development
 help / color / mirror / Atom feed
From: Nikolay Aleksandrov <razor@blackwall.org>
To: netdev@vger.kernel.org
Cc: idosch@nvidia.com, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	bridge@lists.linux.dev
Subject: Re: [PATCH net-next 3/9] net: bridge: vlan: cache the pvid vlan entry directly
Date: Sat, 19 Sep 2026 21:07:47 +0300	[thread overview]
Message-ID: <859a23ef-81a5-4bba-a728-49dbfc8a575e@blackwall.org> (raw)
In-Reply-To: <20260918152950.1938259-4-razor@blackwall.org>

On 18/09/2026 18:29, Nikolay Aleksandrov wrote:
> VLAN groups cache the pvid and its state separately requiring state
> updates to keep both copies synchronized. Lockless readers can also
> observe the pvid and state from different updates. Cache an rcu protected
> pointer to the pvid vlan entry instead. This makes the vlan entry the
> single source of truth and lets the ingress path reuse it without another
> lookup. It also makes the vlan entry always available at the ingress path
> for subsequent forwarding-path optimizations.
> 
> Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
> ---
>   net/bridge/br_mst.c          | 13 ++----
>   net/bridge/br_private.h      | 25 +++++-------
>   net/bridge/br_vlan.c         | 76 ++++++++++++++----------------------
>   net/bridge/br_vlan_options.c | 12 ++----
>   4 files changed, 46 insertions(+), 80 deletions(-)
> 

for this patch Sashiko says:
  Does this code introduce a memory corruption regression due to a missing
  release barrier?
  RCU_INIT_POINTER() publishes the pointer to the datapath without an
  smp_store_release() barrier, unlike rcu_assign_pointer().
  If a lockless reader observes the new vg->pvid pointer before the VLAN
  fields are fully initialized (due to CPU out-of-order execution), it might
  read an uninitialized v->stats pointer in __allowed_ingress() when an
  untagged packet arrives.
  Calling this_cpu_ptr() on an uninitialized v->stats pointer could resolve
  to the base of the per-cpu memory region or an invalid address, causing
  subsequent u64_stats_add() increments to silently corrupt per-cpu variables
  or cause a kernel oops.
  Could rcu_assign_pointer() be used instead to ensure prior initialization
  is visible to readers?


Nik says: No, if that could happen we would be in trouble even today. These
           fields are initialized before the VLAN is published, i.e. before
           inserting it in the VLAN rhashtable and linking it to the VLAN
           list, only after that the pvid is applied by __vlan_flags_commit()

Cheers,
  Nik


  reply	other threads:[~2026-09-19 18:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18 15:29 [PATCH net-next 0/9] net: bridge: vlan: broadcast fwding path optimizations Nikolay Aleksandrov
2026-09-18 15:29 ` [PATCH net-next 1/9] net: bridge: factor out common flood completion handling Nikolay Aleksandrov
2026-09-18 15:29 ` [PATCH net-next 2/9] net: bridge: factor out port flooding Nikolay Aleksandrov
2026-09-18 15:29 ` [PATCH net-next 3/9] net: bridge: vlan: cache the pvid vlan entry directly Nikolay Aleksandrov
2026-09-19 18:07   ` Nikolay Aleksandrov [this message]
2026-09-18 15:29 ` [PATCH net-next 4/9] net: bridge: vlan: introduce a list of port-VLANs in the master VLAN Nikolay Aleksandrov
2026-09-18 15:29 ` [PATCH net-next 5/9] net: bridge: consider only port-VLAN members when flooding Nikolay Aleksandrov
2026-09-18 15:29 ` [PATCH net-next 6/9] net: bridge: vlan: use an RCU array for large flood sets Nikolay Aleksandrov
2026-09-18 15:29 ` [PATCH net-next 7/9] net: bridge: introduce a forwarding destination structure Nikolay Aleksandrov
2026-09-18 15:29 ` [PATCH net-next 8/9] net: bridge: avoid egress VLAN lookups when flooding Nikolay Aleksandrov
2026-09-18 15:29 ` [PATCH net-next 9/9] net: bridge: avoid VLAN lookups for flood neighbour suppression Nikolay Aleksandrov
2026-09-21 13:44 ` [PATCH net-next 0/9] net: bridge: vlan: broadcast fwding path optimizations Ido Schimmel
2026-09-21 13:57   ` Nikolay Aleksandrov
2026-09-22  0:50 ` patchwork-bot+netdevbpf

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=859a23ef-81a5-4bba-a728-49dbfc8a575e@blackwall.org \
    --to=razor@blackwall.org \
    --cc=bridge@lists.linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.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