* [PATCH net-next 01/15] batman-adv: bla: use dedicated key type for claim hash
2026-11-14 9:15 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-14 Simon Wunderlich
@ 2026-11-14 9:15 ` Simon Wunderlich
2026-11-14 9:15 ` [PATCH net-next 02/15] batman-adv: bla: use dedicated key type for backbone gateway hash Simon Wunderlich
` (13 subsequent siblings)
14 siblings, 0 replies; 20+ messages in thread
From: Simon Wunderlich @ 2026-11-14 9:15 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
The claim hash lookup functions are given a struct batadv_bla_claim.
For a lookup, a dummy claim is created on the stack and only its addr
and vid members are filled. All other members stay uninitialized, and
only by reading the hash and compare callbacks can one tell which
members form the key.
Move addr and vid into a new struct batadv_bla_claim_key, embedded as
batadv_bla_claim::key. The helpers are only using this key for
hashing/comparison.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/bridge_loop_avoidance.c | 98 +++++++++++++-------------
net/batman-adv/types.h | 12 +++-
2 files changed, 60 insertions(+), 50 deletions(-)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index fc8336aa09a0c..a5ac7ba24e834 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -59,18 +59,18 @@ batadv_bla_send_announce(struct batadv_priv *bat_priv,
/**
* batadv_choose_claim() - choose the right bucket for a claim.
- * @data: data to hash
+ * @data: &struct batadv_bla_claim_key to hash
* @size: size of the hash table
*
* Return: the hash index of the claim
*/
static inline u32 batadv_choose_claim(const void *data, u32 size)
{
- const struct batadv_bla_claim *claim = data;
+ const struct batadv_bla_claim_key *key = data;
u32 hash = 0;
- hash = jhash(&claim->addr, sizeof(claim->addr), hash);
- hash = jhash(&claim->vid, sizeof(claim->vid), hash);
+ hash = jhash(&key->addr, sizeof(key->addr), hash);
+ hash = jhash(&key->vid, sizeof(key->vid), hash);
return hash % size;
}
@@ -119,24 +119,24 @@ static bool batadv_compare_backbone_gw(const struct hlist_node *node,
}
/**
- * batadv_compare_claim() - compare address and vid of two claims
- * @node: list node of the first entry to compare
- * @data2: pointer to the second claims
+ * batadv_compare_claim() - compare key of a claim with a search key
+ * @node: list node of the claim to compare
+ * @data2: &struct batadv_bla_claim_key to compare with
*
- * Return: true if the claims have the same data, false otherwise
+ * Return: true if the claim has the given key, false otherwise
*/
static bool batadv_compare_claim(const struct hlist_node *node,
const void *data2)
{
- const void *data1 = container_of(node, struct batadv_bla_claim,
- hash_entry);
- const struct batadv_bla_claim *cl1 = data1;
- const struct batadv_bla_claim *cl2 = data2;
+ const struct batadv_bla_claim_key *key = data2;
+ const struct batadv_bla_claim *claim;
+
+ claim = container_of(node, struct batadv_bla_claim, hash_entry);
- if (!batadv_compare_eth(cl1->addr, cl2->addr))
+ if (!batadv_compare_eth(claim->key.addr, key->addr))
return false;
- if (cl1->vid != cl2->vid)
+ if (claim->key.vid != key->vid)
return false;
return true;
@@ -188,7 +188,7 @@ static void batadv_claim_release(struct kref *ref)
spin_unlock_bh(&claim->backbone_lock);
spin_lock_bh(&old_backbone_gw->crc_lock);
- old_backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
+ old_backbone_gw->crc ^= crc16(0, claim->key.addr, ETH_ALEN);
spin_unlock_bh(&old_backbone_gw->crc_lock);
batadv_backbone_gw_put(old_backbone_gw);
@@ -211,13 +211,13 @@ static void batadv_claim_put(struct batadv_bla_claim *claim)
/**
* batadv_claim_hash_find() - looks for a claim in the claim hash
* @bat_priv: the bat priv with all the mesh interface information
- * @data: search data (may be local/static data)
+ * @key: key of the searched claim
*
* Return: claim if found or NULL otherwise.
*/
static struct batadv_bla_claim *
batadv_claim_hash_find(struct batadv_priv *bat_priv,
- struct batadv_bla_claim *data)
+ const struct batadv_bla_claim_key *key)
{
struct batadv_hashtable *hash = bat_priv->bla.claim_hash;
struct batadv_bla_claim *claim_tmp = NULL;
@@ -228,12 +228,12 @@ batadv_claim_hash_find(struct batadv_priv *bat_priv,
if (!hash)
return NULL;
- index = batadv_choose_claim(data, hash->size);
+ index = batadv_choose_claim(key, hash->size);
head = &hash->table[index];
rcu_read_lock();
hlist_for_each_entry_rcu(claim, head, hash_entry) {
- if (!batadv_compare_claim(&claim->hash_entry, data))
+ if (!batadv_compare_claim(&claim->hash_entry, key))
continue;
if (!kref_get_unless_zero(&claim->refcount))
@@ -615,7 +615,8 @@ static void batadv_bla_answer_request(struct batadv_priv *bat_priv,
if (claim->backbone_gw != backbone_gw)
continue;
- batadv_bla_send_claim(bat_priv, claim->addr, claim->vid,
+ batadv_bla_send_claim(bat_priv, claim->key.addr,
+ claim->key.vid,
BATADV_CLAIM_TYPE_CLAIM);
}
rcu_read_unlock();
@@ -688,15 +689,15 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
struct batadv_bla_backbone_gw *backbone_gw)
{
struct batadv_bla_backbone_gw *old_backbone_gw;
- struct batadv_bla_claim search_claim;
+ struct batadv_bla_claim_key claim_key;
struct batadv_bla_claim *claim;
int hash_added;
u16 claim_crc;
bool changed;
- ether_addr_copy(search_claim.addr, mac);
- search_claim.vid = vid;
- claim = batadv_claim_hash_find(bat_priv, &search_claim);
+ ether_addr_copy(claim_key.addr, mac);
+ claim_key.vid = vid;
+ claim = batadv_claim_hash_find(bat_priv, &claim_key);
claim_crc = crc16(0, mac, ETH_ALEN);
/* create a new claim entry if it does not exist yet. */
@@ -705,9 +706,9 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
if (!claim)
return;
- ether_addr_copy(claim->addr, mac);
+ ether_addr_copy(claim->key.addr, mac);
+ claim->key.vid = vid;
spin_lock_init(&claim->backbone_lock);
- claim->vid = vid;
WRITE_ONCE(claim->lasttime, jiffies);
kref_get(&backbone_gw->refcount);
claim->backbone_gw = backbone_gw;
@@ -720,7 +721,7 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
kref_get(&claim->refcount);
hash_added = batadv_hash_add(bat_priv->bla.claim_hash,
batadv_compare_claim,
- batadv_choose_claim, claim,
+ batadv_choose_claim, &claim->key,
&claim->hash_entry);
if (unlikely(hash_added != 0)) {
@@ -813,12 +814,12 @@ static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
{
struct batadv_bla_claim *claim_removed_entry;
struct hlist_node *claim_removed_node;
- struct batadv_bla_claim search_claim;
+ struct batadv_bla_claim_key claim_key;
struct batadv_bla_claim *claim;
- ether_addr_copy(search_claim.addr, mac);
- search_claim.vid = vid;
- claim = batadv_claim_hash_find(bat_priv, &search_claim);
+ ether_addr_copy(claim_key.addr, mac);
+ claim_key.vid = vid;
+ claim = batadv_claim_hash_find(bat_priv, &claim_key);
if (!claim)
return;
@@ -827,7 +828,8 @@ static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
claim_removed_node = batadv_hash_remove(bat_priv->bla.claim_hash,
batadv_compare_claim,
- batadv_choose_claim, claim);
+ batadv_choose_claim,
+ &claim->key);
if (!claim_removed_node)
goto free_claim;
@@ -1355,11 +1357,11 @@ static void batadv_bla_purge_claims(struct batadv_priv *bat_priv,
purge_now:
batadv_dbg(BATADV_DBG_BLA, bat_priv,
"%s(): %pM, vid %d\n", __func__,
- claim->addr, claim->vid);
+ claim->key.addr, claim->key.vid);
batadv_handle_unclaim(bat_priv, primary_if,
backbone_gw->orig,
- claim->addr, claim->vid);
+ claim->key.addr, claim->key.vid);
skip:
batadv_backbone_gw_put(backbone_gw);
batadv_claim_put(claim);
@@ -1960,8 +1962,8 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
unsigned short vid, int packet_type)
{
struct batadv_bla_backbone_gw *backbone_gw;
+ struct batadv_bla_claim_key claim_key;
struct batadv_bla_claim *claim = NULL;
- struct batadv_bla_claim search_claim;
struct batadv_hard_iface *primary_if;
struct ethhdr *ethhdr;
bool own_claim;
@@ -2007,9 +2009,9 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
batadv_bla_check_ucast_duplist(bat_priv, skb))
goto handled;
- ether_addr_copy(search_claim.addr, ethhdr->h_source);
- search_claim.vid = vid;
- claim = batadv_claim_hash_find(bat_priv, &search_claim);
+ ether_addr_copy(claim_key.addr, ethhdr->h_source);
+ claim_key.vid = vid;
+ claim = batadv_claim_hash_find(bat_priv, &claim_key);
if (!claim) {
bool local = batadv_is_my_client(bat_priv, ethhdr->h_source, vid);
@@ -2098,8 +2100,8 @@ bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
unsigned short vid)
{
struct batadv_bla_backbone_gw *backbone_gw;
+ struct batadv_bla_claim_key claim_key;
struct batadv_bla_claim *claim = NULL;
- struct batadv_bla_claim search_claim;
struct batadv_hard_iface *primary_if;
struct ethhdr *ethhdr;
bool client_roamed;
@@ -2122,10 +2124,10 @@ bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
if (is_multicast_ether_addr(ethhdr->h_dest))
goto handled;
- ether_addr_copy(search_claim.addr, ethhdr->h_source);
- search_claim.vid = vid;
+ ether_addr_copy(claim_key.addr, ethhdr->h_source);
+ claim_key.vid = vid;
- claim = batadv_claim_hash_find(bat_priv, &search_claim);
+ claim = batadv_claim_hash_find(bat_priv, &claim_key);
/* if no claim exists, allow it. */
if (!claim)
@@ -2231,8 +2233,8 @@ batadv_bla_claim_dump_entry(struct sk_buff *msg, u32 portid,
goto put_backbone_gw;
}
- if (nla_put(msg, BATADV_ATTR_BLA_ADDRESS, ETH_ALEN, claim->addr) ||
- nla_put_u16(msg, BATADV_ATTR_BLA_VID, claim->vid) ||
+ if (nla_put(msg, BATADV_ATTR_BLA_ADDRESS, ETH_ALEN, claim->key.addr) ||
+ nla_put_u16(msg, BATADV_ATTR_BLA_VID, claim->key.vid) ||
nla_put(msg, BATADV_ATTR_BLA_BACKBONE, ETH_ALEN,
backbone_gw->orig) ||
nla_put_u16(msg, BATADV_ATTR_BLA_CRC,
@@ -2527,8 +2529,8 @@ bool batadv_bla_check_claim(struct batadv_priv *bat_priv,
{
struct batadv_hard_iface *primary_if = NULL;
struct batadv_bla_backbone_gw *backbone_gw;
+ struct batadv_bla_claim_key claim_key;
struct batadv_bla_claim *claim = NULL;
- struct batadv_bla_claim search_claim;
bool ret = true;
if (!READ_ONCE(bat_priv->bridge_loop_avoidance))
@@ -2539,10 +2541,10 @@ bool batadv_bla_check_claim(struct batadv_priv *bat_priv,
return ret;
/* First look if the mac address is claimed */
- ether_addr_copy(search_claim.addr, addr);
- search_claim.vid = vid;
+ ether_addr_copy(claim_key.addr, addr);
+ claim_key.vid = vid;
- claim = batadv_claim_hash_find(bat_priv, &search_claim);
+ claim = batadv_claim_hash_find(bat_priv, &claim_key);
/* If there is a claim and we are not owner of the claim,
* return false.
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index b3edfc71af4a7..9d43e9cac0cc6 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1836,14 +1836,22 @@ struct batadv_bla_backbone_gw {
};
/**
- * struct batadv_bla_claim - claimed non-mesh client structure
+ * struct batadv_bla_claim_key - key of a claim in &batadv_priv_bla.claim_hash
*/
-struct batadv_bla_claim {
+struct batadv_bla_claim_key {
/** @addr: mac address of claimed non-mesh client */
u8 addr[ETH_ALEN] __aligned(2);
/** @vid: vlan id this client was detected on */
unsigned short vid;
+};
+
+/**
+ * struct batadv_bla_claim - claimed non-mesh client structure
+ */
+struct batadv_bla_claim {
+ /** @key: hash key identifying the claim */
+ struct batadv_bla_claim_key key;
/** @backbone_gw: pointer to backbone gw claiming this client */
struct batadv_bla_backbone_gw *backbone_gw;
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH net-next 02/15] batman-adv: bla: use dedicated key type for backbone gateway hash
2026-11-14 9:15 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-14 Simon Wunderlich
2026-11-14 9:15 ` [PATCH net-next 01/15] batman-adv: bla: use dedicated key type for claim hash Simon Wunderlich
@ 2026-11-14 9:15 ` Simon Wunderlich
[not found] ` <sashiko-outbox-215348@kernel.org>
2026-11-14 9:15 ` [PATCH net-next 03/15] batman-adv: dat: use dedicated key type for DAT hash Simon Wunderlich
` (12 subsequent siblings)
14 siblings, 1 reply; 20+ messages in thread
From: Simon Wunderlich @ 2026-11-14 9:15 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
batadv_backbone_hash_find() creates a dummy struct batadv_bla_backbone_gw
on the stack and only fills orig and vid for the lookup. Which members
are part of the key is only visible in the hash and compare callbacks.
Move orig and vid into a new struct batadv_bla_backbone_gw_key, embedded as
batadv_bla_backbone_gw::key. The helpers are only using this key for
hashing/comparison.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/bridge_loop_avoidance.c | 103 ++++++++++++-------------
net/batman-adv/types.h | 13 +++-
2 files changed, 62 insertions(+), 54 deletions(-)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index a5ac7ba24e834..cc7a98fbc3d2a 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -77,42 +77,41 @@ static inline u32 batadv_choose_claim(const void *data, u32 size)
/**
* batadv_choose_backbone_gw() - choose the right bucket for a backbone gateway.
- * @data: data to hash
+ * @data: &struct batadv_bla_backbone_gw_key to hash
* @size: size of the hash table
*
* Return: the hash index of the backbone gateway
*/
static inline u32 batadv_choose_backbone_gw(const void *data, u32 size)
{
- const struct batadv_bla_backbone_gw *gw;
+ const struct batadv_bla_backbone_gw_key *key = data;
u32 hash = 0;
- gw = data;
- hash = jhash(&gw->orig, sizeof(gw->orig), hash);
- hash = jhash(&gw->vid, sizeof(gw->vid), hash);
+ hash = jhash(&key->orig, sizeof(key->orig), hash);
+ hash = jhash(&key->vid, sizeof(key->vid), hash);
return hash % size;
}
/**
- * batadv_compare_backbone_gw() - compare address and vid of two backbone gws
- * @node: list node of the first entry to compare
- * @data2: pointer to the second backbone gateway
+ * batadv_compare_backbone_gw() - compare key of a backbone gw with a search key
+ * @node: list node of the backbone gateway to compare
+ * @data2: &struct batadv_bla_backbone_gw_key to compare with
*
- * Return: true if the backbones have the same data, false otherwise
+ * Return: true if the backbone gateway has the given key, false otherwise
*/
static bool batadv_compare_backbone_gw(const struct hlist_node *node,
const void *data2)
{
- const void *data1 = container_of(node, struct batadv_bla_backbone_gw,
- hash_entry);
- const struct batadv_bla_backbone_gw *gw1 = data1;
- const struct batadv_bla_backbone_gw *gw2 = data2;
+ const struct batadv_bla_backbone_gw_key *key = data2;
+ const struct batadv_bla_backbone_gw *gw;
+
+ gw = container_of(node, struct batadv_bla_backbone_gw, hash_entry);
- if (!batadv_compare_eth(gw1->orig, gw2->orig))
+ if (!batadv_compare_eth(gw->key.orig, key->orig))
return false;
- if (gw1->vid != gw2->vid)
+ if (gw->key.vid != key->vid)
return false;
return true;
@@ -261,24 +260,23 @@ batadv_backbone_hash_find(struct batadv_priv *bat_priv, const u8 *addr,
{
struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
struct batadv_bla_backbone_gw *backbone_gw_tmp = NULL;
- struct batadv_bla_backbone_gw search_entry;
struct batadv_bla_backbone_gw *backbone_gw;
+ struct batadv_bla_backbone_gw_key key;
struct hlist_head *head;
int index;
if (!hash)
return NULL;
- ether_addr_copy(search_entry.orig, addr);
- search_entry.vid = vid;
+ ether_addr_copy(key.orig, addr);
+ key.vid = vid;
- index = batadv_choose_backbone_gw(&search_entry, hash->size);
+ index = batadv_choose_backbone_gw(&key, hash->size);
head = &hash->table[index];
rcu_read_lock();
hlist_for_each_entry_rcu(backbone_gw, head, hash_entry) {
- if (!batadv_compare_backbone_gw(&backbone_gw->hash_entry,
- &search_entry))
+ if (!batadv_compare_backbone_gw(&backbone_gw->hash_entry, &key))
continue;
if (!kref_get_unless_zero(&backbone_gw->refcount))
@@ -462,9 +460,9 @@ static void batadv_bla_loopdetect_report(struct work_struct *work)
batadv_info(bat_priv->mesh_iface,
"Possible loop on VLAN %d detected which can't be handled by BLA - please check your network setup!\n",
- batadv_print_vid(backbone_gw->vid));
+ batadv_print_vid(backbone_gw->key.vid));
snprintf(vid_str, sizeof(vid_str), "%d",
- batadv_print_vid(backbone_gw->vid));
+ batadv_print_vid(backbone_gw->key.vid));
vid_str[sizeof(vid_str) - 1] = 0;
batadv_throw_uevent(bat_priv, BATADV_UEV_BLA, BATADV_UEV_LOOPDETECT,
@@ -503,21 +501,21 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, const u8 *orig,
if (!entry)
return NULL;
- entry->vid = vid;
+ entry->key.vid = vid;
WRITE_ONCE(entry->lasttime, jiffies);
entry->crc = BATADV_BLA_CRC_INIT;
entry->bat_priv = bat_priv;
spin_lock_init(&entry->crc_lock);
entry->state = BATADV_BLA_BACKBONE_GW_SYNCED;
entry->wait_periods = 0;
- ether_addr_copy(entry->orig, orig);
+ ether_addr_copy(entry->key.orig, orig);
INIT_WORK(&entry->report_work, batadv_bla_loopdetect_report);
kref_init(&entry->refcount);
kref_get(&entry->refcount);
hash_added = batadv_hash_add(bat_priv->bla.backbone_hash,
batadv_compare_backbone_gw,
- batadv_choose_backbone_gw, entry,
+ batadv_choose_backbone_gw, &entry->key,
&entry->hash_entry);
if (unlikely(hash_added != 0)) {
@@ -641,11 +639,11 @@ static void batadv_bla_send_request(struct batadv_bla_backbone_gw *backbone_gw)
batadv_bla_del_backbone_claims(backbone_gw);
batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv,
- "Sending REQUEST to %pM\n", backbone_gw->orig);
+ "Sending REQUEST to %pM\n", backbone_gw->key.orig);
/* send request */
- batadv_bla_send_claim(backbone_gw->bat_priv, backbone_gw->orig,
- backbone_gw->vid, BATADV_CLAIM_TYPE_REQUEST);
+ batadv_bla_send_claim(backbone_gw->bat_priv, backbone_gw->key.orig,
+ backbone_gw->key.vid, BATADV_CLAIM_TYPE_REQUEST);
/* no local broadcasts should be sent or received, for now. */
spin_lock_bh(&backbone_gw->bat_priv->bla.num_requests_lock);
@@ -673,7 +671,7 @@ static void batadv_bla_send_announce(struct batadv_priv *bat_priv,
spin_unlock_bh(&backbone_gw->crc_lock);
memcpy(&mac[4], &crc, 2);
- batadv_bla_send_claim(bat_priv, mac, backbone_gw->vid,
+ batadv_bla_send_claim(bat_priv, mac, backbone_gw->key.vid,
BATADV_CLAIM_TYPE_ANNOUNCE);
}
@@ -761,7 +759,7 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
batadv_dbg(BATADV_DBG_BLA, bat_priv,
"%s(): changing ownership for %pM, vid %d to gw %pM\n",
__func__, mac, batadv_print_vid(vid),
- backbone_gw->orig);
+ backbone_gw->key.orig);
/* add claim address to new backbone_gw */
spin_lock_bh(&backbone_gw->crc_lock);
@@ -875,7 +873,7 @@ static bool batadv_handle_announce(struct batadv_priv *bat_priv,
batadv_dbg(BATADV_DBG_BLA, bat_priv,
"%s(): ANNOUNCE vid %d (sent by %pM)... CRC = %#.4x\n",
- __func__, batadv_print_vid(vid), backbone_gw->orig, crc);
+ __func__, batadv_print_vid(vid), backbone_gw->key.orig, crc);
spin_lock_bh(&backbone_gw->crc_lock);
backbone_crc = backbone_gw->crc;
@@ -884,8 +882,8 @@ static bool batadv_handle_announce(struct batadv_priv *bat_priv,
if (backbone_crc != crc) {
batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv,
"%s(): CRC FAILED for %pM/%d (my = %#.4x, sent = %#.4x)\n",
- __func__, backbone_gw->orig,
- batadv_print_vid(backbone_gw->vid),
+ __func__, backbone_gw->key.orig,
+ batadv_print_vid(backbone_gw->key.vid),
backbone_crc, crc);
batadv_bla_send_request(backbone_gw);
@@ -1272,7 +1270,7 @@ static void batadv_bla_purge_backbone_gw(struct batadv_priv *bat_priv, int now)
batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv,
"%s(): backbone gw %pM timed out\n",
- __func__, backbone_gw->orig);
+ __func__, backbone_gw->key.orig);
purge_now:
purged = true;
@@ -1343,7 +1341,7 @@ static void batadv_bla_purge_claims(struct batadv_priv *bat_priv,
if (now)
goto purge_now;
- if (!batadv_compare_eth(backbone_gw->orig,
+ if (!batadv_compare_eth(backbone_gw->key.orig,
primary_if->net_dev->dev_addr))
goto skip;
@@ -1360,7 +1358,7 @@ static void batadv_bla_purge_claims(struct batadv_priv *bat_priv,
claim->key.addr, claim->key.vid);
batadv_handle_unclaim(bat_priv, primary_if,
- backbone_gw->orig,
+ backbone_gw->key.orig,
claim->key.addr, claim->key.vid);
skip:
batadv_backbone_gw_put(backbone_gw);
@@ -1411,11 +1409,11 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
rcu_read_lock();
hlist_for_each_entry_rcu(backbone_gw, head, hash_entry) {
/* own orig still holds the old value. */
- if (!batadv_compare_eth(backbone_gw->orig,
+ if (!batadv_compare_eth(backbone_gw->key.orig,
oldif->net_dev->dev_addr))
continue;
- ether_addr_copy(backbone_gw->orig,
+ ether_addr_copy(backbone_gw->key.orig,
primary_if->net_dev->dev_addr);
/* send an announce frame so others will ask for our
* claims and update their tables.
@@ -1441,9 +1439,10 @@ batadv_bla_send_loopdetect(struct batadv_priv *bat_priv,
struct batadv_bla_backbone_gw *backbone_gw)
{
batadv_dbg(BATADV_DBG_BLA, bat_priv, "Send loopdetect frame for vid %d\n",
- backbone_gw->vid);
+ backbone_gw->key.vid);
batadv_bla_send_claim(bat_priv, bat_priv->bla.loopdetect_addr,
- backbone_gw->vid, BATADV_CLAIM_TYPE_LOOPDETECT);
+ backbone_gw->key.vid,
+ BATADV_CLAIM_TYPE_LOOPDETECT);
}
/**
@@ -1524,7 +1523,7 @@ static void batadv_bla_periodic_work(struct work_struct *work)
rcu_read_lock();
hlist_for_each_entry_rcu(backbone_gw, head, hash_entry) {
- if (!batadv_compare_eth(backbone_gw->orig,
+ if (!batadv_compare_eth(backbone_gw->key.orig,
primary_if->net_dev->dev_addr))
continue;
@@ -1810,8 +1809,8 @@ bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv,
rcu_read_lock();
hlist_for_each_entry_rcu(backbone_gw, head, hash_entry) {
- if (batadv_compare_eth(backbone_gw->orig, orig) &&
- backbone_gw->vid == vid) {
+ if (batadv_compare_eth(backbone_gw->key.orig, orig) &&
+ backbone_gw->key.vid == vid) {
rcu_read_unlock();
return true;
}
@@ -2031,7 +2030,7 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
/* if it is our own claim ... */
backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
- own_claim = batadv_compare_eth(backbone_gw->orig,
+ own_claim = batadv_compare_eth(backbone_gw->key.orig,
primary_if->net_dev->dev_addr);
batadv_backbone_gw_put(backbone_gw);
@@ -2135,7 +2134,7 @@ bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
/* check if we are responsible. */
backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
- client_roamed = batadv_compare_eth(backbone_gw->orig,
+ client_roamed = batadv_compare_eth(backbone_gw->key.orig,
primary_if->net_dev->dev_addr);
batadv_backbone_gw_put(backbone_gw);
@@ -2221,7 +2220,7 @@ batadv_bla_claim_dump_entry(struct sk_buff *msg, u32 portid,
backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
- is_own = batadv_compare_eth(backbone_gw->orig, primary_addr);
+ is_own = batadv_compare_eth(backbone_gw->key.orig, primary_addr);
spin_lock_bh(&backbone_gw->crc_lock);
backbone_crc = backbone_gw->crc;
@@ -2236,7 +2235,7 @@ batadv_bla_claim_dump_entry(struct sk_buff *msg, u32 portid,
if (nla_put(msg, BATADV_ATTR_BLA_ADDRESS, ETH_ALEN, claim->key.addr) ||
nla_put_u16(msg, BATADV_ATTR_BLA_VID, claim->key.vid) ||
nla_put(msg, BATADV_ATTR_BLA_BACKBONE, ETH_ALEN,
- backbone_gw->orig) ||
+ backbone_gw->key.orig) ||
nla_put_u16(msg, BATADV_ATTR_BLA_CRC,
backbone_crc)) {
genlmsg_cancel(msg, hdr);
@@ -2383,7 +2382,7 @@ batadv_bla_backbone_dump_entry(struct sk_buff *msg, u32 portid,
genl_dump_check_consistent(cb, hdr);
- is_own = batadv_compare_eth(backbone_gw->orig, primary_addr);
+ is_own = batadv_compare_eth(backbone_gw->key.orig, primary_addr);
spin_lock_bh(&backbone_gw->crc_lock);
backbone_crc = backbone_gw->crc;
@@ -2399,8 +2398,8 @@ batadv_bla_backbone_dump_entry(struct sk_buff *msg, u32 portid,
}
if (nla_put(msg, BATADV_ATTR_BLA_BACKBONE, ETH_ALEN,
- backbone_gw->orig) ||
- nla_put_u16(msg, BATADV_ATTR_BLA_VID, backbone_gw->vid) ||
+ backbone_gw->key.orig) ||
+ nla_put_u16(msg, BATADV_ATTR_BLA_VID, backbone_gw->key.vid) ||
nla_put_u16(msg, BATADV_ATTR_BLA_CRC,
backbone_crc) ||
nla_put_u32(msg, BATADV_ATTR_LAST_SEEN_MSECS, msecs)) {
@@ -2552,7 +2551,7 @@ bool batadv_bla_check_claim(struct batadv_priv *bat_priv,
if (claim) {
backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
- if (!batadv_compare_eth(backbone_gw->orig,
+ if (!batadv_compare_eth(backbone_gw->key.orig,
primary_if->net_dev->dev_addr))
ret = false;
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 9d43e9cac0cc6..aae9c38a96b48 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1788,9 +1788,10 @@ enum batadv_bla_backbone_gw_state {
};
/**
- * struct batadv_bla_backbone_gw - batman-adv gateway bridged into the LAN
+ * struct batadv_bla_backbone_gw_key - key of a backbone gateway in
+ * &batadv_priv_bla.backbone_hash
*/
-struct batadv_bla_backbone_gw {
+struct batadv_bla_backbone_gw_key {
/**
* @orig: originator address of backbone node (mac address of primary
* iface)
@@ -1799,6 +1800,14 @@ struct batadv_bla_backbone_gw {
/** @vid: vlan id this gateway was detected on */
unsigned short vid;
+};
+
+/**
+ * struct batadv_bla_backbone_gw - batman-adv gateway bridged into the LAN
+ */
+struct batadv_bla_backbone_gw {
+ /** @key: hash key identifying the backbone gateway */
+ struct batadv_bla_backbone_gw_key key;
/** @hash_entry: hlist node for &batadv_priv_bla.backbone_hash */
struct hlist_node hash_entry;
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH net-next 03/15] batman-adv: dat: use dedicated key type for DAT hash
2026-11-14 9:15 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-14 Simon Wunderlich
2026-11-14 9:15 ` [PATCH net-next 01/15] batman-adv: bla: use dedicated key type for claim hash Simon Wunderlich
2026-11-14 9:15 ` [PATCH net-next 02/15] batman-adv: bla: use dedicated key type for backbone gateway hash Simon Wunderlich
@ 2026-11-14 9:15 ` Simon Wunderlich
2026-11-14 9:15 ` [PATCH net-next 04/15] batman-adv: tt: use dedicated key type for hashes Simon Wunderlich
` (11 subsequent siblings)
14 siblings, 0 replies; 20+ messages in thread
From: Simon Wunderlich @ 2026-11-14 9:15 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
The DAT hash and the DHT candidate selection hash a dummy struct
batadv_dat_entry on the stack in which only ip and vid are filled.
batadv_dat_entry_hash_find() then compares ip and vid inline instead of
using batadv_compare_dat(), so the key is spelled out in three places.
Move ip and vid into a new struct batadv_dat_entry_key, embedded as
batadv_dat_entry::key. The helpers are only using this key for
hashing/comparison.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/distributed-arp-table.c | 73 ++++++++++++--------------
net/batman-adv/types.h | 19 +++++--
2 files changed, 49 insertions(+), 43 deletions(-)
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 862a3a5eab566..204d48a8257ae 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -276,19 +276,18 @@ static void batadv_dat_purge(struct work_struct *work)
/**
* batadv_compare_dat() - comparing function used in the local DAT hash table
* @node: node in the local table
- * @data2: second object to compare the node to
+ * @data2: &struct batadv_dat_entry_key to compare the node to
*
- * Return: true if the two entries are the same, false otherwise.
+ * Return: true if the entry has the given key, false otherwise.
*/
static bool batadv_compare_dat(const struct hlist_node *node, const void *data2)
{
- const struct batadv_dat_entry *entry1;
- const struct batadv_dat_entry *entry2;
+ const struct batadv_dat_entry_key *key = data2;
+ const struct batadv_dat_entry *entry;
- entry1 = container_of(node, struct batadv_dat_entry, hash_entry);
- entry2 = data2;
+ entry = container_of(node, struct batadv_dat_entry, hash_entry);
- return entry1->ip == entry2->ip && entry1->vid == entry2->vid;
+ return entry->key.ip == key->ip && entry->key.vid == key->vid;
}
/**
@@ -352,30 +351,30 @@ static __be32 batadv_arp_ip_dst(struct sk_buff *skb, int hdr_size)
/**
* batadv_hash_dat() - compute the hash value for an IP address
- * @data: data to hash
+ * @data: &struct batadv_dat_entry_key to hash
* @size: size of the hash table
*
* Return: the selected index in the hash table for the given data.
*/
static u32 batadv_hash_dat(const void *data, u32 size)
{
- const struct batadv_dat_entry *dat = data;
- const unsigned char *key;
+ const struct batadv_dat_entry_key *key = data;
+ const unsigned char *buf;
u32 hash = 0;
__be16 vid;
u32 i;
- key = (__force const unsigned char *)&dat->ip;
- for (i = 0; i < sizeof(dat->ip); i++) {
- hash += key[i];
+ buf = (__force const unsigned char *)&key->ip;
+ for (i = 0; i < sizeof(key->ip); i++) {
+ hash += buf[i];
hash += (hash << 10);
hash ^= (hash >> 6);
}
- vid = htons(dat->vid);
- key = (__force const unsigned char *)&vid;
- for (i = 0; i < sizeof(dat->vid); i++) {
- hash += key[i];
+ vid = htons(key->vid);
+ buf = (__force const unsigned char *)&vid;
+ for (i = 0; i < sizeof(key->vid); i++) {
+ hash += buf[i];
hash += (hash << 10);
hash ^= (hash >> 6);
}
@@ -402,26 +401,23 @@ batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip,
{
struct batadv_hashtable *hash = bat_priv->dat.hash;
struct batadv_dat_entry *dat_entry_tmp = NULL;
+ struct batadv_dat_entry_key key = {
+ .ip = ip,
+ .vid = vid,
+ };
struct batadv_dat_entry *dat_entry;
- struct batadv_dat_entry to_find;
struct hlist_head *head;
u32 index;
if (!hash)
return NULL;
- to_find.ip = ip;
- to_find.vid = vid;
-
- index = batadv_hash_dat(&to_find, hash->size);
+ index = batadv_hash_dat(&key, hash->size);
head = &hash->table[index];
rcu_read_lock();
hlist_for_each_entry_rcu(dat_entry, head, hash_entry) {
- if (dat_entry->ip != ip)
- continue;
-
- if (dat_entry->vid != vid)
+ if (!batadv_compare_dat(&dat_entry->hash_entry, &key))
continue;
if (!kref_get_unless_zero(&dat_entry->refcount))
@@ -457,7 +453,7 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
WRITE_ONCE(dat_entry->last_update, jiffies);
batadv_dbg(BATADV_DBG_DAT, bat_priv,
"Entry updated: %pI4 %pM (vid: %d)\n",
- &dat_entry->ip, mac_addr,
+ &dat_entry->key.ip, mac_addr,
batadv_print_vid(vid));
goto out;
}
@@ -466,15 +462,15 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
if (!dat_entry)
goto out;
- dat_entry->ip = ip;
- dat_entry->vid = vid;
+ dat_entry->key.ip = ip;
+ dat_entry->key.vid = vid;
atomic64_set(&dat_entry->mac_addr, u64_mac);
WRITE_ONCE(dat_entry->last_update, jiffies);
kref_init(&dat_entry->refcount);
kref_get(&dat_entry->refcount);
hash_added = batadv_hash_add(bat_priv->dat.hash, batadv_compare_dat,
- batadv_hash_dat, dat_entry,
+ batadv_hash_dat, &dat_entry->key,
&dat_entry->hash_entry);
if (unlikely(hash_added != 0)) {
@@ -484,7 +480,7 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
}
batadv_dbg(BATADV_DBG_DAT, bat_priv, "New entry added: %pI4 %pM (vid: %d)\n",
- &dat_entry->ip, mac_addr, batadv_print_vid(vid));
+ &dat_entry->key.ip, mac_addr, batadv_print_vid(vid));
out:
batadv_dat_entry_put(dat_entry);
@@ -712,8 +708,11 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst,
unsigned short vid)
{
batadv_dat_addr_t last_max = BATADV_DAT_ADDR_MAX;
+ struct batadv_dat_entry_key key = {
+ .ip = ip_dst,
+ .vid = vid,
+ };
struct batadv_dat_candidate *res;
- struct batadv_dat_entry dat;
batadv_dat_addr_t ip_key;
int select;
@@ -724,9 +723,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst,
if (!res)
return NULL;
- dat.ip = ip_dst;
- dat.vid = vid;
- ip_key = (batadv_dat_addr_t)batadv_hash_dat(&dat,
+ ip_key = (batadv_dat_addr_t)batadv_hash_dat(&key,
BATADV_DAT_ADDR_MAX);
batadv_dbg(BATADV_DBG_DAT, bat_priv,
@@ -960,9 +957,9 @@ batadv_dat_cache_dump_entry(struct sk_buff *msg, u32 portid,
u64_to_ether_addr(u64_mac, mac);
if (nla_put_in_addr(msg, BATADV_ATTR_DAT_CACHE_IP4ADDRESS,
- dat_entry->ip) ||
+ dat_entry->key.ip) ||
nla_put(msg, BATADV_ATTR_DAT_CACHE_HWADDRESS, ETH_ALEN, mac) ||
- nla_put_u16(msg, BATADV_ATTR_DAT_CACHE_VID, dat_entry->vid) ||
+ nla_put_u16(msg, BATADV_ATTR_DAT_CACHE_VID, dat_entry->key.vid) ||
nla_put_u32(msg, BATADV_ATTR_LAST_SEEN_MSECS, msecs)) {
genlmsg_cancel(msg, hdr);
return -EMSGSIZE;
@@ -1521,7 +1518,7 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
batadv_dbg(BATADV_DBG_DAT, bat_priv,
"Doubled ARP reply removed: ARP MSG = [src: %pM-%pI4 dst: %pM-%pI4]; dat_entry: %pM-%pI4\n",
hw_src, &ip_src, hw_dst, &ip_dst,
- mac, &dat_entry->ip);
+ mac, &dat_entry->key.ip);
dropped = true;
}
}
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index aae9c38a96b48..3a340ce9660d9 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -2229,20 +2229,29 @@ struct batadv_algo_ops {
struct batadv_algo_gw_ops gw;
};
+/**
+ * struct batadv_dat_entry_key - key of a DAT entry in &batadv_priv_dat.hash
+ * and in the DHT
+ */
+struct batadv_dat_entry_key {
+ /** @ip: the IPv4 corresponding to this DAT/ARP entry */
+ __be32 ip;
+
+ /** @vid: the vlan ID associated to this entry */
+ unsigned short vid;
+};
+
/**
* struct batadv_dat_entry - it is a single entry of batman-adv ARP backend. It
* is used to stored ARP entries needed for the global DAT cache
*/
struct batadv_dat_entry {
- /** @ip: the IPv4 corresponding to this DAT/ARP entry */
- __be32 ip;
+ /** @key: hash key identifying the DAT entry */
+ struct batadv_dat_entry_key key;
/** @mac_addr: the MAC address associated to the stored IPv4 */
atomic64_t mac_addr;
- /** @vid: the vlan ID associated to this entry */
- unsigned short vid;
-
/**
* @last_update: time in jiffies when this entry was refreshed last time
*/
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH net-next 04/15] batman-adv: tt: use dedicated key type for hashes
2026-11-14 9:15 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-14 Simon Wunderlich
` (2 preceding siblings ...)
2026-11-14 9:15 ` [PATCH net-next 03/15] batman-adv: dat: use dedicated key type for DAT hash Simon Wunderlich
@ 2026-11-14 9:15 ` Simon Wunderlich
[not found] ` <sashiko-outbox-215350@kernel.org>
2026-11-14 9:15 ` [PATCH net-next 05/15] batman-adv: originator: pass explicit key to orig_hash Simon Wunderlich
` (10 subsequent siblings)
14 siblings, 1 reply; 20+ messages in thread
From: Simon Wunderlich @ 2026-11-14 9:15 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
The TT hash lookup functions are given a struct batadv_tt_common_entry.
For a lookup, a dummy TT entry is created on the stack and only its addr
and vid members are filled. All other members stay uninitialized, and
only by reading the hash and compare callbacks can one tell which
members form the key.
Move addr and vid into a new struct batadv_tt_common_entry_key, embedded as
batadv_tt_common_entry::key. The helpers are only using this key for
hashing/comparison.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 177 +++++++++++++++--------------
net/batman-adv/types.h | 13 ++-
2 files changed, 101 insertions(+), 89 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 50f24a3ad0ea0..926b4a3214196 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -81,60 +81,62 @@ static void batadv_tt_global_del(struct batadv_priv *bat_priv,
bool roaming);
/**
- * batadv_compare_tt() - check if two TT entries are the same
- * @node: the list element pointer of the first TT entry
- * @data2: pointer to the tt_common_entry of the second TT entry
+ * batadv_compare_tt() - check if a TT entry has the given key
+ * @node: the list element pointer of the TT entry
+ * @data2: &struct batadv_tt_common_entry_key to compare with
*
- * Compare the MAC address and the VLAN ID of the two TT entries and check if
- * they are the same TT client.
- * Return: true if the two TT clients are the same, false otherwise
+ * Compare the MAC address and the VLAN ID of the TT entry with the key and
+ * check if they are the same TT client.
+ * Return: true if the TT entry has the given key, false otherwise
*/
static bool batadv_compare_tt(const struct hlist_node *node, const void *data2)
{
- const void *data1 = container_of(node, struct batadv_tt_common_entry,
- hash_entry);
- const struct batadv_tt_common_entry *tt1 = data1;
- const struct batadv_tt_common_entry *tt2 = data2;
+ const struct batadv_tt_common_entry_key *key = data2;
+ const struct batadv_tt_common_entry *tt;
+
+ tt = container_of(node, struct batadv_tt_common_entry, hash_entry);
- return (tt1->vid == tt2->vid) && batadv_compare_eth(data1, data2);
+ return tt->key.vid == key->vid &&
+ batadv_compare_eth(tt->key.addr, key->addr);
}
/**
* batadv_compare_tt_entry() - check if a hash node is a specific TT entry
* @node: the list element pointer of the TT entry stored in the bucket
- * @data2: pointer to the tt_common_entry which is looked for
+ * @data2: &batadv_tt_common_entry.key of the TT entry which is looked for
*
- * Unlike batadv_compare_tt(), this only matches the very object which is
- * passed as @data2 and not just any entry for the same TT client. It is meant
- * for batadv_hash_remove() callers which must not unlink an entry they did not
- * look up themselves.
+ * Unlike batadv_compare_tt(), this only matches the very object which embeds
+ * the key passed as @data2 and not just any entry for the same TT client. It is
+ * meant for batadv_hash_remove() callers which must not unlink an entry they
+ * did not look up themselves.
*
- * Return: true if @node belongs to @data2, false otherwise
+ * Return: true if @node belongs to the entry of @data2, false otherwise
*/
static bool batadv_compare_tt_entry(const struct hlist_node *node,
const void *data2)
{
- const struct batadv_tt_common_entry *tt = data2;
+ const struct batadv_tt_common_entry *tt;
+
+ tt = container_of(data2, struct batadv_tt_common_entry, key);
return node == &tt->hash_entry;
}
/**
* batadv_choose_tt() - return the index of the tt entry in the hash table
- * @data: pointer to the tt_common_entry object to map
+ * @data: &struct batadv_tt_common_entry_key to map
* @size: the size of the hash table
*
- * Return: the hash index where the object represented by 'data' should be
+ * Return: the hash index where the object with the key 'data' should be
* stored at.
*/
static inline u32 batadv_choose_tt(const void *data, u32 size)
{
- const struct batadv_tt_common_entry *tt;
+ const struct batadv_tt_common_entry_key *key = data;
u32 hash = 0;
- tt = data;
- hash = jhash(&tt->addr, ETH_ALEN, hash);
- hash = jhash(&tt->vid, sizeof(tt->vid), hash);
+ hash = jhash(&key->addr, ETH_ALEN, hash);
+ hash = jhash(&key->vid, sizeof(key->vid), hash);
return hash % size;
}
@@ -153,7 +155,7 @@ batadv_tt_hash_find(struct batadv_hashtable *hash, const u8 *addr,
unsigned short vid)
{
struct batadv_tt_common_entry *tt_tmp = NULL;
- struct batadv_tt_common_entry to_search;
+ struct batadv_tt_common_entry_key key;
struct batadv_tt_common_entry *tt;
struct hlist_head *head;
u32 index;
@@ -161,18 +163,15 @@ batadv_tt_hash_find(struct batadv_hashtable *hash, const u8 *addr,
if (!hash)
return NULL;
- ether_addr_copy(to_search.addr, addr);
- to_search.vid = vid;
+ ether_addr_copy(key.addr, addr);
+ key.vid = vid;
- index = batadv_choose_tt(&to_search, hash->size);
+ index = batadv_choose_tt(&key, hash->size);
head = &hash->table[index];
rcu_read_lock();
hlist_for_each_entry_rcu(tt, head, hash_entry) {
- if (!batadv_compare_eth(tt, addr))
- continue;
-
- if (tt->vid != vid)
+ if (!batadv_compare_tt(&tt->hash_entry, &key))
continue;
if (!kref_get_unless_zero(&tt->refcount))
@@ -667,8 +666,8 @@ static void __batadv_tt_local_event(struct batadv_priv *bat_priv,
memset(tt_change_node->change.reserved, 0,
sizeof(tt_change_node->change.reserved));
- ether_addr_copy(tt_change_node->change.addr, common->addr);
- tt_change_node->change.vid = htons(common->vid);
+ ether_addr_copy(tt_change_node->change.addr, common->key.addr);
+ tt_change_node->change.vid = htons(common->key.vid);
del_op_requested = flags & BATADV_TT_CLIENT_DEL;
@@ -686,7 +685,7 @@ static void __batadv_tt_local_event(struct batadv_priv *bat_priv,
changes = READ_ONCE(bat_priv->tt.local_changes);
list_for_each_entry_safe(entry, safe, &bat_priv->tt.changes_list,
list) {
- if (!batadv_compare_eth(entry->change.addr, common->addr))
+ if (!batadv_compare_eth(entry->change.addr, common->key.addr))
continue;
if (entry->change.vid != tt_change_node->change.vid)
@@ -802,14 +801,14 @@ static void batadv_tt_global_free(struct batadv_priv *bat_priv,
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Deleting global tt entry %pM (vid: %d): %s\n",
- tt_global->common.addr,
- batadv_print_vid(tt_global->common.vid), message);
+ tt_global->common.key.addr,
+ batadv_print_vid(tt_global->common.key.vid), message);
/* remove exactly this object when still present in hash */
tt_removed_node = batadv_hash_remove(bat_priv->tt.global_hash,
batadv_compare_tt_entry,
batadv_choose_tt,
- &tt_global->common);
+ &tt_global->common.key);
if (!tt_removed_node)
return;
@@ -865,8 +864,8 @@ static void batadv_tt_local_add_roam(struct batadv_priv *bat_priv,
head = &tt_global->orig_list;
rcu_read_lock();
hlist_for_each_entry_rcu(orig_entry, head, list) {
- batadv_send_roam_adv(bat_priv, tt_global->common.addr,
- tt_global->common.vid,
+ batadv_send_roam_adv(bat_priv, tt_global->common.key.addr,
+ tt_global->common.key.vid,
orig_entry->orig_node);
}
rcu_read_unlock();
@@ -923,7 +922,8 @@ static bool batadv_tt_local_add_existing(struct batadv_priv *bat_priv,
if (common->flags & BATADV_TT_CLIENT_PENDING) {
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Re-adding pending client %pM (vid: %d)\n",
- common->addr, batadv_print_vid(common->vid));
+ common->key.addr,
+ batadv_print_vid(common->key.vid));
/* whatever the reason why the PENDING flag was set,
* this is a client which was enqueued to be removed in
* this orig_interval. Since it popped up again, the
@@ -936,7 +936,8 @@ static bool batadv_tt_local_add_existing(struct batadv_priv *bat_priv,
if (common->flags & BATADV_TT_CLIENT_ROAM) {
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Roaming client %pM (vid: %d) came back to its original location\n",
- common->addr, batadv_print_vid(common->vid));
+ common->key.addr,
+ batadv_print_vid(common->key.vid));
/* the ROAM flag is set because this client roamed away
* and the node got a roaming_advertisement message. Now
* that the client popped up again at its original
@@ -998,8 +999,8 @@ batadv_tt_local_create(struct net_device *mesh_iface, const u8 *addr,
addr, batadv_print_vid(vid),
(u8)atomic_read(&bat_priv->tt.vn));
- ether_addr_copy(tt_local->common.addr, addr);
- tt_local->common.vid = vid;
+ ether_addr_copy(tt_local->common.key.addr, addr);
+ tt_local->common.key.vid = vid;
kref_init(&tt_local->common.refcount);
last_seen = jiffies;
WRITE_ONCE(tt_local->last_seen, last_seen);
@@ -1114,7 +1115,7 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
kref_get(&tt_local->common.refcount);
hash_added = batadv_hash_add(bat_priv->tt.local_hash, batadv_compare_tt,
- batadv_choose_tt, &tt_local->common,
+ batadv_choose_tt, &tt_local->common.key,
&tt_local->common.hash_entry);
if (unlikely(hash_added != 0)) {
@@ -1488,7 +1489,7 @@ batadv_tt_local_dump_entry(struct sk_buff *msg, u32 portid,
last_seen = READ_ONCE(local->last_seen);
last_seen_msecs = jiffies_delta_to_msecs(jiffies - last_seen);
- vlan = batadv_meshif_vlan_get(bat_priv, common->vid);
+ vlan = batadv_meshif_vlan_get(bat_priv, common->key.vid);
if (!vlan)
return 0;
@@ -1506,9 +1507,9 @@ batadv_tt_local_dump_entry(struct sk_buff *msg, u32 portid,
flags = batadv_tt_flags_get(common);
- if (nla_put(msg, BATADV_ATTR_TT_ADDRESS, ETH_ALEN, common->addr) ||
+ if (nla_put(msg, BATADV_ATTR_TT_ADDRESS, ETH_ALEN, common->key.addr) ||
nla_put_u32(msg, BATADV_ATTR_TT_CRC32, crc) ||
- nla_put_u16(msg, BATADV_ATTR_TT_VID, common->vid) ||
+ nla_put_u16(msg, BATADV_ATTR_TT_VID, common->key.vid) ||
nla_put_u32(msg, BATADV_ATTR_TT_FLAGS, flags))
goto nla_put_failure;
@@ -1644,7 +1645,7 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
struct batadv_hashtable *hash = bat_priv->tt.local_hash;
u32 i;
- i = batadv_choose_tt(common, hash->size);
+ i = batadv_choose_tt(&common->key, hash->size);
lockdep_assert_held(&hash->list_locks[i]);
lockdep_assert_held(&common->flags_lock);
@@ -1653,8 +1654,8 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Local tt entry (%pM, vid: %d) pending to be removed: %s\n",
- tt_local_entry->common.addr,
- batadv_print_vid(tt_local_entry->common.vid), message);
+ tt_local_entry->common.key.addr,
+ batadv_print_vid(tt_local_entry->common.key.vid), message);
}
/**
@@ -1686,7 +1687,7 @@ batadv_tt_local_mark_removed(struct batadv_priv *bat_priv,
u16 flags;
u32 i;
- i = batadv_choose_tt(common, hash->size);
+ i = batadv_choose_tt(&common->key, hash->size);
list_lock = &hash->list_locks[i];
spin_lock_bh(list_lock);
@@ -1740,7 +1741,7 @@ batadv_tt_local_remove_now(struct batadv_priv *bat_priv,
/* remove exactly this object when still present in hash */
tt_removed_node = batadv_hash_remove(bat_priv->tt.local_hash,
batadv_compare_tt_entry,
- batadv_choose_tt, common);
+ batadv_choose_tt, &common->key);
if (!tt_removed_node)
return;
@@ -1751,7 +1752,7 @@ batadv_tt_local_remove_now(struct batadv_priv *bat_priv,
* BATADV_TT_CLIENT_NEW check in batadv_tt_local_mark_removed().
*/
if (!(batadv_tt_flags_get(common) & BATADV_TT_CLIENT_NEW))
- batadv_tt_local_size_dec(bat_priv, common->vid);
+ batadv_tt_local_size_dec(bat_priv, common->key.vid);
/* drop reference of remove hash entry */
batadv_tt_local_entry_put(tt_local_entry);
@@ -2070,7 +2071,7 @@ batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global,
INIT_HLIST_NODE(&orig_entry->list);
kref_get(&orig_node->refcount);
- batadv_tt_global_size_inc(orig_node, tt_global->common.vid);
+ batadv_tt_global_size_inc(orig_node, tt_global->common.key.vid);
orig_entry->orig_node = orig_node;
orig_entry->ttvn = ttvn;
orig_entry->flags = flags;
@@ -2111,11 +2112,11 @@ batadv_tt_global_purge_local(struct batadv_priv *bat_priv,
/* Do not remove multicast addresses from the local hash on
* global additions
*/
- if (is_multicast_ether_addr(common->addr))
+ if (is_multicast_ether_addr(common->key.addr))
return;
/* remove address from local hash if present */
- local_flags = batadv_tt_local_remove(bat_priv, common->addr, common->vid,
+ local_flags = batadv_tt_local_remove(bat_priv, common->key.addr, common->key.vid,
"global tt received",
flags & BATADV_TT_CLIENT_ROAM);
@@ -2161,7 +2162,7 @@ batadv_tt_global_merge_flags(struct batadv_tt_global_entry *tt_global_entry,
* TT_CLIENT_TEMP, therefore they have to be copied in the
* client entry
*/
- if (!is_multicast_ether_addr(common->addr))
+ if (!is_multicast_ether_addr(common->key.addr))
common->flags |= flags & (~BATADV_TT_SYNC_MASK);
/* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
@@ -2205,11 +2206,11 @@ batadv_tt_global_create(const unsigned char *tt_addr, unsigned short vid,
return NULL;
common = &tt_global_entry->common;
- ether_addr_copy(common->addr, tt_addr);
- common->vid = vid;
+ ether_addr_copy(common->key.addr, tt_addr);
+ common->key.vid = vid;
spin_lock_init(&common->flags_lock);
- if (!is_multicast_ether_addr(common->addr)) {
+ if (!is_multicast_ether_addr(common->key.addr)) {
scoped_guard(spinlock_bh, &common->flags_lock)
common->flags = flags & (~BATADV_TT_SYNC_MASK);
}
@@ -2291,7 +2292,7 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
kref_get(&common->refcount);
hash_added = batadv_hash_add(bat_priv->tt.global_hash,
batadv_compare_tt,
- batadv_choose_tt, common,
+ batadv_choose_tt, &common->key,
&common->hash_entry);
if (unlikely(hash_added != 0)) {
@@ -2335,7 +2336,7 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Creating new global tt entry: %pM (vid: %d, via %pM)\n",
- common->addr, batadv_print_vid(common->vid),
+ common->key.addr, batadv_print_vid(common->key.vid),
orig_node->orig);
ret = true;
@@ -2417,7 +2418,7 @@ batadv_tt_global_dump_subentry(struct sk_buff *msg, u32 portid, u32 seq,
u32 crc;
vlan = batadv_orig_node_vlan_get(orig->orig_node,
- common->vid);
+ common->key.vid);
if (!vlan)
return 0;
@@ -2434,13 +2435,13 @@ batadv_tt_global_dump_subentry(struct sk_buff *msg, u32 portid, u32 seq,
flags = (batadv_tt_flags_get(common) & (~BATADV_TT_SYNC_MASK)) | orig->flags;
last_ttvn = READ_ONCE(orig->orig_node->last_ttvn);
- if (nla_put(msg, BATADV_ATTR_TT_ADDRESS, ETH_ALEN, common->addr) ||
+ if (nla_put(msg, BATADV_ATTR_TT_ADDRESS, ETH_ALEN, common->key.addr) ||
nla_put(msg, BATADV_ATTR_ORIG_ADDRESS, ETH_ALEN,
orig->orig_node->orig) ||
nla_put_u8(msg, BATADV_ATTR_TT_TTVN, orig->ttvn) ||
nla_put_u8(msg, BATADV_ATTR_TT_LAST_TTVN, last_ttvn) ||
nla_put_u32(msg, BATADV_ATTR_TT_CRC32, crc) ||
- nla_put_u16(msg, BATADV_ATTR_TT_VID, common->vid) ||
+ nla_put_u16(msg, BATADV_ATTR_TT_VID, common->key.vid) ||
nla_put_u32(msg, BATADV_ATTR_TT_FLAGS, flags))
goto nla_put_failure;
@@ -2616,7 +2617,7 @@ _batadv_tt_global_del_orig_entry(struct batadv_tt_global_entry *tt_global_entry,
lockdep_assert_held(&tt_global_entry->list_lock);
batadv_tt_global_size_dec(orig_entry->orig_node,
- tt_global_entry->common.vid);
+ tt_global_entry->common.key.vid);
atomic_dec(&tt_global_entry->orig_list_count);
/* requires holding tt_global_entry->list_lock and orig_entry->list
* being part of a list
@@ -2669,11 +2670,11 @@ batadv_tt_global_del_orig_node(struct batadv_priv *bat_priv,
head = &tt_global_entry->orig_list;
hlist_for_each_entry_safe(orig_entry, safe, head, list) {
if (orig_entry->orig_node == orig_node) {
- vid = tt_global_entry->common.vid;
+ vid = tt_global_entry->common.key.vid;
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Deleting %pM from global tt entry %pM (vid: %d): %s\n",
orig_node->orig,
- tt_global_entry->common.addr,
+ tt_global_entry->common.key.addr,
batadv_print_vid(vid), message);
_batadv_tt_global_del_orig_entry(tt_global_entry,
orig_entry);
@@ -2781,7 +2782,7 @@ static void batadv_tt_global_del(struct batadv_priv *bat_priv,
* the global entry, since it is useless now.
*/
local_entry = batadv_tt_local_hash_find(bat_priv,
- tt_global_entry->common.addr,
+ tt_global_entry->common.key.addr,
vid);
if (local_entry) {
/* local entry exists, case 2: client roamed to us. */
@@ -2832,7 +2833,8 @@ void batadv_tt_global_del_orig(struct batadv_priv *bat_priv,
hlist_for_each_entry_safe(tt_common_entry, safe,
head, hash_entry) {
/* remove only matching entries */
- if (match_vid >= 0 && tt_common_entry->vid != match_vid)
+ if (match_vid >= 0 &&
+ tt_common_entry->key.vid != match_vid)
continue;
tt_global = container_of(tt_common_entry,
@@ -2843,10 +2845,10 @@ void batadv_tt_global_del_orig(struct batadv_priv *bat_priv,
orig_node, message);
if (hlist_empty(&tt_global->orig_list)) {
- vid = tt_global->common.vid;
+ vid = tt_global->common.key.vid;
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Deleting global tt entry %pM (vid: %d): %s\n",
- tt_global->common.addr,
+ tt_global->common.key.addr,
batadv_print_vid(vid), message);
hlist_del_rcu(&tt_common_entry->hash_entry);
batadv_tt_global_entry_put(tt_global);
@@ -2924,8 +2926,8 @@ static void batadv_tt_global_purge(struct batadv_priv *bat_priv)
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Deleting global tt entry %pM (vid: %d): %s\n",
- tt_global->common.addr,
- batadv_print_vid(tt_global->common.vid),
+ tt_global->common.key.addr,
+ batadv_print_vid(tt_global->common.key.vid),
msg);
hlist_del_rcu(&tt_common->hash_entry);
@@ -3125,7 +3127,7 @@ static u32 batadv_tt_global_crc(struct batadv_priv *bat_priv,
/* compute the CRC only for entries belonging to the
* VLAN identified by the vid passed as parameter
*/
- if (tt_common->vid != vid)
+ if (tt_common->key.vid != vid)
continue;
tt_flags = batadv_tt_flags_get(tt_common);
@@ -3156,7 +3158,7 @@ static u32 batadv_tt_global_crc(struct batadv_priv *bat_priv,
/* use network order to read the VID: this ensures that
* every node reads the bytes in the same order.
*/
- tmp_vid = htons(tt_common->vid);
+ tmp_vid = htons(tt_common->key.vid);
crc_tmp = crc32c(0, &tmp_vid, sizeof(tmp_vid));
/* compute the CRC on flags that have to be kept in sync
@@ -3165,7 +3167,7 @@ static u32 batadv_tt_global_crc(struct batadv_priv *bat_priv,
flags = tt_orig->flags;
crc_tmp = crc32c(crc_tmp, &flags, sizeof(flags));
- crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN);
+ crc ^= crc32c(crc_tmp, tt_common->key.addr, ETH_ALEN);
batadv_tt_orig_list_entry_put(tt_orig);
}
@@ -3207,7 +3209,7 @@ static u32 batadv_tt_local_crc(struct batadv_priv *bat_priv,
/* compute the CRC only for entries belonging to the
* VLAN identified by vid
*/
- if (tt_common->vid != vid)
+ if (tt_common->key.vid != vid)
continue;
tt_flags = batadv_tt_flags_get(tt_common);
@@ -3223,7 +3225,7 @@ static u32 batadv_tt_local_crc(struct batadv_priv *bat_priv,
/* use network order to read the VID: this ensures that
* every node reads the bytes in the same order.
*/
- tmp_vid = htons(tt_common->vid);
+ tmp_vid = htons(tt_common->key.vid);
crc_tmp = crc32c(0, &tmp_vid, sizeof(tmp_vid));
/* compute the CRC on flags that have to be kept in sync
@@ -3231,7 +3233,7 @@ static u32 batadv_tt_local_crc(struct batadv_priv *bat_priv,
*/
crc_tmp = crc32c(crc_tmp, &flags, sizeof(flags));
- crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN);
+ crc ^= crc32c(crc_tmp, tt_common->key.addr, ETH_ALEN);
}
rcu_read_unlock();
}
@@ -3492,9 +3494,10 @@ static u16 batadv_tt_tvlv_generate(struct batadv_priv *bat_priv,
if (!ret)
continue;
- ether_addr_copy(tt_change->addr, tt_common_entry->addr);
+ ether_addr_copy(tt_change->addr,
+ tt_common_entry->key.addr);
tt_change->flags = flags;
- tt_change->vid = htons(tt_common_entry->vid);
+ tt_change->vid = htons(tt_common_entry->key.vid);
memset(tt_change->reserved, 0,
sizeof(tt_change->reserved));
@@ -4403,7 +4406,7 @@ static void batadv_tt_local_transition_new(struct batadv_priv *bat_priv)
continue;
batadv_tt_local_size_inc(bat_priv,
- tt_common_entry->vid);
+ tt_common_entry->key.vid);
}
spin_unlock_bh(list_lock);
}
@@ -4447,8 +4450,8 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Deleting local tt entry (%pM, vid: %d): pending\n",
- tt_common->addr,
- batadv_print_vid(tt_common->vid));
+ tt_common->key.addr,
+ batadv_print_vid(tt_common->key.vid));
hlist_del_rcu(&tt_common->hash_entry);
@@ -4456,7 +4459,7 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)
* never counted and must not be uncounted here.
*/
if (!(tt_common->flags & BATADV_TT_CLIENT_NEW))
- batadv_tt_local_size_dec(bat_priv, tt_common->vid);
+ batadv_tt_local_size_dec(bat_priv, tt_common->key.vid);
}
if (cont)
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 3a340ce9660d9..8e590f19d2362 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1883,14 +1883,23 @@ struct batadv_bla_claim {
#endif
/**
- * struct batadv_tt_common_entry - tt local & tt global common data
+ * struct batadv_tt_common_entry_key - key of a TT entry in
+ * &batadv_priv_tt.local_hash or &batadv_priv_tt.global_hash
*/
-struct batadv_tt_common_entry {
+struct batadv_tt_common_entry_key {
/** @addr: mac address of non-mesh client */
u8 addr[ETH_ALEN] __aligned(2);
/** @vid: VLAN identifier */
unsigned short vid;
+};
+
+/**
+ * struct batadv_tt_common_entry - tt local & tt global common data
+ */
+struct batadv_tt_common_entry {
+ /** @key: hash key identifying the TT client */
+ struct batadv_tt_common_entry_key key;
/**
* @hash_entry: hlist node for &batadv_priv_tt.local_hash or for
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH net-next 05/15] batman-adv: originator: pass explicit key to orig_hash
2026-11-14 9:15 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-14 Simon Wunderlich
` (3 preceding siblings ...)
2026-11-14 9:15 ` [PATCH net-next 04/15] batman-adv: tt: use dedicated key type for hashes Simon Wunderlich
@ 2026-11-14 9:15 ` Simon Wunderlich
2026-11-14 9:15 ` [PATCH net-next 06/15] batman-adv: hash: document key argument of hash operations Simon Wunderlich
` (9 subsequent siblings)
14 siblings, 0 replies; 20+ messages in thread
From: Simon Wunderlich @ 2026-11-14 9:15 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
The key of the orig_hash is the originator address. But batadv_hash_add()
was given the whole orig_node, while batadv_orig_hash_find() is given the
bare address, and batadv_compare_orig() and the lookup compare the
orig_node pointer itself against the address. This only works because
orig is the first member of struct batadv_orig_node.
Pass orig_node->orig as key to batadv_hash_add(), compare explicitly
against orig_node->orig in batadv_compare_orig(), use it for the lookup,
and let batadv_orig_hash_find() take a const u8 * address instead of an
untyped pointer.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/bat_iv_ogm.c | 2 +-
net/batman-adv/bat_v_ogm.c | 2 +-
net/batman-adv/originator.c | 19 ++++++++++---------
net/batman-adv/originator.h | 2 +-
4 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 0b2134a8f963a..376c0f80bcee9 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -155,7 +155,7 @@ batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const u8 *addr)
kref_get(&orig_node->refcount);
hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig,
- batadv_choose_orig, orig_node,
+ batadv_choose_orig, orig_node->orig,
&orig_node->hash_entry);
if (hash_added != 0)
goto free_orig_node_hash;
diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c
index cf3c1d22761b9..4abb4c871e8c5 100644
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -68,7 +68,7 @@ struct batadv_orig_node *batadv_v_ogm_orig_get(struct batadv_priv *bat_priv,
kref_get(&orig_node->refcount);
hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig,
- batadv_choose_orig, orig_node,
+ batadv_choose_orig, orig_node->orig,
&orig_node->hash_entry);
if (hash_added != 0) {
/* remove refcnt for newly created orig_node and hash entry */
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 1ac3e0ad66c79..391d97bc938b9 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -45,12 +45,12 @@ static struct lock_class_key batadv_orig_hash_lock_class_key;
/**
* batadv_orig_hash_find() - Find and return originator from orig_hash
* @bat_priv: the bat priv with all the mesh interface information
- * @data: mac address of the originator
+ * @addr: mac address of the originator
*
* Return: orig_node (with increased refcnt), NULL on errors
*/
struct batadv_orig_node *
-batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data)
+batadv_orig_hash_find(struct batadv_priv *bat_priv, const u8 *addr)
{
struct batadv_hashtable *hash = bat_priv->orig_hash;
struct batadv_orig_node *orig_node_tmp = NULL;
@@ -61,12 +61,12 @@ batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data)
if (!hash)
return NULL;
- index = batadv_choose_orig(data, hash->size);
+ index = batadv_choose_orig(addr, hash->size);
head = &hash->table[index];
rcu_read_lock();
hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
- if (!batadv_compare_eth(orig_node, data))
+ if (!batadv_compare_orig(&orig_node->hash_entry, addr))
continue;
if (!kref_get_unless_zero(&orig_node->refcount))
@@ -85,16 +85,17 @@ static void batadv_purge_orig(struct work_struct *work);
/**
* batadv_compare_orig() - comparing function used in the originator hash table
* @node: node in the local table
- * @data2: second object to compare the node to
+ * @data2: mac address of the originator to compare the node to
*
- * Return: true if they are the same originator
+ * Return: true if the node is the originator with the given address
*/
bool batadv_compare_orig(const struct hlist_node *node, const void *data2)
{
- const void *data1 = container_of(node, struct batadv_orig_node,
- hash_entry);
+ const struct batadv_orig_node *orig_node;
- return batadv_compare_eth(data1, data2);
+ orig_node = container_of(node, struct batadv_orig_node, hash_entry);
+
+ return batadv_compare_eth(orig_node->orig, data2);
}
/**
diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h
index fabfc3e67c6eb..dff729ecf2df1 100644
--- a/net/batman-adv/originator.h
+++ b/net/batman-adv/originator.h
@@ -83,7 +83,7 @@ static inline u32 batadv_choose_orig(const void *data, u32 size)
}
struct batadv_orig_node *
-batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data);
+batadv_orig_hash_find(struct batadv_priv *bat_priv, const u8 *addr);
/**
* batadv_orig_node_vlan_put() - decrement the refcounter and possibly release
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH net-next 06/15] batman-adv: hash: document key argument of hash operations
2026-11-14 9:15 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-14 Simon Wunderlich
` (4 preceding siblings ...)
2026-11-14 9:15 ` [PATCH net-next 05/15] batman-adv: originator: pass explicit key to orig_hash Simon Wunderlich
@ 2026-11-14 9:15 ` Simon Wunderlich
2026-11-14 9:15 ` [PATCH net-next 07/15] batman-adv: never consume skb in BLA rx and DAT incoming snooping Simon Wunderlich
` (8 subsequent siblings)
14 siblings, 0 replies; 20+ messages in thread
From: Simon Wunderlich @ 2026-11-14 9:15 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
With all users converted, the data passed to batadv_hash_add(),
batadv_hash_remove() and the compare/choose callbacks is always the key
of the hash table, never a (partially initialized) element. The
kernel-doc of batadv_hash_remove() even still suggested to pass "the
structure you use with just the key filled".
Document the actual key contract.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/hash.h | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h
index 45a432cc15789..fca426c5e3c58 100644
--- a/net/batman-adv/hash.h
+++ b/net/batman-adv/hash.h
@@ -21,7 +21,7 @@
/**
* typedef batadv_hashdata_compare_cb - hash element comparison callback
* @node: hlist node of the element currently stored in the bucket
- * @key: opaque payload to compare @node's key against
+ * @key: key to compare @node's key against
*
* Compare hash element by its keys.
*
@@ -32,7 +32,7 @@ typedef bool (*batadv_hashdata_compare_cb)(const struct hlist_node *node,
/**
* typedef batadv_hashdata_choose_cb - hash bucket selection callback
- * @key: opaque payload whose key selects the bucket
+ * @key: key which selects the bucket
* @size: number of buckets in the hash table
*
* Return: bucket index derived from the key in @key and the table @size.
@@ -80,7 +80,8 @@ void batadv_hash_destroy(struct batadv_hashtable *hash);
* @hash: storage hash table
* @compare: callback to determine if 2 hash elements are identical
* @choose: callback calculating the hash index
- * @data: data passed to the aforementioned callbacks as argument
+ * @data: key of the element to add (the key embedded in the element),
+ * passed to the aforementioned callbacks as argument
* @data_node: to be added element
*
* Return: 0 on success, 1 if the element already is in the hash
@@ -132,10 +133,8 @@ static inline int batadv_hash_add(struct batadv_hashtable *hash,
* @hash: hash table
* @compare: callback to determine if 2 hash elements are identical
* @choose: callback calculating the hash index
- * @data: data passed to the aforementioned callbacks as argument
- *
- * data could be the structure you use with just the key filled, we just need
- * the key for comparing.
+ * @data: key of the element to remove, passed to the aforementioned callbacks
+ * as argument
*
* Return: returns pointer to hlist_node on success, so you can remove the used
* structure yourself, or NULL on error
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH net-next 07/15] batman-adv: never consume skb in BLA rx and DAT incoming snooping
2026-11-14 9:15 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-14 Simon Wunderlich
` (5 preceding siblings ...)
2026-11-14 9:15 ` [PATCH net-next 06/15] batman-adv: hash: document key argument of hash operations Simon Wunderlich
@ 2026-11-14 9:15 ` Simon Wunderlich
[not found] ` <sashiko-outbox-215353@kernel.org>
2026-11-14 9:15 ` [PATCH net-next 08/15] batman-adv: always consume skb in batadv_forw_packet_alloc() Simon Wunderlich
` (7 subsequent siblings)
14 siblings, 1 reply; 20+ messages in thread
From: Simon Wunderlich @ 2026-11-14 9:15 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
batadv_bla_tx() and the outgoing DAT snooping functions return true when
the caller has to drop the skb, and they never free it themselves.
batadv_bla_rx(), batadv_dat_snoop_incoming_arp_request() and
batadv_dat_snoop_incoming_arp_reply() look the same, but they freed the skb
themselves when returning true, and only then.
So callers had to know, for each function, whether "true" meant "already
freed" or "free it now". batadv_bla_rx() and batadv_bla_tx() even had the
same kerneldoc text.
Make all of them only borrow the skb, and let the callers free it when
true is returned.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/bridge_loop_avoidance.c | 13 ++++++-------
net/batman-adv/distributed-arp-table.c | 10 +++++-----
net/batman-adv/mesh-interface.c | 6 ++----
net/batman-adv/routing.c | 16 +++++++++-------
4 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index cc7a98fbc3d2a..9be452f667250 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1952,10 +1952,10 @@ batadv_bla_loopdetect_check(struct batadv_priv *bat_priv, struct sk_buff *skb,
* * we have to race for a claim
* * if the frame is allowed on the LAN
*
- * In these cases, the skb is further handled by this function
+ * The skb is never consumed by this function.
*
- * Return: true if handled, otherwise it returns false and the caller shall
- * further process the skb.
+ * Return: true if the skb has to be dropped, otherwise it returns false and the
+ * caller shall further process the skb.
*/
bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
unsigned short vid, int packet_type)
@@ -2066,7 +2066,6 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
goto out;
handled:
- kfree_skb(skb);
ret = true;
out:
@@ -2085,15 +2084,15 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
* * a claim was received which has to be processed
* * the frame is allowed on the mesh
*
- * in these cases, the skb is further handled by this function.
+ * The skb is never consumed by this function.
*
* Warning: This function may reallocate the skb data buffer via
* batadv_bla_process_claim()/... Any pointer into the skb data (e.g.
* obtained from skb->data or eth_hdr()) before this call must be considered
* invalid afterwards and has to be reacquired.
*
- * Return: true if handled, otherwise it returns false and the caller shall
- * further process the skb.
+ * Return: true if the skb has to be dropped, otherwise it returns false and the
+ * caller shall further process the skb.
*/
bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
unsigned short vid)
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 204d48a8257ae..37de9787104d5 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -1337,6 +1337,8 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
* from skb->data or eth_hdr()) before this call must be considered
* invalid afterwards and has to be reacquired.
*
+ * The skb is never consumed by this function.
+ *
* Return: true if the request has been answered, false otherwise.
*/
bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
@@ -1396,8 +1398,6 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
}
out:
batadv_dat_entry_put(dat_entry);
- if (ret)
- kfree_skb(skb);
return ret;
}
@@ -1466,7 +1466,9 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
* from skb->data or eth_hdr()) before this call must be considered
* invalid afterwards and has to be reacquired.
*
- * Return: true if the packet was snooped and consumed by DAT. False if the
+ * The skb is never consumed by this function.
+ *
+ * Return: true if the packet was snooped and has to be dropped. False if the
* packet has to be delivered to the interface
*/
bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
@@ -1556,8 +1558,6 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
*/
dropped |= batadv_is_my_client(bat_priv, hw_src, vid);
out:
- if (dropped)
- kfree_skb(skb);
batadv_dat_entry_put(dat_entry);
/* if dropped == false -> deliver to the interface */
return dropped;
diff --git a/net/batman-adv/mesh-interface.c b/net/batman-adv/mesh-interface.c
index 16b681e10b33d..cde49b8d6bb8e 100644
--- a/net/batman-adv/mesh-interface.c
+++ b/net/batman-adv/mesh-interface.c
@@ -522,7 +522,7 @@ void batadv_interface_rx(struct net_device *mesh_iface,
* not handle it, we can safely push it up.
*/
if (batadv_bla_rx(bat_priv, skb, vid, packet_type))
- goto out;
+ goto dropped;
if (orig_node)
batadv_tt_add_temporary_global_entry(bat_priv, orig_node,
@@ -547,12 +547,10 @@ void batadv_interface_rx(struct net_device *mesh_iface,
}
netif_rx(skb);
- goto out;
+ return;
dropped:
kfree_skb(skb);
-out:
- return;
}
/**
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index e2951bf047024..ca71e29a9ad33 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -1109,11 +1109,12 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
}
if (batadv_dat_snoop_incoming_arp_request(bat_priv, skb,
- hdr_size))
- goto rx_success;
- if (batadv_dat_snoop_incoming_arp_reply(bat_priv, skb,
- hdr_size))
+ hdr_size) ||
+ batadv_dat_snoop_incoming_arp_reply(bat_priv, skb,
+ hdr_size)) {
+ kfree_skb(skb);
goto rx_success;
+ }
batadv_dat_snoop_incoming_dhcp_ack(bat_priv, skb, hdr_size);
@@ -1351,10 +1352,11 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
if (batadv_bla_is_backbone_gw(skb, orig_node, hdr_size))
goto free_skb;
- if (batadv_dat_snoop_incoming_arp_request(bat_priv, skb, hdr_size))
- goto rx_success;
- if (batadv_dat_snoop_incoming_arp_reply(bat_priv, skb, hdr_size))
+ if (batadv_dat_snoop_incoming_arp_request(bat_priv, skb, hdr_size) ||
+ batadv_dat_snoop_incoming_arp_reply(bat_priv, skb, hdr_size)) {
+ kfree_skb(skb);
goto rx_success;
+ }
batadv_dat_snoop_incoming_dhcp_ack(bat_priv, skb, hdr_size);
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH net-next 08/15] batman-adv: always consume skb in batadv_forw_packet_alloc()
2026-11-14 9:15 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-14 Simon Wunderlich
` (6 preceding siblings ...)
2026-11-14 9:15 ` [PATCH net-next 07/15] batman-adv: never consume skb in BLA rx and DAT incoming snooping Simon Wunderlich
@ 2026-11-14 9:15 ` Simon Wunderlich
2026-11-14 9:15 ` [PATCH net-next 09/15] batman-adv: split fragment forwarding into lookup and forward Simon Wunderlich
` (6 subsequent siblings)
14 siblings, 0 replies; 20+ messages in thread
From: Simon Wunderlich @ 2026-11-14 9:15 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
On success, batadv_forw_packet_alloc() stores the skb in the new
forw_packet, and batadv_forw_packet_free() frees it later. On failure
(queue full or out of memory), the skb was left for the caller to free.
Whether the caller still owned the skb therefore depended on the return
value.
Free the skb inside batadv_forw_packet_alloc() on failure, so the skb is
always consumed, and drop the kfree_skb() calls from both callers.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/bat_iv_ogm.c | 4 +---
net/batman-adv/send.c | 14 +++++++-------
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 376c0f80bcee9..5faac7419e43a 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -647,10 +647,8 @@ static bool batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
queue_left = own_packet ? NULL : &bat_priv->batman_queue_left;
forw_packet_aggr = batadv_forw_packet_alloc(if_incoming, if_outgoing,
queue_left, bat_priv, skb);
- if (!forw_packet_aggr) {
- kfree_skb(skb);
+ if (!forw_packet_aggr)
return false;
- }
forw_packet_aggr->skb->priority = TC_PRIO_CONTROL;
skb_reserve(forw_packet_aggr->skb, ETH_HLEN);
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 929b6dd34c107..6672f81798e91 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -481,6 +481,9 @@ void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet,
* (optional) if_incoming, if_outgoing and queue_left. If queue_left
* is NULL then bat_priv is optional, too.
*
+ * The skb is always consumed: on success, it is owned by the returned
+ * forwarding packet, on failure it is freed.
+ *
* Return: An allocated forwarding packet on success, NULL otherwise.
*/
struct batadv_forw_packet *
@@ -505,6 +508,7 @@ batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming,
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"%s queue is full\n", qname);
+ kfree_skb(skb);
return NULL;
}
@@ -532,6 +536,7 @@ batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming,
if (queue_left)
atomic_inc(queue_left);
+ kfree_skb(skb);
return NULL;
}
@@ -753,13 +758,13 @@ static int batadv_forw_bcast_packet_to_list(struct batadv_priv *bat_priv,
newskb = skb_clone(skb, GFP_ATOMIC);
if (!newskb)
- goto err;
+ return NETDEV_TX_BUSY;
forw_packet = batadv_forw_packet_alloc(if_in, if_out,
&bat_priv->bcast_queue_left,
bat_priv, newskb);
if (!forw_packet)
- goto err_packet_free;
+ return NETDEV_TX_BUSY;
forw_packet->own = own_packet;
@@ -770,11 +775,6 @@ static int batadv_forw_bcast_packet_to_list(struct batadv_priv *bat_priv,
batadv_forw_packet_bcast_queue(bat_priv, forw_packet, send_time);
return NETDEV_TX_OK;
-
-err_packet_free:
- kfree_skb(newskb);
-err:
- return NETDEV_TX_BUSY;
}
/**
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH net-next 09/15] batman-adv: split fragment forwarding into lookup and forward
2026-11-14 9:15 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-14 Simon Wunderlich
` (7 preceding siblings ...)
2026-11-14 9:15 ` [PATCH net-next 08/15] batman-adv: always consume skb in batadv_forw_packet_alloc() Simon Wunderlich
@ 2026-11-14 9:15 ` Simon Wunderlich
2026-11-14 9:15 ` [PATCH net-next 10/15] batman-adv: document skb ownership of always-consuming functions Simon Wunderlich
` (5 subsequent siblings)
14 siblings, 0 replies; 20+ messages in thread
From: Simon Wunderlich @ 2026-11-14 9:15 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
batadv_frag_skb_fwd() consumed the skb only when it returned true, and
passed the receive result back through an out-parameter that was only
valid in that case.
To ensure that the forwarding functions either borrow or consume the skb,
split it into:
* batadv_frag_fwd_neigh_get(): borrows the skb and returns the next-hop
(with a reference) when the merged packet would exceed its MTU
* batadv_frag_skb_fwd(): always consumes the skb and returns
NET_RX_SUCCESS or NET_RX_DROP (instead of using the out-parameter
"rx_result")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/fragmentation.c | 99 ++++++++++++++++++----------------
net/batman-adv/fragmentation.h | 9 ++--
net/batman-adv/routing.c | 15 ++++--
3 files changed, 69 insertions(+), 54 deletions(-)
diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index 493af3091aa8a..9025d5f651464 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -385,70 +385,79 @@ bool batadv_frag_skb_buffer(struct sk_buff **skb,
}
/**
- * batadv_frag_skb_fwd() - forward fragments that would exceed MTU when merged
- * @skb: skb to forward
+ * batadv_frag_fwd_neigh_get() - get next-hop for fragments that would exceed
+ * MTU when merged
+ * @skb: received fragment
* @recv_if: interface that the skb is received on
- * @orig_node_src: originator that the skb is received from
- * @rx_result: set to NET_RX_SUCCESS when the fragment was forwarded and
- * NET_RX_DROP when it was dropped; only valid when true is returned
*
* Look up the next-hop of the fragments payload and check if the merged packet
- * will exceed the MTU towards the next-hop. If so, the fragment is forwarded
- * without merging it.
+ * will exceed the MTU towards the next-hop.
*
- * Return: true if the fragment is consumed/forwarded, false otherwise.
+ * Return: the next-hop neighbor (with increased refcounter) when the fragment
+ * has to be forwarded without merging it, NULL otherwise
*/
-bool batadv_frag_skb_fwd(struct sk_buff *skb,
- struct batadv_hard_iface *recv_if,
- struct batadv_orig_node *orig_node_src,
- int *rx_result)
+struct batadv_neigh_node *
+batadv_frag_fwd_neigh_get(const struct sk_buff *skb,
+ struct batadv_hard_iface *recv_if)
{
struct batadv_priv *bat_priv = netdev_priv(recv_if->mesh_iface);
- struct batadv_neigh_node *neigh_node = NULL;
- struct batadv_frag_packet *packet;
- bool ret = false;
+ const struct batadv_frag_packet *packet;
+ struct batadv_neigh_node *neigh_node;
u16 total_size;
- packet = (struct batadv_frag_packet *)skb->data;
+ packet = (const struct batadv_frag_packet *)skb->data;
neigh_node = batadv_orig_to_router(bat_priv, packet->dest, recv_if);
if (!neigh_node)
- goto out;
+ return NULL;
- /* Forward the fragment, if the merged packet would be too big to
- * be assembled.
- */
total_size = ntohs(packet->total_size);
- if (total_size > neigh_node->if_incoming->net_dev->mtu) {
- if (packet->ttl < 2) {
- kfree_skb(skb);
- *rx_result = NET_RX_DROP;
- ret = true;
- goto out;
- }
+ if (total_size <= neigh_node->if_incoming->net_dev->mtu) {
+ batadv_neigh_node_put(neigh_node);
+ return NULL;
+ }
- if (skb_cow(skb, ETH_HLEN) < 0) {
- kfree_skb(skb);
- *rx_result = NET_RX_DROP;
- ret = true;
- goto out;
- }
+ return neigh_node;
+}
+
+/**
+ * batadv_frag_skb_fwd() - forward fragment without merging it
+ * @bat_priv: the bat priv with all the mesh interface information
+ * @skb: skb to forward
+ * @neigh_node: next-hop to forward the fragment to
+ *
+ * The skb is always consumed by this function.
+ *
+ * Return: NET_RX_SUCCESS when the fragment was forwarded and NET_RX_DROP when
+ * it was dropped
+ */
+int batadv_frag_skb_fwd(struct batadv_priv *bat_priv, struct sk_buff *skb,
+ struct batadv_neigh_node *neigh_node)
+{
+ struct batadv_frag_packet *packet;
- packet = (struct batadv_frag_packet *)skb->data;
+ packet = (struct batadv_frag_packet *)skb->data;
- batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_FWD);
- batadv_add_counter(bat_priv, BATADV_CNT_FRAG_FWD_BYTES,
- skb->len + ETH_HLEN);
+ if (packet->ttl < 2)
+ goto free_skb;
- packet->ttl--;
- batadv_send_unicast_skb(skb, neigh_node);
- *rx_result = NET_RX_SUCCESS;
- ret = true;
- }
+ if (skb_cow(skb, ETH_HLEN) < 0)
+ goto free_skb;
-out:
- batadv_neigh_node_put(neigh_node);
- return ret;
+ packet = (struct batadv_frag_packet *)skb->data;
+
+ batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_FWD);
+ batadv_add_counter(bat_priv, BATADV_CNT_FRAG_FWD_BYTES,
+ skb->len + ETH_HLEN);
+
+ packet->ttl--;
+ batadv_send_unicast_skb(skb, neigh_node);
+
+ return NET_RX_SUCCESS;
+
+free_skb:
+ kfree_skb(skb);
+ return NET_RX_DROP;
}
/**
diff --git a/net/batman-adv/fragmentation.h b/net/batman-adv/fragmentation.h
index 51e281027ab63..3c98a4f82286e 100644
--- a/net/batman-adv/fragmentation.h
+++ b/net/batman-adv/fragmentation.h
@@ -17,10 +17,11 @@
void batadv_frag_purge_orig(struct batadv_orig_node *orig,
bool (*check_cb)(struct batadv_frag_table_entry *));
-bool batadv_frag_skb_fwd(struct sk_buff *skb,
- struct batadv_hard_iface *recv_if,
- struct batadv_orig_node *orig_node_src,
- int *rx_result);
+struct batadv_neigh_node * __must_check
+batadv_frag_fwd_neigh_get(const struct sk_buff *skb,
+ struct batadv_hard_iface *recv_if);
+int batadv_frag_skb_fwd(struct batadv_priv *bat_priv, struct sk_buff *skb,
+ struct batadv_neigh_node *neigh_node);
bool batadv_frag_skb_buffer(struct sk_buff **skb,
struct batadv_orig_node *orig_node);
int batadv_frag_send_packet(struct sk_buff *skb,
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index ca71e29a9ad33..d5772429535e9 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -1206,6 +1206,7 @@ int batadv_recv_frag_packet(struct sk_buff *skb,
struct batadv_priv *bat_priv = netdev_priv(recv_if->mesh_iface);
struct batadv_orig_node *orig_node_src = NULL;
struct batadv_frag_packet *frag_packet;
+ struct batadv_neigh_node *neigh_node;
int ret = NET_RX_DROP;
if (batadv_check_unicast_packet(bat_priv, skb,
@@ -1220,11 +1221,15 @@ int batadv_recv_frag_packet(struct sk_buff *skb,
skb->priority = frag_packet->priority + 256;
/* Route the fragment if it is not for us and too big to be merged. */
- if (!batadv_is_my_mac(bat_priv, frag_packet->dest) &&
- batadv_frag_skb_fwd(skb, recv_if, orig_node_src, &ret)) {
- /* skb was consumed */
- skb = NULL;
- goto put_orig_node;
+ if (!batadv_is_my_mac(bat_priv, frag_packet->dest)) {
+ neigh_node = batadv_frag_fwd_neigh_get(skb, recv_if);
+ if (neigh_node) {
+ ret = batadv_frag_skb_fwd(bat_priv, skb, neigh_node);
+ batadv_neigh_node_put(neigh_node);
+ /* skb was consumed */
+ skb = NULL;
+ goto put_orig_node;
+ }
}
batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_RX);
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH net-next 10/15] batman-adv: document skb ownership of always-consuming functions
2026-11-14 9:15 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-14 Simon Wunderlich
` (8 preceding siblings ...)
2026-11-14 9:15 ` [PATCH net-next 09/15] batman-adv: split fragment forwarding into lookup and forward Simon Wunderlich
@ 2026-11-14 9:15 ` Simon Wunderlich
2026-11-14 9:15 ` [PATCH net-next 11/15] batman-adv: tt: increase hash generation when purging clients Simon Wunderlich
` (4 subsequent siblings)
14 siblings, 0 replies; 20+ messages in thread
From: Simon Wunderlich @ 2026-11-14 9:15 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
Several functions always consume the skb they are given, but their
kernel-doc did not say so. Add an explicit "The skb is always consumed by
this function" to these functions.
Some even suggested the opposite and need corrections:
* batadv_v_elp_packet_recv() said the skb is consumed on NET_RX_SUCCESS,
but it is freed on NET_RX_DROP as well
* batadv_send_skb_to_orig() still documented an -EINPROGRESS return
value, which it no longer returns since the removal of the network coding
support
* batadv_frag_insert_packet() did not say that the skb is freed on error
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/bat_v_elp.c | 6 ++++--
net/batman-adv/fragmentation.c | 2 ++
net/batman-adv/send.c | 17 ++++++++++++++---
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index 0eb07b789cffc..5c251feecabc5 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -551,8 +551,10 @@ static void batadv_v_elp_neigh_update(struct batadv_priv *bat_priv,
* @skb: the received packet
* @if_incoming: the interface this packet was received through
*
- * Return: NET_RX_SUCCESS and consumes the skb if the packet was properly
- * processed or NET_RX_DROP in case of failure.
+ * The skb is always consumed by this function.
+ *
+ * Return: NET_RX_SUCCESS if the packet was properly processed or NET_RX_DROP
+ * in case of failure.
*/
int batadv_v_elp_packet_recv(struct sk_buff *skb,
struct batadv_hard_iface *if_incoming)
diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index 9025d5f651464..936056a78effe 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -131,6 +131,8 @@ static bool batadv_frag_init_chain(struct batadv_frag_table_entry *chain,
* Insert a new fragment into the reverse ordered chain in the right table
* entry. The hash table entry is cleared if "old" fragments exist in it.
*
+ * The skb is always consumed by this function.
+ *
* Return: true if skb is buffered, false on error. If the chain has all the
* fragments needed to merge the packet, the chain is moved to the passed head
* to avoid locking the chain in the table.
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 6672f81798e91..24eb222299d33 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -109,6 +109,8 @@ int batadv_send_skb_packet(struct sk_buff *skb,
* @skb: packet to be transmitted (with batadv header and no outer eth header)
* @hard_iface: outgoing interface
*
+ * The skb is always consumed by this function.
+ *
* Return: A negative errno code is returned on a failure. A success does not
* guarantee the frame will be transmitted as it may be dropped due
* to congestion or traffic shaping.
@@ -126,6 +128,8 @@ int batadv_send_broadcast_skb(struct sk_buff *skb,
* @skb: packet to be transmitted (with batadv header and no outer eth header)
* @neigh: neighbor which is used as next hop to destination
*
+ * The skb is always consumed by this function.
+ *
* Return: A negative errno code is returned on a failure. A success does not
* guarantee the frame will be transmitted as it may be dropped due
* to congestion or traffic shaping.
@@ -163,9 +167,10 @@ int batadv_send_unicast_skb(struct sk_buff *skb,
* host, NULL can be passed as recv_if and no interface alternating is
* attempted.
*
- * Return: negative errno code on a failure, -EINPROGRESS if the skb is
- * buffered for later transmit or the NET_XMIT status returned by the
- * lower routine if the packet has been passed down.
+ * The skb is always consumed by this function.
+ *
+ * Return: negative errno code on a failure or the NET_XMIT status returned by
+ * the lower routine if the packet has been passed down.
*/
int batadv_send_skb_to_orig(struct sk_buff *skb,
struct batadv_orig_node *orig_node,
@@ -313,6 +318,8 @@ bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
* depending on whether BATADV_UNICAST or BATADV_UNICAST_4ADDR was supplied
* as packet_type. Then send this frame to the given orig_node.
*
+ * The skb is always consumed by this function.
+ *
* Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
*/
int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
@@ -389,6 +396,8 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
* BATADV_UNICAST_4ADDR was supplied as packet_type. Then send this frame
* to the according destination node.
*
+ * The skb is always consumed by this function.
+ *
* Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
*/
int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
@@ -429,6 +438,8 @@ int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
* Look up the currently selected gateway. Wrap the given skb into a batman-adv
* unicast header and send this frame to this gateway node.
*
+ * The skb is always consumed by this function.
+ *
* Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
*/
int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH net-next 11/15] batman-adv: tt: increase hash generation when purging clients
2026-11-14 9:15 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-14 Simon Wunderlich
` (9 preceding siblings ...)
2026-11-14 9:15 ` [PATCH net-next 10/15] batman-adv: document skb ownership of always-consuming functions Simon Wunderlich
@ 2026-11-14 9:15 ` Simon Wunderlich
2026-11-14 9:15 ` [PATCH net-next 12/15] batman-adv: dat: increase hash generation when purging entries Simon Wunderlich
` (3 subsequent siblings)
14 siblings, 0 replies; 20+ messages in thread
From: Simon Wunderlich @ 2026-11-14 9:15 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Sashiko,
Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
If batadv_tt_local_dump() is preempted during a netlink dump and resumes in
the middle of a hash bucket while batadv_tt_local_purge_pending_clients()
concurrently removes an entry, the dump offset will be shifted.
Without incrementing the hash generation counter, netlink won't set
NLM_F_DUMP_INTR and the userspace will not be informed by the inconsistent
dump..
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20261008-tt-avoid-unhashed-event-v2-0-7c4eed81606d@narfation.org?part=6
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 926b4a3214196..3ce5569a8872f 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -4454,6 +4454,7 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)
batadv_print_vid(tt_common->key.vid));
hlist_del_rcu(&tt_common->hash_entry);
+ atomic_inc(&hash->generation);
/* An entry which still carries BATADV_TT_CLIENT_NEW was
* never counted and must not be uncounted here.
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH net-next 12/15] batman-adv: dat: increase hash generation when purging entries
2026-11-14 9:15 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-14 Simon Wunderlich
` (10 preceding siblings ...)
2026-11-14 9:15 ` [PATCH net-next 11/15] batman-adv: tt: increase hash generation when purging clients Simon Wunderlich
@ 2026-11-14 9:15 ` Simon Wunderlich
[not found] ` <sashiko-outbox-215358@kernel.org>
2026-11-14 9:15 ` [PATCH net-next 13/15] batman-adv: bla: " Simon Wunderlich
` (2 subsequent siblings)
14 siblings, 1 reply; 20+ messages in thread
From: Simon Wunderlich @ 2026-11-14 9:15 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Sashiko,
Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
If batadv_dat_cache_dump() is preempted during a netlink dump and resumes
in the middle of a hash bucket while __batadv_dat_purge() concurrently
removes an entry, the dump offset will be shifted.
Without incrementing the hash generation counter, netlink won't set
NLM_F_DUMP_INTR and the userspace will not be informed about the
inconsistent dump.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-83da443f-ce69-4393-a29f-e02b70d1ec96
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/distributed-arp-table.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 37de9787104d5..d558d2300d607 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -248,6 +248,7 @@ static void __batadv_dat_purge(struct batadv_priv *bat_priv,
continue;
hlist_del_rcu(&dat_entry->hash_entry);
+ atomic_inc(&bat_priv->dat.hash->generation);
batadv_dat_entry_put(dat_entry);
}
spin_unlock_bh(list_lock);
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH net-next 13/15] batman-adv: bla: increase hash generation when purging entries
2026-11-14 9:15 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-14 Simon Wunderlich
` (11 preceding siblings ...)
2026-11-14 9:15 ` [PATCH net-next 12/15] batman-adv: dat: increase hash generation when purging entries Simon Wunderlich
@ 2026-11-14 9:15 ` Simon Wunderlich
2026-11-14 9:15 ` [PATCH net-next 14/15] batman-adv: increase orig hash generation when purging originators Simon Wunderlich
2026-11-14 9:15 ` [PATCH net-next 15/15] batman-adv: annotate functions returning objects with __must_check Simon Wunderlich
14 siblings, 0 replies; 20+ messages in thread
From: Simon Wunderlich @ 2026-11-14 9:15 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Sashiko,
Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
If batadv_bla_claim_dump() or batadv_bla_backbone_dump() is preempted
during a netlink dump and resumes in the middle of a hash bucket while
batadv_bla_del_backbone_claims() or batadv_bla_purge_backbone_gw()
concurrently removes an entry, the dump offset will be shifted.
Without incrementing the hash generation counter, netlink won't set
NLM_F_DUMP_INTR and the userspace will not be informed about the
inconsistent dump.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-83da443f-ce69-4393-a29f-e02b70d1ec96
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/bridge_loop_avoidance.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 9be452f667250..ba410dca1c89c 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -319,6 +319,7 @@ batadv_bla_del_backbone_claims(struct batadv_bla_backbone_gw *backbone_gw)
continue;
hlist_del_rcu(&claim->hash_entry);
+ atomic_inc(&hash->generation);
batadv_claim_put(claim);
}
spin_unlock_bh(list_lock);
@@ -1286,6 +1287,7 @@ static void batadv_bla_purge_backbone_gw(struct batadv_priv *bat_priv, int now)
batadv_bla_del_backbone_claims(backbone_gw);
hlist_del_rcu(&backbone_gw->hash_entry);
+ atomic_inc(&hash->generation);
break;
}
spin_unlock_bh(list_lock);
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH net-next 14/15] batman-adv: increase orig hash generation when purging originators
2026-11-14 9:15 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-14 Simon Wunderlich
` (12 preceding siblings ...)
2026-11-14 9:15 ` [PATCH net-next 13/15] batman-adv: bla: " Simon Wunderlich
@ 2026-11-14 9:15 ` Simon Wunderlich
2026-11-14 9:15 ` [PATCH net-next 15/15] batman-adv: annotate functions returning objects with __must_check Simon Wunderlich
14 siblings, 0 replies; 20+ messages in thread
From: Simon Wunderlich @ 2026-11-14 9:15 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Sashiko,
Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
If batadv_mcast_flags_dump() is preempted during a netlink dump and resumes
in the middle of a hash bucket while batadv_purge_orig_ref() concurrently
removes an originator, the dump offset will be shifted.
Without incrementing the hash generation counter, netlink won't set
NLM_F_DUMP_INTR and the userspace will not be informed about the
inconsistent dump.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-83da443f-ce69-4393-a29f-e02b70d1ec96
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/originator.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 391d97bc938b9..f85ad961f8a9b 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -7,6 +7,7 @@
#include "originator.h"
#include "main.h"
+#include <linux/atomic.h>
#include <linux/container_of.h>
#include <linux/err.h>
#include <linux/errno.h>
@@ -1290,6 +1291,7 @@ void batadv_purge_orig_ref(struct batadv_priv *bat_priv)
if (batadv_purge_orig_node(bat_priv, orig_node)) {
batadv_gw_node_delete(bat_priv, orig_node);
hlist_del_rcu(&orig_node->hash_entry);
+ atomic_inc(&hash->generation);
batadv_tt_global_del_orig(orig_node->bat_priv,
orig_node, -1,
"originator timed out");
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH net-next 15/15] batman-adv: annotate functions returning objects with __must_check
2026-11-14 9:15 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-14 Simon Wunderlich
` (13 preceding siblings ...)
2026-11-14 9:15 ` [PATCH net-next 14/15] batman-adv: increase orig hash generation when purging originators Simon Wunderlich
@ 2026-11-14 9:15 ` Simon Wunderlich
14 siblings, 0 replies; 20+ messages in thread
From: Simon Wunderlich @ 2026-11-14 9:15 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
Most lookup, get and create functions in batman-adv return an object with
an increased refcounter (or otherwise owned resource), which the caller has
to release again with the matching batadv_*_put(), dev_put() or free
function. If a caller ignores such a return value, the reference leaks.
Mark these functions __must_check so the compiler catches such (potential
future) callers.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/bat_iv_ogm.c | 8 ++++----
net/batman-adv/bat_v.c | 2 +-
net/batman-adv/bat_v_ogm.h | 4 ++--
net/batman-adv/bridge_loop_avoidance.c | 8 ++++----
net/batman-adv/distributed-arp-table.c | 6 +++---
net/batman-adv/fragmentation.c | 10 +++++-----
net/batman-adv/gateway_client.h | 9 +++++----
net/batman-adv/hard-interface.c | 2 +-
net/batman-adv/hard-interface.h | 10 ++++++----
net/batman-adv/hash.h | 2 +-
net/batman-adv/mesh-interface.h | 4 ++--
net/batman-adv/multicast.c | 3 ++-
net/batman-adv/netlink.c | 10 +++++-----
net/batman-adv/netlink.h | 5 +++--
net/batman-adv/originator.c | 10 +++++-----
net/batman-adv/originator.h | 26 +++++++++++++-------------
net/batman-adv/routing.c | 2 +-
net/batman-adv/routing.h | 2 +-
net/batman-adv/send.h | 2 +-
net/batman-adv/tp_meter.c | 8 ++++----
net/batman-adv/translation-table.c | 12 ++++++------
net/batman-adv/translation-table.h | 9 +++++----
net/batman-adv/tvlv.c | 4 ++--
23 files changed, 82 insertions(+), 76 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 5faac7419e43a..a7b5d5a1cc024 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -137,7 +137,7 @@ static u8 batadv_ring_buffer_avg(const u8 lq_recv[])
* on failure.
* If the object does not exist, it is created and initialised.
*/
-static struct batadv_orig_node *
+static struct batadv_orig_node * __must_check
batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const u8 *addr)
{
struct batadv_orig_node *orig_node;
@@ -179,7 +179,7 @@ batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const u8 *addr)
*
* Return: pointer to the neigh_node or NULL in case of failure
*/
-static struct batadv_neigh_node *
+static struct batadv_neigh_node * __must_check
batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface,
const u8 *neigh_addr,
struct batadv_orig_node *orig_node)
@@ -1484,7 +1484,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
* Return: A neighbor node which is the best router towards the given originator
* address. Bonding candidates are ignored.
*/
-static struct batadv_neigh_node *
+static struct batadv_neigh_node * __must_check
batadv_orig_to_direct_router(struct batadv_priv *bat_priv, const u8 *orig_addr,
struct batadv_hard_iface *if_outgoing)
{
@@ -2490,7 +2490,7 @@ static void batadv_iv_init_sel_class(struct batadv_priv *bat_priv)
* Return: gateway node with the highest score for the current selection class,
* or NULL if no eligible gateway exists.
*/
-static struct batadv_gw_node *
+static struct batadv_gw_node * __must_check
batadv_iv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
{
struct batadv_neigh_ifinfo *router_ifinfo;
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index bd2bf2b58635e..1ee9f966e548e 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -614,7 +614,7 @@ static int batadv_v_gw_throughput_get(struct batadv_gw_node *gw_node, u32 *bw)
*
* Return: the GW node having the best GW-metric, NULL if no GW is known
*/
-static struct batadv_gw_node *
+static struct batadv_gw_node * __must_check
batadv_v_gw_get_best_gw_node(struct batadv_priv *bat_priv)
{
struct batadv_gw_node *curr_gw = NULL;
diff --git a/net/batman-adv/bat_v_ogm.h b/net/batman-adv/bat_v_ogm.h
index edeffedecade8..30a4a7d904697 100644
--- a/net/batman-adv/bat_v_ogm.h
+++ b/net/batman-adv/bat_v_ogm.h
@@ -18,8 +18,8 @@ void batadv_v_ogm_free(struct batadv_priv *bat_priv);
void batadv_v_ogm_aggr_work(struct work_struct *work);
int batadv_v_ogm_iface_enable(struct batadv_hard_iface *hard_iface);
void batadv_v_ogm_iface_disable(struct batadv_hard_iface *hard_iface);
-struct batadv_orig_node *batadv_v_ogm_orig_get(struct batadv_priv *bat_priv,
- const u8 *addr);
+struct batadv_orig_node * __must_check
+batadv_v_ogm_orig_get(struct batadv_priv *bat_priv, const u8 *addr);
void batadv_v_ogm_primary_iface_set(struct batadv_hard_iface *primary_iface);
int batadv_v_ogm_packet_recv(struct sk_buff *skb,
struct batadv_hard_iface *if_incoming);
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index ba410dca1c89c..729534eb19fb3 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -214,7 +214,7 @@ static void batadv_claim_put(struct batadv_bla_claim *claim)
*
* Return: claim if found or NULL otherwise.
*/
-static struct batadv_bla_claim *
+static struct batadv_bla_claim * __must_check
batadv_claim_hash_find(struct batadv_priv *bat_priv,
const struct batadv_bla_claim_key *key)
{
@@ -254,7 +254,7 @@ batadv_claim_hash_find(struct batadv_priv *bat_priv,
*
* Return: backbone gateway if found or NULL otherwise
*/
-static struct batadv_bla_backbone_gw *
+static struct batadv_bla_backbone_gw * __must_check
batadv_backbone_hash_find(struct batadv_priv *bat_priv, const u8 *addr,
unsigned short vid)
{
@@ -481,7 +481,7 @@ static void batadv_bla_loopdetect_report(struct work_struct *work)
*
* Return: the (possibly created) backbone gateway or NULL on error
*/
-static struct batadv_bla_backbone_gw *
+static struct batadv_bla_backbone_gw * __must_check
batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, const u8 *orig,
unsigned short vid, bool own_backbone)
{
@@ -789,7 +789,7 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
*
* Return: valid reference to claim::backbone_gw
*/
-static struct batadv_bla_backbone_gw *
+static struct batadv_bla_backbone_gw * __must_check
batadv_bla_claim_get_backbone_gw(struct batadv_bla_claim *claim)
{
struct batadv_bla_backbone_gw *backbone_gw;
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index d558d2300d607..2bb6716a124a4 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -396,7 +396,7 @@ static u32 batadv_hash_dat(const void *data, u32 size)
*
* Return: the dat_entry if found, NULL otherwise.
*/
-static struct batadv_dat_entry *
+static struct batadv_dat_entry * __must_check
batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip,
unsigned short vid)
{
@@ -704,7 +704,7 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv,
*
* Return: the candidate array of size BATADV_DAT_CANDIDATE_NUM.
*/
-static struct batadv_dat_candidate *
+static struct batadv_dat_candidate * __must_check
batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst,
unsigned short vid)
{
@@ -1195,7 +1195,7 @@ static unsigned short batadv_dat_get_vid(struct sk_buff *skb, int *hdr_size)
*
* Return: An skb containing an ARP Reply.
*/
-static struct sk_buff *
+static struct sk_buff * __must_check
batadv_dat_arp_create_reply(struct batadv_priv *bat_priv, __be32 ip_src,
__be32 ip_dst, const u8 *hw_src, const u8 *hw_dst,
unsigned short vid)
diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index 936056a78effe..3a9c4ea860b90 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -259,7 +259,7 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node,
*
* Return: the merged skb or NULL on error.
*/
-static struct sk_buff *
+static struct sk_buff * __must_check
batadv_frag_merge_packets(struct hlist_head *chain)
{
int hdr_size = sizeof(struct batadv_frag_packet);
@@ -475,10 +475,10 @@ int batadv_frag_skb_fwd(struct batadv_priv *bat_priv, struct sk_buff *skb,
*
* Return: the new fragment, NULL on error.
*/
-static struct sk_buff *batadv_frag_create(struct net_device *net_dev,
- struct sk_buff *skb,
- struct batadv_frag_packet *frag_head,
- unsigned int fragment_size)
+static struct sk_buff * __must_check
+batadv_frag_create(struct net_device *net_dev, struct sk_buff *skb,
+ struct batadv_frag_packet *frag_head,
+ unsigned int fragment_size)
{
unsigned int ll_reserved = LL_RESERVED_SPACE(net_dev);
unsigned int tailroom = net_dev->needed_tailroom;
diff --git a/net/batman-adv/gateway_client.h b/net/batman-adv/gateway_client.h
index 95c2ccdaa5545..168175c28680d 100644
--- a/net/batman-adv/gateway_client.h
+++ b/net/batman-adv/gateway_client.h
@@ -18,7 +18,7 @@
void batadv_gw_check_client_stop(struct batadv_priv *bat_priv);
void batadv_gw_reselect(struct batadv_priv *bat_priv);
void batadv_gw_election(struct batadv_priv *bat_priv);
-struct batadv_orig_node *
+struct batadv_orig_node * __must_check
batadv_gw_get_selected_orig(struct batadv_priv *bat_priv);
void batadv_gw_check_election(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node);
@@ -29,15 +29,16 @@ void batadv_gw_node_delete(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node);
void batadv_gw_node_free(struct batadv_priv *bat_priv);
void batadv_gw_node_release(struct kref *ref);
-struct batadv_gw_node *
+struct batadv_gw_node * __must_check
batadv_gw_get_selected_gw_node(struct batadv_priv *bat_priv);
int batadv_gw_dump(struct sk_buff *msg, struct netlink_callback *cb);
bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, struct sk_buff *skb);
enum batadv_dhcp_recipient
batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
u8 *chaddr);
-struct batadv_gw_node *batadv_gw_node_get(struct batadv_priv *bat_priv,
- struct batadv_orig_node *orig_node);
+struct batadv_gw_node * __must_check
+batadv_gw_node_get(struct batadv_priv *bat_priv,
+ struct batadv_orig_node *orig_node);
/**
* batadv_gw_node_put() - decrement the gw_node refcounter and possibly release
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index bf36879caab1b..46dcbba0379b8 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -486,7 +486,7 @@ int batadv_hardif_no_broadcast(struct batadv_hard_iface *if_outgoing,
* Return: first hard interface in BATADV_IF_ACTIVE state attached to
* @mesh_iface, or NULL if none is active.
*/
-static struct batadv_hard_iface *
+static struct batadv_hard_iface * __must_check
batadv_hardif_get_active(struct net_device *mesh_iface)
{
struct batadv_hard_iface *hard_iface;
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index 1aec7ce892445..6bdef0ae1419b 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -62,12 +62,14 @@ enum batadv_hard_if_bcast {
extern struct notifier_block batadv_hard_if_notifier;
-struct net_device *__batadv_get_real_netdev(struct net_device *net_device);
-struct net_device *batadv_get_real_netdev(struct net_device *net_device);
+struct net_device * __must_check
+__batadv_get_real_netdev(struct net_device *net_device);
+struct net_device * __must_check
+batadv_get_real_netdev(struct net_device *net_device);
u32 batadv_netdev_get_wifi_flags(struct net_device *net_dev);
u32 batadv_hardif_get_wifi_flags(struct batadv_hard_iface *hard_iface);
bool batadv_is_wifi_hardif(struct batadv_hard_iface *hard_iface);
-struct batadv_hard_iface*
+struct batadv_hard_iface * __must_check
batadv_hardif_get_by_netdev(struct net_device *net_dev);
int batadv_hardif_enable_interface(struct net_device *net_dev,
struct net_device *mesh_iface);
@@ -99,7 +101,7 @@ static inline void batadv_hardif_put(struct batadv_hard_iface *hard_iface)
*
* Return: primary interface (with increased refcnt), otherwise NULL
*/
-static inline struct batadv_hard_iface *
+static inline struct batadv_hard_iface * __must_check
batadv_primary_if_get_selected(struct batadv_priv *bat_priv)
{
struct batadv_hard_iface *hard_iface;
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h
index fca426c5e3c58..5d9a5abb0f474 100644
--- a/net/batman-adv/hash.h
+++ b/net/batman-adv/hash.h
@@ -66,7 +66,7 @@ struct batadv_hashtable {
};
/* allocates and clears the hash */
-struct batadv_hashtable *batadv_hash_new(u32 size);
+struct batadv_hashtable * __must_check batadv_hash_new(u32 size);
/* set class key for all locks */
void batadv_hash_set_lock_class(struct batadv_hashtable *hash,
diff --git a/net/batman-adv/mesh-interface.h b/net/batman-adv/mesh-interface.h
index 5e1e83e04ffbc..ac73f09f89c91 100644
--- a/net/batman-adv/mesh-interface.h
+++ b/net/batman-adv/mesh-interface.h
@@ -24,8 +24,8 @@ int batadv_meshif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid);
void batadv_meshif_destroy_vlan(struct batadv_priv *bat_priv,
struct batadv_meshif_vlan *vlan);
void batadv_meshif_vlan_release(struct kref *ref);
-struct batadv_meshif_vlan *batadv_meshif_vlan_get(struct batadv_priv *bat_priv,
- unsigned short vid);
+struct batadv_meshif_vlan * __must_check
+batadv_meshif_vlan_get(struct batadv_priv *bat_priv, unsigned short vid);
/**
* batadv_meshif_vlan_put() - decrease the vlan object refcounter and
diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index 1e086a6385261..29bfeb800fa5d 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -81,7 +81,8 @@ static void batadv_mcast_start_timer(struct batadv_priv *bat_priv)
* Return: NULL if no such bridge exists. Otherwise the net device of the
* bridge.
*/
-static struct net_device *batadv_mcast_get_bridge(struct net_device *mesh_iface)
+static struct net_device * __must_check
+batadv_mcast_get_bridge(struct net_device *mesh_iface)
{
struct net_device *upper = mesh_iface;
diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c
index 107647c9badad..fd58523cea7c1 100644
--- a/net/batman-adv/netlink.c
+++ b/net/batman-adv/netlink.c
@@ -1138,7 +1138,7 @@ static int batadv_netlink_set_vlan(struct sk_buff *skb, struct genl_info *info)
* Return: Pointer to mesh interface (with increased refcnt) on success, error
* pointer on error
*/
-static struct net_device *
+static struct net_device * __must_check
batadv_netlink_get_meshif_from_ifindex(struct net *net, int ifindex)
{
struct net_device *mesh_iface;
@@ -1166,7 +1166,7 @@ batadv_netlink_get_meshif_from_ifindex(struct net *net, int ifindex)
* Return: Pointer to mesh interface (with increased refcnt) on success, error
* pointer on error
*/
-static struct net_device *
+static struct net_device * __must_check
batadv_netlink_get_meshif_from_info(struct net *net, struct genl_info *info)
{
int ifindex;
@@ -1206,7 +1206,7 @@ struct net_device *batadv_netlink_get_meshif(struct netlink_callback *cb)
* Return: Pointer to hard interface (with increased refcnt) on success, error
* pointer on error
*/
-static struct batadv_hard_iface *
+static struct batadv_hard_iface * __must_check
batadv_netlink_get_hardif_from_ifindex(struct batadv_priv *bat_priv,
struct net *net, int ifindex)
{
@@ -1248,7 +1248,7 @@ batadv_netlink_get_hardif_from_ifindex(struct batadv_priv *bat_priv,
* Return: Pointer to hard interface (with increased refcnt) on success, error
* pointer on error
*/
-static struct batadv_hard_iface *
+static struct batadv_hard_iface * __must_check
batadv_netlink_get_hardif_from_info(struct batadv_priv *bat_priv,
struct net *net, struct genl_info *info)
{
@@ -1293,7 +1293,7 @@ batadv_netlink_get_hardif(struct batadv_priv *bat_priv,
* Return: Pointer to vlan on success (with increased refcnt), error pointer
* on error
*/
-static struct batadv_meshif_vlan *
+static struct batadv_meshif_vlan * __must_check
batadv_get_vlan_from_info(struct batadv_priv *bat_priv, struct net *net,
struct genl_info *info)
{
diff --git a/net/batman-adv/netlink.h b/net/batman-adv/netlink.h
index f92d3ea7d06cb..d6eeff0e57238 100644
--- a/net/batman-adv/netlink.h
+++ b/net/batman-adv/netlink.h
@@ -14,8 +14,9 @@
int batadv_netlink_register(void);
void batadv_netlink_unregister(void);
-struct net_device *batadv_netlink_get_meshif(struct netlink_callback *cb);
-struct batadv_hard_iface *
+struct net_device * __must_check
+batadv_netlink_get_meshif(struct netlink_callback *cb);
+struct batadv_hard_iface * __must_check
batadv_netlink_get_hardif(struct batadv_priv *bat_priv,
struct netlink_callback *cb);
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index f85ad961f8a9b..0a5ee918cf501 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -530,7 +530,7 @@ batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh,
*
* Return: neighbor when found. Otherwise NULL
*/
-static struct batadv_neigh_node *
+static struct batadv_neigh_node * __must_check
batadv_neigh_node_get(const struct batadv_orig_node *orig_node,
const struct batadv_hard_iface *hard_iface,
const u8 *addr)
@@ -565,7 +565,7 @@ batadv_neigh_node_get(const struct batadv_orig_node *orig_node,
*
* Return: the hardif neighbour node if found or created or NULL otherwise.
*/
-static struct batadv_hardif_neigh_node *
+static struct batadv_hardif_neigh_node * __must_check
batadv_hardif_neigh_create(struct batadv_hard_iface *hard_iface,
const u8 *neigh_addr,
struct batadv_orig_node *orig_node)
@@ -612,7 +612,7 @@ batadv_hardif_neigh_create(struct batadv_hard_iface *hard_iface,
*
* Return: the hardif neighbour node if found or created or NULL otherwise.
*/
-static struct batadv_hardif_neigh_node *
+static struct batadv_hardif_neigh_node * __must_check
batadv_hardif_neigh_get_or_create(struct batadv_hard_iface *hard_iface,
const u8 *neigh_addr,
struct batadv_orig_node *orig_node)
@@ -670,7 +670,7 @@ batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface,
*
* Return: the neighbour node if found or created or NULL otherwise.
*/
-static struct batadv_neigh_node *
+static struct batadv_neigh_node * __must_check
batadv_neigh_node_create(struct batadv_orig_node *orig_node,
struct batadv_hard_iface *hard_iface,
const u8 *neigh_addr)
@@ -1170,7 +1170,7 @@ batadv_purge_orig_neighbors(struct batadv_priv *bat_priv,
*
* Return: the current best neighbor, with refcount increased.
*/
-static struct batadv_neigh_node *
+static struct batadv_neigh_node * __must_check
batadv_find_best_neighbor(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
struct batadv_hard_iface *if_outgoing)
diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h
index dff729ecf2df1..6b17fa62ed2c4 100644
--- a/net/batman-adv/originator.h
+++ b/net/batman-adv/originator.h
@@ -22,46 +22,46 @@ int batadv_originator_init(struct batadv_priv *bat_priv);
void batadv_originator_free(struct batadv_priv *bat_priv);
void batadv_purge_orig_ref(struct batadv_priv *bat_priv);
void batadv_orig_node_release(struct kref *ref);
-struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
- const u8 *addr);
-struct batadv_hardif_neigh_node *
+struct batadv_orig_node * __must_check
+batadv_orig_node_new(struct batadv_priv *bat_priv, const u8 *addr);
+struct batadv_hardif_neigh_node * __must_check
batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface,
const u8 *neigh_addr);
void batadv_hardif_neigh_release(struct kref *ref);
-struct batadv_neigh_node *
+struct batadv_neigh_node * __must_check
batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node,
struct batadv_hard_iface *hard_iface,
const u8 *neigh_addr);
void batadv_neigh_node_release(struct kref *ref);
-struct batadv_neigh_node *
+struct batadv_neigh_node * __must_check
batadv_orig_router_get(struct batadv_orig_node *orig_node,
const struct batadv_hard_iface *if_outgoing);
-struct batadv_neigh_node *
+struct batadv_neigh_node * __must_check
batadv_orig_to_router(struct batadv_priv *bat_priv, const u8 *orig_addr,
struct batadv_hard_iface *if_outgoing);
-struct batadv_neigh_ifinfo *
+struct batadv_neigh_ifinfo * __must_check
batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh,
struct batadv_hard_iface *if_outgoing);
-struct batadv_neigh_ifinfo *
+struct batadv_neigh_ifinfo * __must_check
batadv_neigh_ifinfo_get(struct batadv_neigh_node *neigh,
struct batadv_hard_iface *if_outgoing);
void batadv_neigh_ifinfo_release(struct kref *ref);
int batadv_hardif_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb);
-struct batadv_orig_ifinfo *
+struct batadv_orig_ifinfo * __must_check
batadv_orig_ifinfo_get(struct batadv_orig_node *orig_node,
struct batadv_hard_iface *if_outgoing);
-struct batadv_orig_ifinfo *
+struct batadv_orig_ifinfo * __must_check
batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node,
struct batadv_hard_iface *if_outgoing);
void batadv_orig_ifinfo_release(struct kref *ref);
int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb);
-struct batadv_orig_node_vlan *
+struct batadv_orig_node_vlan * __must_check
batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node,
unsigned short vid);
-struct batadv_orig_node_vlan *
+struct batadv_orig_node_vlan * __must_check
batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node,
unsigned short vid);
void batadv_orig_node_vlan_release(struct kref *ref);
@@ -82,7 +82,7 @@ static inline u32 batadv_choose_orig(const void *data, u32 size)
return hash % size;
}
-struct batadv_orig_node *
+struct batadv_orig_node * __must_check
batadv_orig_hash_find(struct batadv_priv *bat_priv, const u8 *addr);
/**
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index d5772429535e9..6bcd9d9496ba9 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -542,7 +542,7 @@ static int batadv_check_unicast_packet(struct batadv_priv *bat_priv,
*
* The object is returned with refcounter increased by 1.
*/
-static struct batadv_orig_ifinfo *
+static struct batadv_orig_ifinfo * __must_check
batadv_last_bonding_get(struct batadv_orig_node *orig_node)
{
struct batadv_orig_ifinfo *last_bonding_candidate;
diff --git a/net/batman-adv/routing.h b/net/batman-adv/routing.h
index e9849f032a240..74878d06e8443 100644
--- a/net/batman-adv/routing.h
+++ b/net/batman-adv/routing.h
@@ -42,7 +42,7 @@ int batadv_recv_unicast_tvlv(struct sk_buff *skb,
struct batadv_hard_iface *recv_if);
int batadv_recv_unhandled_unicast_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if);
-struct batadv_neigh_node *
+struct batadv_neigh_node * __must_check
batadv_find_router(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
struct batadv_hard_iface *recv_if);
diff --git a/net/batman-adv/send.h b/net/batman-adv/send.h
index 3415afec4a0c2..ebf57751cf954 100644
--- a/net/batman-adv/send.h
+++ b/net/batman-adv/send.h
@@ -17,7 +17,7 @@
void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet,
bool dropped);
-struct batadv_forw_packet *
+struct batadv_forw_packet * __must_check
batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming,
struct batadv_hard_iface *if_outgoing,
atomic_t *queue_left,
diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c
index 56feb02d2b7ef..4014a431951ec 100644
--- a/net/batman-adv/tp_meter.c
+++ b/net/batman-adv/tp_meter.c
@@ -264,7 +264,7 @@ static void batadv_tp_batctl_error_notify(enum batadv_tp_meter_reason reason,
*
* Return: matching tp_vars or NULL when no tp_vars with @dst was found
*/
-static struct batadv_tp_sender *
+static struct batadv_tp_sender * __must_check
batadv_tp_list_find_sender(struct batadv_priv *bat_priv, const u8 *dst)
{
struct batadv_tp_sender *tp_vars = NULL;
@@ -329,7 +329,7 @@ static bool batadv_tp_list_active(struct batadv_priv *bat_priv, const u8 *dst)
*
* Return: matching tp_vars or NULL when no tp_vars was found
*/
-static struct batadv_tp_sender *
+static struct batadv_tp_sender * __must_check
batadv_tp_list_find_sender_session(struct batadv_priv *bat_priv, const u8 *dst,
const u8 *session)
{
@@ -1212,7 +1212,7 @@ void batadv_tp_stop(struct batadv_priv *bat_priv, const u8 *dst,
*
* Return: matching tp_vars or NULL when no tp_vars was found
*/
-static struct batadv_tp_receiver *
+static struct batadv_tp_receiver * __must_check
batadv_tp_list_find_receiver_session(struct batadv_priv *bat_priv, const u8 *dst,
const u8 *session)
{
@@ -1569,7 +1569,7 @@ static void batadv_tp_ack_unordered(struct batadv_tp_receiver *tp_vars)
*
* Return: corresponding tp_vars or NULL on errors
*/
-static struct batadv_tp_receiver *
+static struct batadv_tp_receiver * __must_check
batadv_tp_init_recv(struct batadv_priv *bat_priv,
const struct batadv_icmp_tp_packet *icmp)
{
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 3ce5569a8872f..f9de255ef0dfd 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -150,7 +150,7 @@ static inline u32 batadv_choose_tt(const void *data, u32 size)
* Return: a pointer to the tt_common struct belonging to the searched client if
* found, NULL otherwise.
*/
-static struct batadv_tt_common_entry *
+static struct batadv_tt_common_entry * __must_check
batadv_tt_hash_find(struct batadv_hashtable *hash, const u8 *addr,
unsigned short vid)
{
@@ -194,7 +194,7 @@ batadv_tt_hash_find(struct batadv_hashtable *hash, const u8 *addr,
* Return: a pointer to the corresponding tt_local_entry struct if the client is
* found, NULL otherwise.
*/
-static struct batadv_tt_local_entry *
+static struct batadv_tt_local_entry * __must_check
batadv_tt_local_hash_find(struct batadv_priv *bat_priv, const u8 *addr,
unsigned short vid)
{
@@ -965,7 +965,7 @@ static bool batadv_tt_local_add_existing(struct batadv_priv *bat_priv,
* Return: the new entry with an initialized reference counter on success, NULL
* otherwise.
*/
-static struct batadv_tt_local_entry *
+static struct batadv_tt_local_entry * __must_check
batadv_tt_local_create(struct net_device *mesh_iface, const u8 *addr,
unsigned short vid, bool iif_is_wifi)
{
@@ -1956,7 +1956,7 @@ static void batadv_tt_changes_list_free(struct batadv_priv *bat_priv)
*
* Return: it with an increased refcounter, NULL if not found
*/
-static struct batadv_tt_orig_list_entry *
+static struct batadv_tt_orig_list_entry * __must_check
batadv_tt_global_orig_entry_find(const struct batadv_tt_global_entry *entry,
const struct batadv_orig_node *orig_node)
{
@@ -2194,7 +2194,7 @@ batadv_tt_global_merge_flags(struct batadv_tt_global_entry *tt_global_entry,
* Return: the new entry with an initialized reference counter on success, NULL
* otherwise.
*/
-static struct batadv_tt_global_entry *
+static struct batadv_tt_global_entry * __must_check
batadv_tt_global_create(const unsigned char *tt_addr, unsigned short vid,
u16 flags)
{
@@ -3347,7 +3347,7 @@ static void batadv_tt_req_purge(struct batadv_priv *bat_priv)
* Return: the pointer to the new tt_req_node struct if no request
* has already been issued for this orig_node, NULL otherwise.
*/
-static struct batadv_tt_req_node *
+static struct batadv_tt_req_node * __must_check
batadv_tt_req_node_new(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node)
{
diff --git a/net/batman-adv/translation-table.h b/net/batman-adv/translation-table.h
index 41b7c40790419..2e315d221b3a7 100644
--- a/net/batman-adv/translation-table.h
+++ b/net/batman-adv/translation-table.h
@@ -29,15 +29,16 @@ int batadv_tt_global_dump(struct sk_buff *msg, struct netlink_callback *cb);
void batadv_tt_global_del_orig(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
s32 match_vid, const char *message);
-struct batadv_tt_global_entry *
+struct batadv_tt_global_entry * __must_check
batadv_tt_global_hash_find(struct batadv_priv *bat_priv, const u8 *addr,
unsigned short vid);
void batadv_tt_global_entry_release(struct kref *ref);
int batadv_tt_global_hash_count(struct batadv_priv *bat_priv,
const u8 *addr, unsigned short vid);
-struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv,
- const u8 *src, const u8 *addr,
- unsigned short vid);
+struct batadv_orig_node * __must_check
+batadv_transtable_search(struct batadv_priv *bat_priv,
+ const u8 *src, const u8 *addr,
+ unsigned short vid);
void batadv_tt_free(struct batadv_priv *bat_priv);
bool batadv_is_my_client(struct batadv_priv *bat_priv, const u8 *addr,
unsigned short vid);
diff --git a/net/batman-adv/tvlv.c b/net/batman-adv/tvlv.c
index 93492d393c347..a4f7e474b4245 100644
--- a/net/batman-adv/tvlv.c
+++ b/net/batman-adv/tvlv.c
@@ -69,7 +69,7 @@ static void batadv_tvlv_handler_put(struct batadv_tvlv_handler *tvlv_handler)
*
* Return: tvlv handler if found or NULL otherwise.
*/
-static struct batadv_tvlv_handler *
+static struct batadv_tvlv_handler * __must_check
batadv_tvlv_handler_get(struct batadv_priv *bat_priv, u8 type, u8 version)
{
struct batadv_tvlv_handler *tvlv_handler = NULL;
@@ -132,7 +132,7 @@ static void batadv_tvlv_container_put(struct batadv_tvlv_container *tvlv)
*
* Return: tvlv container if found or NULL otherwise.
*/
-static struct batadv_tvlv_container *
+static struct batadv_tvlv_container * __must_check
batadv_tvlv_container_get(struct batadv_priv *bat_priv, u8 type, u8 version)
{
struct batadv_tvlv_container *tvlv = NULL;
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread