Skip to contentSkip to conversation

pull request for net-next: batman-adv 2026-07-28

PATCH In review Simon Wunderlich 4 participants 26 messages Jul 28 – Aug 6

Subsystems (4)
lore
Share & tools
lore

Simon Wunderlich

author maintainer
#0 lore raw

cover pull request for net-next: batman-adv 2026-07-28

Dear net maintainers,

here is a minor bugfix/cleanup pull request of batman-adv to go into net-next.

Please pull or let me know of any problem!

Thank you,
Simon

The following changes since commit b470fde8f77b56ff273c5527484b99499b894e16:

Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net (2026-07-10 10:20:05 +0200)

are available in the Git repository at:

https://git.open-mesh.org/batadv.git tags/batadv-next-pullrequest-20260728

for you to fetch changes up to 6af11807a9e1e9117bfe4865cc9b30935c339cf2:

batman-adv: tt: simplify NEW flag transition code (2026-07-10 22:35:45 +0200)

----------------------------------------------------------------
This minor bugfix/cleanup patchset includes the following patches (all by Sven Eckelmann):

7 minor bugfix patches:

- bla: fix potential CRC corruptions (2 patches)

- dat: avoid unaligned fault in IP extraction

- dat: atomically update mac addresses

- mcast: ensure linearization, TX prio extraction and unshared skbs (3 patches)

8 cleanup patches:

- dat: drop non-4addr backwards compatibility

- improve kernel-doc, add comments and warnings (3 patches)

- coding style: split declarations, reverse x-mas tree (2 patches)

- tt: atomic flag modifications, simplify NEW flag transition (2 patches)

----------------------------------------------------------------
Sven Eckelmann (15):
batman-adv: bla: avoid CRC corruption due to parallel claim add
batman-adv: bla: prevent CRC corruptions after claim flush
batman-adv: dat: avoid unaligned fault in IP extraction
batman-adv: dat: atomically update mac addresses
batman-adv: fix TX priority extraction for BATADV_FORW_MCAST
batman-adv: mcast: ensure unshared skb for multicast packets
batman-adv: mcast: linearize skbuff for packet generation
batman-adv: dat: drop non-4addr backwards compatibility
batman-adv: add missing kernel-doc comments
batman-adv: fix kernel-doc for functions holding skb ownership
batman-adv: annotate functions which may reallocate the skbuff
batman-adv: split multiple declarations per line
batman-adv: switch var declarations to reverse x-mas tree order
batman-adv: tt: use atomic flag modifications
batman-adv: tt: simplify NEW flag transition code

 include/uapi/linux/batadv_packet.h     |  16 +-
 net/batman-adv/bat_algo.c              |  16 +-
 net/batman-adv/bat_iv_ogm.c            | 303 ++++++++++++----
 net/batman-adv/bat_v.c                 |  87 ++++-
 net/batman-adv/bat_v_elp.c             |  19 +-
 net/batman-adv/bat_v_ogm.c             |  34 +-
 net/batman-adv/bitarray.c              |   9 +-
 net/batman-adv/bridge_loop_avoidance.c | 169 +++++----
 net/batman-adv/distributed-arp-table.c | 305 +++++++++++-----
 net/batman-adv/fragmentation.c         |  34 +-
 net/batman-adv/gateway_client.c        |  41 ++-
 net/batman-adv/gateway_common.c        |   6 +-
 net/batman-adv/hard-interface.c        |  94 ++++-
 net/batman-adv/hash.c                  |   5 +-
 net/batman-adv/hash.h                  |  42 ++-
 net/batman-adv/log.h                   |  16 +-
 net/batman-adv/main.c                  |  59 ++-
 net/batman-adv/mesh-interface.c        | 116 ++++--
 net/batman-adv/multicast.c             |  33 +-
 net/batman-adv/multicast_forw.c        |  33 +-
 net/batman-adv/netlink.c               |  14 +-
 net/batman-adv/originator.c            |  64 ++--
 net/batman-adv/routing.c               | 115 ++++--
 net/batman-adv/send.c                  |   7 +-
 net/batman-adv/tp_meter.c              |  41 ++-
 net/batman-adv/translation-table.c     | 637 +++++++++++++++++++++++----------
 net/batman-adv/tvlv.c                  |  24 +-
 net/batman-adv/types.h                 |   8 +-
 28 files changed, 1692 insertions(+), 655 deletions(-)
author maintainer
#1 lore raw

PATCH 1/15 batman-adv: bla: avoid CRC corruption due to parallel claim add

From: Sven Eckelmann <[email protected]>

batadv_bla_add_claim() is used to add claims and modify the backbone of claims for CLAIM frames from remote backbones and local packets. When it handles a claim, it needs to either

* add the new claim's CRC to the backbone CRC
* remove the already existing claim's CRC from the old backbone and add it to the new backbone

But when the "new" claim code was running in parallel to the "change backbone" code, it can happen that the CRC was invalid because the backbone_gw of the claim was changed twice in the "new" claim code path:

* CPU0 creates the claim for gateway A and publishes it in the claim hash. The crc16 of the address has not yet been added to A's crc at this point.

* CPU1 processes a claim frame of gateway B for the same client, finds the just published claim, and performs the ownership change: it switches the pointer to B, removes the crc16 from A's crc - which never contained it - and adds it to B's crc.

* CPU0 continues behind the creation branch, unconditionally switches the pointer back to A without compensating B's crc (its remove_crc is false for the creation path), and finally adds the crc16 to A's crc

The CRC is then wrong for both:

* claim belongs to A: but CRC is not part of backbone A's CRC
* claim doesn't belong to B: CRC is still part of backbone B's CRC

This wrong CRC is never recomputated from the stored claims. For local backbone claims, this can also not recovered using syncs.

To avoid this, split the functionality in clear separate parts:

* new claim which always adds claim CRC to the backbone CRC (but never changes the already set backbone_gw of the claim back)

* update of existing claim which automatically changes the backbone_gw entry and only updates both backbone CRCs when there was an actual change

Fixes 23721387c409 ("batman-adv: add basic bridge loop avoidance code")
---
 net/batman-adv/bridge_loop_avoidance.c | 60 ++++++++++++++++----------
 1 file changed, 37 insertions(+), 23 deletions(-)
net/batman-adv/bridge_loop_avoidance.c +37 -23
index f9a1fadf8de9e..79c482d24d9e3 100644
@@ -694,12 +694,14 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
 	struct batadv_bla_backbone_gw *old_backbone_gw;
 	struct batadv_bla_claim *claim;
 	struct batadv_bla_claim search_claim;
-	bool remove_crc = false;
 	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);
+	claim_crc = crc16(0, mac, ETH_ALEN);
 
 	/* create a new claim entry if it does not exist yet. */
 	if (!claim) {
@@ -731,43 +733,55 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
 			kfree(claim);
 			return;
 		}
+
+		spin_lock_bh(&backbone_gw->crc_lock);
+		backbone_gw->crc ^= claim_crc;
+		spin_unlock_bh(&backbone_gw->crc_lock);
+
+		WRITE_ONCE(backbone_gw->lasttime, jiffies);
+
+		batadv_claim_put(claim);
+		return;
+	}
+
+	WRITE_ONCE(claim->lasttime, jiffies);
+
+	/* replace backbone_gw atomically and adjust reference counters */
+	spin_lock_bh(&claim->backbone_lock);
+	if (claim->backbone_gw != backbone_gw) {
+		changed = true;
+
+		old_backbone_gw = claim->backbone_gw;
+		kref_get(&backbone_gw->refcount);
+		claim->backbone_gw = backbone_gw;
 	} else {
-		WRITE_ONCE(claim->lasttime, jiffies);
-		if (claim->backbone_gw == backbone_gw)
-			/* no need to register a new backbone */
-			goto claim_free_ref;
+		old_backbone_gw = NULL;
+		changed = false;
+	}
+	spin_unlock_bh(&claim->backbone_lock);
 
+	if (changed) {
 		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);
 
-		remove_crc = true;
+		/* add claim address to new backbone_gw */
+		spin_lock_bh(&backbone_gw->crc_lock);
+		backbone_gw->crc ^= claim_crc;
+		spin_unlock_bh(&backbone_gw->crc_lock);
 	}
 
-	/* replace backbone_gw atomically and adjust reference counters */
-	spin_lock_bh(&claim->backbone_lock);
-	old_backbone_gw = claim->backbone_gw;
-	kref_get(&backbone_gw->refcount);
-	claim->backbone_gw = backbone_gw;
-	spin_unlock_bh(&claim->backbone_lock);
-
-	if (remove_crc) {
+	if (old_backbone_gw) {
 		/* remove claim address from old backbone_gw */
 		spin_lock_bh(&old_backbone_gw->crc_lock);
-		old_backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
+		old_backbone_gw->crc ^= claim_crc;
 		spin_unlock_bh(&old_backbone_gw->crc_lock);
-	}
 
-	batadv_backbone_gw_put(old_backbone_gw);
+		batadv_backbone_gw_put(old_backbone_gw);
+	}
 
-	/* add claim address to new backbone_gw */
-	spin_lock_bh(&backbone_gw->crc_lock);
-	backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
-	spin_unlock_bh(&backbone_gw->crc_lock);
 	WRITE_ONCE(backbone_gw->lasttime, jiffies);
-
-claim_free_ref:
 	batadv_claim_put(claim);
 }
 
Signature · 1 line
2.47.3
author maintainer
#2 lore raw

PATCH 2/15 batman-adv: bla: prevent CRC corruptions after claim flush

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

When batadv_bla_del_backbone_claims() tried to remove all claims of a backbone, it sets the CRC to 0. It assumes that the it had the last reference of the claims because batadv_claim_release() (which runs after the last reference was released), is XORing the crc16 of the claim address with the backbone CRC.

If there would be a parallel holder of any of these references, it could happen that the backbone CRC is (0 ^ crc16(delayed_released_claim)). Which is the wrong starting point for the new claims it may receive when the remote answers the claim request from batadv_bla_send_request().

This reinitializations can be completely dropped to avoid this problem. batadv_claim_release() will take care of fixing the backbone CRC.

Fixes 23721387c409 ("batman-adv: add basic bridge loop avoidance code")
---
 net/batman-adv/bridge_loop_avoidance.c | 5 -----
 1 file changed, 5 deletions(-)
net/batman-adv/bridge_loop_avoidance.c +0 -5
index 79c482d24d9e3..8ee3ec5eb2c5e 100644
@@ -324,11 +324,6 @@ batadv_bla_del_backbone_claims(struct batadv_bla_backbone_gw *backbone_gw)
 		}
 		spin_unlock_bh(list_lock);
 	}
-
-	/* all claims gone, initialize CRC */
-	spin_lock_bh(&backbone_gw->crc_lock);
-	backbone_gw->crc = BATADV_BLA_CRC_INIT;
-	spin_unlock_bh(&backbone_gw->crc_lock);
 }
 
 /**
Signature · 1 line
2.47.3
author maintainer
#3 lore raw

PATCH 3/15 batman-adv: dat: avoid unaligned fault in IP extraction

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

Independent of the alignment of the ARP packet in the SKB, either the batadv_arp_ip_src or the batadv_arp_ip_dst will have an unaligned access (on HW without native unaligned read support).

Use get_unaligned() to handle this properly on all architectures.

Fixes 5c3a0e553593 ("batman-adv: Distributed ARP Table - add ARP parsing functions")
---
 net/batman-adv/distributed-arp-table.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
net/batman-adv/distributed-arp-table.c +6 -2
index a6fe4820f65b9..6ca946da92758 100644
@@ -250,7 +250,10 @@ static u8 *batadv_arp_hw_src(struct sk_buff *skb, int hdr_size)
  */
 static __be32 batadv_arp_ip_src(struct sk_buff *skb, int hdr_size)
 {
-	return *(__force __be32 *)(batadv_arp_hw_src(skb, hdr_size) + ETH_ALEN);
+	u8 *src = batadv_arp_hw_src(skb, hdr_size) + ETH_ALEN;
+	__be32 *ip = (__force __be32 *)src;
+
+	return get_unaligned(ip);
 }
 
 /**
@@ -275,8 +278,9 @@ static u8 *batadv_arp_hw_dst(struct sk_buff *skb, int hdr_size)
 static __be32 batadv_arp_ip_dst(struct sk_buff *skb, int hdr_size)
 {
 	u8 *dst = batadv_arp_hw_src(skb, hdr_size) + ETH_ALEN * 2 + 4;
+	__be32 *ip = (__force __be32 *)dst;
 
-	return *(__force __be32 *)dst;
+	return get_unaligned(ip);
 }
 
 /**
Signature · 1 line
2.47.3
author maintainer
#4 lore raw

PATCH 4/15 batman-adv: dat: atomically update mac addresses

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

When a MAC address is updated in batadv_dat_entry_add(), it is done using a simple copy function. A parallel reader might only see parts of this update. In worst case, the reader is transporting the half updated MAC address over the network or is creating an ARP response using it - poisoning the ARP cache.

atomic64_t can be used to store the 48 bit of a mac address. A reader will then either see the old mac address or the new one - never a mixture of both.

Fixes 2f1dfbe18507 ("batman-adv: Distributed ARP Table - implement local storage")
---
 net/batman-adv/distributed-arp-table.c | 58 +++++++++++++++++---------
 net/batman-adv/types.h                 |  2 +-
 2 files changed, 40 insertions(+), 20 deletions(-)
net/batman-adv/distributed-arp-table.c +39 -19
index 6ca946da92758..95d8e3a383902 100644
@@ -376,18 +376,19 @@ batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip,
 static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
 				 u8 *mac_addr, unsigned short vid)
 {
+	u64 u64_mac = ether_addr_to_u64(mac_addr);
 	struct batadv_dat_entry *dat_entry;
 	int hash_added;
 
 	dat_entry = batadv_dat_entry_hash_find(bat_priv, ip, vid);
 	/* if this entry is already known, just update it */
 	if (dat_entry) {
-		if (!batadv_compare_eth(dat_entry->mac_addr, mac_addr))
-			ether_addr_copy(dat_entry->mac_addr, mac_addr);
+		atomic64_set(&dat_entry->mac_addr, u64_mac);
+
 		dat_entry->last_update = jiffies;
 		batadv_dbg(BATADV_DBG_DAT, bat_priv,
 			   "Entry updated: %pI4 %pM (vid: %d)\n",
-			   &dat_entry->ip, dat_entry->mac_addr,
+			   &dat_entry->ip, mac_addr,
 			   batadv_print_vid(vid));
 		goto out;
 	}
@@ -398,7 +399,7 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
 
 	dat_entry->ip = ip;
 	dat_entry->vid = vid;
-	ether_addr_copy(dat_entry->mac_addr, mac_addr);
+	atomic64_set(&dat_entry->mac_addr, u64_mac);
 	dat_entry->last_update = jiffies;
 	kref_init(&dat_entry->refcount);
 
@@ -414,7 +415,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, dat_entry->mac_addr, batadv_print_vid(vid));
+		   &dat_entry->ip, mac_addr, batadv_print_vid(vid));
 
 out:
 	batadv_dat_entry_put(dat_entry);
@@ -868,6 +869,8 @@ batadv_dat_cache_dump_entry(struct sk_buff *msg, u32 portid,
 			    struct netlink_callback *cb,
 			    struct batadv_dat_entry *dat_entry)
 {
+	u8 mac[ETH_ALEN];
+	u64 u64_mac;
 	int msecs;
 	void *hdr;
 
@@ -880,11 +883,12 @@ batadv_dat_cache_dump_entry(struct sk_buff *msg, u32 portid,
 	genl_dump_check_consistent(cb, hdr);
 
 	msecs = jiffies_to_msecs(jiffies - dat_entry->last_update);
+	u64_mac = atomic64_read(&dat_entry->mac_addr);
+	u64_to_ether_addr(u64_mac, mac);
 
 	if (nla_put_in_addr(msg, BATADV_ATTR_DAT_CACHE_IP4ADDRESS,
 			    dat_entry->ip) ||
-	    nla_put(msg, BATADV_ATTR_DAT_CACHE_HWADDRESS, ETH_ALEN,
-		    dat_entry->mac_addr) ||
+	    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_u32(msg, BATADV_ATTR_LAST_SEEN_MSECS, msecs)) {
 		genlmsg_cancel(msg, hdr);
@@ -1151,6 +1155,8 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
 	struct net_device *mesh_iface = bat_priv->mesh_iface;
 	int hdr_size = 0;
 	unsigned short vid;
+	u8 mac[ETH_ALEN];
+	u64 u64_mac;
 
 	if (!READ_ONCE(bat_priv->distributed_arp_table))
 		goto out;
@@ -1178,6 +1184,9 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
 
 	dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst, vid);
 	if (dat_entry) {
+		u64_mac = atomic64_read(&dat_entry->mac_addr);
+		u64_to_ether_addr(u64_mac, mac);
+
 		/* If the ARP request is destined for a local client the local
 		 * client will answer itself. DAT would only generate a
 		 * duplicate packet.
@@ -1186,7 +1195,7 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
 		 * additional DAT answer may trigger kernel warnings about
 		 * a packet coming from the wrong port.
 		 */
-		if (batadv_is_my_client(bat_priv, dat_entry->mac_addr, vid)) {
+		if (batadv_is_my_client(bat_priv, mac, vid)) {
 			ret = true;
 			goto out;
 		}
@@ -1196,18 +1205,16 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
 		 * the backbone gws belonging to our backbone has claimed the
 		 * destination.
 		 */
-		if (!batadv_bla_check_claim(bat_priv,
-					    dat_entry->mac_addr, vid)) {
+		if (!batadv_bla_check_claim(bat_priv, mac, vid)) {
 			batadv_dbg(BATADV_DBG_DAT, bat_priv,
 				   "Device %pM claimed by another backbone gw. Don't send ARP reply!",
-				   dat_entry->mac_addr);
+				   mac);
 			ret = true;
 			goto out;
 		}
 
 		skb_new = batadv_dat_arp_create_reply(bat_priv, ip_dst, ip_src,
-						      dat_entry->mac_addr,
-						      hw_src, vid);
+						      mac, hw_src, vid);
 		if (!skb_new)
 			goto out;
 
@@ -1249,6 +1256,8 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
 	struct batadv_dat_entry *dat_entry = NULL;
 	bool ret = false;
 	unsigned short vid;
+	u8 mac[ETH_ALEN];
+	u64 u64_mac;
 	int err;
 
 	if (!READ_ONCE(bat_priv->distributed_arp_table))
@@ -1276,8 +1285,11 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
 	if (!dat_entry)
 		goto out;
 
+	u64_mac = atomic64_read(&dat_entry->mac_addr);
+	u64_to_ether_addr(u64_mac, mac);
+
 	skb_new = batadv_dat_arp_create_reply(bat_priv, ip_dst, ip_src,
-					      dat_entry->mac_addr, hw_src, vid);
+					      mac, hw_src, vid);
 	if (!skb_new)
 		goto out;
 
@@ -1368,6 +1380,8 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
 	u8 *hw_src, *hw_dst;
 	bool dropped = false;
 	unsigned short vid;
+	u8 mac[ETH_ALEN];
+	u64 u64_mac;
 
 	if (!READ_ONCE(bat_priv->distributed_arp_table))
 		goto out;
@@ -1396,11 +1410,17 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
 	 * this frame would lead to doubled receive of an ARP reply.
 	 */
 	dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_src, vid);
-	if (dat_entry && batadv_compare_eth(hw_src, dat_entry->mac_addr)) {
-		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,
-			   dat_entry->mac_addr,	&dat_entry->ip);
-		dropped = true;
+	if (dat_entry) {
+		u64_mac = atomic64_read(&dat_entry->mac_addr);
+		u64_to_ether_addr(u64_mac, mac);
+
+		if (batadv_compare_eth(hw_src, mac)) {
+			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);
+			dropped = true;
+		}
 	}
 
 	/* Update our internal cache with both the IP addresses the node got
net/batman-adv/types.h +1 -1
index cd12755d21f35..992de87632954 100644
@@ -2176,7 +2176,7 @@ struct batadv_dat_entry {
 	__be32 ip;
 
 	/** @mac_addr: the MAC address associated to the stored IPv4 */
-	u8 mac_addr[ETH_ALEN];
+	atomic64_t mac_addr;
 
 	/** @vid: the vlan ID associated to this entry */
 	unsigned short vid;
Signature · 1 line
2.47.3
author maintainer
#5 lore raw

PATCH 5/15 batman-adv: fix TX priority extraction for BATADV_FORW_MCAST

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

batadv_mcast_forw_mode_by_count() pushs the skb->data for BATADV_FORW_MCAST forwarding via batadv_mcast_forw_mcsend(). But the batadv_skb_set_priority() expects the ethernet header directly before (skb->data + offset). With the moved skb->data, just some random data would be accessed to get the priority data.

Move the batadv_skb_set_priority() before the decision about the handling multicast packets and potential header modifications.

Fixes 90039133221e ("batman-adv: mcast: implement multicast packet generation")
---
 net/batman-adv/mesh-interface.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
net/batman-adv/mesh-interface.c +5 -2
index 1dc6cfae9e9ae..48bbb28d4576f 100644
@@ -260,6 +260,8 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
 	if (batadv_compare_eth(ethhdr->h_dest, ectp_addr))
 		goto dropped;
 
