]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: add address list snapshot and reconciliation infrastructure
authorStanislav Fomichev <sdf.kernel@gmail.com>
Thu, 16 Apr 2026 18:56:58 +0000 (11:56 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 21 Apr 2026 10:50:03 +0000 (12:50 +0200)
commitdb9e726525e45dbd713c07897a4d20bc18333ccc
tree8fa043a33e29e96043f7f3380bcc6cb09152ae9b
parent4c1367a2d7aad643a6f87c6931b13cc1a25e8ca7
net: add address list snapshot and reconciliation infrastructure

Introduce __hw_addr_list_snapshot() and __hw_addr_list_reconcile()
for use by the upcoming ndo_set_rx_mode_async callback.

The async rx_mode path needs to snapshot the device's unicast and
multicast address lists under the addr_lock, hand those snapshots
to the driver (which may sleep), and then propagate any sync_cnt
changes back to the real lists. Two identical snapshots are taken:
a work copy for the driver to pass to __hw_addr_sync_dev() and a
reference copy to compute deltas against.

__hw_addr_list_reconcile() walks the reference snapshot comparing
each entry against the work snapshot to determine what the driver
synced or unsynced. It then applies those deltas to the real list,
handling concurrent modifications:

  - If the real entry was concurrently removed but the driver synced
    it to hardware (delta > 0), re-insert a stale entry so the next
    work run properly unsyncs it from hardware.
  - If the entry still exists, apply the delta normally. An entry
    whose refcount drops to zero is removed.

  # dev_addr_test_snapshot_benchmark: 1024 addrs x 1000 snapshots: 89872802 ns total, 89872 ns/iter
  # dev_addr_test_snapshot_benchmark.speed: slow

Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20260416185712.2155425-2-sdf@fomichev.me
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/linux/netdevice.h
net/core/dev.h
net/core/dev_addr_lists.c
net/core/dev_addr_lists_test.c