pull request for net-next: batman-adv 2025-09-16
Subsystems (3)
Simon Wunderlich
maintainercover pull request for net-next: batman-adv 2025-09-16
Hi Jakub, hi David,
here is a cleanup pull request of batman-adv to go into net-next.
This time we use a https pull request link as we have turned off our public git protocol server - sorry for the hiccup last time, I hope everything is smooth now.
Please pull or let me know of any problem!
Thank you,
Simon
The following changes since commit d69eb204c255c35abd9e8cb621484e8074c75eaa:
Merge tag 'net-6.17-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net (2025-09-04 09:59:15 -0700)
are available in the Git repository at:
https://git.open-mesh.org/linux-merge.git tags/batadv-next-pullrequest-20250916
for you to fetch changes up to 629a2b18e8729497eeac5b63e575e0961ca3a4ab:
batman-adv: remove includes for extern declarations (2025-09-05 15:11:02 +0200)
----------------------------------------------------------------
This cleanup patchset includes the following patches:
- bump version strings, by Simon Wunderlich
- Remove network coding support, by Sven Eckelmann (2 patches)
- remove includes for extern declarations, by Sven Eckelmann
----------------------------------------------------------------
Simon Wunderlich (1):
batman-adv: Start new development cycle
Sven Eckelmann (3):
batman-adv: remove network coding support
batman-adv: keep skb crc32 helper local in BLA
batman-adv: remove includes for extern declarations
net/batman-adv/Kconfig | 13 - net/batman-adv/Makefile | 1 - net/batman-adv/bat_iv_ogm.c | 5 - net/batman-adv/bridge_loop_avoidance.c | 34 + net/batman-adv/hard-interface.c | 1 + net/batman-adv/hard-interface.h | 1 - net/batman-adv/log.h | 3 - net/batman-adv/main.c | 50 - net/batman-adv/main.h | 5 +- net/batman-adv/mesh-interface.c | 15 +- net/batman-adv/mesh-interface.h | 1 - net/batman-adv/netlink.c | 17 - net/batman-adv/netlink.h | 1 - net/batman-adv/network-coding.c | 1878 -------------------------------- net/batman-adv/network-coding.h | 106 -- net/batman-adv/originator.c | 6 - net/batman-adv/routing.c | 9 +- net/batman-adv/send.c | 16 +- net/batman-adv/translation-table.c | 4 +- net/batman-adv/types.h | 216 ---- 20 files changed, 41 insertions(+), 2341 deletions(-) delete mode 100644 net/batman-adv/network-coding.c delete mode 100644 net/batman-adv/network-coding.h
Simon Wunderlich
maintainerPATCH 1/4 batman-adv: Start new development cycle
This version will contain all the (major or even only minor) changes for Linux 6.18.
The version number isn't a semantic version number with major and minor information. It is just encoding the year of the expected publishing as Linux -rc1 and the number of published versions this year (starting at 0).
--- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/main.h +1 -1
@@ -13,7 +13,7 @@#define BATADV_DRIVER_DEVICE "batman-adv"#ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2025.3" +#define BATADV_SOURCE_VERSION "2025.4"#endif /* B.A.T.M.A.N. parameters */
Signature · 1 line
2.47.3
Re: [PATCH net-next 1/4] batman-adv: Start new development cycle
This series was applied to netdev/net-next.git (main) by Simon Wunderlich <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Simon Wunderlich <[email protected]>:
Quoted 8 lines · On Tue, 16 Sep 2025 14:24:38 +0200 you wrote:
This version will contain all the (major or even only minor) changes for Linux 6.18.
The version number isn't a semantic version number with major and minor information. It is just encoding the year of the expected publishing as Linux -rc1 and the number of published versions this year (starting at 0).
[...]
Here is the summary with links:
- [net-next,1/4] batman-adv: Start new development cycle
https://git.kernel.org/netdev/net-next/c/e89888a1e778 - [net-next,2/4] batman-adv: remove network coding support https://git.kernel.org/netdev/net-next/c/87b95082db32 - [net-next,3/4] batman-adv: keep skb crc32 helper local in BLA https://git.kernel.org/netdev/net-next/c/d5d80ac74f80 - [net-next,4/4] batman-adv: remove includes for extern declarations https://git.kernel.org/netdev/net-next/c/629a2b18e872
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Simon Wunderlich
maintainerPATCH 2/4 batman-adv: remove network coding support
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The Network Coding feature, introduced in 2013, is based on the master thesis "Inter-Flow Network Coding for Wireless Mesh Networks". It relies on the assumption that neighboring mesh nodes can reliably overhear each other's transmissions in promiscuous mode, allowing packets to be combined to reduce forwarding overhead.
This assumption no longer holds for modern wireless mesh networks, which are heterogeneous and make overhearing increasingly unreliable. Factors such as multiple spatial streams, varying data rates, beamforming, and OFDMA all prevent nodes from consistently overhearing each other. The current implementation in batman-adv is not able to detect these conditions and would require a more complex layer beyond its neighbor discovery process to do so.
In addition, the feature has been unmaintained for years and is discouraged for use. None of the current maintainers have the required test setup to verify its functionality, and known issues remain in its data structures (reference counting, RCU usage, and cleanup handling). Its continued presence also blocks necessary refactoring of the core originator infrastructure.
Remove this obsolete and unmaintained feature.
--- net/batman-adv/Kconfig | 13 - net/batman-adv/Makefile | 1 - net/batman-adv/bat_iv_ogm.c | 5 - net/batman-adv/log.h | 3 - net/batman-adv/main.c | 16 - net/batman-adv/main.h | 2 - net/batman-adv/mesh-interface.c | 14 - net/batman-adv/netlink.c | 17 - net/batman-adv/network-coding.c | 1878 ---------------------------- net/batman-adv/network-coding.h | 106 -- net/batman-adv/originator.c | 6 - net/batman-adv/routing.c | 9 +- net/batman-adv/send.c | 16 +- net/batman-adv/translation-table.c | 4 +- net/batman-adv/types.h | 216 ---- 15 files changed, 4 insertions(+), 2302 deletions(-) delete mode 100644 net/batman-adv/network-coding.c delete mode 100644 net/batman-adv/network-coding.h
net/batman-adv/Kconfig +0 -13
@@ -53,19 +53,6 @@ config BATMAN_ADV_DAT mesh networks. If you think that your network does not need this option you can safely remove it and save some space. -config BATMAN_ADV_NC - bool "Network Coding" - depends on BATMAN_ADV - help - This option enables network coding, a mechanism that aims to - increase the overall network throughput by fusing multiple - packets in one transmission. - Note that interfaces controlled by batman-adv must be manually - configured to have promiscuous mode enabled in order to make - network coding work. - If you think that your network does not need this feature you - can safely disable it and save some space. - config BATMAN_ADV_MCAST bool "Multicast optimisation" depends on BATMAN_ADV && INET && !(BRIDGE=m && BATMAN_ADV=y)
net/batman-adv/Makefile +0 -1
@@ -23,7 +23,6 @@ batman-adv-y += mesh-interface.o batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += multicast.o batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += multicast_forw.o batman-adv-y += netlink.o -batman-adv-$(CONFIG_BATMAN_ADV_NC) += network-coding.o batman-adv-y += originator.o batman-adv-y += routing.o batman-adv-y += send.o
net/batman-adv/bat_iv_ogm.c +0 -5
@@ -52,7 +52,6 @@#include "hash.h" #include "log.h" #include "netlink.h" -#include "network-coding.h" #include "originator.h" #include "routing.h" #include "send.h"
@@ -1406,10 +1405,6 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff *skb, int ogm_offset,if (!orig_neigh_node) goto out; -/* Update nc_nodes of the originator */ -batadv_nc_update_nc_node (bat_priv, orig_node, orig_neigh_node, - ogm_packet, is_single_hop_neigh); - orig_neigh_router =batadv_orig_router_get (orig_neigh_node, if_outgoing);
net/batman-adv/log.h +0 -3
@@ -51,9 +51,6 @@ enum batadv_dbg_level {/** @BATADV_DBG_DAT: ARP snooping and DAT related messages */ BATADV_DBG_DAT =BIT (4 ), -/** @BATADV_DBG_NC: network coding related messages */ -BATADV_DBG_NC =BIT (5 ), -/** @BATADV_DBG_MCAST: multicast related messages */ BATADV_DBG_MCAST = BIT(6),
net/batman-adv/main.c +0 -16
@@ -53,7 +53,6 @@#include "mesh-interface.h" #include "multicast.h" #include "netlink.h" -#include "network-coding.h" #include "originator.h" #include "routing.h" #include "send.h"
@@ -103,7 +102,6 @@ static int __init batadv_init(void)batadv_v_init ();batadv_iv_init (); -batadv_nc_init ();batadv_tp_meter_init (); batadv_event_workqueue =create_singlethread_workqueue ("bat_events" );
@@ -218,12 +216,6 @@ int batadv_mesh_init(struct net_device *mesh_iface) goto err_dat; } - ret =batadv_nc_mesh_init (bat_priv); -if (ret <0 ) { -atomic_set (&bat_priv->mesh_state,BATADV_MESH_DEACTIVATING ); - goto err_nc; - } -batadv_gw_init (bat_priv);batadv_mcast_init (bat_priv);
@@ -232,8 +224,6 @@ int batadv_mesh_init(struct net_device *mesh_iface)return 0 ; -err_nc: -batadv_dat_free (bat_priv); err_dat:batadv_bla_free (bat_priv); err_bla:
@@ -264,7 +254,6 @@ void batadv_mesh_free(struct net_device *mesh_iface)batadv_gw_node_free (bat_priv);batadv_v_mesh_free (bat_priv); -batadv_nc_mesh_free (bat_priv);batadv_dat_free (bat_priv);batadv_bla_free (bat_priv);
@@ -336,11 +325,6 @@ int batadv_max_header_len(void) header_len =max_t (int, header_len,sizeof (struct batadv_bcast_packet )); -#ifdef CONFIG_BATMAN_ADV_NC - header_len =max_t (int, header_len, -sizeof (struct batadv_coded_packet )); -#endif -return header_len +ETH_HLEN ; }
net/batman-adv/main.h +0 -2
@@ -121,8 +121,6 @@#define BATADV_RESET_PROTECTION_MS 30000#define BATADV_EXPECTED_SEQNO_RANGE 65536 -#define BATADV_NC_NODE_TIMEOUT 10000/* Milliseconds */ -/** * BATADV_TP_MAX_NUM - maximum number of simultaneously active tp sessions */
net/batman-adv/mesh-interface.c +0 -14
@@ -46,7 +46,6 @@#include "gateway_client.h" #include "hard-interface.h" #include "multicast.h" -#include "network-coding.h" #include "send.h" #include "translation-table.h"
@@ -802,8 +801,6 @@ static int batadv_meshif_init_late(struct net_device *dev) bat_priv->primary_if =NULL ; -batadv_nc_init_bat_priv (bat_priv); -if (!bat_priv->algo_ops) { ret =batadv_algo_select (bat_priv, batadv_routing_algo);if (ret <0 )
@@ -947,17 +944,6 @@ static const struct { { "dat_put_rx" }, { "dat_cached_reply_tx" }, #endif -#ifdef CONFIG_BATMAN_ADV_NC - { "nc_code" }, - { "nc_code_bytes" }, - { "nc_recode" }, - { "nc_recode_bytes" }, - { "nc_buffer" }, - { "nc_decode" }, - { "nc_decode_bytes" }, - { "nc_decode_failed" }, - { "nc_sniffed" }, -#endif }; static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data)
net/batman-adv/netlink.c +0 -17
@@ -44,7 +44,6 @@#include "log.h" #include "mesh-interface.h" #include "multicast.h" -#include "network-coding.h" #include "originator.h" #include "tp_meter.h" #include "translation-table.h"
@@ -144,7 +143,6 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_LOG_LEVEL] = { .type = NLA_U32 }, [BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED] = { .type = NLA_U8 }, [BATADV_ATTR_MULTICAST_FANOUT] = { .type = NLA_U32 }, - [BATADV_ATTR_NETWORK_CODING_ENABLED] = { .type = NLA_U8 }, [BATADV_ATTR_ORIG_INTERVAL] = { .type = NLA_U32 }, [BATADV_ATTR_ELP_INTERVAL] = { .type = NLA_U32 }, [BATADV_ATTR_THROUGHPUT_OVERRIDE] = { .type = NLA_U32 },
@@ -345,12 +343,6 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg, goto nla_put_failure;#endif /* CONFIG_BATMAN_ADV_MCAST */ -#ifdef CONFIG_BATMAN_ADV_NC -if (nla_put_u8 (msg,BATADV_ATTR_NETWORK_CODING_ENABLED , - !!atomic_read (&bat_priv->network_coding))) - goto nla_put_failure; -#endif /* CONFIG_BATMAN_ADV_NC */ -if (nla_put_u32 (msg,BATADV_ATTR_ORIG_INTERVAL ,atomic_read (&bat_priv->orig_interval))) goto nla_put_failure;
@@ -588,15 +580,6 @@ static int batadv_netlink_set_mesh(struct sk_buff *skb, struct genl_info *info) }#endif /* CONFIG_BATMAN_ADV_MCAST */ -#ifdef CONFIG_BATMAN_ADV_NC -if (info->attrs[BATADV_ATTR_NETWORK_CODING_ENABLED ]) { - attr = info->attrs[BATADV_ATTR_NETWORK_CODING_ENABLED ]; - -atomic_set (&bat_priv->network_coding, !!nla_get_u8 (attr)); -batadv_nc_status_update (bat_priv->mesh_iface); - } -#endif /* CONFIG_BATMAN_ADV_NC */ -if (info->attrs[BATADV_ATTR_ORIG_INTERVAL ]) {u32 orig_interval;
net/batman-adv/network-coding.c deleted +0 -1878
1,878 lines not on this page · raw message
net/batman-adv/network-coding.h deleted +0 -106
106 lines not on this page · raw message
net/batman-adv/originator.c +0 -6
@@ -37,7 +37,6 @@#include "log.h" #include "multicast.h" #include "netlink.h" -#include "network-coding.h" #include "routing.h" #include "translation-table.h"
@@ -883,9 +882,6 @@ void batadv_orig_node_release(struct kref *ref) }spin_unlock_bh (&orig_node->vlan_list_lock); -/* Free nc_nodes */ -batadv_nc_purge_orig (orig_node->bat_priv, orig_node,NULL ); -call_rcu (&orig_node->rcu, batadv_orig_node_free_rcu); }
@@ -959,8 +955,6 @@ struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,spin_lock_init (&orig_node->tt_lock);spin_lock_init (&orig_node->vlan_list_lock); -batadv_nc_init_orig (orig_node); -/* extra reference for return */ kref_init (&orig_node->refcount);
net/batman-adv/routing.c +1 -8
@@ -31,7 +31,6 @@#include "hard-interface.h" #include "log.h" #include "mesh-interface.h" -#include "network-coding.h" #include "originator.h" #include "send.h" #include "tp_meter.h"
@@ -956,15 +955,9 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,/* function returns -EREMOTE for promiscuous packets */ check =batadv_check_unicast_packet (bat_priv, skb, hdr_size); - -/* Even though the packet is not for us, we might save it to use for -* decoding a later received coded packet -*/ -if (check == -EREMOTE ) -batadv_nc_skb_store_sniffed_unicast (bat_priv, skb); -if (check <0 ) goto free_skb; +if (!batadv_check_unicast_ttvn (bat_priv, skb, hdr_size)) goto free_skb;
net/batman-adv/send.c +1 -15
@@ -34,7 +34,6 @@#include "hard-interface.h" #include "log.h" #include "mesh-interface.h" -#include "network-coding.h" #include "originator.h" #include "routing.h" #include "translation-table.h"
@@ -63,12 +62,9 @@ int batadv_send_skb_packet(struct sk_buff *skb,struct batadv_hard_iface *hard_iface, const u8 *dst_addr) { - struct batadv_priv *bat_priv; struct ethhdr *ethhdr;int ret; - bat_priv =netdev_priv (hard_iface->mesh_iface); -if (hard_iface->if_status !=BATADV_IF_ACTIVE ) goto send_skb_err;
@@ -97,9 +93,6 @@ int batadv_send_skb_packet(struct sk_buff *skb, skb->dev = hard_iface->net_dev; -/* Save a clone of the skb to use when decoding coded packets */ -batadv_nc_skb_store_for_decoding (bat_priv, skb); -/* dev_queue_xmit() returns a negative result on error. However on * congestion and traffic shaping, it drops and returns NET_XMIT_DROP * (which is > 0). This will not be treated as an error.
@@ -202,14 +195,7 @@ int batadv_send_skb_to_orig(struct sk_buff *skb, goto put_neigh_node; } -/* try to network code the packet, if it is received on an interface -* (i.e. being forwarded). If the packet originates from this node or if -* network coding fails, then send the packet as usual. -*/ -if (recv_if &&batadv_nc_skb_forward (skb, neigh_node)) - ret = -EINPROGRESS ; -else - ret =batadv_send_unicast_skb (skb, neigh_node); + ret =batadv_send_unicast_skb (skb, neigh_node);/* skb was consumed */ skb =NULL ;
net/batman-adv/translation-table.c +2 -2
@@ -212,7 +212,7 @@ batadv_tt_global_hash_find(struct batadv_priv *bat_priv, const u8 *addr,/** * batadv_tt_local_entry_release() - release tt_local_entry from lists and queue * for free after rcu grace period -* @ref: kref pointer of the nc_node +* @ref: kref pointer of the batadv_tt_local_entry */ static void batadv_tt_local_entry_release (struct kref *ref) {
@@ -244,7 +244,7 @@ batadv_tt_local_entry_put(struct batadv_tt_local_entry *tt_local_entry)/** * batadv_tt_global_entry_release() - release tt_global_entry from lists and * queue for free after rcu grace period -* @ref: kref pointer of the nc_node +* @ref: kref pointer of the batadv_tt_global_entry */ void batadv_tt_global_entry_release (struct kref *ref) {
net/batman-adv/types.h +0 -216
257 lines not on this page · raw message
Signature · 1 line
2.47.3
Simon Wunderlich
maintainerPATCH 3/4 batman-adv: keep skb crc32 helper local in BLA
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
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.
--- 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(-)
net/batman-adv/bridge_loop_avoidance.c +34 -0
@@ -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
net/batman-adv/main.c +0 -34
@@ -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
net/batman-adv/main.h +0 -1
@@ -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
Signature · 1 line
2.47.3
Re: [PATCH net-next 3/4] batman-adv: keep skb crc32 helper local in BLA
Hi,
Quoted 10 lines · Simon Wunderlich
net/batman-adv/bridge_loop_avoidance.c +10
-0+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 ; +
net/batman-adv/bridge_loop_avoidance.c int batadv_bla_init(struct batadv_priv *bat_priv) · line 1619
Quoted 10 lines
net/batman-adv/bridge_loop_avoidance.c +10
-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); +}
Has using skb_crc32c() been considered here?
- Eric
Sven Eckelmann
maintainerRe: [PATCH net-next 3/4] batman-adv: keep skb crc32 helper local in BLA
Quoted 17 lines · On Saturday, 27 September 2025 22:55:52 CEST Eric Biggers wrote:
Hi,
Quoted 14 lines · Simon Wunderlich
(quoted diff) +14
-0+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) {
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ crc = crc32c(crc, data, len); + consumed += len; + } + + return htonl(crc); +}Has using
skb_crc32c()been considered here?
No. At the time this was written (v3.8), skb_crc32c (v6.16) didnt exist. Also its predecessor __skb_checksum only started its existence in v3.13. And no one noticed it as candidate to replace batadv_skb_crc32 with
And this patch here was just moving the function between two places - so not introducing new code.
Do you want to submit a patch to integrate your new function in batman-adv? I only performed a quick-and-dirty test to see if it returns the same results and it seemed to do its job fine.
net/batman-adv/Kconfig +1 -0
@@ -35,6 +35,7 @@ config BATMAN_ADV_BLA bool "Bridge Loop Avoidance" depends on BATMAN_ADV && INET select CRC16 + select NET_CRC32C default y help This option enables BLA (Bridge Loop Avoidance), a mechanism
net/batman-adv/bridge_loop_avoidance.c +7 -42
94 lines not on this page · raw message
Regards,
Sven
Re: [PATCH net-next 3/4] batman-adv: keep skb crc32 helper local in BLA
Quoted 142 lines · Sven Eckelmann
Quoted 17 lines · On Saturday, 27 September 2025 22:55:52 CEST Eric Biggers wrote:
Hi,
Quoted 14 lines · Simon Wunderlich
(quoted diff) +14
-0+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) {Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ crc = crc32c(crc, data, len); + consumed += len; + } + + return htonl(crc); +}Has using
skb_crc32c()been considered here?No. At the time this was written (v3.8),
skb_crc32c(v6.16) didnt exist. Also its predecessor__skb_checksumonly started its existence in v3.13. And no one noticed it as candidate to replacebatadv_skb_crc32withAnd this patch here was just moving the function between two places - so not introducing new code.
Do you want to submit a patch to integrate your new function in batman-adv? I only performed a quick-and-dirty test to see if it returns the same results and it seemed to do its job fine.
net/batman-adv/Kconfig +1
-0@@ -35,6 +35,7 @@ config BATMAN_ADV_BLA bool "Bridge Loop Avoidance" depends on BATMAN_ADV && INET select CRC16 + select NET_CRC32C default y help This option enables BLA (Bridge Loop Avoidance), a mechanismnet/batman-adv/bridge_loop_avoidance.c +6
-39@@ -12,7 +12,6 @@#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> @@ -1585,45 +1584,11 @@ 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 * @skb: contains the multicast packet to be checked -* @payload_ptr: pointer to position inside the head buffer of the skb -* marking the start of the data to be CRC'ed +* @payload_offset: offset in the skb, marking the start of the data to be CRC'ed * @orig: originator mac address, NULL if unknown * * Check if it is on our broadcast list. Another gateway might have sent the @@ -1638,16 +1603,18 @@ static __be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr)* Return: true if a packet is in the duplicate list, false otherwise. */ static bool batadv_bla_check_duplist (struct batadv_priv *bat_priv, -struct sk_buff *skb,u8 *payload_ptr, +struct sk_buff *skb,int payload_offset,const u8 *orig) {struct batadv_bcast_duplist_entry *entry;bool ret = false; +int payload_len;int i, curr;__be32 crc;/* calculate the crc ... */ - crc =batadv_skb_crc32 (skb, payload_ptr); + payload_len = skb->len - payload_offset; + crc =htonl (skb_crc32c (skb, payload_offset, payload_len,0 ));spin_lock_bh (&bat_priv->bla.bcast_duplist_lock);@@ -1727,7 +1694,7 @@ static bool batadv_bla_check_duplist(struct batadv_priv *bat_priv,static bool batadv_bla_check_ucast_duplist (struct batadv_priv *bat_priv,struct sk_buff *skb) { -return batadv_bla_check_duplist (bat_priv, skb, (u8 *)skb->data,NULL ); +return batadv_bla_check_duplist (bat_priv, skb,0 ,NULL ); }/** @@ -1745,12 +1712,10 @@ bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, struct sk_buff *skb) {
net/batman-adv/bridge_loop_avoidance.c bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, · line 1720
Quoted 10 lines
net/batman-adv/bridge_loop_avoidance.c +1
-3struct batadv_bcast_packet *bcast_packet; -u8 *payload_ptr; bcast_packet = (struct batadv_bcast_packet *)skb->data; - payload_ptr = (u8 *)(bcast_packet +1 ); -return batadv_bla_check_duplist (bat_priv, skb, payload_ptr, +return batadv_bla_check_duplist (bat_priv, skb,sizeof (*bcast_packet), bcast_packet->orig); }
It looks like you're already most of the way there, so I suggest you send the patch. Thanks!
- Eric
Simon Wunderlich
maintainerPATCH 4/4 batman-adv: remove includes for extern declarations
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
It is not necessary to include the header for the struct definition for an "extern " declaration. It can simply be dropped from the headers to reduce the number of includes the preprocessor has to process. If needed, it can be added to the actual C source file.
--- net/batman-adv/hard-interface.c | 1 + net/batman-adv/hard-interface.h | 1 - net/batman-adv/mesh-interface.c | 1 + net/batman-adv/mesh-interface.h | 1 - net/batman-adv/netlink.h | 1 - 5 files changed, 2 insertions(+), 3 deletions(-)
net/batman-adv/hard-interface.c +1 -0
@@ -22,6 +22,7 @@#include <linux/minmax.h> #include <linux/mutex.h> #include <linux/netdevice.h> +#include <linux/notifier.h> #include <linux/printk.h> #include <linux/rculist.h> #include <linux/rtnetlink.h>
net/batman-adv/hard-interface.h +0 -1
@@ -12,7 +12,6 @@#include <linux/compiler.h> #include <linux/kref.h> #include <linux/netdevice.h> -#include <linux/notifier.h> #include <linux/rcupdate.h> #include <linux/stddef.h> #include <linux/types.h>
net/batman-adv/mesh-interface.c +1 -0
@@ -37,6 +37,7 @@#include <linux/string.h> #include <linux/types.h> #include <net/netlink.h> +#include <net/rtnetlink.h> #include <uapi/linux/batadv_packet.h> #include <uapi/linux/batman_adv.h>
net/batman-adv/mesh-interface.h +0 -1
@@ -13,7 +13,6 @@#include <linux/netdevice.h> #include <linux/skbuff.h> #include <linux/types.h> -#include <net/rtnetlink.h> int batadv_skb_head_push (struct sk_buff *skb,unsigned int len); void batadv_interface_rx(struct net_device *mesh_iface,
net/batman-adv/netlink.h +0 -1
@@ -11,7 +11,6 @@#include <linux/netlink.h> #include <linux/types.h> -#include <net/genetlink.h> void batadv_netlink_register (void );void batadv_netlink_unregister (void );
Signature · 1 line
2.47.3