+	batadv_skb_set_priority(skb, 0);
+
 	gw_mode = READ_ONCE(bat_priv->gw.mode);
 	if (is_multicast_ether_addr(ethhdr->h_dest)) {
 		/* if gw mode is off, broadcast every packet */
@@ -293,6 +295,9 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
 
 send:
 		if (do_bcast && !is_broadcast_ether_addr(ethhdr->h_dest)) {
+			/* WARNING batadv_mcast_forw_mode might add more headers
+			 * in front of the skb. and might even reallocate the skb
+			 */
 			forw_mode = batadv_mcast_forw_mode(bat_priv, skb, vid,
 							   &mcast_is_routable);
 			switch (forw_mode) {
@@ -310,8 +315,6 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
 		}
 	}
 
-	batadv_skb_set_priority(skb, 0);
-
 	/* ethernet packet should be broadcasted */
 	if (do_bcast) {
 		primary_if = batadv_primary_if_get_selected(bat_priv);
Signature · 1 line
2.47.3
author maintainer
#6 lore raw

PATCH 6/15 batman-adv: mcast: ensure unshared skb for multicast packets

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

When a packet is transmitted via a batman-adv interface and has already enough room for the header then the nothing will make sure that the skbuff is unshared. But it is now allowed to modify a currently shared skbuff.

Always make sure that the pskb_expand_head() is not only called for a too small header but also for shared skbuffs.

Fixes 90039133221e ("batman-adv: mcast: implement multicast packet generation")
---
 net/batman-adv/multicast_forw.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/batman-adv/multicast_forw.c +1 -2
index 1404a3b7adfb1..240ed7380cb0f 100644
@@ -1100,8 +1100,7 @@ static int batadv_mcast_forw_expand_head(struct batadv_priv *bat_priv,
 		return -EINVAL;
 	}
 
-	if (skb_headroom(skb) < hdr_size &&
-	    pskb_expand_head(skb, hdr_size, 0, GFP_ATOMIC) < 0)
+	if (skb_cow(skb, hdr_size) < 0)
 		return -ENOMEM;
 
 	return 0;
Signature · 1 line
2.47.3
author maintainer
#7 lore raw

PATCH 7/15 batman-adv: mcast: linearize skbuff for packet generation

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

batadv_mcast_forw_packet() and batadv_mcast_forw_packet() is not only called by the unsharing+linearizing batadv_recv_mcast_packet() handler. When it is called by batadv_mcast_forw_mcsend() then it will be unshared but not linearized. The SKB_LINEAR_ASSERT() can therefore cause a fatal BUG().

The linearization should happen during the expansion of the head because the call chain because the scrape function can be hit already during the initial batadv_mcast_forw_mode() selection code:

* batadv_interface_tx
* batadv_mcast_forw_mode
* batadv_mcast_forw_mode_by_count()
* batadv_mcast_forw_push()
-> calls batadv_mcast_forw_expand_head() before everything else
* batadv_mcast_forw_push_tvlvs()
* batadv_mcast_forw_push_dests()
* batadv_mcast_forw_push_adjust_padding()
* batadv_mcast_forw_scrape()

Fixes 07afe1ba288c ("batman-adv: mcast: implement multicast packet reception and forwarding")
---
 net/batman-adv/multicast_forw.c | 4 ++++
 1 file changed, 4 insertions(+)
net/batman-adv/multicast_forw.c +4 -0
index 240ed7380cb0f..c99579dc1ca98 100644
@@ -1103,6 +1103,10 @@ static int batadv_mcast_forw_expand_head(struct batadv_priv *bat_priv,
 	if (skb_cow(skb, hdr_size) < 0)
 		return -ENOMEM;
 
+	/* batadv_mcast_forw_scrape() + batadv_mcast_forw_packet() require linearized skb */
+	if (skb_linearize(skb) < 0)
+		return -ENOMEM;
+
 	return 0;
 }
 
Signature · 1 line
2.47.3
author maintainer
#8 lore raw

PATCH 8/15 batman-adv: dat: drop non-4addr backwards compatibility

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

The 4addr unicast packet support is mandatory in compat version 15. No older compat version is supported and the kernel doesn't need to keep code to talk to nodes which cannot be in the same mesh.

---
 net/batman-adv/distributed-arp-table.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
net/batman-adv/distributed-arp-table.c +3 -11
index 95d8e3a383902..180f654d5e515 100644
@@ -1293,17 +1293,9 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
 	if (!skb_new)
 		goto out;
 
-	/* To preserve backwards compatibility, the node has choose the outgoing
-	 * format based on the incoming request packet type. The assumption is
-	 * that a node not using the 4addr packet format doesn't support it.
-	 */
-	if (hdr_size == sizeof(struct batadv_unicast_4addr_packet))
-		err = batadv_send_skb_via_tt_4addr(bat_priv, skb_new,
-						   BATADV_P_DAT_CACHE_REPLY,
-						   NULL, vid);
-	else
-		err = batadv_send_skb_via_tt(bat_priv, skb_new, NULL, vid);
-
+	err = batadv_send_skb_via_tt_4addr(bat_priv, skb_new,
+					   BATADV_P_DAT_CACHE_REPLY,
+					   NULL, vid);
 	if (err != NET_XMIT_DROP) {
 		batadv_inc_counter(bat_priv, BATADV_CNT_DAT_CACHED_REPLY_TX);
 		ret = true;
Signature · 1 line
2.47.3
author maintainer
#9 lore raw

PATCH 9/15 batman-adv: add missing kernel-doc comments

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

batman-adv requires kernel-doc for all functions and data types visible outside their own translation unit. Promoting a function from static to module-wide visibility currently requires adding documentation from scratch. However, this burden falls on whoever promotes a function from static to module-wide visibility, rather than its original implementer.

Add the missing kernel-doc comments for the remaining undocumented functions and data types to reduce the complexity for new contributions.

---
 include/uapi/linux/batadv_packet.h     |  16 ++-
 net/batman-adv/bat_algo.c              |  10 ++
 net/batman-adv/bat_iv_ogm.c            | 166 ++++++++++++++++++++++-
 net/batman-adv/bat_v.c                 |  52 ++++++++
 net/batman-adv/bitarray.c              |   9 +-
 net/batman-adv/distributed-arp-table.c |  38 ++++++
 net/batman-adv/gateway_client.c        |   8 ++
 net/batman-adv/hard-interface.c        |  82 ++++++++++++
 net/batman-adv/hash.c                  |   5 +-
 net/batman-adv/hash.h                  |  34 +++--
 net/batman-adv/main.c                  |  36 ++++-
 net/batman-adv/mesh-interface.c        |  63 +++++++++
 net/batman-adv/netlink.c               |   8 +-
 net/batman-adv/originator.c            |   7 +
 net/batman-adv/routing.c               |  31 +++++
 net/batman-adv/translation-table.c     | 177 ++++++++++++++++++++++++-
 net/batman-adv/types.h                 |   4 +-
 17 files changed, 711 insertions(+), 35 deletions(-)
include/uapi/linux/batadv_packet.h +11 -5
index 1241285b866cd..32436560ecc8b 100644
@@ -192,13 +192,19 @@ enum batadv_tvlv_type {
 };
 
 #pragma pack(2)
-/* the destination hardware field in the ARP frame is used to
- * transport the claim type and the group id
+/**
+ * struct batadv_bla_claim_dst - layout of the destination MAC of a BLA claim
+ *  frame
+ * @magic: fixed magic prefix (FF:43:05) identifying claim frames
+ * @type: claim frame type, see &enum batadv_bla_claimframe
+ * @group: group identifier of the announcing backbone gateway
+ *
+ * used in the destination hardware field of the ARP frame
  */
 struct batadv_bla_claim_dst {
-	__u8   magic[3];	/* FF:43:05 */
-	__u8   type;		/* bla_claimframe */
-	__be16 group;		/* group id */
+	__u8   magic[3];
+	__u8   type;
+	__be16 group;
 };
 
 /**
net/batman-adv/bat_algo.c +10 -0
index 49e5861b58ec2..a040141cdf1a4 100644
@@ -116,6 +116,16 @@ int batadv_algo_select(struct batadv_priv *bat_priv, const char *name)
 	return 0;
 }
 
+/**
+ * batadv_param_set_ra() - Validate and store routing_algo module parameter
+ * @val: new value for the routing_algo module parameter
+ * @kp: kernel parameter description used to store the value
+ *
+ * Check that the requested algorithm is known to batman-adv and then store
+ * the name as the new default routing algorithm.
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
 static int batadv_param_set_ra(const char *val, const struct kernel_param *kp)
 {
 	struct batadv_algo_ops *bat_algo_ops;
net/batman-adv/bat_iv_ogm.c +160 -6

279 lines not on this page · raw message

net/batman-adv/bat_v.c +52 -0

94 lines not on this page · raw message

net/batman-adv/bitarray.c +8 -1
index 67cb356332bf1..f814756d9533f 100644
@@ -11,7 +11,14 @@
 
 #include "log.h"
 
-/* shift the packet array by n places. */
+/**
+ * batadv_bitmap_shift_left() - shift the sequence number bitmap left
+ * @seq_bits: the sequence number bitmap to shift
+ * @n: number of positions to shift left
+ *
+ * Shift @seq_bits by @n positions. No-op if @n is not within the bounds of
+ * the bitmap.
+ */
 static void batadv_bitmap_shift_left(unsigned long *seq_bits, s32 n)
 {
 	if (n <= 0 || n >= BATADV_TQ_LOCAL_WINDOW_SIZE)
net/batman-adv/distributed-arp-table.c +38 -0
index 180f654d5e515..0251cdf5542bb 100644
@@ -50,27 +50,65 @@
 #include "translation-table.h"
 #include "tvlv.h"
 
+/**
+ * enum batadv_bootpop - BOOTP/DHCP message op codes
+ */
 enum batadv_bootpop {
+	/** @BATADV_BOOTREPLY: server-to-client reply */
 	BATADV_BOOTREPLY	= 2,
 };
 
+/**
+ * enum batadv_boothtype - BOOTP/DHCP hardware address types
+ */
 enum batadv_boothtype {
+	/** @BATADV_HTYPE_ETHERNET: Ethernet (10Mb) */
 	BATADV_HTYPE_ETHERNET	= 1,
 };
 
+/**
+ * enum batadv_dhcpoptioncode - DHCP option codes relevant for batman-adv DAT
+ */
 enum batadv_dhcpoptioncode {
+	/** @BATADV_DHCP_OPT_PAD: pad option */
 	BATADV_DHCP_OPT_PAD		= 0,
+
+	/** @BATADV_DHCP_OPT_MSG_TYPE: DHCP message type option */
 	BATADV_DHCP_OPT_MSG_TYPE	= 53,
+
+	/** @BATADV_DHCP_OPT_END: end of options marker */
 	BATADV_DHCP_OPT_END		= 255,
 };
 
+/**
+ * enum batadv_dhcptype - DHCP message types relevant for batman-adv DAT
+ */
 enum batadv_dhcptype {
+	/** @BATADV_DHCPACK: DHCPACK message */
 	BATADV_DHCPACK		= 5,
 };
 
 /* { 99, 130, 83, 99 } */
 #define BATADV_DHCP_MAGIC 1669485411
 
+/**
+ * struct batadv_dhcp_packet - BOOTP/DHCP packet header
+ * @op: message op code / message type
+ * @htype: hardware address type
+ * @hlen: hardware address length
+ * @hops: number of relay hops
+ * @xid: transaction identifier
+ * @secs: seconds elapsed since client started trying to boot
+ * @flags: BOOTP/DHCP flags
+ * @ciaddr: client IP address
+ * @yiaddr: "your" (client) IP address as assigned by the server
+ * @siaddr: IP address of next server to use in bootstrap
+ * @giaddr: relay agent IP address
+ * @chaddr: client hardware address
+ * @sname: optional server host name
+ * @file: boot file name
+ * @magic: BOOTP/DHCP magic cookie identifying the start of options
+ */
 struct batadv_dhcp_packet {
 	__u8 op;
 	__u8 htype;
net/batman-adv/gateway_client.c +8 -0
index a5ac82eabd250..48fc711b8fd62 100644
@@ -125,6 +125,14 @@ batadv_gw_get_selected_orig(struct batadv_priv *bat_priv)
 	return orig_node;
 }
 
+/**
+ * batadv_gw_select() - select a new currently active gateway
+ * @bat_priv: the bat priv with all the mesh interface information
+ * @new_gw_node: gateway node to be set as the current gateway, may be NULL
+ *
+ * Atomically replace the currently active gateway with @new_gw_node and drop
+ * the reference to the previous one.
+ */
 static void batadv_gw_select(struct batadv_priv *bat_priv,
 			     struct batadv_gw_node *new_gw_node)
 {
net/batman-adv/hard-interface.c +82 -0

136 lines not on this page · raw message

net/batman-adv/hash.c +4 -1
index 759fa29176db5..b9a652bd523b1 100644
@@ -11,7 +11,10 @@
 #include <linux/lockdep.h>
 #include <linux/slab.h>
 
-/* clears the hash */
+/**
+ * batadv_hash_init() - clear all buckets of a hashtable
+ * @hash: hashtable to clear
+ */
 static void batadv_hash_init(struct batadv_hashtable *hash)
 {
 	u32 i;
net/batman-adv/hash.h +24 -10
index 86a2c20000dcf..debbbc936cf74 100644
@@ -18,21 +18,35 @@
 #include <linux/stddef.h>
 #include <linux/types.h>
 
-/* callback to a compare function.  should compare 2 element data for their
- * keys
+/**
+ * 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
+ *
+ * Compare hash element by its keys.
  *
- * Return: true if same and false if not same
+ * Return: true if both elements are considered equal, false otherwise.
  */
-typedef bool (*batadv_hashdata_compare_cb)(const struct hlist_node *,
-					   const void *);
+typedef bool (*batadv_hashdata_compare_cb)(const struct hlist_node *node,
+					   const void *key);
 
-/* the hashfunction
+/**
+ * typedef batadv_hashdata_choose_cb - hash bucket selection callback
+ * @key: opaque payload whose key selects the bucket
+ * @size: number of buckets in the hash table
+ *
+ * Return: bucket index derived from the key in @data and the table @size.
+ */
+typedef u32 (*batadv_hashdata_choose_cb)(const void *key, u32 size);
+
+/**
+ * typedef batadv_hashdata_free_cb - hash element free callback
+ * @node: hlist node of the element being removed
+ * @arg: opaque caller-supplied argument forwarded from the caller
  *
- * Return: an index based on the key in the data of the first argument and the
- * size the second
+ * Release a previously inserted hash element.
  */
-typedef u32 (*batadv_hashdata_choose_cb)(const void *, u32);
-typedef void (*batadv_hashdata_free_cb)(struct hlist_node *, void *);
+typedef void (*batadv_hashdata_free_cb)(struct hlist_node *node, void *arg);
 
 /**
  * struct batadv_hashtable - Wrapper of simple hlist based hashtable
net/batman-adv/main.c +32 -4
index 73becb0549488..c5f4e9f8728c0 100644
@@ -82,6 +82,14 @@ static char *batadv_uev_type_str[] = {
 	"bla",
 };
 
+/**
+ * batadv_init() - batman-adv module init function
+ *
+ * Initialise the global state used by all mesh interfaces, register the
+ * netdevice notifier and the netlink/rtnl family.
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
 static int __init batadv_init(void)
 {
 	int ret;
@@ -128,6 +136,12 @@ static int __init batadv_init(void)
 	return ret;
 }
 
+/**
+ * batadv_exit() - batman-adv module exit function
+ *
+ * Unregister the netdevice notifier and tear down all global state allocated
+ * by batadv_init().
+ */
 static void __exit batadv_exit(void)
 {
 	batadv_netlink_unregister();
@@ -398,6 +412,17 @@ void batadv_skb_set_priority(struct sk_buff *skb, int offset)
 	skb->priority = prio + 256;
 }
 
+/**
+ * batadv_recv_unhandled_packet() - default RX handler for unsupported packet
+ *  types
+ * @skb: incoming packet
+ * @recv_if: interface on which the packet was received (unused)
+ *
+ * Drop incoming packets whose packet_type has no dedicated RX handler
+ * registered.
+ *
+ * Return: NET_RX_DROP
+ */
 static int batadv_recv_unhandled_packet(struct sk_buff *skb,
 					struct batadv_hard_iface *recv_if)
 {
@@ -406,10 +431,6 @@ static int batadv_recv_unhandled_packet(struct sk_buff *skb,
 	return NET_RX_DROP;
 }
 
-/* incoming packets with the batman ethertype received on any active hard
- * interface
- */
-
 /**
  * batadv_batman_skb_recv() - Handle incoming message from an hard interface
  * @skb: the received packet
@@ -492,6 +513,13 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
 	return NET_RX_DROP;
 }
 
+/**
+ * batadv_recv_handler_init() - initialise the RX handler dispatch table
+ *
+ * Initialise all entries of the RX handler table (+ unused to the
+ * default drop handler) and perform compile-time size sanity checks on
+ * all on-wire packet structs.
+ */
 static void batadv_recv_handler_init(void)
 {
 	int i;
net/batman-adv/mesh-interface.c +63 -0

111 lines not on this page · raw message

net/batman-adv/netlink.c +7 -1
index d2bc48c707143..f4aa7d2055107 100644
@@ -52,9 +52,15 @@
 
 struct genl_family batadv_netlink_family;
 
-/* multicast groups */
+/**
+ * enum batadv_netlink_multicast_groups - batman-adv generic netlink multicast
+ *  groups
+ */
 enum batadv_netlink_multicast_groups {
+	/** @BATADV_NL_MCGRP_CONFIG: configuration change notifications */
 	BATADV_NL_MCGRP_CONFIG,
+
+	/** @BATADV_NL_MCGRP_TPMETER: throughput meter result notifications */
 	BATADV_NL_MCGRP_TPMETER,
 };
 
net/batman-adv/originator.c +7 -0
index 48f837cf665a2..bab1eb61d9ef2 100644
@@ -1295,6 +1295,13 @@ void batadv_purge_orig_ref(struct batadv_priv *bat_priv)
 	batadv_gw_election(bat_priv);
 }
 
+/**
+ * batadv_purge_orig() - periodic worker to purge stale originator entries
+ * @work: delayed work embedded in the bat_priv
+ *
+ * Invoke batadv_purge_orig_ref() to drop stale originators and reschedule the
+ * next run after BATADV_ORIG_WORK_PERIOD milliseconds.
+ */
 static void batadv_purge_orig(struct work_struct *work)
 {
 	struct delayed_work *delayed_work;
net/batman-adv/routing.c +31 -0
index bbd40fe3a8e59..b0b6c5ca210a2 100644
@@ -328,6 +328,16 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv,
 	return ret;
 }
 
+/**
+ * batadv_recv_icmp_ttl_exceeded() - handle an ICMP packet that hit TTL 0
+ * @bat_priv: the bat priv with all the mesh interface information
+ * @skb: ICMP packet whose TTL has expired
+ *
+ * For traceroute-style ICMP echo requests, send a TTL exceeded reply back to
+ * the source. Other ICMP types are simply dropped.
+ *
+ * Return: NET_XMIT_SUCCESS if the reply was queued, NET_RX_DROP otherwise
+ */
 static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
 					 struct sk_buff *skb)
 {
@@ -706,6 +716,18 @@ batadv_find_router(struct batadv_priv *bat_priv,
 	return router;
 }
 
+/**
+ * batadv_route_unicast_packet() - forward a unicast packet towards its
+ *  destination originator
+ * @skb: the received unicast packet
+ * @recv_if: interface on which the packet was received
+ *
+ * Decrement the TTL, look up the originator for the destination address and
+ * hand the packet over to batadv_send_skb_to_orig() for transmission. Drop
+ * the packet when the TTL is exhausted or no route exists.
+ *
+ * Return: NET_RX_SUCCESS if the packet was forwarded, NET_RX_DROP otherwise
+ */
 static int batadv_route_unicast_packet(struct sk_buff *skb,
 				       struct batadv_hard_iface *recv_if)
 {
@@ -836,6 +858,15 @@ batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, struct sk_buff *skb,
 	return ret;
 }
 
+/**
+ * batadv_check_unicast_ttvn() - check and adjust the TTVN of a unicast packet
+ * @bat_priv: the bat priv with all the mesh interface information
+ * @skb: the unicast packet to check
+ * @hdr_len: length of the unicast header preceding the payload
+ *
+ * Return: true if the packet may be processed further, false if it has been
+ *  consumed or has to be dropped by the caller
+ */
 static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
 				      struct sk_buff *skb, int hdr_len)
 {
net/batman-adv/translation-table.c +172 -5

309 lines not on this page · raw message

net/batman-adv/types.h +2 -2
index 992de87632954..9bdc5a3e799e2 100644
@@ -1827,10 +1827,10 @@ struct batadv_bla_claim {
 	/** @hash_entry: hlist node for &batadv_priv_bla.claim_hash */
 	struct hlist_node hash_entry;
 
-	/** @refcount: number of contexts the object is used */
+	/** @rcu: struct used for freeing in an RCU-safe manner */
 	struct rcu_head rcu;
 
-	/** @rcu: struct used for freeing in an RCU-safe manner */
+	/** @refcount: number of contexts the object is used */
 	struct kref refcount;
 };
 #endif
Signature · 1 line
2.47.3
author maintainer
#10 lore raw

PATCH 10/15 batman-adv: fix kernel-doc for functions holding skb ownership

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

Most functions in batman-adv will take the ownership of an skb when they receive it as argument. Their NET_RX_DROP return value is only indicating whether there was direct visible problem while processing it. The caller must not try to also free the skb when such a negative return code was received.

---
 net/batman-adv/routing.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
net/batman-adv/routing.c +5 -8
index b0b6c5ca210a2..c1114ee575478 100644
@@ -263,8 +263,7 @@ static bool batadv_skb_decrement_ttl(struct sk_buff *skb)
  * @bat_priv: the bat priv with all the mesh interface information
  * @skb: icmp packet to process
  *
- * Return: NET_RX_SUCCESS if the packet has been consumed or NET_RX_DROP
- * otherwise.
+ * Return: NET_RX_SUCCESS on success or NET_RX_DROP in case of failure
  */
 static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv,
 				      struct sk_buff *skb)
@@ -986,8 +985,7 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
  * @skb: unicast tvlv packet to process
  * @recv_if: pointer to interface this packet was received on
  *
- * Return: NET_RX_SUCCESS if the packet has been consumed or NET_RX_DROP
- * otherwise.
+ * Return: NET_RX_SUCCESS on success or NET_RX_DROP in case of failure
  */
 int batadv_recv_unhandled_unicast_packet(struct sk_buff *skb,
 					 struct batadv_hard_iface *recv_if)
@@ -1120,8 +1118,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
  * @skb: unicast tvlv packet to process
  * @recv_if: pointer to interface this packet was received on
  *
- * Return: NET_RX_SUCCESS if the packet has been consumed or NET_RX_DROP
- * otherwise.
+ * Return: NET_RX_SUCCESS on success or NET_RX_DROP in case of failure
  */
 int batadv_recv_unicast_tvlv(struct sk_buff *skb,
 			     struct batadv_hard_iface *recv_if)
@@ -1177,7 +1174,7 @@ int batadv_recv_unicast_tvlv(struct sk_buff *skb,
  * the assembled packet will exceed our MTU; 2) Buffer fragment, if we still
  * lack further fragments; 3) Merge fragments, if we have all needed parts.
  *
- * Return: NET_RX_DROP if the skb is not consumed, NET_RX_SUCCESS otherwise.
+ * Return: NET_RX_SUCCESS on success or NET_RX_DROP in case of failure
  */
 int batadv_recv_frag_packet(struct sk_buff *skb,
 			    struct batadv_hard_iface *recv_if)
@@ -1365,7 +1362,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
  * contents of its TVLV forwards it and/or decapsulates it to hand it to the
  * mesh interface.
  *
- * Return: NET_RX_DROP if the skb is not consumed, NET_RX_SUCCESS otherwise.
+ * Return: NET_RX_SUCCESS on success or NET_RX_DROP in case of failure
  */
 int batadv_recv_mcast_packet(struct sk_buff *skb,
 			     struct batadv_hard_iface *recv_if)
Signature · 1 line
2.47.3
author maintainer
#11 lore raw

PATCH 11/15 batman-adv: annotate functions which may reallocate the skbuff

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

When a function is called which reallocated the skbuff, it is necessary to reacquire the pointers into the skb data. Otherwise they might cause an use-after-free.

But is hard to identify such case when it is not clear that helpers are actually using skb-reallocating functions.

---
 net/batman-adv/bridge_loop_avoidance.c | 10 +++++++
 net/batman-adv/distributed-arp-table.c | 40 ++++++++++++++++++++++++++
 net/batman-adv/gateway_client.c        |  6 +++-
 net/batman-adv/main.c                  |  5 ++++
 net/batman-adv/mesh-interface.c        |  5 ++++
 net/batman-adv/multicast_forw.c        | 10 +++++++
 net/batman-adv/routing.c               | 10 +++++++
 7 files changed, 85 insertions(+), 1 deletion(-)
net/batman-adv/bridge_loop_avoidance.c +10 -0
index 8ee3ec5eb2c5e..18eafbeeccfdd 100644
@@ -1087,6 +1087,11 @@ static int batadv_check_claim_group(struct batadv_priv *bat_priv,
  * @primary_if: the primary hard interface of this batman mesh interface
  * @skb: the frame to be checked
  *
+ * Warning: This function may reallocate the skb data buffer via
+ * batadv_get_vid(). 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 it was a claim frame, otherwise return false to
  * tell the callee that it can use the frame on its own.
  */
@@ -1816,6 +1821,11 @@ bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig,
  * @orig_node: the orig_node of the frame
  * @hdr_size: maximum length of the frame
  *
+ * Warning: This function may reallocate the skb data buffer via
+ * pskb_may_pull() and batadv_get_vid(). 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 the orig_node is also a gateway on the mesh interface,
  * otherwise it returns false.
  */
net/batman-adv/distributed-arp-table.c +40 -0
index 0251cdf5542bb..e9cc4690068eb 100644
@@ -1039,6 +1039,11 @@ int batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb)
  * @skb: packet to analyse
  * @hdr_size: size of the possible header before the ARP packet in the skb
  *
+ * Warning: This function may reallocate the skb data buffer via
+ * pskb_may_pull(). 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: the ARP type if the skb contains a valid ARP packet, 0 otherwise.
  */
 static u16 batadv_arp_get_type(struct batadv_priv *bat_priv,
@@ -1115,6 +1120,11 @@ static u16 batadv_arp_get_type(struct batadv_priv *bat_priv,
  * The caller must ensure that at least @hdr_size + ETH_HLEN bytes are
  * accessible after skb->data.
  *
+ * Warning: This function calls batadv_get_vid() and may therefore reallocate
+ * the skb data buffer. 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: If the packet embedded in the skb is vlan tagged this function
  * returns the VID with the BATADV_VLAN_HAS_TAG flag. Otherwise BATADV_NO_FLAGS
  * is returned.
@@ -1177,6 +1187,11 @@ batadv_dat_arp_create_reply(struct batadv_priv *bat_priv, __be32 ip_src,
  * @bat_priv: the bat priv with all the mesh interface information
  * @skb: packet to check
  *
+ * Warning: This function may reallocate the skb data buffer via
+ * batadv_dat_get_vid(). 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 the message has been sent to the dht candidates, false
  * otherwise. In case of a positive return value the message has to be enqueued
  * to permit the fallback.
@@ -1282,6 +1297,11 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
  * @skb: packet to check
  * @hdr_size: size of the encapsulation header
  *
+ * Warning: This function may reallocate the skb data buffer via
+ * batadv_dat_get_vid(). 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 the request has been answered, false otherwise.
  */
 bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
@@ -1349,6 +1369,11 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
  * batadv_dat_snoop_outgoing_arp_reply() - snoop the ARP reply and fill the DHT
  * @bat_priv: the bat priv with all the mesh interface information
  * @skb: packet to check
+ *
+ * Warning: This function may reallocate the skb data buffer via
+ * batadv_dat_get_vid(). 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.
  */
 void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
 					 struct sk_buff *skb)
@@ -1398,6 +1423,11 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
  * @skb: packet to check
  * @hdr_size: size of the encapsulation header
  *
+ * Warning: This function may reallocate the skb data buffer via
+ * batadv_dat_get_vid(). 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 the packet was snooped and consumed by DAT. False if the
  * packet has to be delivered to the interface
  */
@@ -1812,6 +1842,11 @@ void batadv_dat_snoop_outgoing_dhcp_ack(struct batadv_priv *bat_priv,
  * This function first checks whether the given skb is a valid DHCPACK. If
  * so then its source MAC and IP as well as its DHCP Client Hardware Address
  * field and DHCP Your IP Address field are added to the local DAT cache.
+ *
+ * Warning: This function may reallocate the skb data buffer via
+ * pskb_may_pull()/batadv_dat_get_vid(). 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.
  */
 void batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv,
 					struct sk_buff *skb, int hdr_size)
@@ -1859,6 +1894,11 @@ void batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv,
  * @bat_priv: the bat priv with all the mesh interface information
  * @forw_packet: the broadcast packet
  *
+ * Warning: This function may reallocate the skb data buffer via
+ * batadv_dat_get_vid(). 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 the node can drop the packet, false otherwise.
  */
 bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
net/batman-adv/gateway_client.c +5 -1
index 48fc711b8fd62..f4d53d9ea3b31 100644
@@ -677,7 +677,11 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
  * server. Due to topology changes it may be the case that the GW server
  * previously selected is not the best one anymore.
  *
- * This call might reallocate skb data.
+ * Warning: This function may reallocate the skb data buffer via
+ * batadv_get_vid(). 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.
+ *
  * Must be invoked only when the DHCP packet is going TO a DHCP SERVER.
  *
  * Return: true if the packet destination is unicast and it is not the best gw,
net/batman-adv/main.c +5 -0
index c5f4e9f8728c0..fa82ffb706b3f 100644
@@ -610,6 +610,11 @@ void batadv_recv_handler_unregister(u8 packet_type)
  * The caller must ensure that at least @header_len + ETH_HLEN bytes are
  * accessible after skb->data.
  *
+ * Warning: This function may reallocate the skb data buffer via
+ * pskb_may_pull(). 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: VID with the BATADV_VLAN_HAS_TAG flag when the packet embedded in the
  * skb is vlan tagged. Otherwise BATADV_NO_FLAGS.
  */
net/batman-adv/mesh-interface.c +5 -0
index 667ea5704fbdb..982de90906b59 100644
@@ -57,6 +57,11 @@
  * @skb: packet buffer which should be modified
  * @len: number of bytes to add
  *
+ * Warning: This function may reallocate the skb data buffer via
+ * skb_cow_head(). 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: 0 on success or negative error number in case of failure
  */
 int batadv_skb_head_push(struct sk_buff *skb, unsigned int len)
net/batman-adv/multicast_forw.c +10 -0
index c99579dc1ca98..75a3a4567b08b 100644
@@ -1080,6 +1080,11 @@ unsigned int batadv_mcast_forw_packet_hdrlen(unsigned int num_dests)
  * Tries to expand an skb's headroom so that its head to tail is 1298
  * bytes (minimum IPv6 MTU + vlan ethernet header size) large.
  *
+ * Warning: This function may reallocate the skb data buffer via
+ * skb_cow() / skb_linearize(). 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: -EINVAL if the given skb's length is too large or -ENOMEM on memory
  * allocation failure. Otherwise, on success, zero is returned.
  */
@@ -1123,6 +1128,11 @@ static int batadv_mcast_forw_expand_head(struct batadv_priv *bat_priv,
  * that signaled interest in it, that is either via the translation table or the
  * according want-all flags, is attached accordingly.
  *
+ * Warning: This function may reallocate the skb data buffer via
+ * batadv_mcast_forw_expand_head(). 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 on success, false otherwise.
  */
 bool batadv_mcast_forw_push(struct batadv_priv *bat_priv, struct sk_buff *skb,
net/batman-adv/routing.c +10 -0
index c1114ee575478..770037b8ca4e4 100644
@@ -172,6 +172,11 @@ bool batadv_window_protected(struct batadv_priv *bat_priv, s32 seq_num_diff,
  * @hard_iface: incoming hard interface
  * @header_len: minimal header length of packet type
  *
+ * Warning: This function may reallocate the skb data buffer via
+ * skb_cow() / skb_linearize(). 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 when management preconditions are met, false otherwise
  */
 bool batadv_check_management_packet(struct sk_buff *skb,
@@ -863,6 +868,11 @@ batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, struct sk_buff *skb,
  * @skb: the unicast packet to check
  * @hdr_len: length of the unicast header preceding the payload
  *
+ * Warning: This function may reallocate the skb data buffer via
+ * pskb_may_pull() and batadv_get_vid(). 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 the packet may be processed further, false if it has been
  *  consumed or has to be dropped by the caller
  */
Signature · 1 line
2.47.3
author maintainer
#12 lore raw

PATCH 12/15 batman-adv: split multiple declarations per line

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

The Linux coding style suggests to use single variable declarations per line. This suggestion turned out to make reviewing patches easier when single variable declarations are modified. Instead of having to search for the modified variable, it is directly visible as a line change in the diff.

Most functions are already using this style. The remaining ones are just adjusted by splitting the lines without ensuring the reverse x-mas tree order because this makes it easier to check the modification.

---
 net/batman-adv/bat_algo.c              |  3 +-
 net/batman-adv/bat_iv_ogm.c            | 38 ++++++++----
 net/batman-adv/bat_v.c                 | 19 ++++--
 net/batman-adv/bat_v_elp.c             |  3 +-
 net/batman-adv/bat_v_ogm.c             | 13 +++--
 net/batman-adv/bridge_loop_avoidance.c | 30 ++++++----
 net/batman-adv/distributed-arp-table.c | 55 ++++++++++++------
 net/batman-adv/fragmentation.c         | 12 ++--
 net/batman-adv/gateway_client.c        |  9 ++-
 net/batman-adv/gateway_common.c        |  6 +-
 net/batman-adv/main.c                  | 12 ++--
 net/batman-adv/mesh-interface.c        | 15 +++--
 net/batman-adv/multicast.c             | 15 +++--
 net/batman-adv/multicast_forw.c        |  9 ++-
 net/batman-adv/originator.c            | 31 ++++++----
 net/batman-adv/routing.c               | 37 ++++++++----
 net/batman-adv/send.c                  |  3 +-
 net/batman-adv/tp_meter.c              | 24 +++++---
 net/batman-adv/translation-table.c     | 80 ++++++++++++++++++--------
 net/batman-adv/tvlv.c                  | 12 ++--
 20 files changed, 288 insertions(+), 138 deletions(-)
net/batman-adv/bat_algo.c +2 -1
index a040141cdf1a4..bd094bc793e30 100644
@@ -42,7 +42,8 @@ void batadv_algo_init(void)
  */
 struct batadv_algo_ops *batadv_algo_get(const char *name)
 {
-	struct batadv_algo_ops *bat_algo_ops = NULL, *bat_algo_ops_tmp;
+	struct batadv_algo_ops *bat_algo_ops = NULL;
+	struct batadv_algo_ops *bat_algo_ops_tmp;
 
 	hlist_for_each_entry(bat_algo_ops_tmp, &batadv_algo_list, list) {
 		if (strcmp(bat_algo_ops_tmp->name, name) != 0)
net/batman-adv/bat_iv_ogm.c +26 -12
index a9e80330fcb63..337e8e3554bb7 100644
@@ -896,7 +896,8 @@ static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface)
 	struct batadv_priv *bat_priv = netdev_priv(hard_iface->mesh_iface);
 	struct batadv_ogm_buf *ogm_buff = &hard_iface->bat_iv.ogm_buff;
 	struct batadv_ogm_packet *batadv_ogm_packet;
-	struct batadv_hard_iface *primary_if, *tmp_hard_iface;
+	struct batadv_hard_iface *primary_if;
+	struct batadv_hard_iface *tmp_hard_iface;
 	struct list_head *iter;
 	u32 seqno;
 	u16 tvlv_len = 0;
@@ -1109,7 +1110,8 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
 	struct batadv_neigh_node *neigh_node = NULL;
 	struct batadv_neigh_node *tmp_neigh_node = NULL;
 	struct batadv_neigh_node *router = NULL;
-	u8 sum_orig, sum_neigh;
+	u8 sum_orig;
+	u8 sum_neigh;
 	u8 *neigh_addr;
 	u8 tq_avg;
 
@@ -1241,13 +1243,19 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
 				  struct batadv_hard_iface *if_outgoing)
 {
 	struct batadv_priv *bat_priv = netdev_priv(if_incoming->mesh_iface);
-	struct batadv_neigh_node *neigh_node = NULL, *tmp_neigh_node;
+	struct batadv_neigh_node *neigh_node = NULL;
+	struct batadv_neigh_node *tmp_neigh_node;
 	struct batadv_neigh_ifinfo *neigh_ifinfo;
 	u8 total_count;
-	u8 orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own;
+	u8 orig_eq_count;
+	u8 neigh_rq_count;
+	u8 neigh_rq_inv;
+	u8 tq_own;
 	unsigned int tq_iface_hop_penalty = BATADV_TQ_MAX_VALUE;
-	unsigned int neigh_rq_inv_cube, neigh_rq_max_cube;
-	unsigned int tq_asym_penalty, inv_asym_penalty;
+	unsigned int neigh_rq_inv_cube;
+	unsigned int neigh_rq_max_cube;
+	unsigned int tq_asym_penalty;
+	unsigned int inv_asym_penalty;
 	unsigned int combined_tq;
 	bool ret = false;
 
@@ -1521,7 +1529,8 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff *skb, int ogm_offset,
 	enum batadv_dup_status dup_status;
 	bool is_from_best_next_hop = false;
 	bool is_single_hop_neigh = false;
-	bool sameseq, similar_ttl;
+	bool sameseq;
+	bool similar_ttl;
 	struct sk_buff *skb_priv;
 	struct ethhdr *ethhdr;
 	u8 *prev_sender;
@@ -1747,7 +1756,8 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset,
 				  struct batadv_hard_iface *if_incoming)
 {
 	struct batadv_priv *bat_priv = netdev_priv(if_incoming->mesh_iface);
-	struct batadv_orig_node *orig_neigh_node, *orig_node;
+	struct batadv_orig_node *orig_neigh_node;
+	struct batadv_orig_node *orig_node;
 	struct batadv_hard_iface *hard_iface;
 	struct batadv_ogm_packet *ogm_packet;
 	u32 if_incoming_seqno;
@@ -2230,8 +2240,10 @@ static bool batadv_iv_ogm_neigh_diff(struct batadv_neigh_node *neigh1,
 				     struct batadv_hard_iface *if_outgoing2,
 				     int *diff)
 {
-	struct batadv_neigh_ifinfo *neigh1_ifinfo, *neigh2_ifinfo;
-	u8 tq1, tq2;
+	struct batadv_neigh_ifinfo *neigh1_ifinfo;
+	struct batadv_neigh_ifinfo *neigh2_ifinfo;
+	u8 tq1;
+	u8 tq2;
 	bool ret = true;
 
 	neigh1_ifinfo = batadv_neigh_ifinfo_get(neigh1, if_outgoing1);
@@ -2474,7 +2486,8 @@ batadv_iv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
 {
 	struct batadv_neigh_node *router;
 	struct batadv_neigh_ifinfo *router_ifinfo;
-	struct batadv_gw_node *gw_node, *curr_gw = NULL;
+	struct batadv_gw_node *gw_node;
+	struct batadv_gw_node *curr_gw = NULL;
 	u64 max_gw_factor = 0;
 	u64 tmp_gw_factor = 0;
 	u8 max_tq = 0;
@@ -2568,7 +2581,8 @@ static bool batadv_iv_gw_is_eligible(struct batadv_priv *bat_priv,
 	u32 sel_class = READ_ONCE(bat_priv->gw.sel_class);
 	struct batadv_neigh_node *router_gw = NULL;
 	struct batadv_neigh_node *router_orig = NULL;
-	u8 gw_tq_avg, orig_tq_avg;
+	u8 gw_tq_avg;
+	u8 orig_tq_avg;
 	bool ret = false;
 
 	/* dynamic re-election is performed only on fast or late switch */
net/batman-adv/bat_v.c +13 -6
index 0068f0e238da6..be28875c201d7 100644
@@ -490,7 +490,8 @@ static int batadv_v_neigh_cmp(struct batadv_neigh_node *neigh1,
 			      struct batadv_neigh_node *neigh2,
 			      struct batadv_hard_iface *if_outgoing2)
 {
-	struct batadv_neigh_ifinfo *ifinfo1, *ifinfo2;
+	struct batadv_neigh_ifinfo *ifinfo1;
+	struct batadv_neigh_ifinfo *ifinfo2;
 	int ret = 0;
 
 	ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1);
@@ -526,7 +527,8 @@ static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1,
 				  struct batadv_neigh_node *neigh2,
 				  struct batadv_hard_iface *if_outgoing2)
 {
-	struct batadv_neigh_ifinfo *ifinfo1, *ifinfo2;
+	struct batadv_neigh_ifinfo *ifinfo1;
+	struct batadv_neigh_ifinfo *ifinfo2;
 	u32 threshold;
 	bool ret = false;
 
@@ -610,8 +612,10 @@ static int batadv_v_gw_throughput_get(struct batadv_gw_node *gw_node, u32 *bw)
 static struct batadv_gw_node *
 batadv_v_gw_get_best_gw_node(struct batadv_priv *bat_priv)
 {
-	struct batadv_gw_node *gw_node, *curr_gw = NULL;
-	u32 max_bw = 0, bw;
+	struct batadv_gw_node *gw_node;
+	struct batadv_gw_node *curr_gw = NULL;
+	u32 max_bw = 0;
+	u32 bw;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.gateway_list, list) {
@@ -650,8 +654,11 @@ static bool batadv_v_gw_is_eligible(struct batadv_priv *bat_priv,
 				    struct batadv_orig_node *curr_gw_orig,
 				    struct batadv_orig_node *orig_node)
 {
-	struct batadv_gw_node *curr_gw, *orig_gw = NULL;
-	u32 gw_throughput, orig_throughput, threshold;
+	struct batadv_gw_node *curr_gw;
+	struct batadv_gw_node *orig_gw = NULL;
+	u32 gw_throughput;
+	u32 orig_throughput;
+	u32 threshold;
 	bool ret = false;
 
 	threshold = READ_ONCE(bat_priv->gw.sel_class);
net/batman-adv/bat_v_elp.c +2 -1
index 262e40040007c..eb7fb8c14ef30 100644
@@ -233,7 +233,8 @@ batadv_v_elp_wifi_neigh_probe(struct batadv_hardif_neigh_node *neigh)
 	struct batadv_priv *bat_priv = netdev_priv(hard_iface->mesh_iface);
 	unsigned long last_tx_diff;
 	struct sk_buff *skb;
-	int probe_len, i;
+	int probe_len;
+	int i;
 	int elp_skb_len;
 
 	/* this probing routine is for Wifi neighbours only */
net/batman-adv/bat_v_ogm.c +9 -4
index e921d49f7eced..d4527663f76d9 100644
@@ -271,7 +271,8 @@ static void batadv_v_ogm_send_meshif(struct batadv_priv *bat_priv)
 	struct batadv_hard_iface *hard_iface;
 	struct batadv_ogm2_packet *ogm_packet;
 	struct batadv_ogm_buf *ogm_buff;
-	struct sk_buff *skb, *skb_tmp;
+	struct sk_buff *skb;
+	struct sk_buff *skb_tmp;
 	struct list_head *iter;
 	u16 tvlv_len;
 	int ret;
@@ -706,8 +707,10 @@ static bool batadv_v_ogm_route_update(struct batadv_priv *bat_priv,
 	struct batadv_neigh_node *router = NULL;
 	struct batadv_orig_node *orig_neigh_node;
 	struct batadv_neigh_node *orig_neigh_router = NULL;
-	struct batadv_neigh_ifinfo *router_ifinfo = NULL, *neigh_ifinfo = NULL;
-	u32 router_throughput, neigh_throughput;
+	struct batadv_neigh_ifinfo *router_ifinfo = NULL;
+	struct batadv_neigh_ifinfo *neigh_ifinfo = NULL;
+	u32 router_throughput;
+	u32 neigh_throughput;
 	u32 router_last_seqno;
 	u32 neigh_last_seqno;
 	s32 neigh_seq_diff;
@@ -877,7 +880,9 @@ static void batadv_v_ogm_process(const struct sk_buff *skb, int ogm_offset,
 	struct batadv_neigh_node *neigh_node = NULL;
 	struct batadv_hard_iface *hard_iface;
 	struct batadv_ogm2_packet *ogm_packet;
-	u32 ogm_throughput, link_throughput, path_throughput;
+	u32 ogm_throughput;
+	u32 link_throughput;
+	u32 path_throughput;
 	struct list_head *iter;
 	int ret;
 
net/batman-adv/bridge_loop_avoidance.c +20 -10
index 18eafbeeccfdd..363d1819f521c 100644
@@ -261,7 +261,8 @@ batadv_backbone_hash_find(struct batadv_priv *bat_priv, const u8 *addr,
 {
 	struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
 	struct hlist_head *head;
-	struct batadv_bla_backbone_gw search_entry, *backbone_gw;
+	struct batadv_bla_backbone_gw search_entry;
+	struct batadv_bla_backbone_gw *backbone_gw;
 	struct batadv_bla_backbone_gw *backbone_gw_tmp = NULL;
 	int index;
 
@@ -809,7 +810,8 @@ batadv_bla_claim_get_backbone_gw(struct batadv_bla_claim *claim)
 static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
 				 const u8 *mac, const unsigned short vid)
 {
-	struct batadv_bla_claim search_claim, *claim;
+	struct batadv_bla_claim search_claim;
+	struct batadv_bla_claim *claim;
 	struct batadv_bla_claim *claim_removed_entry;
 	struct hlist_node *claim_removed_node;
 
@@ -851,7 +853,8 @@ static bool batadv_handle_announce(struct batadv_priv *bat_priv, u8 *an_addr,
 				   u8 *backbone_addr, unsigned short vid)
 {
 	struct batadv_bla_backbone_gw *backbone_gw;
-	u16 backbone_crc, crc;
+	u16 backbone_crc;
+	u16 crc;
 
 	if (memcmp(an_addr, batadv_announce_mac, 4) != 0)
 		return false;
@@ -1030,7 +1033,8 @@ static int batadv_check_claim_group(struct batadv_priv *bat_priv,
 {
 	u8 *backbone_addr;
 	struct batadv_orig_node *orig_node;
-	struct batadv_bla_claim_dst *bla_dst, *bla_dst_own;
+	struct batadv_bla_claim_dst *bla_dst;
+	struct batadv_bla_claim_dst *bla_dst_own;
 
 	bla_dst = (struct batadv_bla_claim_dst *)hw_dst;
 	bla_dst_own = &bat_priv->bla.claim_dest;
@@ -1099,9 +1103,12 @@ static bool batadv_bla_process_claim(struct batadv_priv *bat_priv,
 				     struct batadv_hard_iface *primary_if,
 				     struct sk_buff *skb)
 {
-	struct batadv_bla_claim_dst *bla_dst, *bla_dst_own;
-	u8 *hw_src, *hw_dst;
-	struct vlan_hdr *vhdr, vhdr_buf;
+	struct batadv_bla_claim_dst *bla_dst;
+	struct batadv_bla_claim_dst *bla_dst_own;
+	u8 *hw_src;
+	u8 *hw_dst;
+	struct vlan_hdr *vhdr;
+	struct vlan_hdr vhdr_buf;
 	struct ethhdr *ethhdr;
 	struct arphdr *arphdr;
 	unsigned short vid;
@@ -1665,7 +1672,8 @@ static bool batadv_bla_check_duplist(struct batadv_priv *bat_priv,
 	struct batadv_bcast_duplist_entry *entry;
 	bool ret = false;
 	int payload_len;
-	int i, curr;
+	int i;
+	int curr;
 	u32 crc;
 
 	/* calculate the crc ... */
@@ -1956,7 +1964,8 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
 {
 	struct batadv_bla_backbone_gw *backbone_gw;
 	struct ethhdr *ethhdr;
-	struct batadv_bla_claim search_claim, *claim = NULL;
+	struct batadv_bla_claim search_claim;
+	struct batadv_bla_claim *claim = NULL;
 	struct batadv_hard_iface *primary_if;
 	bool own_claim;
 	bool ret;
@@ -2089,7 +2098,8 @@ bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
 		   unsigned short vid)
 {
 	struct ethhdr *ethhdr;
-	struct batadv_bla_claim search_claim, *claim = NULL;
+	struct batadv_bla_claim search_claim;
+	struct batadv_bla_claim *claim = NULL;
 	struct batadv_bla_backbone_gw *backbone_gw;
 	struct batadv_hard_iface *primary_if;
 	bool client_roamed;
net/batman-adv/distributed-arp-table.c +37 -18

139 lines not on this page · raw message

net/batman-adv/fragmentation.c +8 -4
index 2e20a2cb64cbf..f382af8588b56 100644
@@ -140,11 +140,13 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node,
 				      struct hlist_head *chain_out)
 {
 	struct batadv_frag_table_entry *chain;
-	struct batadv_frag_list_entry *frag_entry_new = NULL, *frag_entry_curr;
+	struct batadv_frag_list_entry *frag_entry_new = NULL;
+	struct batadv_frag_list_entry *frag_entry_curr;
 	struct batadv_frag_list_entry *frag_entry_last = NULL;
 	struct batadv_frag_packet *frag_packet;
 	u8 bucket;
-	u16 seqno, hdr_size = sizeof(struct batadv_frag_packet);
+	u16 seqno;
+	u16 hdr_size = sizeof(struct batadv_frag_packet);
 	bool overflow = false;
 	bool ret = false;
 	size_t data_len;
@@ -261,7 +263,8 @@ batadv_frag_merge_packets(struct hlist_head *chain)
 	struct batadv_frag_packet *packet;
 	struct batadv_frag_list_entry *entry;
 	struct sk_buff *skb_out;
-	int size, hdr_size = sizeof(struct batadv_frag_packet);
+	int size;
+	int hdr_size = sizeof(struct batadv_frag_packet);
 	bool dropped = false;
 
 	/* Remove first entry, as this is the destination for the rest of the
@@ -509,7 +512,8 @@ int batadv_frag_send_packet(struct sk_buff *skb,
 	struct sk_buff *skb_fragment;
 	unsigned int mtu = net_dev->mtu;
 	unsigned int header_size = sizeof(frag_header);
-	unsigned int max_fragment_size, num_fragments;
+	unsigned int max_fragment_size;
+	unsigned int num_fragments;
 	int ret;
 
 	/* To avoid merge and refragmentation at next-hops we never send
net/batman-adv/gateway_client.c +6 -3
index f4d53d9ea3b31..b1a5b9ca31888 100644
@@ -378,7 +378,8 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv,
 struct batadv_gw_node *batadv_gw_node_get(struct batadv_priv *bat_priv,
 					  struct batadv_orig_node *orig_node)
 {
-	struct batadv_gw_node *gw_node_tmp, *gw_node = NULL;
+	struct batadv_gw_node *gw_node_tmp;
+	struct batadv_gw_node *gw_node = NULL;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(gw_node_tmp, &bat_priv->gw.gateway_list,
@@ -408,7 +409,8 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv,
 			   struct batadv_orig_node *orig_node,
 			   struct batadv_tvlv_gateway_data *gateway)
 {
-	struct batadv_gw_node *gw_node, *curr_gw = NULL;
+	struct batadv_gw_node *gw_node;
+	struct batadv_gw_node *curr_gw = NULL;
 
 	spin_lock_bh(&bat_priv->gw.list_lock);
 	gw_node = batadv_gw_node_get(bat_priv, orig_node);
@@ -695,7 +697,8 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
 	struct batadv_orig_node *orig_dst_node = NULL;
 	struct batadv_gw_node *gw_node = NULL;
 	struct batadv_gw_node *curr_gw = NULL;
-	struct batadv_neigh_ifinfo *curr_ifinfo, *old_ifinfo;
+	struct batadv_neigh_ifinfo *curr_ifinfo;
+	struct batadv_neigh_ifinfo *old_ifinfo;
 	struct ethhdr *ethhdr;
 	bool out_of_range = false;
 	u8 curr_tq_avg;
net/batman-adv/gateway_common.c +4 -2
index 675ebf098d4ec..b5ebe837bfdd1 100644
@@ -26,7 +26,8 @@ void batadv_gw_tvlv_container_update(struct batadv_priv *bat_priv)
 {
 	struct batadv_tvlv_gateway_data gw;
 	enum batadv_gw_modes gw_mode;
-	u32 down, up;
+	u32 down;
+	u32 up;
 
 	gw_mode = READ_ONCE(bat_priv->gw.mode);
 
@@ -59,7 +60,8 @@ static void batadv_gw_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
 					  u8 flags,
 					  void *tvlv_value, u16 tvlv_value_len)
 {
-	struct batadv_tvlv_gateway_data gateway, *gateway_ptr;
+	struct batadv_tvlv_gateway_data gateway;
+	struct batadv_tvlv_gateway_data *gateway_ptr;
 
 	/* only fetch the tvlv value if the handler wasn't called via the
 	 * CIFNOTFND flag and if there is data to fetch
net/batman-adv/main.c +8 -4
index fa82ffb706b3f..d8e9d20add898 100644
@@ -368,10 +368,14 @@ int batadv_max_header_len(void)
  */
 void batadv_skb_set_priority(struct sk_buff *skb, int offset)
 {
-	struct iphdr ip_hdr_tmp, *ip_hdr;
-	struct ipv6hdr ip6_hdr_tmp, *ip6_hdr;
-	struct ethhdr ethhdr_tmp, *ethhdr;
-	struct vlan_ethhdr *vhdr, vhdr_tmp;
+	struct iphdr ip_hdr_tmp;
+	struct iphdr *ip_hdr;
+	struct ipv6hdr ip6_hdr_tmp;
+	struct ipv6hdr *ip6_hdr;
+	struct ethhdr ethhdr_tmp;
+	struct ethhdr *ethhdr;
+	struct vlan_ethhdr *vhdr;
+	struct vlan_ethhdr vhdr_tmp;
 	u32 prio;
 
 	/* already set, do nothing */
net/batman-adv/mesh-interface.c +10 -5
index 982de90906b59..534e96eb96953 100644
@@ -92,7 +92,8 @@ int batadv_skb_head_push(struct sk_buff *skb, unsigned int len)
  */
 static u64 batadv_sum_counter(struct batadv_priv *bat_priv,  size_t idx)
 {
-	u64 *counters, sum = 0;
+	u64 *counters;
+	u64 sum = 0;
 	int cpu;
 
 	for_each_possible_cpu(cpu) {
@@ -221,12 +222,15 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
 	static const u8 ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00,
 					       0x00, 0x00};
 	enum batadv_dhcp_recipient dhcp_rcp = BATADV_DHCP_NO;
-	u8 *dst_hint = NULL, chaddr[ETH_ALEN];
+	u8 *dst_hint = NULL;
+	u8 chaddr[ETH_ALEN];
 	struct vlan_ethhdr *vhdr;
 	unsigned int header_len = 0;
-	int data_len = skb->len, ret;
+	int data_len = skb->len;
+	int ret;
 	unsigned long brd_delay = 0;
-	bool do_bcast = false, client_added;
+	bool do_bcast = false;
+	bool client_added;
 	unsigned short vid;
 	u32 seqno;
 	int gw_mode;
@@ -569,7 +573,8 @@ 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 *vlan_tmp, *vlan = NULL;
+	struct batadv_meshif_vlan *vlan_tmp;
+	struct batadv_meshif_vlan *vlan = NULL;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(vlan_tmp, &bat_priv->meshif_vlan_list, list) {
net/batman-adv/multicast.c +11 -4
index 1c5315e55c046..5b9e2168a0467 100644
@@ -274,7 +274,8 @@ static struct batadv_mcast_mla_flags
 batadv_mcast_mla_flags_get(struct batadv_priv *bat_priv)
 {
 	struct net_device *dev = bat_priv->mesh_iface;
-	struct batadv_mcast_querier_state *qr4, *qr6;
+	struct batadv_mcast_querier_state *qr4;
+	struct batadv_mcast_querier_state *qr6;
 	struct batadv_mcast_mla_flags mla_flags;
 	struct net_device *bridge;
 
@@ -521,7 +522,8 @@ batadv_mcast_mla_meshif_get(struct net_device *dev,
 			    struct batadv_mcast_mla_flags *flags)
 {
 	struct net_device *bridge = batadv_mcast_get_bridge(dev);
-	int ret4, ret6 = 0;
+	int ret4;
+	int ret6 = 0;
 
 	if (bridge)
 		dev = bridge;
@@ -585,7 +587,8 @@ static int batadv_mcast_mla_bridge_get(struct net_device *dev,
 				       struct batadv_mcast_mla_flags *flags)
 {
 	struct list_head bridge_mcast_list = LIST_HEAD_INIT(bridge_mcast_list);
-	struct br_ip_list *br_ip_entry, *tmp;
+	struct br_ip_list *br_ip_entry;
+	struct br_ip_list *tmp;
 	u8 tvlv_flags = flags->tvlv_flags;
 	struct batadv_hw_addr *new;
 	u8 mcast_addr[ETH_ALEN];
@@ -1223,7 +1226,11 @@ enum batadv_forw_mode
 batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
 		       unsigned short vid, int *is_routable)
 {
-	int ret, tt_count, ip_count, unsnoop_count, total_count;
+	int ret;
+	int tt_count;
+	int ip_count;
+	int unsnoop_count;
+	int total_count;
 	bool is_unsnoopable = false;
 	struct ethhdr *ethhdr;
 	int rtr_count = 0;
net/batman-adv/multicast_forw.c +6 -3
index 75a3a4567b08b..6dcac586b1d95 100644
@@ -368,7 +368,8 @@ static void batadv_mcast_forw_scrape(struct sk_buff *skb,
 				     unsigned short offset,
 				     unsigned short len)
 {
-	char *to, *from;
+	char *to;
+	char *from;
 
 	SKB_LINEAR_ASSERT(skb);
 
@@ -411,7 +412,8 @@ static bool batadv_mcast_forw_push_insert_padding(struct sk_buff *skb,
 						  unsigned short *tvlv_len)
 {
 	unsigned short offset =	*tvlv_len;
-	char *to, *from = skb->data;
+	char *to;
+	char *from = skb->data;
 
 	to = batadv_mcast_forw_push_padding(skb, tvlv_len);
 	if (!to)
@@ -933,7 +935,8 @@ static int batadv_mcast_forw_packet(struct batadv_priv *bat_priv,
 	unsigned int tvlv_len;
 	unsigned long offset;
 	bool xmitted = false;
-	u8 *dest, *next_dest;
+	u8 *dest;
+	u8 *next_dest;
 	u16 num_dests;
 	int ret;
 
net/batman-adv/originator.c +20 -11
index bab1eb61d9ef2..57bb4a0131b0e 100644
@@ -54,7 +54,8 @@ batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data)
 {
 	struct batadv_hashtable *hash = bat_priv->orig_hash;
 	struct hlist_head *head;
-	struct batadv_orig_node *orig_node, *orig_node_tmp = NULL;
+	struct batadv_orig_node *orig_node;
+	struct batadv_orig_node *orig_node_tmp = NULL;
 	int index;
 
 	if (!hash)
@@ -108,7 +109,8 @@ struct batadv_orig_node_vlan *
 batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node,
 			  unsigned short vid)
 {
-	struct batadv_orig_node_vlan *vlan = NULL, *tmp;
+	struct batadv_orig_node_vlan *vlan = NULL;
+	struct batadv_orig_node_vlan *tmp;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(tmp, &orig_node->vlan_list, list) {
@@ -373,7 +375,8 @@ struct batadv_orig_ifinfo *
 batadv_orig_ifinfo_get(struct batadv_orig_node *orig_node,
 		       struct batadv_hard_iface *if_outgoing)
 {
-	struct batadv_orig_ifinfo *tmp, *orig_ifinfo = NULL;
+	struct batadv_orig_ifinfo *tmp;
+	struct batadv_orig_ifinfo *orig_ifinfo = NULL;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(tmp, &orig_node->ifinfo_list,
@@ -451,8 +454,8 @@ struct batadv_neigh_ifinfo *
 batadv_neigh_ifinfo_get(struct batadv_neigh_node *neigh,
 			struct batadv_hard_iface *if_outgoing)
 {
-	struct batadv_neigh_ifinfo *neigh_ifinfo = NULL,
-				   *tmp_neigh_ifinfo;
+	struct batadv_neigh_ifinfo *neigh_ifinfo = NULL;
+	struct batadv_neigh_ifinfo *tmp_neigh_ifinfo;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(tmp_neigh_ifinfo, &neigh->ifinfo_list,
@@ -530,7 +533,8 @@ batadv_neigh_node_get(const struct batadv_orig_node *orig_node,
 		      const struct batadv_hard_iface *hard_iface,
 		      const u8 *addr)
 {
-	struct batadv_neigh_node *tmp_neigh_node, *res = NULL;
+	struct batadv_neigh_node *tmp_neigh_node;
+	struct batadv_neigh_node *res = NULL;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(tmp_neigh_node, &orig_node->neigh_list, list) {
@@ -634,7 +638,8 @@ struct batadv_hardif_neigh_node *
 batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface,
 			const u8 *neigh_addr)
 {
-	struct batadv_hardif_neigh_node *tmp_hardif_neigh, *hardif_neigh = NULL;
+	struct batadv_hardif_neigh_node *tmp_hardif_neigh;
+	struct batadv_hardif_neigh_node *hardif_neigh = NULL;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(tmp_hardif_neigh,
@@ -753,7 +758,8 @@ batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node,
  */
 int batadv_hardif_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb)
 {
-	struct batadv_hard_iface *primary_if, *hard_iface;
+	struct batadv_hard_iface *primary_if;
+	struct batadv_hard_iface *hard_iface;
 	struct net_device *mesh_iface;
 	struct batadv_priv *bat_priv;
 	int ret;
@@ -1167,7 +1173,8 @@ batadv_find_best_neighbor(struct batadv_priv *bat_priv,
 			  struct batadv_orig_node *orig_node,
 			  struct batadv_hard_iface *if_outgoing)
 {
-	struct batadv_neigh_node *best = NULL, *neigh;
+	struct batadv_neigh_node *best = NULL;
+	struct batadv_neigh_node *neigh;
 	struct batadv_algo_ops *bao = bat_priv->algo_ops;
 
 	rcu_read_lock();
@@ -1203,7 +1210,8 @@ static bool batadv_purge_orig_node(struct batadv_priv *bat_priv,
 {
 	struct batadv_neigh_node *best_neigh_node;
 	struct batadv_hard_iface *hard_iface;
-	bool changed_ifinfo, changed_neigh;
+	bool changed_ifinfo;
+	bool changed_neigh;
 	struct list_head *iter;
 
 	if (batadv_has_timed_out(orig_node->last_seen,
@@ -1325,7 +1333,8 @@ static void batadv_purge_orig(struct work_struct *work)
  */
 int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb)
 {
-	struct batadv_hard_iface *primary_if, *hard_iface;
+	struct batadv_hard_iface *primary_if;
+	struct batadv_hard_iface *hard_iface;
 	struct net_device *mesh_iface;
 	struct batadv_priv *bat_priv;
 	int ret;
net/batman-adv/routing.c +25 -12
index 770037b8ca4e4..b4c6e13877c12 100644
@@ -276,7 +276,8 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv,
 	struct batadv_hard_iface *primary_if = NULL;
 	struct batadv_orig_node *orig_node = NULL;
 	struct batadv_icmp_header *icmph;
-	int res, ret = NET_RX_DROP;
+	int res;
+	int ret = NET_RX_DROP;
 
 	icmph = (struct batadv_icmp_header *)skb->data;
 
@@ -348,7 +349,8 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
 	struct batadv_hard_iface *primary_if = NULL;
 	struct batadv_orig_node *orig_node = NULL;
 	struct batadv_icmp_packet *icmp_packet;
-	int res, ret = NET_RX_DROP;
+	int res;
+	int ret = NET_RX_DROP;
 
 	icmp_packet = (struct batadv_icmp_packet *)skb->data;
 
@@ -411,7 +413,8 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
 	struct ethhdr *ethhdr;
 	struct batadv_orig_node *orig_node = NULL;
 	int hdr_size = sizeof(struct batadv_icmp_header);
-	int res, ret = NET_RX_DROP;
+	int res;
+	int ret = NET_RX_DROP;
 
 	/* drop packet if it has not necessary minimum size */
 	if (unlikely(!pskb_may_pull(skb, hdr_size)))
@@ -593,9 +596,11 @@ batadv_find_router(struct batadv_priv *bat_priv,
 	struct batadv_algo_ops *bao = bat_priv->algo_ops;
 	struct batadv_neigh_node *first_candidate_router = NULL;
 	struct batadv_neigh_node *next_candidate_router = NULL;
-	struct batadv_neigh_node *router, *cand_router = NULL;
+	struct batadv_neigh_node *router;
+	struct batadv_neigh_node *cand_router = NULL;
 	struct batadv_neigh_node *last_cand_router = NULL;
-	struct batadv_orig_ifinfo *cand, *first_candidate = NULL;
+	struct batadv_orig_ifinfo *cand;
+	struct batadv_orig_ifinfo *first_candidate = NULL;
 	struct batadv_orig_ifinfo *next_candidate = NULL;
 	struct batadv_orig_ifinfo *last_candidate;
 	bool last_candidate_found = false;
@@ -739,7 +744,9 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
 	struct batadv_orig_node *orig_node = NULL;
 	struct batadv_unicast_packet *unicast_packet;
 	struct ethhdr *ethhdr = eth_hdr(skb);
-	int res, hdr_len, ret = NET_RX_DROP;
+	int res;
+	int hdr_len;
+	int ret = NET_RX_DROP;
 	unsigned int len;
 
 	unicast_packet = (struct batadv_unicast_packet *)skb->data;
@@ -882,7 +889,8 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
 	struct batadv_unicast_packet *unicast_packet;
 	struct batadv_hard_iface *primary_if;
 	struct batadv_orig_node *orig_node;
-	u8 curr_ttvn, old_ttvn;
+	u8 curr_ttvn;
+	u8 old_ttvn;
 	struct ethhdr *ethhdr;
 	unsigned short vid;
 	int is_old_ttvn;
@@ -1002,7 +1010,8 @@ int batadv_recv_unhandled_unicast_packet(struct sk_buff *skb,
 {
 	struct batadv_unicast_packet *unicast_packet;
 	struct batadv_priv *bat_priv = netdev_priv(recv_if->mesh_iface);
-	int check, hdr_size = sizeof(*unicast_packet);
+	int check;
+	int hdr_size = sizeof(*unicast_packet);
 
 	check = batadv_check_unicast_packet(bat_priv, skb, hdr_size);
 	if (check < 0)
@@ -1033,12 +1042,16 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
 	struct batadv_priv *bat_priv = netdev_priv(recv_if->mesh_iface);
 	struct batadv_unicast_packet *unicast_packet;
 	struct batadv_unicast_4addr_packet *unicast_4addr_packet;
-	u8 *orig_addr, *orig_addr_gw;
-	struct batadv_orig_node *orig_node = NULL, *orig_node_gw = NULL;
-	int check, hdr_size = sizeof(*unicast_packet);
+	u8 *orig_addr;
+	u8 *orig_addr_gw;
+	struct batadv_orig_node *orig_node = NULL;
+	struct batadv_orig_node *orig_node_gw = NULL;
+	int check;
+	int hdr_size = sizeof(*unicast_packet);
 	enum batadv_subtype subtype;
 	int ret = NET_RX_DROP;
-	bool is4addr, is_gw;
+	bool is4addr;
+	bool is_gw;
 
 	unicast_packet = (struct batadv_unicast_packet *)skb->data;
 	is4addr = unicast_packet->packet_type == BATADV_UNICAST_4ADDR;
net/batman-adv/send.c +2 -1
index 7f449338a4909..29f2cbc61285d 100644
@@ -394,7 +394,8 @@ int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
 {
 	struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
 	struct batadv_orig_node *orig_node;
-	u8 *src, *dst;
+	u8 *src;
+	u8 *dst;
 	int ret;
 
 	src = ethhdr->h_source;
net/batman-adv/tp_meter.c +16 -8
index 00467aa79de9d..b957a59dcf262 100644
@@ -267,7 +267,8 @@ static void batadv_tp_batctl_error_notify(enum batadv_tp_meter_reason reason,
 static struct batadv_tp_sender *
 batadv_tp_list_find_sender(struct batadv_priv *bat_priv, const u8 *dst)
 {
-	struct batadv_tp_sender *pos, *tp_vars = NULL;
+	struct batadv_tp_sender *pos;
+	struct batadv_tp_sender *tp_vars = NULL;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(pos, &bat_priv->tp_sender_list, common.list) {
@@ -332,7 +333,8 @@ static struct batadv_tp_sender *
 batadv_tp_list_find_sender_session(struct batadv_priv *bat_priv, const u8 *dst,
 				   const u8 *session)
 {
-	struct batadv_tp_sender *pos, *tp_vars = NULL;
+	struct batadv_tp_sender *pos;
+	struct batadv_tp_sender *tp_vars = NULL;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(pos, &bat_priv->tp_sender_list, common.list) {
@@ -864,7 +866,8 @@ static void batadv_tp_recv_ack(struct batadv_priv *bat_priv,
 static bool batadv_tp_avail(struct batadv_tp_sender *tp_vars,
 			    size_t payload_len)
 {
-	u32 win_left, win_limit;
+	u32 win_left;
+	u32 win_limit;
 
 	spin_lock_bh(&tp_vars->cc_lock);
 
@@ -914,7 +917,8 @@ static int batadv_tp_send(void *arg)
 	struct batadv_priv *bat_priv = tp_vars->common.bat_priv;
 	struct batadv_hard_iface *primary_if = NULL;
 	struct batadv_orig_node *orig_node = NULL;
-	size_t payload_len, packet_len;
+	size_t payload_len;
+	size_t packet_len;
 	u32 last_sent;
 	int err = 0;
 
@@ -1211,7 +1215,8 @@ static struct batadv_tp_receiver *
 batadv_tp_list_find_receiver_session(struct batadv_priv *bat_priv, const u8 *dst,
 				     const u8 *session)
 {
-	struct batadv_tp_receiver *pos, *tp_vars = NULL;
+	struct batadv_tp_receiver *pos;
+	struct batadv_tp_receiver *tp_vars = NULL;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(pos, &bat_priv->tp_receiver_list, common.list) {
@@ -1296,7 +1301,8 @@ static void batadv_tp_reset_receiver_timer(struct batadv_tp_receiver *tp_vars)
 static void batadv_tp_receiver_shutdown(struct timer_list *t)
 {
 	struct batadv_tp_receiver *tp_vars = timer_container_of(tp_vars, t, common.timer);
-	struct batadv_tp_unacked *un, *safe;
+	struct batadv_tp_unacked *un;
+	struct batadv_tp_unacked *safe;
 	struct batadv_priv *bat_priv;
 
 	bat_priv = tp_vars->common.bat_priv;
@@ -1351,7 +1357,8 @@ static int batadv_tp_send_ack(struct batadv_priv *bat_priv, const u8 *dst,
 	struct batadv_orig_node *orig_node;
 	struct batadv_icmp_tp_packet *icmp;
 	struct sk_buff *skb;
-	int r, ret;
+	int r;
+	int ret;
 
 	orig_node = batadv_orig_hash_find(bat_priv, dst);
 	if (unlikely(!orig_node)) {
@@ -1528,7 +1535,8 @@ static bool batadv_tp_handle_out_of_order(struct batadv_tp_receiver *tp_vars,
 static void batadv_tp_ack_unordered(struct batadv_tp_receiver *tp_vars)
 	__must_hold(&tp_vars->ack_seqno_lock)
 {
-	struct batadv_tp_unacked *un, *safe;
+	struct batadv_tp_unacked *un;
+	struct batadv_tp_unacked *safe;
 	u32 to_ack;
 
 	/* go through the unacked packet list and possibly ACK them as
net/batman-adv/translation-table.c +55 -25

212 lines not on this page · raw message

net/batman-adv/tvlv.c +8 -4
index 49bf2ed9ecdc3..066468acf20d7 100644
@@ -72,7 +72,8 @@ static void batadv_tvlv_handler_put(struct batadv_tvlv_handler *tvlv_handler)
 static struct batadv_tvlv_handler *
 batadv_tvlv_handler_get(struct batadv_priv *bat_priv, u8 type, u8 version)
 {
-	struct batadv_tvlv_handler *tvlv_handler_tmp, *tvlv_handler = NULL;
+	struct batadv_tvlv_handler *tvlv_handler_tmp;
+	struct batadv_tvlv_handler *tvlv_handler = NULL;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(tvlv_handler_tmp,
@@ -134,7 +135,8 @@ static void batadv_tvlv_container_put(struct batadv_tvlv_container *tvlv)
 static struct batadv_tvlv_container *
 batadv_tvlv_container_get(struct batadv_priv *bat_priv, u8 type, u8 version)
 {
-	struct batadv_tvlv_container *tvlv_tmp, *tvlv = NULL;
+	struct batadv_tvlv_container *tvlv_tmp;
+	struct batadv_tvlv_container *tvlv = NULL;
 
 	lockdep_assert_held(&bat_priv->tvlv.container_list_lock);
 
@@ -236,7 +238,8 @@ void batadv_tvlv_container_register(struct batadv_priv *bat_priv,
 				    u8 type, u8 version,
 				    void *tvlv_value, u16 tvlv_value_len)
 {
-	struct batadv_tvlv_container *tvlv_old, *tvlv_new;
+	struct batadv_tvlv_container *tvlv_old;
+	struct batadv_tvlv_container *tvlv_new;
 
 	if (!tvlv_value)
 		tvlv_value_len = 0;
@@ -394,7 +397,8 @@ static int batadv_tvlv_call_handler(struct batadv_priv *bat_priv,
 				    u16 tvlv_value_len)
 {
 	unsigned int tvlv_offset;
-	u8 *src, *dst;
+	u8 *src;
+	u8 *dst;
 
 	if (!tvlv_handler)
 		return NET_RX_SUCCESS;
Signature · 1 line
2.47.3
author maintainer
#13 lore raw

PATCH 13/15 batman-adv: switch var declarations to reverse x-mas tree order

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

The network related code should use for local variable declarations an ordering scheme which orders lines longest to shortest. Initializations should only be kept in the declarations when the dependencies between them are not preventing the reverse x-mas tree order.

Many functions are already using this order. The remaining ones were supposed to slowly convert to the x-mas tree order when working on them. But this never happened because the patches tried to only modify the relevant lines. Instead of getting better, the order often just became worse.

Just fix the remaining offending functions to finally solve this coding style (minor) problem.

---
 net/batman-adv/bat_algo.c              |   3 +-
 net/batman-adv/bat_iv_ogm.c            | 129 +++++++++---------
 net/batman-adv/bat_v.c                 |  24 ++--
 net/batman-adv/bat_v_elp.c             |  18 +--
 net/batman-adv/bat_v_ogm.c             |  29 ++--
 net/batman-adv/bridge_loop_avoidance.c |  90 ++++++-------
 net/batman-adv/distributed-arp-table.c | 130 ++++++++++--------
 net/batman-adv/fragmentation.c         |  32 ++---
 net/batman-adv/gateway_client.c        |  26 ++--
 net/batman-adv/gateway_common.c        |   2 +-
 net/batman-adv/hard-interface.c        |  12 +-
 net/batman-adv/hash.h                  |   8 +-
 net/batman-adv/log.h                   |  16 ++-
 net/batman-adv/main.c                  |  16 +--
 net/batman-adv/mesh-interface.c        |  38 +++---
 net/batman-adv/multicast.c             |  36 +++--
 net/batman-adv/multicast_forw.c        |  13 +-
 net/batman-adv/netlink.c               |   6 +-
 net/batman-adv/originator.c            |  38 +++---
 net/batman-adv/routing.c               |  54 ++++----
 net/batman-adv/send.c                  |   4 +-
 net/batman-adv/tp_meter.c              |  31 ++---
 net/batman-adv/translation-table.c     | 179 +++++++++++++------------
 net/batman-adv/tvlv.c                  |  16 +--
 24 files changed, 491 insertions(+), 459 deletions(-)
net/batman-adv/bat_algo.c +2 -1
index bd094bc793e30..93cd77680e644 100644
@@ -131,8 +131,9 @@ static int batadv_param_set_ra(const char *val, const struct kernel_param *kp)
 {
 	struct batadv_algo_ops *bat_algo_ops;
 	char *algo_name = (char *)val;
-	size_t name_len = strlen(algo_name);
+	size_t name_len;
 
+	name_len = strlen(algo_name);
 	if (name_len > 0 && algo_name[name_len - 1] == '\n')
 		algo_name[name_len - 1] = '\0';
 
net/batman-adv/bat_iv_ogm.c +65 -64

348 lines not on this page · raw message

net/batman-adv/bat_v.c +12 -12
index be28875c201d7..ee372fc9d44e9 100644
@@ -159,9 +159,9 @@ static int
 batadv_v_neigh_dump_neigh(struct sk_buff *msg, u32 portid, u32 seq,
 			  struct batadv_hardif_neigh_node *hardif_neigh)
 {
-	void *hdr;
 	unsigned int last_seen_msecs;
 	u32 throughput;
+	void *hdr;
 
 	last_seen_msecs = jiffies_to_msecs(jiffies - hardif_neigh->last_seen);
 	throughput = ewma_throughput_read(&hardif_neigh->bat_v.throughput);
@@ -242,12 +242,12 @@ batadv_v_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb,
 		    struct batadv_priv *bat_priv,
 		    struct batadv_hard_iface *single_hardif)
 {
+	int portid = NETLINK_CB(cb->skb).portid;
 	struct batadv_hard_iface *hard_iface;
-	struct list_head *iter;
-	int i_hardif = 0;
 	int i_hardif_s = cb->args[0];
+	struct list_head *iter;
 	int idx = cb->args[1];
-	int portid = NETLINK_CB(cb->skb).portid;
+	int i_hardif = 0;
 
 	rcu_read_lock();
 	if (single_hardif) {
@@ -452,11 +452,11 @@ batadv_v_orig_dump(struct sk_buff *msg, struct netlink_callback *cb,
 		   struct batadv_hard_iface *if_outgoing)
 {
 	struct batadv_hashtable *hash = bat_priv->orig_hash;
-	struct hlist_head *head;
+	int portid = NETLINK_CB(cb->skb).portid;
 	int bucket = cb->args[0];
+	struct hlist_head *head;
 	int idx = cb->args[1];
 	int sub = cb->args[2];
-	int portid = NETLINK_CB(cb->skb).portid;
 
 	while (bucket < hash->size) {
 		head = &hash->table[bucket];
@@ -529,8 +529,8 @@ static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1,
 {
 	struct batadv_neigh_ifinfo *ifinfo1;
 	struct batadv_neigh_ifinfo *ifinfo2;
-	u32 threshold;
 	bool ret = false;
+	u32 threshold;
 
 	ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1);
 	if (!ifinfo1)
@@ -612,8 +612,8 @@ static int batadv_v_gw_throughput_get(struct batadv_gw_node *gw_node, u32 *bw)
 static struct batadv_gw_node *
 batadv_v_gw_get_best_gw_node(struct batadv_priv *bat_priv)
 {
-	struct batadv_gw_node *gw_node;
 	struct batadv_gw_node *curr_gw = NULL;
+	struct batadv_gw_node *gw_node;
 	u32 max_bw = 0;
 	u32 bw;
 
@@ -654,12 +654,12 @@ static bool batadv_v_gw_is_eligible(struct batadv_priv *bat_priv,
 				    struct batadv_orig_node *curr_gw_orig,
 				    struct batadv_orig_node *orig_node)
 {
-	struct batadv_gw_node *curr_gw;
 	struct batadv_gw_node *orig_gw = NULL;
-	u32 gw_throughput;
+	struct batadv_gw_node *curr_gw;
 	u32 orig_throughput;
-	u32 threshold;
+	u32 gw_throughput;
 	bool ret = false;
+	u32 threshold;
 
 	threshold = READ_ONCE(bat_priv->gw.sel_class);
 
@@ -715,8 +715,8 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid,
 				  struct batadv_gw_node *gw_node)
 {
 	struct batadv_neigh_ifinfo *router_ifinfo = NULL;
-	struct batadv_neigh_node *router;
 	struct batadv_gw_node *curr_gw = NULL;
+	struct batadv_neigh_node *router;
 	int ret = 0;
 	void *hdr;
 
net/batman-adv/bat_v_elp.c +10 -8
index eb7fb8c14ef30..6ad6042a5d9b6 100644
@@ -230,12 +230,14 @@ static bool
 batadv_v_elp_wifi_neigh_probe(struct batadv_hardif_neigh_node *neigh)
 {
 	struct batadv_hard_iface *hard_iface = neigh->if_incoming;
-	struct batadv_priv *bat_priv = netdev_priv(hard_iface->mesh_iface);
+	struct batadv_priv *bat_priv;
 	unsigned long last_tx_diff;
 	struct sk_buff *skb;
+	int elp_skb_len;
 	int probe_len;
 	int i;
-	int elp_skb_len;
+
+	bat_priv = netdev_priv(hard_iface->mesh_iface);
 
 	/* this probing routine is for Wifi neighbours only */
 	if (!batadv_is_wifi_hardif(hard_iface))
@@ -290,8 +292,8 @@ static void batadv_v_elp_periodic_work(struct work_struct *work)
 	struct batadv_v_metric_queue_entry *metric_entry;
 	struct batadv_v_metric_queue_entry *metric_safe;
 	struct batadv_hardif_neigh_node *hardif_neigh;
-	struct batadv_hard_iface *hard_iface;
 	struct batadv_hard_iface_bat_v *bat_v;
+	struct batadv_hard_iface *hard_iface;
 	struct batadv_elp_packet *elp_packet;
 	struct list_head metric_queue;
 	struct batadv_priv *bat_priv;
@@ -396,9 +398,9 @@ int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface)
 	static const size_t tvlv_padding = sizeof(__be32);
 	struct batadv_elp_packet *elp_packet;
 	unsigned char *elp_buff;
+	int res = -ENOMEM;
 	u32 random_seqno;
 	size_t size;
-	int res = -ENOMEM;
 
 	size = ETH_HLEN + NET_IP_ALIGN + BATADV_ELP_HLEN + tvlv_padding;
 	hard_iface->bat_v.elp_skb = dev_alloc_skb(size);
@@ -501,11 +503,11 @@ static void batadv_v_elp_neigh_update(struct batadv_priv *bat_priv,
 				      struct batadv_elp_packet *elp_packet)
 
 {
-	struct batadv_neigh_node *neigh;
-	struct batadv_orig_node *orig_neigh;
 	struct batadv_hardif_neigh_node *hardif_neigh;
-	s32 seqno_diff;
+	struct batadv_orig_node *orig_neigh;
+	struct batadv_neigh_node *neigh;
 	s32 elp_latest_seqno;
+	s32 seqno_diff;
 
 	orig_neigh = batadv_v_ogm_orig_get(bat_priv, elp_packet->orig);
 	if (!orig_neigh)
@@ -557,8 +559,8 @@ int batadv_v_elp_packet_recv(struct sk_buff *skb,
 	struct batadv_elp_packet *elp_packet;
 	struct batadv_hard_iface *primary_if;
 	struct ethhdr *ethhdr;
-	bool res;
 	int ret = NET_RX_DROP;
+	bool res;
 
 	res = batadv_check_management_packet(skb, if_incoming, BATADV_ELP_HLEN);
 	if (!res)
net/batman-adv/bat_v_ogm.c +15 -14
index d4527663f76d9..70846c997410d 100644
@@ -101,6 +101,7 @@ static void batadv_v_ogm_start_queue_timer(struct batadv_hard_iface *hard_iface)
 static void batadv_v_ogm_start_timer(struct batadv_priv *bat_priv)
 {
 	unsigned long msecs;
+
 	/* this function may be invoked in different contexts (ogm rescheduling
 	 * or hard_iface activation), but the work timer should not be reset
 	 */
@@ -268,12 +269,12 @@ static void batadv_v_ogm_queue_on_if(struct sk_buff *skb,
  */
 static void batadv_v_ogm_send_meshif(struct batadv_priv *bat_priv)
 {
-	struct batadv_hard_iface *hard_iface;
 	struct batadv_ogm2_packet *ogm_packet;
+	struct batadv_hard_iface *hard_iface;
 	struct batadv_ogm_buf *ogm_buff;
-	struct sk_buff *skb;
 	struct sk_buff *skb_tmp;
 	struct list_head *iter;
+	struct sk_buff *skb;
 	u16 tvlv_len;
 	int ret;
 
@@ -622,11 +623,11 @@ static int batadv_v_ogm_metric_update(struct batadv_priv *bat_priv,
 				      struct batadv_hard_iface *if_incoming,
 				      struct batadv_hard_iface *if_outgoing)
 {
-	struct batadv_orig_ifinfo *orig_ifinfo;
 	struct batadv_neigh_ifinfo *neigh_ifinfo = NULL;
+	struct batadv_orig_ifinfo *orig_ifinfo;
 	bool protection_started = false;
-	int ret = -EINVAL;
 	u32 path_throughput;
+	int ret = -EINVAL;
 	s32 seq_diff;
 
 	orig_ifinfo = batadv_orig_ifinfo_new(orig_node, if_outgoing);
@@ -704,17 +705,17 @@ static bool batadv_v_ogm_route_update(struct batadv_priv *bat_priv,
 				      struct batadv_hard_iface *if_incoming,
 				      struct batadv_hard_iface *if_outgoing)
 {
-	struct batadv_neigh_node *router = NULL;
-	struct batadv_orig_node *orig_neigh_node;
 	struct batadv_neigh_node *orig_neigh_router = NULL;
 	struct batadv_neigh_ifinfo *router_ifinfo = NULL;
 	struct batadv_neigh_ifinfo *neigh_ifinfo = NULL;
+	struct batadv_orig_node *orig_neigh_node;
+	struct batadv_neigh_node *router = NULL;
 	u32 router_throughput;
-	u32 neigh_throughput;
 	u32 router_last_seqno;
+	u32 neigh_throughput;
 	u32 neigh_last_seqno;
-	s32 neigh_seq_diff;
 	bool forward = false;
+	s32 neigh_seq_diff;
 
 	orig_neigh_node = batadv_v_ogm_orig_get(bat_priv, ethhdr->h_source);
 	if (!orig_neigh_node)
@@ -874,16 +875,16 @@ static void batadv_v_ogm_process(const struct sk_buff *skb, int ogm_offset,
 				 struct batadv_hard_iface *if_incoming)
 {
 	struct batadv_priv *bat_priv = netdev_priv(if_incoming->mesh_iface);
-	struct ethhdr *ethhdr;
-	struct batadv_orig_node *orig_node = NULL;
 	struct batadv_hardif_neigh_node *hardif_neigh = NULL;
 	struct batadv_neigh_node *neigh_node = NULL;
-	struct batadv_hard_iface *hard_iface;
+	struct batadv_orig_node *orig_node = NULL;
 	struct batadv_ogm2_packet *ogm_packet;
-	u32 ogm_throughput;
+	struct batadv_hard_iface *hard_iface;
+	struct list_head *iter;
+	struct ethhdr *ethhdr;
 	u32 link_throughput;
 	u32 path_throughput;
-	struct list_head *iter;
+	u32 ogm_throughput;
 	int ret;
 
 	ethhdr = eth_hdr(skb);
@@ -1009,9 +1010,9 @@ int batadv_v_ogm_packet_recv(struct sk_buff *skb,
 	struct batadv_priv *bat_priv = netdev_priv(if_incoming->mesh_iface);
 	struct batadv_ogm2_packet *ogm_packet;
 	struct ethhdr *ethhdr;
+	int ret = NET_RX_DROP;
 	int ogm_offset;
 	u8 *packet_pos;
-	int ret = NET_RX_DROP;
 
 	/* did we receive a OGM2 packet on an interface that does not have
 	 * B.A.T.M.A.N. V enabled ?
net/batman-adv/bridge_loop_avoidance.c +45 -45

273 lines not on this page · raw message

net/batman-adv/distributed-arp-table.c +76 -54

256 lines not on this page · raw message

net/batman-adv/fragmentation.c +17 -15
index f382af8588b56..5142a911db9ff 100644
@@ -139,17 +139,17 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node,
 				      struct sk_buff *skb,
 				      struct hlist_head *chain_out)
 {
-	struct batadv_frag_table_entry *chain;
+	struct batadv_frag_list_entry *frag_entry_last = NULL;
 	struct batadv_frag_list_entry *frag_entry_new = NULL;
+	u16 hdr_size = sizeof(struct batadv_frag_packet);
 	struct batadv_frag_list_entry *frag_entry_curr;
-	struct batadv_frag_list_entry *frag_entry_last = NULL;
 	struct batadv_frag_packet *frag_packet;
-	u8 bucket;
-	u16 seqno;
-	u16 hdr_size = sizeof(struct batadv_frag_packet);
+	struct batadv_frag_table_entry *chain;
 	bool overflow = false;
 	bool ret = false;
 	size_t data_len;
+	u8 bucket;
+	u16 seqno;
 
 	/* Linearize packet to avoid linearizing 16 packets in a row when doing
 	 * the later merge. Non-linear merge should be added to remove this
@@ -260,12 +260,12 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node,
 static struct sk_buff *
 batadv_frag_merge_packets(struct hlist_head *chain)
 {
-	struct batadv_frag_packet *packet;
+	int hdr_size = sizeof(struct batadv_frag_packet);
 	struct batadv_frag_list_entry *entry;
+	struct batadv_frag_packet *packet;
 	struct sk_buff *skb_out;
-	int size;
-	int hdr_size = sizeof(struct batadv_frag_packet);
 	bool dropped = false;
+	int size;
 
 	/* Remove first entry, as this is the destination for the rest of the
 	 * fragments.
@@ -351,8 +351,8 @@ static bool batadv_skb_is_frag(struct sk_buff *skb)
 bool batadv_frag_skb_buffer(struct sk_buff **skb,
 			    struct batadv_orig_node *orig_node_src)
 {
-	struct sk_buff *skb_out = NULL;
 	struct hlist_head head = HLIST_HEAD_INIT;
+	struct sk_buff *skb_out = NULL;
 	bool ret = false;
 
 	/* Add packet to buffer and table entry if merge is possible. */
@@ -406,8 +406,8 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb,
 	struct batadv_priv *bat_priv = netdev_priv(recv_if->mesh_iface);
 	struct batadv_neigh_node *neigh_node = NULL;
 	struct batadv_frag_packet *packet;
-	u16 total_size;
 	bool ret = false;
+	u16 total_size;
 
 	packet = (struct batadv_frag_packet *)skb->data;
 
@@ -471,10 +471,11 @@ static struct sk_buff *batadv_frag_create(struct net_device *net_dev,
 {
 	unsigned int ll_reserved = LL_RESERVED_SPACE(net_dev);
 	unsigned int tailroom = net_dev->needed_tailroom;
-	struct sk_buff *skb_fragment;
 	unsigned int header_size = sizeof(*frag_head);
-	unsigned int mtu = fragment_size + header_size;
+	struct sk_buff *skb_fragment;
+	unsigned int mtu;
 
+	mtu = fragment_size + header_size;
 	skb_fragment = dev_alloc_skb(ll_reserved + mtu + tailroom);
 	if (!skb_fragment)
 		goto err;
@@ -506,19 +507,20 @@ int batadv_frag_send_packet(struct sk_buff *skb,
 			    struct batadv_neigh_node *neigh_node)
 {
 	struct net_device *net_dev = neigh_node->if_incoming->net_dev;
-	struct batadv_priv *bat_priv;
 	struct batadv_hard_iface *primary_if = NULL;
 	struct batadv_frag_packet frag_header;
-	struct sk_buff *skb_fragment;
 	unsigned int mtu = net_dev->mtu;
-	unsigned int header_size = sizeof(frag_header);
 	unsigned int max_fragment_size;
+	struct batadv_priv *bat_priv;
+	struct sk_buff *skb_fragment;
 	unsigned int num_fragments;
+	unsigned int header_size;
 	int ret;
 
 	/* To avoid merge and refragmentation at next-hops we never send
 	 * fragments larger than BATADV_FRAG_MAX_FRAG_SIZE
 	 */
+	header_size = sizeof(frag_header);
 	mtu = min_t(unsigned int, mtu, BATADV_FRAG_MAX_FRAG_SIZE);
 	max_fragment_size = mtu - header_size;
 
net/batman-adv/gateway_client.c +13 -13
index b1a5b9ca31888..0dfbd3f514c1c 100644
@@ -103,8 +103,8 @@ batadv_gw_get_selected_gw_node(struct batadv_priv *bat_priv)
 struct batadv_orig_node *
 batadv_gw_get_selected_orig(struct batadv_priv *bat_priv)
 {
-	struct batadv_gw_node *gw_node;
 	struct batadv_orig_node *orig_node = NULL;
+	struct batadv_gw_node *gw_node;
 
 	gw_node = batadv_gw_get_selected_gw_node(bat_priv);
 	if (!gw_node)
@@ -205,10 +205,10 @@ void batadv_gw_check_client_stop(struct batadv_priv *bat_priv)
  */
 void batadv_gw_election(struct batadv_priv *bat_priv)
 {
+	struct batadv_neigh_ifinfo *router_ifinfo = NULL;
+	struct batadv_neigh_node *router = NULL;
 	struct batadv_gw_node *curr_gw = NULL;
 	struct batadv_gw_node *next_gw = NULL;
-	struct batadv_neigh_node *router = NULL;
-	struct batadv_neigh_ifinfo *router_ifinfo = NULL;
 	char gw_addr[18] = { '\0' };
 
 	if (READ_ONCE(bat_priv->gw.mode) != BATADV_GW_MODE_CLIENT)
@@ -378,8 +378,8 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv,
 struct batadv_gw_node *batadv_gw_node_get(struct batadv_priv *bat_priv,
 					  struct batadv_orig_node *orig_node)
 {
-	struct batadv_gw_node *gw_node_tmp;
 	struct batadv_gw_node *gw_node = NULL;
+	struct batadv_gw_node *gw_node_tmp;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(gw_node_tmp, &bat_priv->gw.gateway_list,
@@ -409,8 +409,8 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv,
 			   struct batadv_orig_node *orig_node,
 			   struct batadv_tvlv_gateway_data *gateway)
 {
-	struct batadv_gw_node *gw_node;
 	struct batadv_gw_node *curr_gw = NULL;
+	struct batadv_gw_node *gw_node;
 
 	spin_lock_bh(&bat_priv->gw.list_lock);
 	gw_node = batadv_gw_node_get(bat_priv, orig_node);
@@ -568,11 +568,11 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
 			     u8 *chaddr)
 {
 	enum batadv_dhcp_recipient ret = BATADV_DHCP_NO;
-	struct ethhdr *ethhdr;
-	struct iphdr *iphdr;
+	struct vlan_ethhdr *vhdr;
 	struct ipv6hdr *ipv6hdr;
+	struct ethhdr *ethhdr;
 	struct udphdr *udphdr;
-	struct vlan_ethhdr *vhdr;
+	struct iphdr *iphdr;
 	int chaddr_offset;
 	__be16 proto;
 	u8 *p;
@@ -692,17 +692,17 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
 bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
 			    struct sk_buff *skb)
 {
+	struct batadv_orig_node *orig_dst_node = NULL;
 	struct batadv_neigh_node *neigh_curr = NULL;
 	struct batadv_neigh_node *neigh_old = NULL;
-	struct batadv_orig_node *orig_dst_node = NULL;
-	struct batadv_gw_node *gw_node = NULL;
-	struct batadv_gw_node *curr_gw = NULL;
 	struct batadv_neigh_ifinfo *curr_ifinfo;
 	struct batadv_neigh_ifinfo *old_ifinfo;
-	struct ethhdr *ethhdr;
+	struct batadv_gw_node *gw_node = NULL;
+	struct batadv_gw_node *curr_gw = NULL;
 	bool out_of_range = false;
-	u8 curr_tq_avg;
+	struct ethhdr *ethhdr;
 	unsigned short vid;
+	u8 curr_tq_avg;
 
 	vid = batadv_get_vid(skb, 0);
 	ethhdr = (struct ethhdr *)skb->data;
net/batman-adv/gateway_common.c +1 -1
index b5ebe837bfdd1..65d3392050906 100644
@@ -60,8 +60,8 @@ static void batadv_gw_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
 					  u8 flags,
 					  void *tvlv_value, u16 tvlv_value_len)
 {
-	struct batadv_tvlv_gateway_data gateway;
 	struct batadv_tvlv_gateway_data *gateway_ptr;
+	struct batadv_tvlv_gateway_data gateway;
 
 	/* only fetch the tvlv value if the handler wasn't called via the
 	 * CIFNOTFND flag and if there is data to fetch
net/batman-adv/hard-interface.c +6 -6
index 1950b8809d99f..e7ad295504e4f 100644
@@ -350,8 +350,8 @@ static bool batadv_is_cfg80211_netdev(struct net_device *net_device)
  */
 static u32 batadv_wifi_flags_evaluate(struct net_device *net_device)
 {
-	u32 wifi_flags = 0;
 	struct net_device *real_netdev;
+	u32 wifi_flags = 0;
 
 	if (batadv_is_wext_netdev(net_device))
 		wifi_flags |= BATADV_HARDIF_WIFI_WEXT_DIRECT;
@@ -445,8 +445,8 @@ int batadv_hardif_no_broadcast(struct batadv_hard_iface *if_outgoing,
 			       u8 *orig_addr, u8 *orig_neigh)
 {
 	struct batadv_hardif_neigh_node *hardif_neigh;
-	struct hlist_node *first;
 	int ret = BATADV_HARDIF_BCAST_OK;
+	struct hlist_node *first;
 
 	rcu_read_lock();
 
@@ -731,8 +731,8 @@ void batadv_update_min_mtu(struct net_device *mesh_iface)
 static void
 batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)
 {
-	struct batadv_priv *bat_priv;
 	struct batadv_hard_iface *primary_if = NULL;
+	struct batadv_priv *bat_priv;
 
 	if (hard_iface->if_status != BATADV_IF_INACTIVE)
 		goto out;
@@ -794,10 +794,10 @@ batadv_hardif_deactivate_interface(struct batadv_hard_iface *hard_iface)
 int batadv_hardif_enable_interface(struct net_device *net_dev,
 				   struct net_device *mesh_iface)
 {
-	struct batadv_priv *bat_priv;
-	__be16 ethertype = htons(ETH_P_BATMAN);
 	int max_header_len = batadv_max_header_len();
+	__be16 ethertype = htons(ETH_P_BATMAN);
 	struct batadv_hard_iface *hard_iface;
+	struct batadv_priv *bat_priv;
 	unsigned int required_mtu;
 	unsigned int hardif_mtu;
 	bool fragmentation;
@@ -1106,8 +1106,8 @@ static int batadv_hard_if_event(struct notifier_block *this,
 				unsigned long event, void *ptr)
 {
 	struct net_device *net_dev = netdev_notifier_info_to_dev(ptr);
-	struct batadv_hard_iface *hard_iface;
 	struct batadv_hard_iface *primary_if = NULL;
+	struct batadv_hard_iface *hard_iface;
 	struct batadv_priv *bat_priv;
 
 	if (batadv_meshif_is_valid(net_dev))
net/batman-adv/hash.h +4 -4
index debbbc936cf74..755ced52a01c5 100644
@@ -92,11 +92,11 @@ static inline int batadv_hash_add(struct batadv_hashtable *hash,
 				  const void *data,
 				  struct hlist_node *data_node)
 {
-	u32 index;
-	int ret = -1;
+	spinlock_t *list_lock; /* spinlock to protect write access */
 	struct hlist_head *head;
 	struct hlist_node *node;
-	spinlock_t *list_lock; /* spinlock to protect write access */
+	int ret = -1;
+	u32 index;
 
 	if (!hash)
 		goto out;
@@ -145,10 +145,10 @@ static inline void *batadv_hash_remove(struct batadv_hashtable *hash,
 				       batadv_hashdata_choose_cb choose,
 				       void *data)
 {
-	u32 index;
 	struct hlist_node *node;
 	struct hlist_head *head;
 	void *data_save = NULL;
+	u32 index;
 
 	index = choose(data, hash->size);
 	head = &hash->table[index];
net/batman-adv/log.h +12 -4
index a0d2b0d64b2b0..9f3aed826dea6 100644
@@ -117,8 +117,12 @@ static inline void _batadv_dbg(int type __always_unused,
  */
 #define batadv_info(net_dev, fmt, arg...)				\
 	do {								\
-		struct net_device *_netdev = (net_dev);                 \
-		struct batadv_priv *_batpriv = netdev_priv(_netdev);    \
+		struct batadv_priv *_batpriv;				\
+		struct net_device *_netdev;				\
+									\
+		_netdev = (net_dev);					\
+		_batpriv = netdev_priv(_netdev);			\
+									\
 		batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg);	\
 		pr_info("%s: " fmt, _netdev->name, ## arg);		\
 	} while (0)
@@ -131,8 +135,12 @@ static inline void _batadv_dbg(int type __always_unused,
  */
 #define batadv_err(net_dev, fmt, arg...)				\
 	do {								\
-		struct net_device *_netdev = (net_dev);                 \
-		struct batadv_priv *_batpriv = netdev_priv(_netdev);    \
+		struct batadv_priv *_batpriv;				\
+		struct net_device *_netdev;				\
+									\
+		_netdev = (net_dev);					\
+		_batpriv = netdev_priv(_netdev);			\
+									\
 		batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg);	\
 		pr_err("%s: " fmt, _netdev->name, ## arg);		\
 	} while (0)
net/batman-adv/main.c +8 -8
index d8e9d20add898..5981e8eb6d979 100644
@@ -368,14 +368,14 @@ int batadv_max_header_len(void)
  */
 void batadv_skb_set_priority(struct sk_buff *skb, int offset)
 {
-	struct iphdr ip_hdr_tmp;
-	struct iphdr *ip_hdr;
+	struct vlan_ethhdr vhdr_tmp;
 	struct ipv6hdr ip6_hdr_tmp;
-	struct ipv6hdr *ip6_hdr;
 	struct ethhdr ethhdr_tmp;
-	struct ethhdr *ethhdr;
 	struct vlan_ethhdr *vhdr;
-	struct vlan_ethhdr vhdr_tmp;
+	struct iphdr ip_hdr_tmp;
+	struct ipv6hdr *ip6_hdr;
+	struct ethhdr *ethhdr;
+	struct iphdr *ip_hdr;
 	u32 prio;
 
 	/* already set, do nothing */
@@ -448,9 +448,9 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
 			   struct packet_type *ptype,
 			   struct net_device *orig_dev)
 {
-	struct batadv_priv *bat_priv;
 	struct batadv_ogm_packet *batadv_ogm_packet;
 	struct batadv_hard_iface *hard_iface;
+	struct batadv_priv *bat_priv;
 	u8 idx;
 
 	hard_iface = container_of(ptype, struct batadv_hard_iface,
@@ -687,9 +687,9 @@ bool batadv_vlan_ap_isola_get(struct batadv_priv *bat_priv, unsigned short vid)
 int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type,
 			enum batadv_uev_action action, const char *data)
 {
-	int ret = -ENOMEM;
-	struct kobject *bat_kobj;
 	char *uevent_env[4] = { NULL, NULL, NULL, NULL };
+	struct kobject *bat_kobj;
+	int ret = -ENOMEM;
 
 	bat_kobj = &bat_priv->mesh_iface->dev.kobj;
 
net/batman-adv/mesh-interface.c +18 -20
index 534e96eb96953..90830b10403f3 100644
@@ -213,31 +213,29 @@ static void batadv_interface_set_rx_mode(struct net_device *dev)
 static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
 				       struct net_device *mesh_iface)
 {
-	struct ethhdr *ethhdr;
+	static const u8 ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00, 0x00, 0x00};
+	static const u8 stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x00};
 	struct batadv_priv *bat_priv = netdev_priv(mesh_iface);
+	enum batadv_dhcp_recipient dhcp_rcp = BATADV_DHCP_NO;
+	enum batadv_forw_mode forw_mode = BATADV_FORW_BCAST;
 	struct batadv_hard_iface *primary_if = NULL;
 	struct batadv_bcast_packet *bcast_packet;
-	static const u8 stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00,
-					      0x00, 0x00};
-	static const u8 ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00,
-					       0x00, 0x00};
-	enum batadv_dhcp_recipient dhcp_rcp = BATADV_DHCP_NO;
-	u8 *dst_hint = NULL;
-	u8 chaddr[ETH_ALEN];
-	struct vlan_ethhdr *vhdr;
+	int network_offset = ETH_HLEN;
 	unsigned int header_len = 0;
-	int data_len = skb->len;
-	int ret;
 	unsigned long brd_delay = 0;
+	int mcast_is_routable = 0;
+	struct vlan_ethhdr *vhdr;
+	int data_len = skb->len;
+	struct ethhdr *ethhdr;
 	bool do_bcast = false;
-	bool client_added;
+	u8 *dst_hint = NULL;
+	u8 chaddr[ETH_ALEN];
 	unsigned short vid;
-	u32 seqno;
-	int gw_mode;
-	enum batadv_forw_mode forw_mode = BATADV_FORW_BCAST;
-	int mcast_is_routable = 0;
-	int network_offset = ETH_HLEN;
+	bool client_added;
 	__be16 proto;
+	int gw_mode;
+	u32 seqno;
+	int ret;
 
 	if (READ_ONCE(bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
 		goto dropped;
@@ -458,8 +456,8 @@ void batadv_interface_rx(struct net_device *mesh_iface,
 			 struct sk_buff *skb, int hdr_size,
 			 struct batadv_orig_node *orig_node)
 {
-	struct batadv_bcast_packet *batadv_bcast_packet;
 	struct batadv_priv *bat_priv = netdev_priv(mesh_iface);
+	struct batadv_bcast_packet *batadv_bcast_packet;
 	struct vlan_ethhdr *vhdr;
 	struct ethhdr *ethhdr;
 	unsigned short vid;
@@ -573,8 +571,8 @@ 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 *vlan_tmp;
 	struct batadv_meshif_vlan *vlan = NULL;
+	struct batadv_meshif_vlan *vlan_tmp;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(vlan_tmp, &bat_priv->meshif_vlan_list, list) {
@@ -792,10 +790,10 @@ static void batadv_set_lockdep_class(struct net_device *dev)
  */
 static int batadv_meshif_init_late(struct net_device *dev)
 {
+	size_t cnt_len = sizeof(u64) * BATADV_CNT_NUM;
 	struct batadv_priv *bat_priv;
 	u32 random_seqno;
 	int ret;
-	size_t cnt_len = sizeof(u64) * BATADV_CNT_NUM;
 
 	batadv_set_lockdep_class(dev);
 
net/batman-adv/multicast.c +17 -19
index 5b9e2168a0467..929dca6f21f50 100644
@@ -274,9 +274,9 @@ static struct batadv_mcast_mla_flags
 batadv_mcast_mla_flags_get(struct batadv_priv *bat_priv)
 {
 	struct net_device *dev = bat_priv->mesh_iface;
+	struct batadv_mcast_mla_flags mla_flags;
 	struct batadv_mcast_querier_state *qr4;
 	struct batadv_mcast_querier_state *qr6;
-	struct batadv_mcast_mla_flags mla_flags;
 	struct net_device *bridge;
 
 	bridge = batadv_mcast_get_bridge(dev);
@@ -522,8 +522,8 @@ batadv_mcast_mla_meshif_get(struct net_device *dev,
 			    struct batadv_mcast_mla_flags *flags)
 {
 	struct net_device *bridge = batadv_mcast_get_bridge(dev);
-	int ret4;
 	int ret6 = 0;
+	int ret4;
 
 	if (bridge)
 		dev = bridge;
@@ -587,11 +587,11 @@ static int batadv_mcast_mla_bridge_get(struct net_device *dev,
 				       struct batadv_mcast_mla_flags *flags)
 {
 	struct list_head bridge_mcast_list = LIST_HEAD_INIT(bridge_mcast_list);
-	struct br_ip_list *br_ip_entry;
-	struct br_ip_list *tmp;
 	u8 tvlv_flags = flags->tvlv_flags;
+	struct br_ip_list *br_ip_entry;
 	struct batadv_hw_addr *new;
 	u8 mcast_addr[ETH_ALEN];
+	struct br_ip_list *tmp;
 	int ret;
 
 	/* we don't need to detect these devices/listeners, the IGMP/MLD
@@ -938,8 +938,8 @@ static void __batadv_mcast_mla_update(struct batadv_priv *bat_priv)
  */
 static void batadv_mcast_mla_update(struct work_struct *work)
 {
-	struct delayed_work *delayed_work;
 	struct batadv_priv_mcast *priv_mcast;
+	struct delayed_work *delayed_work;
 	struct batadv_priv *bat_priv;
 
 	delayed_work = to_delayed_work(work);
@@ -1226,14 +1226,14 @@ enum batadv_forw_mode
 batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
 		       unsigned short vid, int *is_routable)
 {
-	int ret;
-	int tt_count;
-	int ip_count;
-	int unsnoop_count;
-	int total_count;
 	bool is_unsnoopable = false;
 	struct ethhdr *ethhdr;
+	int unsnoop_count;
 	int rtr_count = 0;
+	int total_count;
+	int tt_count;
+	int ip_count;
+	int ret;
 
 	ret = batadv_mcast_forw_mode_check(bat_priv, skb, &is_unsnoopable,
 					   is_routable);
@@ -1308,13 +1308,11 @@ static int
 batadv_mcast_forw_tt(struct batadv_priv *bat_priv, struct sk_buff *skb,
 		     unsigned short vid)
 {
-	int ret = NET_XMIT_SUCCESS;
-	struct sk_buff *newskb;
-
 	struct batadv_tt_orig_list_entry *orig_entry;
-
 	struct batadv_tt_global_entry *tt_global;
 	const u8 *addr = eth_hdr(skb)->h_dest;
+	int ret = NET_XMIT_SUCCESS;
+	struct sk_buff *newskb;
 
 	tt_global = batadv_tt_global_hash_find(bat_priv, addr, vid);
 	if (!tt_global)
@@ -1609,8 +1607,8 @@ static void batadv_mcast_want_unsnoop_update(struct batadv_priv *bat_priv,
 					     struct batadv_orig_node *orig,
 					     u8 mcast_flags)
 {
-	struct hlist_node *node = &orig->mcast_want_all_unsnoopables_node;
 	struct hlist_head *head = &bat_priv->mcast.want_all_unsnoopables_list;
+	struct hlist_node *node = &orig->mcast_want_all_unsnoopables_node;
 
 	lockdep_assert_held(&orig->mcast_handler_lock);
 
@@ -1654,8 +1652,8 @@ static void batadv_mcast_want_ipv4_update(struct batadv_priv *bat_priv,
 					  struct batadv_orig_node *orig,
 					  u8 mcast_flags)
 {
-	struct hlist_node *node = &orig->mcast_want_all_ipv4_node;
 	struct hlist_head *head = &bat_priv->mcast.want_all_ipv4_list;
+	struct hlist_node *node = &orig->mcast_want_all_ipv4_node;
 
 	lockdep_assert_held(&orig->mcast_handler_lock);
 
@@ -1699,8 +1697,8 @@ static void batadv_mcast_want_ipv6_update(struct batadv_priv *bat_priv,
 					  struct batadv_orig_node *orig,
 					  u8 mcast_flags)
 {
-	struct hlist_node *node = &orig->mcast_want_all_ipv6_node;
 	struct hlist_head *head = &bat_priv->mcast.want_all_ipv6_list;
+	struct hlist_node *node = &orig->mcast_want_all_ipv6_node;
 
 	lockdep_assert_held(&orig->mcast_handler_lock);
 
@@ -1744,8 +1742,8 @@ static void batadv_mcast_want_rtr4_update(struct batadv_priv *bat_priv,
 					  struct batadv_orig_node *orig,
 					  u8 mcast_flags)
 {
-	struct hlist_node *node = &orig->mcast_want_all_rtr4_node;
 	struct hlist_head *head = &bat_priv->mcast.want_all_rtr4_list;
+	struct hlist_node *node = &orig->mcast_want_all_rtr4_node;
 
 	lockdep_assert_held(&orig->mcast_handler_lock);
 
@@ -1789,8 +1787,8 @@ static void batadv_mcast_want_rtr6_update(struct batadv_priv *bat_priv,
 					  struct batadv_orig_node *orig,
 					  u8 mcast_flags)
 {
-	struct hlist_node *node = &orig->mcast_want_all_rtr6_node;
 	struct hlist_head *head = &bat_priv->mcast.want_all_rtr6_list;
+	struct hlist_node *node = &orig->mcast_want_all_rtr6_node;
 
 	lockdep_assert_held(&orig->mcast_handler_lock);
 
net/batman-adv/multicast_forw.c +5 -8
index 6dcac586b1d95..ccd4ae158dcd3 100644
@@ -195,8 +195,8 @@ static int batadv_mcast_forw_push_dests_list(struct batadv_priv *bat_priv,
 					     unsigned short *num_dests,
 					     unsigned short *tvlv_len)
 {
-	struct hlist_node *node;
 	struct batadv_orig_node *orig_node;
+	struct hlist_node *node;
 
 	rcu_read_lock();
 	__hlist_for_each_rcu(node, head) {
@@ -232,12 +232,9 @@ batadv_mcast_forw_push_tt(struct batadv_priv *bat_priv, struct sk_buff *skb,
 			  unsigned short *tvlv_len)
 {
 	struct batadv_tt_orig_list_entry *orig_entry;
-
 	struct batadv_tt_global_entry *tt_global;
 	const u8 *addr = eth_hdr(skb)->h_dest;
-
-	/* ok */
-	int ret = true;
+	int ret = true; /* ok */
 
 	tt_global = batadv_tt_global_hash_find(bat_priv, addr, vid);
 	if (!tt_global)
@@ -368,8 +365,8 @@ static void batadv_mcast_forw_scrape(struct sk_buff *skb,
 				     unsigned short offset,
 				     unsigned short len)
 {
-	char *to;
 	char *from;
+	char *to;
 
 	SKB_LINEAR_ASSERT(skb);
 
@@ -412,8 +409,8 @@ static bool batadv_mcast_forw_push_insert_padding(struct sk_buff *skb,
 						  unsigned short *tvlv_len)
 {
 	unsigned short offset =	*tvlv_len;
-	char *to;
 	char *from = skb->data;
+	char *to;
 
 	to = batadv_mcast_forw_push_padding(skb, tvlv_len);
 	if (!to)
@@ -935,9 +932,9 @@ static int batadv_mcast_forw_packet(struct batadv_priv *bat_priv,
 	unsigned int tvlv_len;
 	unsigned long offset;
 	bool xmitted = false;
-	u8 *dest;
 	u8 *next_dest;
 	u16 num_dests;
+	u8 *dest;
 	int ret;
 
 	/* (at least) TVLV part needs to be linearized */
net/batman-adv/netlink.c +3 -3
index f4aa7d2055107..926210a67d640 100644
@@ -752,8 +752,8 @@ static int
 batadv_netlink_tp_meter_cancel(struct sk_buff *skb, struct genl_info *info)
 {
 	struct batadv_priv *bat_priv = info->user_ptr[0];
-	u8 *dst;
 	int ret = 0;
+	u8 *dst;
 
 	if (!info->attrs[BATADV_ATTR_ORIG_ADDRESS])
 		return -EINVAL;
@@ -959,10 +959,10 @@ static int batadv_netlink_set_hardif(struct sk_buff *skb,
 static int
 batadv_netlink_dump_hardif(struct sk_buff *msg, struct netlink_callback *cb)
 {
-	struct net_device *mesh_iface;
+	int portid = NETLINK_CB(cb->skb).portid;
 	struct batadv_hard_iface *hard_iface;
+	struct net_device *mesh_iface;
 	struct batadv_priv *bat_priv;
-	int portid = NETLINK_CB(cb->skb).portid;
 	int skip = cb->args[0];
 	struct list_head *iter;
 	int i = 0;
net/batman-adv/originator.c +19 -19
index 57bb4a0131b0e..f06583ef9b3f5 100644
@@ -53,9 +53,9 @@ struct batadv_orig_node *
 batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data)
 {
 	struct batadv_hashtable *hash = bat_priv->orig_hash;
-	struct hlist_head *head;
-	struct batadv_orig_node *orig_node;
 	struct batadv_orig_node *orig_node_tmp = NULL;
+	struct batadv_orig_node *orig_node;
+	struct hlist_head *head;
 	int index;
 
 	if (!hash)
@@ -284,9 +284,9 @@ void batadv_hardif_neigh_release(struct kref *ref)
  */
 void batadv_neigh_node_release(struct kref *ref)
 {
-	struct hlist_node *node_tmp;
-	struct batadv_neigh_node *neigh_node;
 	struct batadv_neigh_ifinfo *neigh_ifinfo;
+	struct batadv_neigh_node *neigh_node;
+	struct hlist_node *node_tmp;
 
 	neigh_node = container_of(ref, struct batadv_neigh_node, refcount);
 
@@ -316,8 +316,8 @@ struct batadv_neigh_node *
 batadv_orig_router_get(struct batadv_orig_node *orig_node,
 		       const struct batadv_hard_iface *if_outgoing)
 {
-	struct batadv_orig_ifinfo *orig_ifinfo;
 	struct batadv_neigh_node *router = NULL;
+	struct batadv_orig_ifinfo *orig_ifinfo;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(orig_ifinfo, &orig_node->ifinfo_list, list) {
@@ -375,8 +375,8 @@ struct batadv_orig_ifinfo *
 batadv_orig_ifinfo_get(struct batadv_orig_node *orig_node,
 		       struct batadv_hard_iface *if_outgoing)
 {
-	struct batadv_orig_ifinfo *tmp;
 	struct batadv_orig_ifinfo *orig_ifinfo = NULL;
+	struct batadv_orig_ifinfo *tmp;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(tmp, &orig_node->ifinfo_list,
@@ -638,8 +638,8 @@ struct batadv_hardif_neigh_node *
 batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface,
 			const u8 *neigh_addr)
 {
-	struct batadv_hardif_neigh_node *tmp_hardif_neigh;
 	struct batadv_hardif_neigh_node *hardif_neigh = NULL;
+	struct batadv_hardif_neigh_node *tmp_hardif_neigh;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(tmp_hardif_neigh,
@@ -673,8 +673,8 @@ batadv_neigh_node_create(struct batadv_orig_node *orig_node,
 			 struct batadv_hard_iface *hard_iface,
 			 const u8 *neigh_addr)
 {
-	struct batadv_neigh_node *neigh_node;
 	struct batadv_hardif_neigh_node *hardif_neigh = NULL;
+	struct batadv_neigh_node *neigh_node;
 
 	spin_lock_bh(&orig_node->neigh_list_lock);
 
@@ -856,12 +856,12 @@ static void batadv_orig_node_free_rcu(struct rcu_head *rcu)
  */
 void batadv_orig_node_release(struct kref *ref)
 {
-	struct hlist_node *node_tmp;
+	struct batadv_orig_ifinfo *last_candidate;
+	struct batadv_orig_ifinfo *orig_ifinfo;
 	struct batadv_neigh_node *neigh_node;
 	struct batadv_orig_node *orig_node;
-	struct batadv_orig_ifinfo *orig_ifinfo;
 	struct batadv_orig_node_vlan *vlan;
-	struct batadv_orig_ifinfo *last_candidate;
+	struct hlist_node *node_tmp;
 
 	orig_node = container_of(ref, struct batadv_orig_node, refcount);
 
@@ -904,11 +904,11 @@ void batadv_orig_node_release(struct kref *ref)
  */
 void batadv_originator_free(struct batadv_priv *bat_priv)
 {
+	spinlock_t *list_lock; /* spinlock to protect write access */
 	struct batadv_hashtable *hash = bat_priv->orig_hash;
+	struct batadv_orig_node *orig_node;
 	struct hlist_node *node_tmp;
 	struct hlist_head *head;
-	spinlock_t *list_lock; /* spinlock to protect write access */
-	struct batadv_orig_node *orig_node;
 	u32 i;
 
 	if (!hash)
@@ -1115,11 +1115,11 @@ static bool
 batadv_purge_orig_neighbors(struct batadv_priv *bat_priv,
 			    struct batadv_orig_node *orig_node)
 {
-	struct hlist_node *node_tmp;
+	struct batadv_hard_iface *if_incoming;
 	struct batadv_neigh_node *neigh_node;
+	struct hlist_node *node_tmp;
 	bool neigh_purged = false;
 	unsigned long last_seen;
-	struct batadv_hard_iface *if_incoming;
 
 	spin_lock_bh(&orig_node->neigh_list_lock);
 
@@ -1173,9 +1173,9 @@ batadv_find_best_neighbor(struct batadv_priv *bat_priv,
 			  struct batadv_orig_node *orig_node,
 			  struct batadv_hard_iface *if_outgoing)
 {
+	struct batadv_algo_ops *bao = bat_priv->algo_ops;
 	struct batadv_neigh_node *best = NULL;
 	struct batadv_neigh_node *neigh;
-	struct batadv_algo_ops *bao = bat_priv->algo_ops;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(neigh, &orig_node->neigh_list, list) {
@@ -1210,9 +1210,9 @@ static bool batadv_purge_orig_node(struct batadv_priv *bat_priv,
 {
 	struct batadv_neigh_node *best_neigh_node;
 	struct batadv_hard_iface *hard_iface;
+	struct list_head *iter;
 	bool changed_ifinfo;
 	bool changed_neigh;
-	struct list_head *iter;
 
 	if (batadv_has_timed_out(orig_node->last_seen,
 				 2 * BATADV_PURGE_TIMEOUT)) {
@@ -1264,11 +1264,11 @@ static bool batadv_purge_orig_node(struct batadv_priv *bat_priv,
  */
 void batadv_purge_orig_ref(struct batadv_priv *bat_priv)
 {
+	spinlock_t *list_lock; /* spinlock to protect write access */
 	struct batadv_hashtable *hash = bat_priv->orig_hash;
+	struct batadv_orig_node *orig_node;
 	struct hlist_node *node_tmp;
 	struct hlist_head *head;
-	spinlock_t *list_lock; /* spinlock to protect write access */
-	struct batadv_orig_node *orig_node;
 	u32 i;
 
 	if (!hash)
net/batman-adv/routing.c +27 -27

153 lines not on this page · raw message

net/batman-adv/send.c +2 -2
index 29f2cbc61285d..2122560c90e51 100644
@@ -271,8 +271,8 @@ bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
 					   struct batadv_orig_node *orig,
 					   int packet_subtype)
 {
-	struct batadv_hard_iface *primary_if;
 	struct batadv_unicast_4addr_packet *uc_4addr_packet;
+	struct batadv_hard_iface *primary_if;
 	bool ret = false;
 
 	primary_if = batadv_primary_if_get_selected(bat_priv);
@@ -322,8 +322,8 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
 			    unsigned short vid)
 {
 	struct batadv_unicast_packet *unicast_packet;
-	struct ethhdr *ethhdr;
 	int ret = NET_XMIT_DROP;
+	struct ethhdr *ethhdr;
 
 	if (!orig_node)
 		goto out;
net/batman-adv/tp_meter.c +16 -15
index b957a59dcf262..022eb13e8ec47 100644
@@ -221,9 +221,9 @@ static void batadv_tp_batctl_notify(enum batadv_tp_meter_reason reason,
 				    unsigned long start_time, u64 total_sent,
 				    u32 cookie)
 {
+	u32 total_bytes;
 	u32 test_time;
 	u8 result;
-	u32 total_bytes;
 
 	if (!batadv_tp_is_error(reason)) {
 		result = BATADV_TP_REASON_COMPLETE;
@@ -267,8 +267,8 @@ static void batadv_tp_batctl_error_notify(enum batadv_tp_meter_reason reason,
 static struct batadv_tp_sender *
 batadv_tp_list_find_sender(struct batadv_priv *bat_priv, const u8 *dst)
 {
-	struct batadv_tp_sender *pos;
 	struct batadv_tp_sender *tp_vars = NULL;
+	struct batadv_tp_sender *pos;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(pos, &bat_priv->tp_sender_list, common.list) {
@@ -333,8 +333,8 @@ static struct batadv_tp_sender *
 batadv_tp_list_find_sender_session(struct batadv_priv *bat_priv, const u8 *dst,
 				   const u8 *session)
 {
-	struct batadv_tp_sender *pos;
 	struct batadv_tp_sender *tp_vars = NULL;
+	struct batadv_tp_sender *pos;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(pos, &bat_priv->tp_sender_list, common.list) {
@@ -580,8 +580,8 @@ static void batadv_tp_sender_timeout(struct timer_list *t)
 static void batadv_tp_fill_prerandom(struct batadv_tp_sender *tp_vars,
 				     u8 *buf, size_t nbytes)
 {
-	u32 local_offset;
 	size_t bytes_inbuf;
+	u32 local_offset;
 	size_t to_copy;
 	size_t pos = 0;
 
@@ -627,9 +627,9 @@ static int batadv_tp_send_msg(struct batadv_tp_sender *tp_vars, const u8 *src,
 {
 	struct batadv_icmp_tp_packet *icmp;
 	struct sk_buff *skb;
-	int r;
-	u8 *data;
 	size_t data_len;
+	u8 *data;
+	int r;
 
 	skb = netdev_alloc_skb_ip_align(NULL, len + ETH_HLEN);
 	if (unlikely(!skb))
@@ -866,8 +866,8 @@ static void batadv_tp_recv_ack(struct batadv_priv *bat_priv,
 static bool batadv_tp_avail(struct batadv_tp_sender *tp_vars,
 			    size_t payload_len)
 {
-	u32 win_left;
 	u32 win_limit;
+	u32 win_left;
 
 	spin_lock_bh(&tp_vars->cc_lock);
 
@@ -913,15 +913,16 @@ static int batadv_tp_wait_available(struct batadv_tp_sender *tp_vars, size_t ple
  */
 static int batadv_tp_send(void *arg)
 {
-	struct batadv_tp_sender *tp_vars = arg;
-	struct batadv_priv *bat_priv = tp_vars->common.bat_priv;
 	struct batadv_hard_iface *primary_if = NULL;
 	struct batadv_orig_node *orig_node = NULL;
+	struct batadv_tp_sender *tp_vars = arg;
+	struct batadv_priv *bat_priv;
 	size_t payload_len;
 	size_t packet_len;
 	u32 last_sent;
 	int err = 0;
 
+	bat_priv = tp_vars->common.bat_priv;
 	orig_node = batadv_orig_hash_find(bat_priv, tp_vars->common.other_end);
 	if (unlikely(!orig_node)) {
 		err = BATADV_TP_REASON_DST_UNREACHABLE;
@@ -1009,8 +1010,8 @@ static int batadv_tp_send(void *arg)
  */
 static void batadv_tp_start_kthread(struct batadv_tp_sender *tp_vars)
 {
-	struct task_struct *kthread;
 	struct batadv_priv *bat_priv = tp_vars->common.bat_priv;
+	struct task_struct *kthread;
 	u32 session_cookie;
 
 	kref_get(&tp_vars->common.refcount);
@@ -1046,9 +1047,9 @@ void batadv_tp_start(struct batadv_priv *bat_priv, const u8 *dst,
 		     u32 test_length, u32 *cookie)
 {
 	struct batadv_tp_sender *tp_vars;
+	u32 session_cookie;
 	u8 session_id[2];
 	u8 icmp_uid;
-	u32 session_cookie;
 
 	get_random_bytes(session_id, sizeof(session_id));
 	get_random_bytes(&icmp_uid, 1);
@@ -1215,8 +1216,8 @@ static struct batadv_tp_receiver *
 batadv_tp_list_find_receiver_session(struct batadv_priv *bat_priv, const u8 *dst,
 				     const u8 *session)
 {
-	struct batadv_tp_receiver *pos;
 	struct batadv_tp_receiver *tp_vars = NULL;
+	struct batadv_tp_receiver *pos;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(pos, &bat_priv->tp_receiver_list, common.list) {
@@ -1301,8 +1302,8 @@ static void batadv_tp_reset_receiver_timer(struct batadv_tp_receiver *tp_vars)
 static void batadv_tp_receiver_shutdown(struct timer_list *t)
 {
 	struct batadv_tp_receiver *tp_vars = timer_container_of(tp_vars, t, common.timer);
-	struct batadv_tp_unacked *un;
 	struct batadv_tp_unacked *safe;
+	struct batadv_tp_unacked *un;
 	struct batadv_priv *bat_priv;
 
 	bat_priv = tp_vars->common.bat_priv;
@@ -1357,8 +1358,8 @@ static int batadv_tp_send_ack(struct batadv_priv *bat_priv, const u8 *dst,
 	struct batadv_orig_node *orig_node;
 	struct batadv_icmp_tp_packet *icmp;
 	struct sk_buff *skb;
-	int r;
 	int ret;
+	int r;
 
 	orig_node = batadv_orig_hash_find(bat_priv, dst);
 	if (unlikely(!orig_node)) {
@@ -1535,8 +1536,8 @@ static bool batadv_tp_handle_out_of_order(struct batadv_tp_receiver *tp_vars,
 static void batadv_tp_ack_unordered(struct batadv_tp_receiver *tp_vars)
 	__must_hold(&tp_vars->ack_seqno_lock)
 {
-	struct batadv_tp_unacked *un;
 	struct batadv_tp_unacked *safe;
+	struct batadv_tp_unacked *un;
 	u32 to_ack;
 
 	/* go through the unacked packet list and possibly ACK them as
net/batman-adv/translation-table.c +90 -89

549 lines not on this page · raw message

net/batman-adv/tvlv.c +8 -8
index 066468acf20d7..5600aaf00627c 100644
@@ -72,8 +72,8 @@ static void batadv_tvlv_handler_put(struct batadv_tvlv_handler *tvlv_handler)
 static struct batadv_tvlv_handler *
 batadv_tvlv_handler_get(struct batadv_priv *bat_priv, u8 type, u8 version)
 {
-	struct batadv_tvlv_handler *tvlv_handler_tmp;
 	struct batadv_tvlv_handler *tvlv_handler = NULL;
+	struct batadv_tvlv_handler *tvlv_handler_tmp;
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(tvlv_handler_tmp,
@@ -135,8 +135,8 @@ static void batadv_tvlv_container_put(struct batadv_tvlv_container *tvlv)
 static struct batadv_tvlv_container *
 batadv_tvlv_container_get(struct batadv_priv *bat_priv, u8 type, u8 version)
 {
-	struct batadv_tvlv_container *tvlv_tmp;
 	struct batadv_tvlv_container *tvlv = NULL;
+	struct batadv_tvlv_container *tvlv_tmp;
 
 	lockdep_assert_held(&bat_priv->tvlv.container_list_lock);
 
@@ -537,13 +537,13 @@ int batadv_tvlv_containers_process(struct batadv_priv *bat_priv,
 				   struct sk_buff *skb, void *tvlv_value,
 				   u16 tvlv_value_len)
 {
+	u8 cifnotfound = BATADV_TVLV_HANDLER_OGM_CIFNOTFND;
 	u16 tvlv_value_start_len = tvlv_value_len;
 	struct batadv_tvlv_handler *tvlv_handler;
 	void *tvlv_value_start = tvlv_value;
 	struct batadv_tvlv_hdr *tvlv_hdr;
-	u16 tvlv_value_cont_len;
-	u8 cifnotfound = BATADV_TVLV_HANDLER_OGM_CIFNOTFND;
 	int ret = NET_RX_SUCCESS;
+	u16 tvlv_value_cont_len;
 
 	while ((tvlv_hdr = batadv_tvlv_hdr_next(&tvlv_value, &tvlv_value_len))) {
 		tvlv_value_cont_len = ntohs(tvlv_hdr->len);
@@ -600,8 +600,8 @@ void batadv_tvlv_ogm_receive(struct batadv_priv *bat_priv,
 			     struct batadv_ogm_packet *batadv_ogm_packet,
 			     struct batadv_orig_node *orig_node)
 {
-	void *tvlv_value;
 	u16 tvlv_value_len;
+	void *tvlv_value;
 
 	if (!batadv_ogm_packet)
 		return;
@@ -721,12 +721,12 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, const u8 *src,
 			      void *tvlv_value, u16 tvlv_value_len)
 {
 	struct batadv_unicast_tvlv_packet *unicast_tvlv_packet;
-	struct batadv_tvlv_hdr *tvlv_hdr;
+	ssize_t hdr_len = sizeof(*unicast_tvlv_packet);
 	struct batadv_orig_node *orig_node;
-	struct sk_buff *skb;
+	struct batadv_tvlv_hdr *tvlv_hdr;
 	unsigned char *tvlv_buff;
 	unsigned int tvlv_len;
-	ssize_t hdr_len = sizeof(*unicast_tvlv_packet);
+	struct sk_buff *skb;
 
 	orig_node = batadv_orig_hash_find(bat_priv, dst);
 	if (!orig_node)
Signature · 1 line
2.47.3
author maintainer
#14 lore raw

PATCH 14/15 batman-adv: tt: use atomic flag modifications

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

The flags of translation table entries are modified in various places using RMW operations like:

* read flags + add flag + store
* read flags + remove flag + store

These were done without making sure that no other context is doing a similar operation at the same time. If another context does modify the flags then it could happen that a store of the flag modifications is simply lost. This problem can usually be fixed at a later point when the flags are tried to be adjusted again.

To reduce the time the wrong flags are used, it is better to change the u16 flags type to use an atomic_t with its atomic helper to perform these adjustments.

---
 net/batman-adv/translation-table.c | 246 +++++++++++++++++++----------
 net/batman-adv/types.h             |   2 +-
 2 files changed, 167 insertions(+), 81 deletions(-)
net/batman-adv/translation-table.c +166 -80
index 96bfd5f303c1e..5295e3a59906f 100644
@@ -424,8 +424,8 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv,
 				  u8 event_flags)
 {
 	struct batadv_tt_common_entry *common = &tt_local_entry->common;
+	u8 flags = atomic_read(&common->flags) | event_flags;
 	struct batadv_tt_change_node *tt_change_node;
-	u8 flags = common->flags | event_flags;
 	struct batadv_tt_change_node *entry;
 	struct batadv_tt_change_node *safe;
 	bool del_op_requested;
@@ -624,11 +624,16 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
 	bool iif_is_wifi = false;
 	struct hlist_head *head;
 	int packet_size_max;
+	u8 new_remote_flags;
 	bool ret = false;
 	u8 remote_flags;
 	int hash_added;
 	int table_size;
 	u32 match_mark;
+	u8 clear_flags;
+	u16 old_flags;
+	u8 set_flags;
+	u16 flags;
 
 	if (ifindex != BATADV_NULL_IFINDEX)
 		in_dev = dev_get_by_index(net, ifindex);
@@ -646,7 +651,9 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
 
 	if (tt_local) {
 		tt_local->last_seen = jiffies;
-		if (tt_local->common.flags & BATADV_TT_CLIENT_PENDING) {
+
+		flags = atomic_read(&tt_local->common.flags);
+		if (flags & BATADV_TT_CLIENT_PENDING) {
 			batadv_dbg(BATADV_DBG_TT, bat_priv,
 				   "Re-adding pending client %pM (vid: %d)\n",
 				   addr, batadv_print_vid(vid));
@@ -655,11 +662,11 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
 			 * this orig_interval. Since it popped up again, the
 			 * flag can be reset like it was never enqueued
 			 */
-			tt_local->common.flags &= ~BATADV_TT_CLIENT_PENDING;
+			atomic_andnot(BATADV_TT_CLIENT_PENDING, &tt_local->common.flags);
 			goto add_event;
 		}
 
-		if (tt_local->common.flags & BATADV_TT_CLIENT_ROAM) {
+		if (flags & BATADV_TT_CLIENT_ROAM) {
 			batadv_dbg(BATADV_DBG_TT, bat_priv,
 				   "Roaming client %pM (vid: %d) came back to its original location\n",
 				   addr, batadv_print_vid(vid));
@@ -668,7 +675,7 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
 			 * that the client popped up again at its original
 			 * location such flag can be unset
 			 */
-			tt_local->common.flags &= ~BATADV_TT_CLIENT_ROAM;
+			atomic_andnot(BATADV_TT_CLIENT_ROAM, &tt_local->common.flags);
 			roamed_back = true;
 		}
 		goto check_roaming;
@@ -705,26 +712,29 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
 		   addr, batadv_print_vid(vid),
 		   (u8)atomic_read(&bat_priv->tt.vn));
 
+	tt_local->common.vid = vid;
+	kref_init(&tt_local->common.refcount);
+	tt_local->last_seen = jiffies;
+	tt_local->common.added_at = tt_local->last_seen;
+	tt_local->vlan = vlan;
+
 	ether_addr_copy(tt_local->common.addr, addr);
 	/* The local entry has to be marked as NEW to avoid to send it in
 	 * a full table response going out before the next ttvn increment
 	 * (consistency check)
 	 */
-	tt_local->common.flags = BATADV_TT_CLIENT_NEW;
-	tt_local->common.vid = vid;
+	flags = BATADV_TT_CLIENT_NEW;
 	if (iif_is_wifi)
-		tt_local->common.flags |= BATADV_TT_CLIENT_WIFI;
-	kref_init(&tt_local->common.refcount);
-	tt_local->last_seen = jiffies;
-	tt_local->common.added_at = tt_local->last_seen;
-	tt_local->vlan = vlan;
+		flags |= BATADV_TT_CLIENT_WIFI;
 
 	/* the batman interface mac and multicast addresses should never be
 	 * purged
 	 */
 	if (batadv_compare_eth(addr, mesh_iface->dev_addr) ||
 	    is_multicast_ether_addr(addr))
-		tt_local->common.flags |= BATADV_TT_CLIENT_NOPURGE;
+		flags |= BATADV_TT_CLIENT_NOPURGE;
+
+	atomic_set(&tt_local->common.flags, flags);
 
 	kref_get(&tt_local->common.refcount);
 	hash_added = batadv_hash_add(bat_priv->tt.local_hash, batadv_compare_tt,
@@ -742,9 +752,17 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
 
 check_roaming:
 	/* Check whether it is a roaming, but don't do anything if the roaming
-	 * process has already been handled
+	 * process has already been handled. The ROAM flag is claimed via an
+	 * atomic test-and-set to make sure that only a single context handles
+	 * the advertisement for a client
 	 */
-	if (tt_global && !(tt_global->common.flags & BATADV_TT_CLIENT_ROAM)) {
+	old_flags = BATADV_TT_CLIENT_ROAM;
+	if (tt_global &&
+	    !(atomic_read(&tt_global->common.flags) & BATADV_TT_CLIENT_ROAM))
+		old_flags = atomic_fetch_or(BATADV_TT_CLIENT_ROAM,
+					    &tt_global->common.flags);
+
+	if (tt_global && !(old_flags & BATADV_TT_CLIENT_ROAM)) {
 		/* These node are probably going to update their tt table */
 		head = &tt_global->orig_list;
 		rcu_read_lock();
@@ -754,27 +772,30 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
 					     orig_entry->orig_node);
 		}
 		rcu_read_unlock();
-		if (roamed_back) {
-			batadv_tt_global_free(bat_priv, tt_global,
-					      "Roaming canceled");
-		} else {
-			/* The global entry has to be marked as ROAMING and
+
+		if (!roamed_back) {
+			/* The global entry was marked as ROAMING and
 			 * has to be kept for consistency purpose
 			 */
-			tt_global->common.flags |= BATADV_TT_CLIENT_ROAM;
 			tt_global->roam_at = jiffies;
 		}
 	}
 
+	/* clean up independent of the roaming advertisement handler */
+	if (tt_global && roamed_back)
+		batadv_tt_global_free(bat_priv, tt_global, "Roaming canceled");
+
 	/* store the current remote flags before altering them. This helps
 	 * understanding is flags are changing or not
 	 */
-	remote_flags = tt_local->common.flags & BATADV_TT_REMOTE_MASK;
+	remote_flags = atomic_read(&tt_local->common.flags) & BATADV_TT_REMOTE_MASK;
+
+	new_remote_flags = remote_flags;
 
 	if (iif_is_wifi)
-		tt_local->common.flags |= BATADV_TT_CLIENT_WIFI;
+		new_remote_flags |= BATADV_TT_CLIENT_WIFI;
 	else
-		tt_local->common.flags &= ~BATADV_TT_CLIENT_WIFI;
+		new_remote_flags &= ~BATADV_TT_CLIENT_WIFI;
 
 	/* check the mark in the skb: if it's equal to the configured
 	 * isolation_mark, it means the packet is coming from an isolated
@@ -783,14 +804,22 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
 	match_mark = (mark & bat_priv->isolation_mark_mask);
 	if (bat_priv->isolation_mark_mask &&
 	    match_mark == bat_priv->isolation_mark)
-		tt_local->common.flags |= BATADV_TT_CLIENT_ISOLA;
+		new_remote_flags |= BATADV_TT_CLIENT_ISOLA;
 	else
-		tt_local->common.flags &= ~BATADV_TT_CLIENT_ISOLA;
+		new_remote_flags &= ~BATADV_TT_CLIENT_ISOLA;
+
+	set_flags = new_remote_flags & ~remote_flags;
+	if (set_flags)
+		atomic_or(set_flags, &tt_local->common.flags);
+
+	clear_flags = remote_flags & ~new_remote_flags;
+	if (clear_flags)
+		atomic_andnot(clear_flags, &tt_local->common.flags);
 
 	/* if any "dynamic" flag has been modified, resend an ADD event for this
 	 * entry so that all the nodes can get the new flags
 	 */
-	if (remote_flags ^ (tt_local->common.flags & BATADV_TT_REMOTE_MASK))
+	if (set_flags || clear_flags)
 		batadv_tt_local_event(bat_priv, tt_local, BATADV_NO_FLAGS);
 
 	ret = true;
@@ -1115,10 +1144,12 @@ batadv_tt_local_dump_entry(struct sk_buff *msg, u32 portid,
 	struct batadv_meshif_vlan *vlan;
 	unsigned int last_seen_msecs;
 	void *hdr;
+	u16 flags;
 	u32 crc;
 
 	local = container_of(common, struct batadv_tt_local_entry, common);
 	last_seen_msecs = jiffies_to_msecs(jiffies - local->last_seen);
+	flags = atomic_read(&common->flags);
 
 	vlan = batadv_meshif_vlan_get(bat_priv, common->vid);
 	if (!vlan)
@@ -1139,10 +1170,10 @@ batadv_tt_local_dump_entry(struct sk_buff *msg, u32 portid,
 	if (nla_put(msg, BATADV_ATTR_TT_ADDRESS, ETH_ALEN, common->addr) ||
 	    nla_put_u32(msg, BATADV_ATTR_TT_CRC32, crc) ||
 	    nla_put_u16(msg, BATADV_ATTR_TT_VID, common->vid) ||
-	    nla_put_u32(msg, BATADV_ATTR_TT_FLAGS, common->flags))
+	    nla_put_u32(msg, BATADV_ATTR_TT_FLAGS, flags))
 		goto nla_put_failure;
 
-	if (!(common->flags & BATADV_TT_CLIENT_NOPURGE) &&
+	if (!(flags & BATADV_TT_CLIENT_NOPURGE) &&
 	    nla_put_u32(msg, BATADV_ATTR_LAST_SEEN_MSECS, last_seen_msecs))
 		goto nla_put_failure;
 
@@ -1270,7 +1301,7 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
 	 * to be kept in the table in order to send it in a full table
 	 * response issued before the net ttvn increment (consistency check)
 	 */
-	tt_local_entry->common.flags |= BATADV_TT_CLIENT_PENDING;
+	atomic_or(BATADV_TT_CLIENT_PENDING, &tt_local_entry->common.flags);
 
 	batadv_dbg(BATADV_DBG_TT, bat_priv,
 		   "Local tt entry (%pM, vid: %d) pending to be removed: %s\n",
@@ -1296,13 +1327,14 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr,
 	struct batadv_tt_local_entry *tt_local_entry;
 	struct hlist_node *tt_removed_node;
 	u16 curr_flags = BATADV_NO_FLAGS;
+	u16 old_flags;
 	u16 flags;
 
 	tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr, vid);
 	if (!tt_local_entry)
 		goto out;
 
-	curr_flags = tt_local_entry->common.flags;
+	curr_flags = atomic_read(&tt_local_entry->common.flags);
 
 	flags = BATADV_TT_CLIENT_DEL;
 	/* if this global entry addition is due to a roaming, the node has to
@@ -1312,10 +1344,12 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr,
 	if (roaming) {
 		flags |= BATADV_TT_CLIENT_ROAM;
 		/* mark the local client as ROAMed */
-		tt_local_entry->common.flags |= BATADV_TT_CLIENT_ROAM;
+		atomic_or(BATADV_TT_CLIENT_ROAM, &tt_local_entry->common.flags);
 	}
 
-	if (!(tt_local_entry->common.flags & BATADV_TT_CLIENT_NEW)) {
+	old_flags = atomic_fetch_andnot(BATADV_TT_CLIENT_NEW,
+					&tt_local_entry->common.flags);
+	if (!(old_flags & BATADV_TT_CLIENT_NEW)) {
 		batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags,
 					    message);
 		goto out;
@@ -1358,17 +1392,21 @@ static void batadv_tt_local_purge_list(struct batadv_priv *bat_priv,
 	struct batadv_tt_common_entry *tt_common_entry;
 	struct batadv_tt_local_entry *tt_local_entry;
 	struct hlist_node *node_tmp;
+	u16 flags;
 
 	hlist_for_each_entry_safe(tt_common_entry, node_tmp, head,
 				  hash_entry) {
 		tt_local_entry = container_of(tt_common_entry,
 					      struct batadv_tt_local_entry,
 					      common);
-		if (tt_local_entry->common.flags & BATADV_TT_CLIENT_NOPURGE)
+
+		flags = atomic_read(&tt_local_entry->common.flags);
+
+		if (flags & BATADV_TT_CLIENT_NOPURGE)
 			continue;
 
 		/* entry already marked for deletion */
-		if (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING)
+		if (flags & BATADV_TT_CLIENT_PENDING)
 			continue;
 
 		if (!batadv_has_timed_out(tt_local_entry->last_seen, timeout))
@@ -1574,6 +1612,8 @@ batadv_tt_global_sync_flags(struct batadv_tt_global_entry *tt_global)
 	struct batadv_tt_orig_list_entry *orig_entry;
 	const struct hlist_head *head;
 	u16 flags = BATADV_NO_FLAGS;
+	int new_flags;
+	int old_flags;
 
 	rcu_read_lock();
 	head = &tt_global->orig_list;
@@ -1581,8 +1621,15 @@ batadv_tt_global_sync_flags(struct batadv_tt_global_entry *tt_global)
 		flags |= orig_entry->flags;
 	rcu_read_unlock();
 
-	flags |= tt_global->common.flags & (~BATADV_TT_SYNC_MASK);
-	tt_global->common.flags = flags;
+	/* replace the sync flags without dropping concurrent modifications of
+	 * the non-sync flags
+	 */
+	old_flags = atomic_read(&tt_global->common.flags);
+	do {
+		new_flags = (old_flags & ~BATADV_TT_SYNC_MASK) | flags;
+		if (new_flags == old_flags)
+			break;
+	} while (!atomic_try_cmpxchg(&tt_global->common.flags, &old_flags, new_flags));
 }
 
 /**
@@ -1665,7 +1712,9 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
 	struct batadv_tt_common_entry *common;
 	bool ret = false;
 	u16 local_flags;
+	u16 clear_flags;
 	int hash_added;
+	u16 old_flags;
 
 	/* ignore global entries from backbone nodes */
 	if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig, vid))
@@ -1679,7 +1728,7 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
 	 * table
 	 */
 	if ((flags & BATADV_TT_CLIENT_TEMP) && tt_local_entry &&
-	    !(tt_local_entry->common.flags & BATADV_TT_CLIENT_NEW))
+	    !(atomic_read(&tt_local_entry->common.flags) & BATADV_TT_CLIENT_NEW))
 		goto out;
 
 	if (!tt_global_entry) {
@@ -1693,7 +1742,7 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
 		common->vid = vid;
 
 		if (!is_multicast_ether_addr(common->addr))
-			common->flags = flags & (~BATADV_TT_SYNC_MASK);
+			atomic_set(&common->flags, flags & (~BATADV_TT_SYNC_MASK));
 
 		tt_global_entry->roam_at = 0;
 		/* node must store current time in case of roaming. This is
@@ -1722,6 +1771,8 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
 		}
 	} else {
 		common = &tt_global_entry->common;
+		clear_flags = 0;
+
 		/* If there is already a global entry, we can use this one for
 		 * our processing.
 		 * But if we are trying to add a temporary client then here are
@@ -1733,7 +1784,7 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
 		 *    originator list and add the new one orig_entry
 		 */
 		if (flags & BATADV_TT_CLIENT_TEMP) {
-			if (!(common->flags & BATADV_TT_CLIENT_TEMP))
+			if (!(atomic_read(&common->flags) & BATADV_TT_CLIENT_TEMP))
 				goto out;
 			if (batadv_tt_global_entry_has_orig(tt_global_entry,
 							    orig_node, NULL))
@@ -1742,24 +1793,26 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
 			goto add_orig_entry;
 		}
 
+		/* the change can carry possible "attribute" flags like the
+		 * TT_CLIENT_TEMP, therefore they have to be copied in the
+		 * client entry
+		 */
+		if (!is_multicast_ether_addr(common->addr))
+			atomic_or(flags & (~BATADV_TT_SYNC_MASK), &common->flags);
+
+		old_flags = atomic_read(&common->flags);
+
 		/* if the client was temporary added before receiving the first
 		 * OGM announcing it, we have to clear the TEMP flag. Also,
 		 * remove the previous temporary orig node and re-add it
 		 * if required. If the orig entry changed, the new one which
 		 * is a non-temporary entry is preferred.
 		 */
-		if (common->flags & BATADV_TT_CLIENT_TEMP) {
+		if (old_flags & BATADV_TT_CLIENT_TEMP) {
 			batadv_tt_global_del_orig_list(tt_global_entry);
-			common->flags &= ~BATADV_TT_CLIENT_TEMP;
+			clear_flags |= BATADV_TT_CLIENT_TEMP;
 		}
 
-		/* the change can carry possible "attribute" flags like the
-		 * TT_CLIENT_TEMP, therefore they have to be copied in the
-		 * client entry
-		 */
-		if (!is_multicast_ether_addr(common->addr))
-			common->flags |= flags & (~BATADV_TT_SYNC_MASK);
-
 		/* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
 		 * one originator left in the list and we previously received a
 		 * delete + roaming change for this originator.
@@ -1767,11 +1820,14 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
 		 * We should first delete the old originator before adding the
 		 * new one.
 		 */
-		if (common->flags & BATADV_TT_CLIENT_ROAM) {
+		if (old_flags & BATADV_TT_CLIENT_ROAM) {
 			batadv_tt_global_del_orig_list(tt_global_entry);
-			common->flags &= ~BATADV_TT_CLIENT_ROAM;
+			clear_flags |= BATADV_TT_CLIENT_ROAM;
 			tt_global_entry->roam_at = 0;
 		}
+
+		if (clear_flags)
+			atomic_andnot(clear_flags, &common->flags);
 	}
 add_orig_entry:
 	/* add the new orig_entry (if needed) or update it */
@@ -1795,13 +1851,15 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
 	local_flags = batadv_tt_local_remove(bat_priv, tt_addr, vid,
 					     "global tt received",
 					     flags & BATADV_TT_CLIENT_ROAM);
-	tt_global_entry->common.flags |= local_flags & BATADV_TT_CLIENT_WIFI;
+	if (local_flags & BATADV_TT_CLIENT_WIFI)
+		atomic_or(local_flags & BATADV_TT_CLIENT_WIFI,
+			  &tt_global_entry->common.flags);
 
 	if (!(flags & BATADV_TT_CLIENT_ROAM))
 		/* this is a normal global add. Therefore the client is not in a
 		 * roaming state anymore.
 		 */
-		tt_global_entry->common.flags &= ~BATADV_TT_CLIENT_ROAM;
+		atomic_andnot(BATADV_TT_CLIENT_ROAM, &tt_global_entry->common.flags);
 
 out:
 	batadv_tt_global_entry_put(tt_global_entry);
@@ -1871,7 +1929,7 @@ batadv_tt_global_dump_subentry(struct sk_buff *msg, u32 portid, u32 seq,
 			       struct batadv_tt_orig_list_entry *orig,
 			       bool best)
 {
-	u16 flags = (common->flags & (~BATADV_TT_SYNC_MASK)) | orig->flags;
+	u16 flags = (atomic_read(&common->flags) & (~BATADV_TT_SYNC_MASK)) | orig->flags;
 	struct batadv_orig_node_vlan *vlan;
 	u8 last_ttvn;
 	void *hdr;
@@ -2180,7 +2238,7 @@ batadv_tt_global_del_roaming(struct batadv_priv *bat_priv,
 
 	if (last_entry) {
 		/* its the last one, mark for roaming. */
-		tt_global_entry->common.flags |= BATADV_TT_CLIENT_ROAM;
+		atomic_or(BATADV_TT_CLIENT_ROAM, &tt_global_entry->common.flags);
 		tt_global_entry->roam_at = jiffies;
 	} else {
 		/* there is another entry, we can simply delete this
@@ -2328,15 +2386,16 @@ static bool batadv_tt_global_to_purge(struct batadv_tt_global_entry *tt_global,
 {
 	unsigned long roam_timeout = BATADV_TT_CLIENT_ROAM_TIMEOUT;
 	unsigned long temp_timeout = BATADV_TT_CLIENT_TEMP_TIMEOUT;
+	u16 flags = atomic_read(&tt_global->common.flags);
 	bool purge = false;
 
-	if ((tt_global->common.flags & BATADV_TT_CLIENT_ROAM) &&
+	if ((flags & BATADV_TT_CLIENT_ROAM) &&
 	    batadv_has_timed_out(tt_global->roam_at, roam_timeout)) {
 		purge = true;
 		*msg = "Roaming timeout\n";
 	}
 
-	if ((tt_global->common.flags & BATADV_TT_CLIENT_TEMP) &&
+	if ((flags & BATADV_TT_CLIENT_TEMP) &&
 	    batadv_has_timed_out(tt_global->common.added_at, temp_timeout)) {
 		purge = true;
 		*msg = "Temporary client timeout\n";
@@ -2448,13 +2507,16 @@ static bool
 _batadv_is_ap_isolated(struct batadv_tt_local_entry *tt_local_entry,
 		       struct batadv_tt_global_entry *tt_global_entry)
 {
-	if (tt_local_entry->common.flags & BATADV_TT_CLIENT_WIFI &&
-	    tt_global_entry->common.flags & BATADV_TT_CLIENT_WIFI)
+	u16 global_flags = atomic_read(&tt_global_entry->common.flags);
+	u16 local_flags = atomic_read(&tt_local_entry->common.flags);
+
+	if (local_flags & BATADV_TT_CLIENT_WIFI &&
+	    global_flags & BATADV_TT_CLIENT_WIFI)
 		return true;
 
 	/* check if the two clients are marked as isolated */
-	if (tt_local_entry->common.flags & BATADV_TT_CLIENT_ISOLA &&
-	    tt_global_entry->common.flags & BATADV_TT_CLIENT_ISOLA)
+	if (local_flags & BATADV_TT_CLIENT_ISOLA &&
+	    global_flags & BATADV_TT_CLIENT_ISOLA)
 		return true;
 
 	return false;
@@ -2487,7 +2549,7 @@ struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv,
 	if (src && batadv_vlan_ap_isola_get(bat_priv, vid)) {
 		tt_local_entry = batadv_tt_local_hash_find(bat_priv, src, vid);
 		if (!tt_local_entry ||
-		    (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING))
+		    (atomic_read(&tt_local_entry->common.flags) & BATADV_TT_CLIENT_PENDING))
 			goto out;
 	}
 
@@ -2551,6 +2613,7 @@ static u32 batadv_tt_global_crc(struct batadv_priv *bat_priv,
 	struct batadv_tt_common_entry *tt_common;
 	struct batadv_tt_global_entry *tt_global;
 	struct hlist_head *head;
+	u16 entry_flags;
 	__be16 tmp_vid;
 	u32 crc_tmp;
 	u32 crc = 0;
@@ -2571,18 +2634,20 @@ static u32 batadv_tt_global_crc(struct batadv_priv *bat_priv,
 			if (tt_common->vid != vid)
 				continue;
 
+			entry_flags = atomic_read(&tt_common->flags);
+
 			/* Roaming clients are in the global table for
 			 * consistency only. They don't have to be
 			 * taken into account while computing the
 			 * global crc
 			 */
-			if (tt_common->flags & BATADV_TT_CLIENT_ROAM)
+			if (entry_flags & BATADV_TT_CLIENT_ROAM)
 				continue;
 			/* Temporary clients have not been announced yet, so
 			 * they have to be skipped while computing the global
 			 * crc
 			 */
-			if (tt_common->flags & BATADV_TT_CLIENT_TEMP)
+			if (entry_flags & BATADV_TT_CLIENT_TEMP)
 				continue;
 
 			/* find out if this global entry is announced by this
@@ -2631,6 +2696,7 @@ static u32 batadv_tt_local_crc(struct batadv_priv *bat_priv,
 	struct batadv_hashtable *hash = bat_priv->tt.local_hash;
 	struct batadv_tt_common_entry *tt_common;
 	struct hlist_head *head;
+	u16 entry_flags;
 	__be16 tmp_vid;
 	u32 crc_tmp;
 	u32 crc = 0;
@@ -2648,10 +2714,12 @@ static u32 batadv_tt_local_crc(struct batadv_priv *bat_priv,
 			if (tt_common->vid != vid)
 				continue;
 
+			entry_flags = atomic_read(&tt_common->flags);
+
 			/* not yet committed clients have not to be taken into
 			 * account while computing the CRC
 			 */
-			if (tt_common->flags & BATADV_TT_CLIENT_NEW)
+			if (entry_flags & BATADV_TT_CLIENT_NEW)
 				continue;
 
 			/* use network order to read the VID: this ensures that
@@ -2663,7 +2731,7 @@ static u32 batadv_tt_local_crc(struct batadv_priv *bat_priv,
 			/* compute the CRC on flags that have to be kept in sync
 			 * among nodes
 			 */
-			flags = tt_common->flags & BATADV_TT_SYNC_MASK;
+			flags = entry_flags & BATADV_TT_SYNC_MASK;
 			crc_tmp = crc32c(crc_tmp, &flags, sizeof(flags));
 
 			crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN);
@@ -2826,12 +2894,13 @@ static bool batadv_tt_local_valid(const void *entry_ptr,
 				  u8 *flags)
 {
 	const struct batadv_tt_common_entry *tt_common_entry = entry_ptr;
+	u16 entry_flags = atomic_read(&tt_common_entry->flags);
 
-	if (tt_common_entry->flags & BATADV_TT_CLIENT_NEW)
+	if (entry_flags & BATADV_TT_CLIENT_NEW)
 		return false;
 
 	if (flags)
-		*flags = tt_common_entry->flags;
+		*flags = entry_flags;
 
 	return true;
 }
@@ -2855,9 +2924,10 @@ static bool batadv_tt_global_valid(const void *entry_ptr,
 	const struct batadv_tt_common_entry *tt_common_entry = entry_ptr;
 	const struct batadv_tt_global_entry *tt_global_entry;
 	const struct batadv_orig_node *orig_node = data_ptr;
+	u16 entry_flags;
 
-	if (tt_common_entry->flags & BATADV_TT_CLIENT_ROAM ||
-	    tt_common_entry->flags & BATADV_TT_CLIENT_TEMP)
+	entry_flags = atomic_read(&tt_common_entry->flags);
+	if (entry_flags & (BATADV_TT_CLIENT_ROAM | BATADV_TT_CLIENT_TEMP))
 		return false;
 
 	tt_global_entry = container_of(tt_common_entry,
@@ -3512,6 +3582,7 @@ bool batadv_is_my_client(struct batadv_priv *bat_priv, const u8 *addr,
 {
 	struct batadv_tt_local_entry *tt_local_entry;
 	bool ret = false;
+	u16 entry_flags;
 
 	tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr, vid);
 	if (!tt_local_entry)
@@ -3519,8 +3590,8 @@ bool batadv_is_my_client(struct batadv_priv *bat_priv, const u8 *addr,
 	/* Check if the client has been logically deleted (but is kept for
 	 * consistency purpose)
 	 */
-	if ((tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING) ||
-	    (tt_local_entry->common.flags & BATADV_TT_CLIENT_ROAM))
+	entry_flags = atomic_read(&tt_local_entry->common.flags);
+	if (entry_flags & (BATADV_TT_CLIENT_PENDING | BATADV_TT_CLIENT_ROAM))
 		goto out;
 	ret = true;
 out:
@@ -3795,6 +3866,8 @@ static void batadv_tt_local_set_flags(struct batadv_priv *bat_priv, u16 flags,
 	struct batadv_hashtable *hash = bat_priv->tt.local_hash;
 	struct batadv_tt_common_entry *tt_common_entry;
 	struct hlist_head *head;
+	atomic_t *entry_flags;
+	u16 old_flags;
 	u32 i;
 
 	if (!hash)
@@ -3806,14 +3879,27 @@ static void batadv_tt_local_set_flags(struct batadv_priv *bat_priv, u16 flags,
 		rcu_read_lock();
 		hlist_for_each_entry_rcu(tt_common_entry,
 					 head, hash_entry) {
+			entry_flags = &tt_common_entry->flags;
+			old_flags = atomic_read(entry_flags);
+
+			/* the old_flags value of the atomic test-and-
+			 * set/clear decides whether this entry counts as
+			 * changed.
+			 */
 			if (enable) {
-				if ((tt_common_entry->flags & flags) == flags)
+				if ((old_flags & flags) == flags)
+					continue;
+
+				old_flags = atomic_fetch_or(flags, entry_flags);
+				if ((old_flags & flags) == flags)
 					continue;
-				tt_common_entry->flags |= flags;
 			} else {
-				if (!(tt_common_entry->flags & flags))
+				if (!(old_flags & flags))
+					continue;
+
+				old_flags = atomic_fetch_andnot(flags, entry_flags);
+				if (!(old_flags & flags))
 					continue;
-				tt_common_entry->flags &= ~flags;
 			}
 
 			if (!count)
@@ -3854,7 +3940,7 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)
 		spin_lock_bh(list_lock);
 		hlist_for_each_entry_safe(tt_common, node_tmp, head,
 					  hash_entry) {
-			if (!(tt_common->flags & BATADV_TT_CLIENT_PENDING))
+			if (!(atomic_read(&tt_common->flags) & BATADV_TT_CLIENT_PENDING))
 				continue;
 
 			batadv_dbg(BATADV_DBG_TT, bat_priv,
@@ -4067,7 +4153,7 @@ bool batadv_tt_global_client_is_roaming(struct batadv_priv *bat_priv,
 	if (!tt_global_entry)
 		goto out;
 
-	ret = tt_global_entry->common.flags & BATADV_TT_CLIENT_ROAM;
+	ret = atomic_read(&tt_global_entry->common.flags) & BATADV_TT_CLIENT_ROAM;
 	batadv_tt_global_entry_put(tt_global_entry);
 out:
 	return ret;
@@ -4093,7 +4179,7 @@ bool batadv_tt_local_client_is_roaming(struct batadv_priv *bat_priv,
 	if (!tt_local_entry)
 		goto out;
 
-	ret = tt_local_entry->common.flags & BATADV_TT_CLIENT_ROAM;
+	ret = atomic_read(&tt_local_entry->common.flags) & BATADV_TT_CLIENT_ROAM;
 	batadv_tt_local_entry_put(tt_local_entry);
 out:
 	return ret;
@@ -4403,7 +4489,7 @@ bool batadv_tt_global_is_isolated(struct batadv_priv *bat_priv,
 	if (!tt)
 		return false;
 
-	ret = tt->common.flags & BATADV_TT_CLIENT_ISOLA;
+	ret = atomic_read(&tt->common.flags) & BATADV_TT_CLIENT_ISOLA;
 
 	batadv_tt_global_entry_put(tt);
 
net/batman-adv/types.h +1 -1
index 9bdc5a3e799e2..d6e15d467a8f7 100644
@@ -1852,7 +1852,7 @@ struct batadv_tt_common_entry {
 	struct hlist_node hash_entry;
 
 	/** @flags: various state handling flags (see batadv_tt_client_flags) */
-	u16 flags;
+	atomic_t flags;
 
 	/** @added_at: timestamp used for purging stale tt common entries */
 	unsigned long added_at;
Signature · 1 line
2.47.3
author maintainer
#15 lore raw

PATCH 15/15 batman-adv: tt: simplify NEW flag transition code

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

The function batadv_tt_local_set_flags() implements support for various flags and to set/unset them. It is also possible to decide whether this change should increase the TT size or not.

But in reality, this function is only used to transition tt local entries from the NEW state and count these entries. Remove the rest of the code to simplify the function.

---
 net/batman-adv/translation-table.c | 37 ++++++++----------------------
 1 file changed, 9 insertions(+), 28 deletions(-)
net/batman-adv/translation-table.c +9 -28
index 5295e3a59906f..5e10e6bb7bd6a 100644
@@ -3853,15 +3853,11 @@ void batadv_tt_free(struct batadv_priv *bat_priv)
 }
 
 /**
- * batadv_tt_local_set_flags() - set or unset the specified flags on the local
- *  table and possibly count them in the TT size
+ * batadv_tt_local_transition_new() - unset the NEW flag on the local
+ *  table and count them in the TT size
  * @bat_priv: the bat priv with all the mesh interface information
- * @flags: the flag to switch
- * @enable: whether to set or unset the flag
- * @count: whether to increase the TT size by the number of changed entries
  */
-static void batadv_tt_local_set_flags(struct batadv_priv *bat_priv, u16 flags,
-				      bool enable, bool count)
+static void batadv_tt_local_transition_new(struct batadv_priv *bat_priv)
 {
 	struct batadv_hashtable *hash = bat_priv->tt.local_hash;
 	struct batadv_tt_common_entry *tt_common_entry;
@@ -3882,27 +3878,12 @@ static void batadv_tt_local_set_flags(struct batadv_priv *bat_priv, u16 flags,
 			entry_flags = &tt_common_entry->flags;
 			old_flags = atomic_read(entry_flags);
 
-			/* the old_flags value of the atomic test-and-
-			 * set/clear decides whether this entry counts as
-			 * changed.
-			 */
-			if (enable) {
-				if ((old_flags & flags) == flags)
-					continue;
-
-				old_flags = atomic_fetch_or(flags, entry_flags);
-				if ((old_flags & flags) == flags)
-					continue;
-			} else {
-				if (!(old_flags & flags))
-					continue;
-
-				old_flags = atomic_fetch_andnot(flags, entry_flags);
-				if (!(old_flags & flags))
-					continue;
-			}
+			if (!(old_flags & BATADV_TT_CLIENT_NEW))
+				continue;
 
-			if (!count)
+			old_flags = atomic_fetch_andnot(BATADV_TT_CLIENT_NEW,
+							entry_flags);
+			if (!(old_flags & BATADV_TT_CLIENT_NEW))
 				continue;
 
 			batadv_tt_local_size_inc(bat_priv,
@@ -3977,7 +3958,7 @@ static void batadv_tt_local_commit_changes_nolock(struct batadv_priv *bat_priv)
 		return;
 	}
 
-	batadv_tt_local_set_flags(bat_priv, BATADV_TT_CLIENT_NEW, false, true);
+	batadv_tt_local_transition_new(bat_priv);
 
 	batadv_tt_local_purge_pending_clients(bat_priv);
 	batadv_tt_local_update_crc(bat_priv);
Signature · 1 line
2.47.3
maintainer
#16 lore raw
In reply to Simon Wunderlich
Quoted 1 line · On Tue, 28 Jul 2026 15:39:03 +0200 Simon Wunderlich wrote:

here is a minor bugfix/cleanup pull request of batman-adv to go into net-next.

Can you look thru the Sashiko comments here (especially Medium+ severity)?

https://netdev-ai.bots.linux.dev/sashiko/#/patchset/[email protected]

At a glance patch 14 does not inspire confidence. I guess patch 15 removes the worst part - but is there a real reason not to use locking?

maintainer
#17 lore raw
Quoted 7 lines · On Tuesday, 4 August 2026 04:19:20 CEST Jakub Kicinski wrote:
Quoted 1 line · On Tue, 28 Jul 2026 15:39:03 +0200 Simon Wunderlich wrote:

here is a minor bugfix/cleanup pull request of batman-adv to go into net-next.

Can you look thru the Sashiko comments here (especially Medium+ severity)?

https://netdev-ai.bots.linux.dev/sashiko/#/patchset/[email protected]

https://patchwork.open-mesh.org/bundle/ecsv/pu-main/

We were just waiting for a verdict. I am guessing it it a "no, will not merge", correct?

Quoted 2 lines

At a glance patch 14 does not inspire confidence. I guess patch 15 removes the worst part - but is there a real reason not to use locking?

In its current state, you would need spinlocks over larger (op-count) portions of code in the hot-path. And since it it nearly impossible to get feedback from the TT author/maintainer, I am not willing to invest time in a total rewrite of the TT infrastructure.

Regards,
Sven

maintainer
#18 lore raw
Quoted 7 lines · Sven Eckelmann
Quoted 6 lines · On Tuesday, 4 August 2026 04:19:20 CEST Jakub Kicinski wrote:
Quoted 1 line · On Tue, 28 Jul 2026 15:39:03 +0200 Simon Wunderlich wrote:

here is a minor bugfix/cleanup pull request of batman-adv to go into net-next.

Can you look thru the Sashiko comments here (especially Medium+ severity)?

Quoted 6 lines
Quoted 1 line

https://netdev-ai.bots.linux.dev/sashiko/#/patchset/[email protected]

https://patchwork.open-mesh.org/bundle/ecsv/pu-main/

We were just waiting for a verdict. I am guessing it it a "no, will not merge", correct?

Please be aware of net-next commit c82ff94592fb: the expectation is that submitters reply proactively to AI review comments.

Specifically it would be helpful an evaluation of how critical is problem reported and if it could safely addressed with a follow-up.

Quoted 5 lines
Quoted 2 lines

At a glance patch 14 does not inspire confidence. I guess patch 15 removes the worst part - but is there a real reason not to use locking?

In its current state, you would need spinlocks over larger (op-count) portions of code in the hot-path.

I'm not sure if the following is well known/helps, but performance wise slightly lager critical regions are usually preferable to a larger number of atomic operations,

/P

maintainer
#19 lore raw
Quoted 6 lines · On Tuesday, 4 August 2026 15:16:54 CEST Paolo Abeni wrote:

Please be aware of net-next commit c82ff94592fb: the expectation is that submitters reply proactively to AI review comments.

Specifically it would be helpful an evaluation of how critical is problem reported and if it could safely addressed with a follow-up.

You sashiko instance is not sending out mails and AFAIK, there is no mbox download button for the Sashiko "replies". It is therefore a little bit inconvenient to reply to something which is just on some website.

I just wanted to go through all the accusations in
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260805143200.722098-1-sw%40simonwunderlich.de

Regards,
Sven

maintainer
#20 lore raw
In reply to Simon Wunderlich
Quoted 3 lines · Simon Wunderlich

Dear net maintainers,

here is a minor bugfix/cleanup pull request of batman-adv to go into net-next.

Note that it's preferred to avoid fixes and stable tags for changes targeting the net-next tree. If the fixes are really minor, both could possibly safely dropped. If there is some real problem behind, such changes should instead target the net tree.

Can you easily rebase your tree and adjust the PR vs the above?

Also note that sashiko nipa has something to say, but that could be a follow-up, AFAICS:

https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260728133918.643267-1-sw%40simonwunderlich.de

/P

maintainer
#21 lore raw
Quoted 11 lines · On Tuesday, 4 August 2026 12:19:13 CEST Paolo Abeni wrote:
Quoted 3 lines · Simon Wunderlich

Dear net maintainers,

here is a minor bugfix/cleanup pull request of batman-adv to go into net-next.

Note that it's preferred to avoid fixes and stable tags for changes targeting the net-next tree. If the fixes are really minor, both could possibly safely dropped. If there is some real problem behind, such changes should instead target the net tree.

Can you easily rebase your tree and adjust the PR vs the above?

I have a different statement from Linus:
https://lore.kernel.org/lkml/CAHk-=wjt1NiKOdyAMz_DT7NmZ++SizPOhRSi492ukdTnpDzHQw@mail.gmail.com/T/#u

This is why we started to not send out net.git fixes PRs for things which aren't highly critical or for Linus' "just merged for this release commits" late in the development process.

Regards,
Sven

maintainer
#22 lore raw
Quoted 11 lines · Sven Eckelmann
Quoted 10 lines · On Tuesday, 4 August 2026 12:19:13 CEST Paolo Abeni wrote:
Quoted 3 lines · Simon Wunderlich

Dear net maintainers,

here is a minor bugfix/cleanup pull request of batman-adv to go into net-next.

Note that it's preferred to avoid fixes and stable tags for changes targeting the net-next tree. If the fixes are really minor, both could possibly safely dropped. If there is some real problem behind, such changes should instead target the net tree.

Quoted 8 lines
Quoted 1 line

Can you easily rebase your tree and adjust the PR vs the above?

I have a different statement from Linus:
https://lore.kernel.org/lkml/CAHk-=wjt1NiKOdyAMz_DT7NmZ++SizPOhRSi492ukdTnpDzHQw@mail.gmail.com/T/#u

This is why we started to not send out net.git fixes PRs for things which aren't highly critical or for Linus' "just merged for this release commits" late in the development process.

I actually think netdev preference is consistent with Linus'ask: move the "fixlet" to net-next.

The additional twist is the ask to drop the stable and fixes tag (otherwise stable will be flooded, too).

PR are a bit apart from plain series, hence my initial questions WRT how problematic would be stripping such tags and how impactful are actually the things addressed in the first 6 patches.

/P

maintainer
#23 lore raw

On Tuesday, 4 August 2026 15:08:01 CEST Paolo Abeni wrote:
[...]

Quoted 10 lines
Quoted 10 lines
Quoted 6 lines

Note that it's preferred to avoid fixes and stable tags for changes targeting the net-next tree. If the fixes are really minor, both could possibly safely dropped. If there is some real problem behind, such changes should instead target the net tree.

Can you easily rebase your tree and adjust the PR vs the above?

I have a different statement from Linus:
https://lore.kernel.org/lkml/CAHk-=wjt1NiKOdyAMz_DT7NmZ++SizPOhRSi492ukdTnpDzHQw@mail.gmail.com/T/#u

Quoted 8 lines
Quoted 3 lines

This is why we started to not send out net.git fixes PRs for things which aren't highly critical or for Linus' "just merged for this release commits" late in the development process.

I actually think netdev preference is consistent with Linus'ask: move the "fixlet" to net-next.

The additional twist is the ask to drop the stable and fixes tag (otherwise stable will be flooded, too).

I find it quite unusual to drop the fixes and stable tags - just so Greg+Sasha have to use their tools to figure out that these were maybe fixes and need to be backported? This already caused problems in the past and had then go manually through literally years of changes (LTS releases!!!) to figure out what was lost in the backporting process. Yes, the years in which it was disallowed to use Cc stable@

But to be honest, I have no idea what "fixlet" means here. Is for example
https://patchwork.open-mesh.org/project/b.a.t.m.a.n./patch/[email protected]/
meant by it? Because this is for example something i don't consider worth backporting. It is definitely fixing something but I never was interested enough to do it myself when two or three other people tried to send incorrect/incomplete patches for it and then disappeared after promising a v2. Which at least makes me think that it isn't worth the effort.

But maybe you are talking about something completely different.

Quoted 3 lines

PR are a bit apart from plain series, hence my initial questions WRT how problematic would be stripping such tags and how impactful are actually the things addressed in the first 6 patches.

Sorry, I am lost. There is stuff for which people have actual PoC code. Afaik, nothing for an RCE but enough to locally be a minor annoyance. The things which have no "Reported-by" are things which I have problems with on my installations.

And about the others: The "bla: avoid CRC corruption due to parallel claim add" + "prevent CRC corruptions after claim flush" were a problems I had (next to another which was not yet posted to netdev) but has a "Reported-by:
Sashiko" because it was also reported by Sashiko when posting other bla patches and I think I've stolen the example from the commit message partially from the Sashiko report.

On the other hand, "dat: atomically update mac addresses" looks like something I had from time to time problems with but never found a reproducer - and Sashiko provided a convincing explanation when I posted completely unrelated patches. Not sure if it was the sole underlying problem (next to the ones I've fixed recently regarding the vlan + tie-breaker)

The Sashiko-reported fixes "dat: avoid unaligned fault in IP extraction" and "mcast: linearize skbuff for packet generation" are luckily nothing I had experienced first hand. The latter would end up in a BUG(). This already makes me think that it is worth backporting. But at the same time, I didn't hear yet about anyone complaining (and it is already in the codebase for a while) - so I am at the same time not convinced that I should anger Linus by asking netdev to integrate it to net.git so late in the game.

None of these things, are super-critical (I could be wrong) but all of them are worth backporting. This is why I was trying in the last moths to proactively backport similar patches to all stable kernels and either directly send the backported patches to stable@ or provide backported versions when only some of them have backporting conflicts.

If you think I should sit on them until them until the release of 7.2 and then submit them around the time of the merge window) then I am also fine. It would then not be sitting in a "linux-next tree". But this is the best I can do without submitting them to net-next.git

Quoted 5 lines · On Tuesday, 4 August 2026 15:16:54 CEST Paolo Abeni wrote:

Please be aware of net-next commit c82ff94592fb: the expectation is that submitters reply proactively to AI review comments.

Specifically it would be helpful an evaluation of how critical is problem reported and if it could safely addressed with a follow-up.

The LLM situation is really starting to get unbearable. It is like cutting of
the hydra's head - it will directly bombard you with 20 more "and now for something completely different" reports. But preparing proper fixes is now also not ok... And at the same time, LLM tools are becoming a must-have for posting patches and now I even have to start to write rebuttals/explanations for these reports. I get why it is helpful for you do see comments from authors/submitters about the Sashiko reports - otherwise you have to go through the reports and figure out if it is unfunded or even already fixed in one of the next patches in the series.

At the moment, I feel like the last survivor for batman-adv which tries to solve (at least some) things. But at the same time, it seems that what I'm doing isn't well-received and I get (for me) conflicting information. Not a super motivating situation.

Not sure what I will do about it.

Regards,
Sven

maintainer
#24 lore raw
Quoted 47 lines · Sven Eckelmann

On Tuesday, 4 August 2026 15:08:01 CEST Paolo Abeni wrote:
[...]

Quoted 10 lines
Quoted 10 lines
Quoted 6 lines

Note that it's preferred to avoid fixes and stable tags for changes targeting the net-next tree. If the fixes are really minor, both could possibly safely dropped. If there is some real problem behind, such changes should instead target the net tree.

Can you easily rebase your tree and adjust the PR vs the above?

I have a different statement from Linus:
https://lore.kernel.org/lkml/CAHk-=wjt1NiKOdyAMz_DT7NmZ++SizPOhRSi492ukdTnpDzHQw@mail.gmail.com/T/#u

Quoted 8 lines
Quoted 3 lines

This is why we started to not send out net.git fixes PRs for things which aren't highly critical or for Linus' "just merged for this release commits" late in the development process.

I actually think netdev preference is consistent with Linus'ask: move the "fixlet" to net-next.

The additional twist is the ask to drop the stable and fixes tag (otherwise stable will be flooded, too).

I find it quite unusual to drop the fixes and stable tags - just so Greg+Sasha have to use their tools to figure out that these were maybe fixes and need to be backported? This already caused problems in the past and had then go manually through literally years of changes (LTS releases!!!) to figure out what was lost in the backporting process. Yes, the years in which it was disallowed to use Cc stable@

But to be honest, I have no idea what "fixlet" means here. Is for example
https://patchwork.open-mesh.org/project/b.a.t.m.a.n./patch/[email protected]/
meant by it? Because this is for example something i don't consider worth backporting. It is definitely fixing something but I never was interested enough to do it myself when two or three other people tried to send incorrect/incomplete patches for it and then disappeared after promising a v2. Which at least makes me think that it isn't worth the effort.

But maybe you are talking about something completely different.

Quoted 3 lines

PR are a bit apart from plain series, hence my initial questions WRT how problematic would be stripping such tags and how impactful are actually the things addressed in the first 6 patches.

Sorry, I am lost. There is stuff for which people have actual PoC code. Afaik, nothing for an RCE but enough to locally be a minor annoyance. The things which have no "Reported-by" are things which I have problems with on my installations.

Quoted 6 lines

And about the others: The "bla: avoid CRC corruption due to parallel claim add" + "prevent CRC corruptions after claim flush" were a problems I had (next to another which was not yet posted to netdev) but has a "Reported-by:
Sashiko" because it was also reported by Sashiko when posting other bla patches and I think I've stolen the example from the commit message partially from the Sashiko report.

I'm sorry this is getting more complicated than really intended. The rule of thumb is that real problems actually bothering users go into the 'net' tree, and other stuff goes into net-next without the fixes tag.

Jakub is actually the one usually more strict about the 'no fixes in net-next patches' mandate, but he actually did not raise the point here. If he is fine with here, I'll not insist.

Quoted 7 lines · On Tuesday, 4 August 2026 15:16:54 CEST Paolo Abeni wrote:
Quoted 5 lines

Please be aware of net-next commit c82ff94592fb: the expectation is that submitters reply proactively to AI review comments.

Specifically it would be helpful an evaluation of how critical is problem reported and if it could safely addressed with a follow-up.

Quoted 9 lines

The LLM situation is really starting to get unbearable. It is like cutting of
the hydra's head - it will directly bombard you with 20 more "and now for something completely different" reports. But preparing proper fixes is now also not ok... And at the same time, LLM tools are becoming a must-have for posting patches and now I even have to start to write rebuttals/explanations for these reports. I get why it is helpful for you do see comments from authors/submitters about the Sashiko reports - otherwise you have to go through the reports and figure out if it is unfunded or even already fixed in one of the next patches in the series.

You are not alone in this painful situation. AI reviews are striking to everyone. LLMs improvements make every day harder get "all green" reports.

From maintainer's perspective the most difficult and time-consuming part is assess the impact of the AI findings, especially for code subjectively less-known. It's not a matter of simply reading through the AI report text, is requires context information and analysis that should be more easily at hands to the patch's author.

Providing feedback there really helps a lot with patch processing.

Thanks,

Paolo

maintainer
#25 lore raw
Quoted 12 lines · On Tue, 4 Aug 2026 20:32:21 +0200 Paolo Abeni wrote:
Quoted 11 lines

Sorry, I am lost. There is stuff for which people have actual PoC code. Afaik, nothing for an RCE but enough to locally be a minor annoyance. The things which have no "Reported-by" are things which I have problems with on my installations.

And about the others: The "bla: avoid CRC corruption due to parallel claim add" + "prevent CRC corruptions after claim flush" were a problems I had (next to another which was not yet posted to netdev) but has a "Reported-by:
Sashiko" because it was also reported by Sashiko when posting other bla patches and I think I've stolen the example from the commit message partially from the Sashiko report.

Quoted 3 lines

I'm sorry this is getting more complicated than really intended. The rule of thumb is that real problems actually bothering users go into the 'net' tree, and other stuff goes into net-next without the fixes tag.

My rule of thumb is "there is no such thing as 'worth backporting but not worth net'". People tend to send to -next fixes they didn't bother testing.