Re: [PATCH net] neighbour: stop using device addresses in hashes

From: Eric Dumazet

Date: Wed Oct 07 2026 - 04:56:25 EST


Le mer. 7 oct. 2026 à 10:25, Ido Schimmel <idosch@xxxxxxxxxx> a écrit :
>
> On Tue, Oct 06, 2026 at 03:41:18PM -0700, Kyle Zeng wrote:
> > RTM_GETNEIGHTBL exposes the live hash multiplier and bucket mask. For
> > ARP, that multiplier is applied to the IPv4 key XOR hash32_ptr(dev).
> > Since hash32_ptr() merely folds the address, timing chosen-key misses
> > through the unprivileged SIOCGARP ioctl can reveal the folded address
> > of the loopback net_device. NDISC uses the same address-dependent
> > first hash term.
> >
> > Give each net_device an independent random neighbour hash discriminator
> > at allocation time and use it in both protocol hashes. Keep it immutable
> > so that lookups, insertion and rehashing agree even if the device's
> > ifindex or network namespace changes. This retains the cross-namespace
> > hash distribution that motivated using the device pointer, without
> > putting a kernel address into the observable hash. A dedicated value
> > also avoids making a salt used by unrelated network hashes observable.
> >
> > The existing NDTA_CONFIG fields and neighbour key comparisons can stay
> > unchanged. Update the net_device cacheline documentation and assertions
> > for the new read-mostly field.
> >
> > Fixes: b14f243a42c7 ("net: Dont use ifindices in hash fns")
> > Assisted-by: Codex:gpt-6-astra
> > Signed-off-by: Kyle Zeng <kylebot@xxxxxxxxxx>
> > ---
> > Documentation/networking/net_cachelines/net_device.rst | 1 +
> > include/linux/netdevice.h | 2 ++
> > include/net/arp.h | 3 +--
> > include/net/ndisc.h | 3 +--
> > net/core/dev.c | 4 +++-
> > 5 files changed, 8 insertions(+), 5 deletions(-)
>
> Eric,
>
> Given [1], do you think this should be targeted at net-next?
>
> In net-next the neighbour tables are per-netns, so we can return to
> hashing based on the device index instead of its pointer. Something like
> [2].

Definitely this can target net-next and avoid merge conflicts.