pull request for net-next: batman-adv 2024-10-15
Subsystems (3)
Simon Wunderlich
maintainercover pull request for net-next: batman-adv 2024-10-15
Hi Jakub, hi David,
here is a feature/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 9852d85ec9d492ebef56dc5f229416c925758edc:
Linux 6.12-rc1 (2024-09-29 15:06:19 -0700)
are available in the Git repository at:
git://git.open-mesh.org/linux-merge.git tags/batadv-next-pullrequest-20241015
for you to fetch changes up to 356c81b6c494a359ed6e25087931acc78c518fb9:
batman-adv: replace call_rcu by kfree_rcu for simple kmem_cache_free callback (2024-10-14 09:08:39 +0200)
----------------------------------------------------------------
This cleanup patchset includes the following patches:
- bump version strings, by Simon Wunderlich
- Add flex array to struct batadv_tvlv_tt_data, by Erick Archer
- Use string choice helper to print booleans, by Sven Eckelmann
- replace call_rcu by kfree_rcu for simple kmem_cache_free callback, by Julia Lawall
----------------------------------------------------------------
Erick Archer (1):
batman-adv: Add flex array to struct batadv_tvlv_tt_data
Julia Lawall (1):
batman-adv: replace call_rcu by kfree_rcu for simple kmem_cache_free callback
Simon Wunderlich (1):
batman-adv: Start new development cycle
Sven Eckelmann (1):
batman-adv: Use string choice helper to print booleans
include/uapi/linux/batadv_packet.h | 29 +++++----- net/batman-adv/bat_iv_ogm.c | 4 +- net/batman-adv/bridge_loop_avoidance.c | 8 +-- net/batman-adv/main.h | 2 +- net/batman-adv/translation-table.c | 96 ++++++++-------------------------- 5 files changed, 46 insertions(+), 93 deletions(-)
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.13.
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 "2024.2" +#define BATADV_SOURCE_VERSION "2024.3"#endif /* B.A.T.M.A.N. parameters */
Signature · 1 line
2.39.5
Re: [PATCH 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, 15 Oct 2024 09:39:43 +0200 you wrote:
This version will contain all the (major or even only minor) changes for Linux 6.13.
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:
- [1/4] batman-adv: Start new development cycle
https://git.kernel.org/netdev/net-next/c/0f4e6f947600 - [2/4] batman-adv: Add flex array to struct batadv_tvlv_tt_data https://git.kernel.org/netdev/net-next/c/4436df478860 - [3/4] batman-adv: Use string choice helper to print booleans https://git.kernel.org/netdev/net-next/c/5c956d11cfca - [4/4] batman-adv: replace call_rcu by kfree_rcu for simple kmem_cache_free callback https://git.kernel.org/netdev/net-next/c/356c81b6c494
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: Add flex array to struct batadv_tvlv_tt_data
In reply to Simon WunderlichFrom: Erick Archer <[email protected]>
The "struct batadv_tvlv_tt_data" uses a dynamically sized set of trailing elements. Specifically, it uses an array of structures of type "batadv_tvlv_tt_vlan_data". So, use the preferred way in the kernel declaring a flexible array [1].
At the same time, prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions). In this case, it is important to note that the attribute used is specifically __counted_by_be since variable "num_vlan" is of type __be16.
The following change to the "batadv_tt_tvlv_ogm_handler_v1" function:
- tt_vlan = (struct batadv_tvlv_tt_vlan_data *)(tt_data + 1);
- tt_change = (struct batadv_tvlv_tt_change *)(tt_vlan + num_vlan);
+ tt_change = (struct batadv_tvlv_tt_change *)((void *)tt_data
+ + flex_size);
is intended to prevent the compiler from generating an "out-of-bounds" notification due to the __counted_by attribute. The compiler can do a pointer calculation using the vlan_data flexible array memory, or in other words, this may be calculated as an array offset, since it is the same as:
&tt_data->vlan_data[num_vlan]
Therefore, we go past the end of the array. In other "multiple trailing flexible array" situations, this has been solved by addressing from the base pointer, since the compiler either knows the full allocation size or it knows nothing about it (this case, since it came from a "void *" function argument).
The order in which the structure batadv_tvlv_tt_data and the structure batadv_tvlv_tt_vlan_data are defined must be swap to avoid an incomplete type error.
Also, avoid the open-coded arithmetic in memory allocator functions [2] using the "struct_size" macro and use the "flex_array_size" helper to clarify some calculations, when possible.
Moreover, the new structure member also allow us to avoid the open-coded arithmetic on pointers in some situations. Take advantage of this.
This code was detected with the help of Coccinelle, and audited and modified manually.
--- include/uapi/linux/batadv_packet.h | 29 ++++++++++-------- net/batman-adv/translation-table.c | 49 ++++++++++++------------------ 2 files changed, 36 insertions(+), 42 deletions(-)
include/uapi/linux/batadv_packet.h +16 -13
@@ -9,6 +9,7 @@#include <asm/byteorder.h> #include <linux/if_ether.h> +#include <linux/stddef.h> #include <linux/types.h> /**
@@ -592,19 +593,6 @@ struct batadv_tvlv_gateway_data {__be32 bandwidth_up; }; -/** -* struct batadv_tvlv_tt_data - tt data propagated through the tt tvlv container -* @flags: translation table flags (see batadv_tt_data_flags) -* @ttvn: translation table version number -* @num_vlan: number of announced VLANs. In the TVLV this struct is followed by -* one batadv_tvlv_tt_vlan_data object per announced vlan -*/ -struct batadv_tvlv_tt_data { -__u8 flags; -__u8 ttvn; -__be16 num_vlan; -}; -/** * struct batadv_tvlv_tt_vlan_data - vlan specific tt data propagated through * the tt tvlv container
@@ -618,6 +606,21 @@ struct batadv_tvlv_tt_vlan_data {__u16 reserved; }; +/** +* struct batadv_tvlv_tt_data - tt data propagated through the tt tvlv container +* @flags: translation table flags (see batadv_tt_data_flags) +* @ttvn: translation table version number +* @num_vlan: number of announced VLANs. In the TVLV this struct is followed by +* one batadv_tvlv_tt_vlan_data object per announced vlan +* @vlan_data: array of batadv_tvlv_tt_vlan_data objects +*/ +struct batadv_tvlv_tt_data { +__u8 flags; +__u8 ttvn; +__be16 num_vlan; + struct batadv_tvlv_tt_vlan_data vlan_data[] __counted_by_be(num_vlan); +}; +/** * struct batadv_tvlv_tt_change - translation table diff data * @flags: status indicators concerning the non-mesh client (see
net/batman-adv/translation-table.c +20 -29
151 lines not on this page · raw message
Signature · 1 line
2.39.5
Simon Wunderlich
maintainerPATCH 3/4 batman-adv: Use string choice helper to print booleans
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The commit ea4692c75e1c ("lib/string_helpers: Consolidate string helpers implementation") introduced common helpers to print string representations of boolean helpers. These are supposed to be used instead of open coded versions.
--- net/batman-adv/bat_iv_ogm.c | 4 ++-- net/batman-adv/bridge_loop_avoidance.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
net/batman-adv/bat_iv_ogm.c +2 -2
@@ -36,6 +36,7 @@#include <linux/spinlock.h> #include <linux/stddef.h> #include <linux/string.h> +#include <linux/string_choices.h> #include <linux/types.h> #include <linux/workqueue.h> #include <net/genetlink.h>
@@ -371,8 +372,7 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet, batadv_ogm_packet->orig,ntohl (batadv_ogm_packet->seqno), batadv_ogm_packet->tq, batadv_ogm_packet->ttl, - ((batadv_ogm_packet->flags &BATADV_DIRECTLINK ) ? -"on" :"off" ), +str_on_off (batadv_ogm_packet->flags &BATADV_DIRECTLINK ), hard_iface->net_dev->name, hard_iface->net_dev->dev_addr);
net/batman-adv/bridge_loop_avoidance.c +4 -4
@@ -33,6 +33,7 @@#include <linux/sprintf.h> #include <linux/stddef.h> #include <linux/string.h> +#include <linux/string_choices.h> #include <linux/workqueue.h> #include <net/arp.h> #include <net/genetlink.h>
@@ -1946,16 +1947,15 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, claim =batadv_claim_hash_find (bat_priv, &search_claim);if (!claim) { +bool local =batadv_is_my_client (bat_priv, ethhdr->h_source, vid); +/* possible optimization: race for a claim */ /* No claim exists yet, claim it for us! */ batadv_dbg (BATADV_DBG_BLA , bat_priv,"%s(): Unclaimed MAC %pM found. Claim it. Local: %s\n" , - __func__, ethhdr->h_source, -batadv_is_my_client (bat_priv, - ethhdr->h_source, vid) ? -"yes" :"no" ); + __func__, ethhdr->h_source,str_yes_no (local));batadv_handle_claim (bat_priv, primary_if, primary_if->net_dev->dev_addr, ethhdr->h_source, vid);
Signature · 1 line
2.39.5
Simon Wunderlich
maintainerPATCH 4/4 batman-adv: replace call_rcu by kfree_rcu for simple kmem_cache_free callback
In reply to Simon WunderlichFrom: Julia Lawall <[email protected]>
Since SLOB was removed and since
commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"), it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly.
The changes were made using Coccinelle.
--- net/batman-adv/translation-table.c | 47 ++---------------------------- 1 file changed, 3 insertions(+), 44 deletions(-)
net/batman-adv/translation-table.c +3 -44
@@ -209,20 +209,6 @@ batadv_tt_global_hash_find(struct batadv_priv *bat_priv, const u8 *addr,return tt_global_entry; } -/** -* batadv_tt_local_entry_free_rcu() - free the tt_local_entry -* @rcu: rcu pointer of the tt_local_entry -*/ -static void batadv_tt_local_entry_free_rcu (struct rcu_head *rcu) -{ -struct batadv_tt_local_entry *tt_local_entry; - - tt_local_entry = container_of(rcu, struct batadv_tt_local_entry, - common.rcu); - -kmem_cache_free (batadv_tl_cache, tt_local_entry); -} -/** * batadv_tt_local_entry_release() - release tt_local_entry from lists and queue * for free after rcu grace period
@@ -237,7 +223,7 @@ static void batadv_tt_local_entry_release(struct kref *ref)batadv_softif_vlan_put (tt_local_entry->vlan); -call_rcu (&tt_local_entry->common.rcu, batadv_tt_local_entry_free_rcu); +kfree_rcu (tt_local_entry, common.rcu); }/**
@@ -255,20 +241,6 @@ batadv_tt_local_entry_put(struct batadv_tt_local_entry *tt_local_entry) batadv_tt_local_entry_release); } -/** -* batadv_tt_global_entry_free_rcu() - free the tt_global_entry -* @rcu: rcu pointer of the tt_global_entry -*/ -static void batadv_tt_global_entry_free_rcu (struct rcu_head *rcu) -{ -struct batadv_tt_global_entry *tt_global_entry; - - tt_global_entry = container_of(rcu, struct batadv_tt_global_entry, - common.rcu); - -kmem_cache_free (batadv_tg_cache, tt_global_entry); -} -/** * batadv_tt_global_entry_release() - release tt_global_entry from lists and * queue for free after rcu grace period
@@ -283,7 +255,7 @@ void batadv_tt_global_entry_release(struct kref *ref)batadv_tt_global_del_orig_list (tt_global_entry); -call_rcu (&tt_global_entry->common.rcu, batadv_tt_global_entry_free_rcu); +kfree_rcu (tt_global_entry, common.rcu); }/**
@@ -408,19 +380,6 @@ static void batadv_tt_global_size_dec(struct batadv_orig_node *orig_node,batadv_tt_global_size_mod (orig_node, vid,-1 ); } -/** -* batadv_tt_orig_list_entry_free_rcu() - free the orig_entry -* @rcu: rcu pointer of the orig_entry -*/ -static void batadv_tt_orig_list_entry_free_rcu (struct rcu_head *rcu) -{ -struct batadv_tt_orig_list_entry *orig_entry; - - orig_entry = container_of(rcu, struct batadv_tt_orig_list_entry, rcu); - -kmem_cache_free (batadv_tt_orig_cache, orig_entry); -} -/** * batadv_tt_orig_list_entry_release() - release tt orig entry from lists and * queue for free after rcu grace period
@@ -434,7 +393,7 @@ static void batadv_tt_orig_list_entry_release(struct kref *ref) refcount);batadv_orig_node_put (orig_entry->orig_node); -call_rcu (&orig_entry->rcu, batadv_tt_orig_list_entry_free_rcu); +kfree_rcu (orig_entry, rcu); }/**
Signature · 1 line
2.39.5