]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
batman-adv: tp_meter: split vars into sender and receiver types
authorSven Eckelmann <sven@narfation.org>
Sat, 9 May 2026 16:33:16 +0000 (18:33 +0200)
committerSven Eckelmann <sven@narfation.org>
Wed, 3 Jun 2026 06:02:21 +0000 (08:02 +0200)
commitfeb4a390a540eec60a2c39f7b893f19fdf57b3a5
treefe80d439a362d32d0f998e5277e321109c7e27dc
parent15ccbf685222274f5add1387af58c2a41a95f81e
batman-adv: tp_meter: split vars into sender and receiver types

The monolithic batadv_tp_vars struct holds fields for both sender and
receiver roles, distinguished only by a runtime enum role. This makes it
easy to accidentally access a field intended for the opposite role, since
neither the compiler nor the type system provide any guard against such
mistakes. The role check also adds unnecessary branching in several code
paths.

Introduce batadv_tp_vars_common to hold fields shared across both roles,
then derive two separate types (sender/receiver) from it. The functions can
operate on them without any ambiguity about the available fields. This also
reduces the memory footprint of receiver sessions, which no longer carry
the substantial sender-only fields.

Care must be taken to prevent concurrent TP sessions between the same two
peers in opposite directions, since sender and receiver sessions are now
tracked in separate lists and a lookup in one list no longer detects a
session in the other.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
net/batman-adv/main.c
net/batman-adv/tp_meter.c
net/batman-adv/types.h