[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250916122441.89246-4-sw@simonwunderlich.de>
Date: Tue, 16 Sep 2025 14:24:40 +0200
From: Simon Wunderlich <sw@...onwunderlich.de>
To: kuba@...nel.org,
davem@...emloft.net
Cc: netdev@...r.kernel.org,
b.a.t.m.a.n@...ts.open-mesh.org,
Sven Eckelmann <sven@...fation.org>,
Simon Wunderlich <sw@...onwunderlich.de>
Subject: [PATCH net-next 3/4] batman-adv: keep skb crc32 helper local in BLA
From: Sven Eckelmann <sven@...fation.org>
The batadv_skb_crc32() helper was shared between Bridge Loop Avoidance and
Network Coding. With the removal of the network coding feature, it is
possible to just move this helper directly to Bridge Loop Avoidance.
Signed-off-by: Sven Eckelmann <sven@...fation.org>
Signed-off-by: Simon Wunderlich <sw@...onwunderlich.de>
---
net/batman-adv/bridge_loop_avoidance.c | 34 ++++++++++++++++++++++++++
net/batman-adv/main.c | 34 --------------------------
net/batman-adv/main.h | 1 -
3 files changed, 34 insertions(+), 35 deletions(-)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 747755647c6a4..b992ba12aa247 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -12,6 +12,7 @@
#include <linux/compiler.h>
#include <linux/container_of.h>
#include <linux/crc16.h>
+#include <linux/crc32.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
@@ -1584,6 +1585,39 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
return 0;
}
+/**
+ * batadv_skb_crc32() - calculate CRC32 of the whole packet and skip bytes in
+ * the header
+ * @skb: skb pointing to fragmented socket buffers
+ * @payload_ptr: Pointer to position inside the head buffer of the skb
+ * marking the start of the data to be CRC'ed
+ *
+ * payload_ptr must always point to an address in the skb head buffer and not to
+ * a fragment.
+ *
+ * Return: big endian crc32c of the checksummed data
+ */
+static __be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr)
+{
+ unsigned int to = skb->len;
+ unsigned int consumed = 0;
+ struct skb_seq_state st;
+ unsigned int from;
+ unsigned int len;
+ const u8 *data;
+ u32 crc = 0;
+
+ from = (unsigned int)(payload_ptr - skb->data);
+
+ skb_prepare_seq_read(skb, from, to, &st);
+ while ((len = skb_seq_read(consumed, &data, &st)) != 0) {
+ crc = crc32c(crc, data, len);
+ consumed += len;
+ }
+
+ return htonl(crc);
+}
+
/**
* batadv_bla_check_duplist() - Check if a frame is in the broadcast dup.
* @bat_priv: the bat priv with all the mesh interface information
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 1dcacfc310ee9..3a35aadd8b419 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -11,7 +11,6 @@
#include <linux/build_bug.h>
#include <linux/byteorder/generic.h>
#include <linux/container_of.h>
-#include <linux/crc32.h>
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/gfp.h>
@@ -561,39 +560,6 @@ void batadv_recv_handler_unregister(u8 packet_type)
batadv_rx_handler[packet_type] = batadv_recv_unhandled_packet;
}
-/**
- * batadv_skb_crc32() - calculate CRC32 of the whole packet and skip bytes in
- * the header
- * @skb: skb pointing to fragmented socket buffers
- * @payload_ptr: Pointer to position inside the head buffer of the skb
- * marking the start of the data to be CRC'ed
- *
- * payload_ptr must always point to an address in the skb head buffer and not to
- * a fragment.
- *
- * Return: big endian crc32c of the checksummed data
- */
-__be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr)
-{
- u32 crc = 0;
- unsigned int from;
- unsigned int to = skb->len;
- struct skb_seq_state st;
- const u8 *data;
- unsigned int len;
- unsigned int consumed = 0;
-
- from = (unsigned int)(payload_ptr - skb->data);
-
- skb_prepare_seq_read(skb, from, to, &st);
- while ((len = skb_seq_read(consumed, &data, &st)) != 0) {
- crc = crc32c(crc, data, len);
- consumed += len;
- }
-
- return htonl(crc);
-}
-
/**
* batadv_get_vid() - extract the VLAN identifier from skb if any
* @skb: the buffer containing the packet
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 7352b11df968c..2be1ac17acaa4 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -248,7 +248,6 @@ batadv_recv_handler_register(u8 packet_type,
int (*recv_handler)(struct sk_buff *,
struct batadv_hard_iface *));
void batadv_recv_handler_unregister(u8 packet_type);
-__be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr);
/**
* batadv_compare_eth() - Compare two not u16 aligned Ethernet addresses
--
2.47.3
Powered by blists - more mailing lists