[PATCH 4/4] batman-adv: replace call_rcu by kfree_rcu for simple kmem_cache_free callback
From: Julia Lawall 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. Signed-off-by: Julia Lawall Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/translation-table.c | 47 ++ 1 file changed, 3 insertions(+), 44 deletions(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 6815d1262feb..b44c382226a1 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -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); } /** -- 2.39.5
[PATCH 3/4] batman-adv: Use string choice helper to print booleans
From: Sven Eckelmann 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. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/bat_iv_ogm.c| 4 ++-- net/batman-adv/bridge_loop_avoidance.c | 8 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 74b49c35ddc1..07ae5dd1f150 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -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); diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 5f46ca3d4bb8..449faf5a5487 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -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); -- 2.39.5
[PATCH 2/4] batman-adv: Add flex array to struct batadv_tvlv_tt_data
From: Erick Archer 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. Link: https://www.kernel.org/doc/html/next/process/deprecated.html#zero-length-and-one-element-arrays [1] Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [2] Reviewed-by: Kees Cook Signed-off-by: Erick Archer Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- include/uapi/linux/batadv_packet.h | 29 ++ net/batman-adv/translation-table.c | 49 -- 2 files changed, 36 insertions(+), 42 deletions(-) diff --git a/include/uapi/linux/batadv_packet.h b/include/uapi/linux/batadv_packet.h index 6e25753015df..439132a819ea 100644 --- a/include/uapi/linux/batadv_packet.h +++ b/include/uapi/linux/batadv_packet.h @@ -9,6 +9,7 @@ #include #include +#include #include /** @@ -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 diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 2243cec18ecc..6815d1262feb 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -856,8 +857,7 @@ batadv_tt_prepare_tvlv_global_data(stru
[PATCH 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). Signed-off-by: Simon Wunderlich --- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 3d4c36ae2e1a..97ea71a052f8 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -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 */ -- 2.39.5
[PATCH 0/4] 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(-)
[PATCH 2/2] Revert "batman-adv: prefer kfree_rcu() over call_rcu() with free-only callbacks"
) knlGS: [ 112.273001] CS: 0010 DS: ES: CR0: 80050033 [ 112.273923] CR2: 5584ef830110 CR3: 0787c000 CR4: 06f0 [ 112.275050] Call Trace: [ 112.275464] [ 112.275810] ? kmem_cache_destroy+0x14d/0x160 [ 112.276518] ? __warn+0x81/0x130 [ 112.277043] ? kmem_cache_destroy+0x14d/0x160 [ 112.277730] ? report_bug+0x171/0x1a0 [ 112.278315] ? prb_read_valid+0x1b/0x30 [ 112.278919] ? handle_bug+0x3c/0x80 [ 112.279467] ? exc_invalid_op+0x17/0x70 [ 112.280071] ? asm_exc_invalid_op+0x1a/0x20 [ 112.280741] ? kmem_cache_destroy+0x14d/0x160 [ 112.281603] ? kmem_cache_destroy+0x14d/0x160 [ 112.282489] batadv_tt_cache_destroy+0x15/0x60 [batman_adv] [ 112.283373] __do_sys_delete_module+0x1d5/0x320 [ 112.284080] do_syscall_64+0x83/0x190 [ 112.284696] ? do_syscall_64+0x8f/0x190 [ 112.285315] ? exc_page_fault+0x7f/0x180 [ 112.285970] entry_SYSCALL_64_after_hwframe+0x78/0x80 [ 112.286768] RIP: 0033:0x7f2ac8434977 [ 112.287355] Code: 73 01 c3 48 8b 0d a9 94 0c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 b0 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 79 94 0c 00 f7 d8 64 89 01 48 [ 112.290282] RSP: 002b:7ffe0adf6138 EFLAGS: 0206 ORIG_RAX: 00b0 [ 112.291465] RAX: ffda RBX: 55db9018e770 RCX: 7f2ac8434977 [ 112.292595] RDX: RSI: 0800 RDI: 55db9018e7d8 [ 112.293724] RBP: R08: 1999 R09: [ 112.294863] R10: 7f2ac84a6ac0 R11: 0206 R12: 7ffe0adf6390 [ 112.295982] R13: 55db9018e770 R14: 55db9018d2a0 R15: [ 112.297103] [ 112.297465] ---[ end trace ]--- ``` So far, after some debugging, the actual cause for this could not immediately be found within the batman-adv code. Therefore reverting this for now until the underlying issue can be found and better understood. Some additional debugging information and discussions can be found on our Redmine bugtracker, linked below. Link: https://www.open-mesh.org/issues/428 Fixes: 537db05da2ca ("batman-adv: prefer kfree_rcu() over call_rcu() with free-only callbacks") Signed-off-by: Linus Lüssing Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/translation-table.c | 47 -- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index b21ff3c36b07..2243cec18ecc 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -208,6 +208,20 @@ 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 @@ -222,7 +236,7 @@ static void batadv_tt_local_entry_release(struct kref *ref) batadv_softif_vlan_put(tt_local_entry->vlan); - kfree_rcu(tt_local_entry, common.rcu); + call_rcu(&tt_local_entry->common.rcu, batadv_tt_local_entry_free_rcu); } /** @@ -240,6 +254,20 @@ 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 @@ -254,7 +282,7 @@ void batadv_tt_global_entry_release(struct kref *ref) batadv_tt_global_del_orig_list(tt_global_entry); - kfree_rcu(tt_global_entry, common.rcu); + call_rcu(&tt_global_entry->common.rcu, batadv_tt_global_entry_free_rcu); } /** @@ -379,6 +407,19 @@ 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
[PATCH 1/2] batman-adv: Don't accept TT entries for out-of-spec VIDs
From: Sven Eckelmann The internal handling of VLAN IDs in batman-adv is only specified for following encodings: * VLAN is used - bit 15 is 1 - bit 11 - bit 0 is the VLAN ID (0-4095) - remaining bits are 0 * No VLAN is used - bit 15 is 0 - remaining bits are 0 batman-adv was only preparing new translation table entries (based on its soft interface information) using this encoding format. But the receive path was never checking if entries in the roam or TT TVLVs were also following this encoding. It was therefore possible to create more than the expected maximum of 4096 + 1 entries in the originator VLAN list. Simply by setting the "remaining bits" to "random" values in corresponding TVLV. Cc: sta...@vger.kernel.org Fixes: 7ea7b4a14275 ("batman-adv: make the TT CRC logic VLAN specific") Reported-by: Linus Lüssing Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/originator.c | 27 +++ 1 file changed, 27 insertions(+) diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index ac74f6ead62d..8f6dd2c6ee41 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -131,6 +132,29 @@ batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node, return vlan; } +/** + * batadv_vlan_id_valid() - check if vlan id is in valid batman-adv encoding + * @vid: the VLAN identifier + * + * Return: true when either no vlan is set or if VLAN is in correct range, + * false otherwise + */ +static bool batadv_vlan_id_valid(unsigned short vid) +{ + unsigned short non_vlan = vid & ~(BATADV_VLAN_HAS_TAG | VLAN_VID_MASK); + + if (vid == 0) + return true; + + if (!(vid & BATADV_VLAN_HAS_TAG)) + return false; + + if (non_vlan) + return false; + + return true; +} + /** * batadv_orig_node_vlan_new() - search and possibly create an orig_node_vlan * object @@ -149,6 +173,9 @@ batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node, { struct batadv_orig_node_vlan *vlan; + if (!batadv_vlan_id_valid(vid)) + return NULL; + spin_lock_bh(&orig_node->vlan_list_lock); /* first look if an object for this vid already exists */ -- 2.39.2
[PATCH 0/2] pull request for net: batman-adv 2024-06-21
Hi David, hi Jakub, here are two bugfixes for batman-adv which we would like to have integrated into net. Please pull or let me know of any problem! Thank you, Simon The following changes since commit 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0: Linux 6.10-rc1 (2024-05-26 15:20:12 -0700) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-net-pullrequest-20240621 for you to fetch changes up to 6bfff3582416b2f809e6b08c6e9d57b18086bdbd: Revert "batman-adv: prefer kfree_rcu() over call_rcu() with free-only callbacks" (2024-06-12 20:18:00 +0200) Here are some batman-adv bugfixes: - Don't accept TT entries for out-of-spec VIDs, by Sven Eckelmann - Revert "batman-adv: prefer kfree_rcu() over call_rcu() with free-only callbacks", by Linus Lüssing Linus Lüssing (1): Revert "batman-adv: prefer kfree_rcu() over call_rcu() with free-only callbacks" Sven Eckelmann (1): batman-adv: Don't accept TT entries for out-of-spec VIDs net/batman-adv/originator.c| 27 ++ net/batman-adv/translation-table.c | 47 +++--- 2 files changed, 71 insertions(+), 3 deletions(-)
Re: How to cite the BATMAN routing protocol in a research paper?
On Sunday, April 7, 2024 11:46:49 AM CEST Liunian Bian wrote: > Subject: How to cite the BATMAN routing protocol in a research paper? > Hi, I cannot find a proper citation for the BATMAN routing protocol. > > The citations I could find were: > > A. Neumann, C. Aichele, M. Lindner, and S. Wunderlich, “Better approach to > > mobile ad-hoc networking (B.A.T.M.A.N.)," IETF Draft, 2008 [Online] R. > > Sanchez-Iborra, M. -D. Cano and J. Garcia-Haro, "Performance Evaluation > > of BATMAN Routing Protocol for VoIP Services: A QoE Perspective," in IEEE > > Transactions on Wireless Communications, Sept. 2014 > which are incomplete and outdated. > Is there any references I can use for citing BATMAN IV or BATMAN V in a > research paper? It would help me a lot. > Hi Liunian Bian, unfortunately we don't have a good way to cite batman-adv in a paper. What most people did is to cite the 2008 IETF draft (which is actually not supposed be cited) or refer to our website www.open-mesh.org/. Perhaps the best way is to cite both, referring to the website for up-to-date documentation. Cheers, Simon signature.asc Description: This is a digitally signed message part.
[PATCH 2/3] batman-adv: prefer kfree_rcu() over call_rcu() with free-only callbacks
From: Dmitry Antipov Drop 'batadv_tt_local_entry_free_rcu()', 'batadv_tt_global_entry_free_rcu()' and 'batadv_tt_orig_list_entry_free_rcu()' in favor of 'kfree_rcu()' in 'batadv_tt_local_entry_release()', 'batadv_tt_global_entry_release()' and 'batadv_tt_orig_list_entry_release()', respectively. Signed-off-by: Dmitry Antipov Acked-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/translation-table.c | 47 ++ 1 file changed, 3 insertions(+), 44 deletions(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index b95c36765d04..0555cb611489 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -208,20 +208,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 @@ -236,7 +222,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); } /** @@ -254,20 +240,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 @@ -282,7 +254,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); } /** @@ -407,19 +379,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 @@ -433,7 +392,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); } /** -- 2.39.2
[PATCH 3/3] batman-adv: bypass empty buckets in batadv_purge_orig_ref()
From: Eric Dumazet Many syzbot reports are pointing to soft lockups in batadv_purge_orig_ref() [1] Root cause is unknown, but we can avoid spending too much time there and perhaps get more interesting reports. [1] watchdog: BUG: soft lockup - CPU#0 stuck for 27s! [kworker/u4:6:621] Modules linked in: irq event stamp: 6182794 hardirqs last enabled at (6182793): [] __local_bh_enable_ip+0x224/0x44c kernel/softirq.c:386 hardirqs last disabled at (6182794): [] __el1_irq arch/arm64/kernel/entry-common.c:533 [inline] hardirqs last disabled at (6182794): [] el1_interrupt+0x24/0x68 arch/arm64/kernel/entry-common.c:551 softirqs last enabled at (6182792): [] spin_unlock_bh include/linux/spinlock.h:396 [inline] softirqs last enabled at (6182792): [] batadv_purge_orig_ref+0x114c/0x1228 net/batman-adv/originator.c:1287 softirqs last disabled at (6182790): [] spin_lock_bh include/linux/spinlock.h:356 [inline] softirqs last disabled at (6182790): [] batadv_purge_orig_ref+0x164/0x1228 net/batman-adv/originator.c:1271 CPU: 0 PID: 621 Comm: kworker/u4:6 Not tainted 6.8.0-rc7-syzkaller-g707081b61156 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/29/2024 Workqueue: bat_events batadv_purge_orig pstate: 8045 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : should_resched arch/arm64/include/asm/preempt.h:79 [inline] pc : __local_bh_enable_ip+0x228/0x44c kernel/softirq.c:388 lr : __local_bh_enable_ip+0x224/0x44c kernel/softirq.c:386 sp : 800099007970 x29: 800099007980 x28: 1fffe00018fce1bd x27: dfff8000 x26: d2620008 x25: c7e70de8 x24: 0001 x23: 1fffe00018e57781 x22: dfff8000 x21: 80008aab71c4 x20: 0001b40136c0 x19: c72bbc08 x18: 1fffe0001a817bb0 x17: 800125414000 x16: 80008032116c x15: 0001 x14: 1fffe0001ee9d610 x13: x12: 0003 x11: x10: 00ff0100 x9 : x8 : 005e5789 x7 : 80008aab61dc x6 : x5 : x4 : 0001 x3 : x2 : 0006 x1 : 0080 x0 : 800125414000 Call trace: __daif_local_irq_enable arch/arm64/include/asm/irqflags.h:27 [inline] arch_local_irq_enable arch/arm64/include/asm/irqflags.h:49 [inline] __local_bh_enable_ip+0x228/0x44c kernel/softirq.c:386 __raw_spin_unlock_bh include/linux/spinlock_api_smp.h:167 [inline] _raw_spin_unlock_bh+0x3c/0x4c kernel/locking/spinlock.c:210 spin_unlock_bh include/linux/spinlock.h:396 [inline] batadv_purge_orig_ref+0x114c/0x1228 net/batman-adv/originator.c:1287 batadv_purge_orig+0x20/0x70 net/batman-adv/originator.c:1300 process_one_work+0x694/0x1204 kernel/workqueue.c:2633 process_scheduled_works kernel/workqueue.c:2706 [inline] worker_thread+0x938/0xef4 kernel/workqueue.c:2787 kthread+0x288/0x310 kernel/kthread.c:388 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860 Sending NMI from CPU 0 to CPUs 1: NMI backtrace for cpu 1 CPU: 1 PID: 0 Comm: swapper/1 Not tainted 6.8.0-rc7-syzkaller-g707081b61156 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/29/2024 pstate: 8045 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : arch_local_irq_enable+0x8/0xc arch/arm64/include/asm/irqflags.h:51 lr : default_idle_call+0xf8/0x128 kernel/sched/idle.c:103 sp : 800093a17d30 x29: 800093a17d30 x28: dfff8000 x27: 100012742fb4 x26: 80008ec9d000 x25: x24: 0002 x23: 100011d93a74 x22: 80008ec9d3a0 x21: x20: c19dbc00 x19: 8000802d0fd8 x18: 1fffe00036804396 x17: 80008ec9d000 x16: 8000802d089c x15: 0001 x14: 1fffe00036805f10 x13: x12: 0003 x11: 0001 x10: 0003 x9 : x8 : 000ce8d1 x7 : 8000804609e4 x6 : x5 : 0001 x4 : 0001 x3 : 80008ad6aac0 x2 : x1 : 80008aedea60 x0 : 800125436000 Call trace: __daif_local_irq_enable arch/arm64/include/asm/irqflags.h:27 [inline] arch_local_irq_enable+0x8/0xc arch/arm64/include/asm/irqflags.h:49 cpuidle_idle_call kernel/sched/idle.c:170 [inline] do_idle+0x1f0/0x4e8 kernel/sched/idle.c:312 cpu_startup_entry+0x5c/0x74 kernel/sched/idle.c:410 secondary_start_kernel+0x198/0x1c0 arch/arm64/kernel/smp.c:272 __secondary_switched+0xb8/0xbc arch/arm64/kernel/head.S:404 Signed-off-by: Eric Dumazet Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/originator.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 71c143d4b6d0..ac74f6ead62d 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -1266,6 +1266,8 @@ void batadv_purge_orig_ref(struct batadv_priv *bat_priv) /* for all origins... */ for (i = 0
[PATCH 1/3] batman-adv: Start new development cycle
This version will contain all the (major or even only minor) changes for Linux 6.10. 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). Signed-off-by: Simon Wunderlich --- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 8ca854a75a32..3d4c36ae2e1a 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -13,7 +13,7 @@ #define BATADV_DRIVER_DEVICE "batman-adv" #ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2024.1" +#define BATADV_SOURCE_VERSION "2024.2" #endif /* B.A.T.M.A.N. parameters */ -- 2.39.2
[PATCH 0/3] pull request for net-next: batman-adv 2024-04-05
Hi Jakub, hi David, here is a 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 4cece764965020c22cff7665b18a012006359095: Linux 6.9-rc1 (2024-03-24 14:10:05 -0700) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-next-pullrequest-20240405 for you to fetch changes up to 40dc8ab605894acae1473e434944924a22cfaaa0: batman-adv: bypass empty buckets in batadv_purge_orig_ref() (2024-03-31 10:13:36 +0200) This cleanup patchset includes the following patches: - bump version strings, by Simon Wunderlich - prefer kfree_rcu() over call_rcu() with free-only callbacks, by Dmitry Antipov - bypass empty buckets in batadv_purge_orig_ref(), by Eric Dumazet Dmitry Antipov (1): batman-adv: prefer kfree_rcu() over call_rcu() with free-only callbacks Eric Dumazet (1): batman-adv: bypass empty buckets in batadv_purge_orig_ref() Simon Wunderlich (1): batman-adv: Start new development cycle net/batman-adv/main.h | 2 +- net/batman-adv/originator.c| 2 ++ net/batman-adv/translation-table.c | 47 +++--- 3 files changed, 6 insertions(+), 45 deletions(-)
[PATCH 1/1] batman-adv: Avoid infinite loop trying to resize local TT
From: Sven Eckelmann If the MTU of one of an attached interface becomes too small to transmit the local translation table then it must be resized to fit inside all fragments (when enabled) or a single packet. But if the MTU becomes too low to transmit even the header + the VLAN specific part then the resizing of the local TT will never succeed. This can for example happen when the usable space is 110 bytes and 11 VLANs are on top of batman-adv. In this case, at least 116 byte would be needed. There will just be an endless spam of batman_adv: batadv0: Forced to purge local tt entries to fit new maximum fragment MTU (110) in the log but the function will never finish. Problem here is that the timeout will be halved all the time and will then stagnate at 0 and therefore never be able to reduce the table even more. There are other scenarios possible with a similar result. The number of BATADV_TT_CLIENT_NOPURGE entries in the local TT can for example be too high to fit inside a packet. Such a scenario can therefore happen also with only a single VLAN + 7 non-purgable addresses - requiring at least 120 bytes. While this should be handled proactively when: * interface with too low MTU is added * VLAN is added * non-purgeable local mac is added * MTU of an attached interface is reduced * fragmentation setting gets disabled (which most likely requires dropping attached interfaces) not all of these scenarios can be prevented because batman-adv is only consuming events without the the possibility to prevent these actions (non-purgable MAC address added, MTU of an attached interface is reduced). It is therefore necessary to also make sure that the code is able to handle also the situations when there were already incompatible system configuration are present. Cc: sta...@vger.kernel.org Fixes: a19d3d85e1b8 ("batman-adv: limit local translation table max size") Reported-by: syzbot+a6a4b5bb3da165594...@syzkaller.appspotmail.com Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/translation-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index b95c36765d04..2243cec18ecc 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -3948,7 +3948,7 @@ void batadv_tt_local_resize_to_mtu(struct net_device *soft_iface) spin_lock_bh(&bat_priv->tt.commit_lock); - while (true) { + while (timeout) { table_size = batadv_tt_local_table_transmit_size(bat_priv); if (packet_size_max >= table_size) break; -- 2.39.2
[PATCH 0/1] pull request for net: batman-adv 2024-04-05
Hi David, hi Jakub, here is a bugfix for batman-adv which we would like to have integrated into net. Please pull or let me know of any problem! Thank you, Simon The following changes since commit 4cece764965020c22cff7665b18a012006359095: Linux 6.9-rc1 (2024-03-24 14:10:05 -0700) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-net-pullrequest-20240405 for you to fetch changes up to b1f532a3b1e6d2e5559c7ace49322922637a28aa: batman-adv: Avoid infinite loop trying to resize local TT (2024-03-29 20:18:43 +0100) Here is a batman-adv bugfix: - void infinite loop trying to resize local TT, by Sven Eckelmann Sven Eckelmann (1): batman-adv: Avoid infinite loop trying to resize local TT net/batman-adv/translation-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH 4/4] batman-adv: Drop usage of export.h
From: Sven Eckelmann The linux/export.h include was introduced in commit 9bcb94c8617e ("batman-adv: Introduce missing headers for genetlink restructure") to have access to THIS_MODULE. But with commit 5b20755b7780 ("init: move THIS_MODULE from to "), it was moved and the include for export.h is no longer needed. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/netlink.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c index 1f7ed9d4f6fd..0954757f0b8b 100644 --- a/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include -- 2.39.2
[PATCH 3/4] batman-adv: Improve exception handling in batadv_throw_uevent()
From: Markus Elfring The kfree() function was called in up to three cases by the batadv_throw_uevent() function during error handling even if the passed variable contained a null pointer. This issue was detected by using the Coccinelle software. * Thus adjust jump targets. * Reorder kfree() calls at the end. Signed-off-by: Markus Elfring Acked-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/main.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 5fc754b0b3f7..75119f1ffccc 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -691,29 +691,31 @@ int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type, "%s%s", BATADV_UEV_TYPE_VAR, batadv_uev_type_str[type]); if (!uevent_env[0]) - goto out; + goto report_error; uevent_env[1] = kasprintf(GFP_ATOMIC, "%s%s", BATADV_UEV_ACTION_VAR, batadv_uev_action_str[action]); if (!uevent_env[1]) - goto out; + goto free_first_env; /* If the event is DEL, ignore the data field */ if (action != BATADV_UEV_DEL) { uevent_env[2] = kasprintf(GFP_ATOMIC, "%s%s", BATADV_UEV_DATA_VAR, data); if (!uevent_env[2]) - goto out; + goto free_second_env; } ret = kobject_uevent_env(bat_kobj, KOBJ_CHANGE, uevent_env); -out: - kfree(uevent_env[0]); - kfree(uevent_env[1]); kfree(uevent_env[2]); +free_second_env: + kfree(uevent_env[1]); +free_first_env: + kfree(uevent_env[0]); if (ret) +report_error: batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Impossible to send uevent for (%s,%s,%s) event (err: %d)\n", batadv_uev_type_str[type], -- 2.39.2
[PATCH 2/4] batman-adv: Return directly after a failed batadv_dat_select_candidates() in batadv_dat_forward_data()
From: Markus Elfring The kfree() function was called in one case by the batadv_dat_forward_data() function during error handling even if the passed variable contained a null pointer. This issue was detected by using the Coccinelle software. * Thus return directly after a batadv_dat_select_candidates() call failed at the beginning. * Delete the label “out” which became unnecessary with this refactoring. Signed-off-by: Markus Elfring Acked-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/distributed-arp-table.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index 28a939d56090..4c7e85534324 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c @@ -684,7 +684,7 @@ static bool batadv_dat_forward_data(struct batadv_priv *bat_priv, cand = batadv_dat_select_candidates(bat_priv, ip, vid); if (!cand) - goto out; + return ret; batadv_dbg(BATADV_DBG_DAT, bat_priv, "DHT_SEND for %pI4\n", &ip); @@ -728,7 +728,6 @@ static bool batadv_dat_forward_data(struct batadv_priv *bat_priv, batadv_orig_node_put(cand[i].orig_node); } -out: kfree(cand); return ret; } -- 2.39.2
[PATCH 1/4] batman-adv: Start new development cycle
This version will contain all the (major or even only minor) changes for Linux 6.9. 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). Signed-off-by: Simon Wunderlich --- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 870dcd7f1786..8ca854a75a32 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -13,7 +13,7 @@ #define BATADV_DRIVER_DEVICE "batman-adv" #ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2024.0" +#define BATADV_SOURCE_VERSION "2024.1" #endif /* B.A.T.M.A.N. parameters */ -- 2.39.2
[PATCH 0/4] pull request for net-next: batman-adv 2024-02-01
Hi Jakub, hi David, here is a 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 6613476e225e090cc9aad49be7fa504e290dd33d: Linux 6.8-rc1 (2024-01-21 14:11:32 -0800) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-next-pullrequest-20240201 for you to fetch changes up to db60ad8b21cee0394cb0a1092d9f9190d310562c: batman-adv: Drop usage of export.h (2024-01-27 09:13:59 +0100) This cleanup patchset includes the following patches: - bump version strings, by Simon Wunderlich - Improve error handling in DAT and uevent generator, by Markus Elfring (2 patches) - Drop usage of export.h, by Sven Eckelmann Markus Elfring (2): batman-adv: Return directly after a failed batadv_dat_select_candidates() in batadv_dat_forward_data() batman-adv: Improve exception handling in batadv_throw_uevent() Simon Wunderlich (1): batman-adv: Start new development cycle Sven Eckelmann (1): batman-adv: Drop usage of export.h net/batman-adv/distributed-arp-table.c | 3 +-- net/batman-adv/main.c | 14 -- net/batman-adv/main.h | 2 +- net/batman-adv/netlink.c | 1 - 4 files changed, 10 insertions(+), 10 deletions(-)
[PATCH 2/2] batman-adv: mcast: fix memory leak on deleting a batman-adv interface
From: Linus Lüssing The batman-adv multicast tracker TVLV handler is registered for the new batman-adv multicast packet type upon creating a batman-adv interface, but not unregistered again upon the interface's deletion, leading to a memory leak. Fix this memory leak by calling the according TVLV handler unregister routine for the multicast tracker TVLV upon batman-adv interface deletion. Fixes: 07afe1ba288c ("batman-adv: mcast: implement multicast packet reception and forwarding") Reported-and-tested-by: syzbot+ebe64cc5950868e77...@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/beadc4060f0cb...@google.com/ Signed-off-by: Linus Lüssing Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/multicast.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index b4f8b4af1722..14088c4ff2f6 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -2175,6 +2175,7 @@ void batadv_mcast_free(struct batadv_priv *bat_priv) cancel_delayed_work_sync(&bat_priv->mcast.work); batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_MCAST, 2); + batadv_tvlv_handler_unregister(bat_priv, BATADV_TVLV_MCAST_TRACKER, 1); batadv_tvlv_handler_unregister(bat_priv, BATADV_TVLV_MCAST, 2); /* safely calling outside of worker, as worker was canceled above */ -- 2.39.2
[PATCH 1/2] batman-adv: mcast: fix mcast packet type counter on timeouted nodes
From: Linus Lüssing When a node which does not have the new batman-adv multicast packet type capability vanishes then the according, global counter erroneously would not be reduced in response on other nodes. Which in turn leads to the mesh never switching back to sending with the new multicast packet type. Fix this by reducing the according counter when such a node times out. Fixes: 90039133221e ("batman-adv: mcast: implement multicast packet generation") Signed-off-by: Linus Lüssing Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/multicast.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index d982daea8329..b4f8b4af1722 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -2198,6 +2198,8 @@ void batadv_mcast_purge_orig(struct batadv_orig_node *orig) BATADV_MCAST_WANT_NO_RTR4); batadv_mcast_want_rtr6_update(bat_priv, orig, BATADV_MCAST_WANT_NO_RTR6); + batadv_mcast_have_mc_ptype_update(bat_priv, orig, + BATADV_MCAST_HAVE_MC_PTYPE_CAPA); spin_unlock_bh(&orig->mcast_handler_lock); } -- 2.39.2
[PATCH 0/2] pull request for net: batman-adv 2024-02-01
Hi David, hi Jakub, here are two bugfixes for batman-adv which we would like to have integrated into net. Please pull or let me know of any problem! Thank you, Simon The following changes since commit 6613476e225e090cc9aad49be7fa504e290dd33d: Linux 6.8-rc1 (2024-01-21 14:11:32 -0800) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-net-pullrequest-20240201 for you to fetch changes up to 0a186b49bba596b81de5a686ce5bfc9cd48ab3ef: batman-adv: mcast: fix memory leak on deleting a batman-adv interface (2024-01-27 09:13:39 +0100) Here are some batman-adv bugfixes: - fix a timeout issue and a memory leak in batman-adv multicast, by Linus Lüssing (2 patches) Linus Lüssing (2): batman-adv: mcast: fix mcast packet type counter on timeouted nodes batman-adv: mcast: fix memory leak on deleting a batman-adv interface net/batman-adv/multicast.c | 3 +++ 1 file changed, 3 insertions(+)
[PATCH 6/6] batman-adv: Switch to linux/array_size.h
From: Sven Eckelmann The commit 3cd39bc3b11b ("kernel.h: Move ARRAY_SIZE() to a separate header") introduced a new header for the ARRAY_SIZE macro which was previously exposed via linux/kernel.h. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/main.c| 2 +- net/batman-adv/netlink.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index e8c25583a127..5fc754b0b3f7 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -6,6 +6,7 @@ #include "main.h" +#include #include #include #include @@ -20,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c index 0c64d81a7761..1f7ed9d4f6fd 100644 --- a/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c @@ -7,6 +7,7 @@ #include "netlink.h" #include "main.h" +#include #include #include #include @@ -20,7 +21,6 @@ #include #include #include -#include #include #include #include -- 2.39.2
[PATCH 4/6] batman-adv: mcast: shrink tracker packet after scrubbing
From: Linus Lüssing Remove all zero MAC address entries (00:00:00:00:00:00) from a multicast packet's tracker TVLV before transmitting it and update all headers accordingly. This way, instead of keeping the multicast packet at a constant size throughout its journey through the mesh, it will become more lightweight, smaller with every interested receiver on the way and on each splitting intersection. Which can save some valuable bandwidth. Signed-off-by: Linus Lüssing Signed-off-by: Simon Wunderlich --- net/batman-adv/multicast_forw.c | 207 1 file changed, 207 insertions(+) diff --git a/net/batman-adv/multicast_forw.c b/net/batman-adv/multicast_forw.c index a2c5c587b8fb..fafd6ba8c056 100644 --- a/net/batman-adv/multicast_forw.c +++ b/net/batman-adv/multicast_forw.c @@ -697,6 +697,212 @@ batadv_mcast_forw_scrub_dests(struct batadv_priv *bat_priv, } } +/** + * batadv_mcast_forw_shrink_fill() - swap slot with next non-zero destination + * @slot: the to be filled zero-MAC destination entry in a tracker TVLV + * @num_dests_slot: remaining entries in tracker TVLV from/including slot + * + * Searches for the next non-zero-MAC destination entry in a tracker TVLV after + * the given slot pointer. And if found, swaps it with the zero-MAC destination + * entry which the slot points to. + * + * Return: true if slot was swapped/filled successfully, false otherwise. + */ +static bool batadv_mcast_forw_shrink_fill(u8 *slot, u16 num_dests_slot) +{ + u16 num_dests_filler; + u8 *filler; + + /* sanity check, should not happen */ + if (!num_dests_slot) + return false; + + num_dests_filler = num_dests_slot - 1; + filler = slot + ETH_ALEN; + + /* find a candidate to fill the empty slot */ + batadv_mcast_forw_tracker_for_each_dest(filler, num_dests_filler) { + if (is_zero_ether_addr(filler)) + continue; + + ether_addr_copy(slot, filler); + eth_zero_addr(filler); + return true; + } + + return false; +} + +/** + * batadv_mcast_forw_shrink_pack_dests() - pack destinations of a tracker TVLV + * @skb: the batman-adv multicast packet to compact destinations in + * + * Compacts the originator destination MAC addresses in the multicast tracker + * TVLV of the given multicast packet. This is done by moving all non-zero + * MAC addresses in direction of the skb head and all zero MAC addresses in skb + * tail direction, within the multicast tracker TVLV. + * + * Return: The number of consecutive zero MAC address destinations which are + * now at the end of the multicast tracker TVLV. + */ +static int batadv_mcast_forw_shrink_pack_dests(struct sk_buff *skb) +{ + struct batadv_tvlv_mcast_tracker *mcast_tracker; + unsigned char *skb_net_hdr; + u16 num_dests_slot; + u8 *slot; + + skb_net_hdr = skb_network_header(skb); + mcast_tracker = (struct batadv_tvlv_mcast_tracker *)skb_net_hdr; + num_dests_slot = ntohs(mcast_tracker->num_dests); + + slot = (u8 *)mcast_tracker + sizeof(*mcast_tracker); + + batadv_mcast_forw_tracker_for_each_dest(slot, num_dests_slot) { + /* find an empty slot */ + if (!is_zero_ether_addr(slot)) + continue; + + if (!batadv_mcast_forw_shrink_fill(slot, num_dests_slot)) + /* could not find a filler, so we successfully packed +* and can stop - and must not reduce num_dests_slot! +*/ + break; + } + + /* num_dests_slot is now the amount of reduced, zeroed +* destinations at the end of the tracker TVLV +*/ + return num_dests_slot; +} + +/** + * batadv_mcast_forw_shrink_align_offset() - get new alignment offset + * @num_dests_old: the old, to be updated amount of destination nodes + * @num_dests_reduce: the number of destinations that were removed + * + * Calculates the amount of potential extra alignment offset that is needed to + * adjust the TVLV padding after the change in destination nodes. + * + * Return: + * 0: If no change to padding is needed. + * 2: If padding needs to be removed. + * -2: If padding needs to be added. + */ +static short +batadv_mcast_forw_shrink_align_offset(unsigned int num_dests_old, + unsigned int num_dests_reduce) +{ + /* even amount of removed destinations -> no alignment change */ + if (!(num_dests_reduce % 2)) + return 0; + + /* even to odd amount of destinations -> remove padding */ + if (!(num_dests_old % 2)) + return 2; + + /* odd to even amount of destinations -> add padding */ + return -2; +} + +/** + * batadv_mcast_forw_shrink_update_headers() - update shrunk mc packet headers + * @skb: the batman-adv multicast packet to
[PATCH 5/6] batman-adv: Switch to linux/sprintf.h
From: Sven Eckelmann The commit 39ced19b9e60 ("lib/vsprintf: split out sprintf() and friends") introduced a new header for the sprintf related functions which were previously exposed via linux/kernel.h. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/bridge_loop_avoidance.c | 2 +- net/batman-adv/gateway_client.c| 2 +- net/batman-adv/main.c | 1 + net/batman-adv/multicast.c | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 37ce6cfb3520..5f46ca3d4bb8 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -31,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index d26124bc27e1..0ddd8b4b3f4c 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -29,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 50b2bf2b748c..e8c25583a127 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index 62288afdad49..d982daea8329 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -36,6 +35,7 @@ #include #include #include +#include #include #include #include -- 2.39.2
[PATCH 3/6] batman-adv: mcast: implement multicast packet generation
From: Linus Lüssing Implement the preparation of a batman-adv multicast packet and use this under certain conditions. For one thing this implements the capability to push a complete batman-adv multicast packet header, including a tracker TVLV with all originator destinations that have signaled interest in it, onto a given ethernet frame with an IP multicast packet inside. For another checks are implemented to determine if encapsulating a multicast packet in this new batman-adv multicast packet type and using it is feasible. Those checks are: 1) Have all nodes signaled that they are capable of handling the new batman-adv multicast packet type? 2) Do all active hard interfaces of all nodes, including us, have an MTU of at least 1280 bytes? 3) Does a complete multicast packet header with all its destination addresses fit onto the given multicast packet / ethernet frame and does not exceed 1280 bytes? If all checks passed then the new batman-adv multicast packet type will be used for transmission and distribution. Otherwise we fall back to one or more batman-adv unicast packet transmissions, if possible. Or if not possible we will fall back to classic flooding through a batman-adv broadcast packet. Signed-off-by: Linus Lüssing Signed-off-by: Simon Wunderlich --- net/batman-adv/multicast.c | 79 +++- net/batman-adv/multicast.h | 25 +- net/batman-adv/multicast_forw.c | 732 net/batman-adv/soft-interface.c | 6 +- net/batman-adv/types.h | 6 + 5 files changed, 840 insertions(+), 8 deletions(-) diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index dfc2c645b13f..62288afdad49 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -1169,17 +1169,62 @@ static int batadv_mcast_forw_rtr_count(struct batadv_priv *bat_priv, } } +/** + * batadv_mcast_forw_mode_by_count() - get forwarding mode by count + * @bat_priv: the bat priv with all the soft interface information + * @skb: the multicast packet to check + * @vid: the vlan identifier + * @is_routable: stores whether the destination is routable + * @count: the number of originators the multicast packet need to be sent to + * + * For a multicast packet with multiple destination originators, checks which + * mode to use. For BATADV_FORW_MCAST it also encapsulates the packet with a + * complete batman-adv multicast header. + * + * Return: + * BATADV_FORW_MCAST: If all nodes have multicast packet routing + * capabilities and an MTU >= 1280 on all hard interfaces (including us) + * and the encapsulated multicast packet with all destination addresses + * would still fit into an 1280 bytes batman-adv multicast packet + * (excluding the outer ethernet frame) and we could successfully push + * the full batman-adv multicast packet header. + * BATADV_FORW_UCASTS: If the packet cannot be sent in a batman-adv + * multicast packet and the amount of batman-adv unicast packets needed + * is smaller or equal to the configured multicast fanout. + * BATADV_FORW_BCAST: Otherwise. + */ +static enum batadv_forw_mode +batadv_mcast_forw_mode_by_count(struct batadv_priv *bat_priv, + struct sk_buff *skb, unsigned short vid, + int is_routable, int count) +{ + unsigned int mcast_hdrlen = batadv_mcast_forw_packet_hdrlen(count); + u8 own_tvlv_flags = bat_priv->mcast.mla_flags.tvlv_flags; + + if (!atomic_read(&bat_priv->mcast.num_no_mc_ptype_capa) && + own_tvlv_flags & BATADV_MCAST_HAVE_MC_PTYPE_CAPA && + skb->len + mcast_hdrlen <= IPV6_MIN_MTU && + batadv_mcast_forw_push(bat_priv, skb, vid, is_routable, count)) + return BATADV_FORW_MCAST; + + if (count <= atomic_read(&bat_priv->multicast_fanout)) + return BATADV_FORW_UCASTS; + + return BATADV_FORW_BCAST; +} + /** * batadv_mcast_forw_mode() - check on how to forward a multicast packet * @bat_priv: the bat priv with all the soft interface information * @skb: the multicast packet to check + * @vid: the vlan identifier * @is_routable: stores whether the destination is routable * * Return: The forwarding mode as enum batadv_forw_mode. */ enum batadv_forw_mode batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, - int *is_routable) + unsigned short vid, int *is_routable) { int ret, tt_count, ip_count, unsnoop_count, total_count; bool is_unsnoopable = false; @@ -1209,10 +1254,8 @@ batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, else if (unsnoop_count) return BATADV_FORW_BCAST; - if (total_count <= atomic_read(&bat_priv->multicast_fanout)) - return BATADV_FORW_UCASTS; - - return BATADV_FORW_BCAST
[PATCH 2/6] batman-adv: mcast: implement multicast packet reception and forwarding
From: Linus Lüssing Implement functionality to receive and forward a new TVLV capable multicast packet type. The new batman-adv multicast packet type allows to contain several originator destination addresses within a TVLV. Routers on the way will potentially split the batman-adv multicast packet and adjust its tracker TVLV contents. Routing decisions are still based on the selected BATMAN IV or BATMAN V routing algorithm. So this new batman-adv multicast packet type retains the same loop-free properties. Also a new OGM multicast TVLV flag is introduced to signal to other nodes that we are capable of handling a batman-adv multicast packet and multicast tracker TVLV. And that all of our hard interfaces have an MTU of at least 1280 bytes (IPv6 minimum MTU), as a simple solution for now to avoid MTU issues while forwarding. Signed-off-by: Linus Lüssing Signed-off-by: Simon Wunderlich --- include/uapi/linux/batadv_packet.h | 45 +- net/batman-adv/Makefile| 1 + net/batman-adv/fragmentation.c | 8 +- net/batman-adv/main.c | 2 + net/batman-adv/multicast.c | 48 +- net/batman-adv/multicast.h | 5 + net/batman-adv/multicast_forw.c| 239 + net/batman-adv/originator.c| 28 net/batman-adv/originator.h| 3 + net/batman-adv/routing.c | 70 + net/batman-adv/routing.h | 11 ++ net/batman-adv/soft-interface.c| 12 ++ net/batman-adv/types.h | 64 13 files changed, 518 insertions(+), 18 deletions(-) create mode 100644 net/batman-adv/multicast_forw.c diff --git a/include/uapi/linux/batadv_packet.h b/include/uapi/linux/batadv_packet.h index 9204e4494b25..6e25753015df 100644 --- a/include/uapi/linux/batadv_packet.h +++ b/include/uapi/linux/batadv_packet.h @@ -116,6 +116,9 @@ enum batadv_icmp_packettype { * only need routable IPv4 multicast packets we signed up for explicitly * @BATADV_MCAST_WANT_NO_RTR6: we have no IPv6 multicast router and therefore * only need routable IPv6 multicast packets we signed up for explicitly + * @BATADV_MCAST_HAVE_MC_PTYPE_CAPA: we can parse, receive and forward + * batman-adv multicast packets with a multicast tracker TVLV. And all our + * hard interfaces have an MTU of at least 1280 bytes. */ enum batadv_mcast_flags { BATADV_MCAST_WANT_ALL_UNSNOOPABLES = 1UL << 0, @@ -123,6 +126,7 @@ enum batadv_mcast_flags { BATADV_MCAST_WANT_ALL_IPV6 = 1UL << 2, BATADV_MCAST_WANT_NO_RTR4 = 1UL << 3, BATADV_MCAST_WANT_NO_RTR6 = 1UL << 4, + BATADV_MCAST_HAVE_MC_PTYPE_CAPA = 1UL << 5, }; /* tt data subtypes */ @@ -174,14 +178,16 @@ enum batadv_bla_claimframe { * @BATADV_TVLV_TT: translation table tvlv * @BATADV_TVLV_ROAM: roaming advertisement tvlv * @BATADV_TVLV_MCAST: multicast capability tvlv + * @BATADV_TVLV_MCAST_TRACKER: multicast tracker tvlv */ enum batadv_tvlv_type { - BATADV_TVLV_GW = 0x01, - BATADV_TVLV_DAT = 0x02, - BATADV_TVLV_NC = 0x03, - BATADV_TVLV_TT = 0x04, - BATADV_TVLV_ROAM= 0x05, - BATADV_TVLV_MCAST = 0x06, + BATADV_TVLV_GW = 0x01, + BATADV_TVLV_DAT = 0x02, + BATADV_TVLV_NC = 0x03, + BATADV_TVLV_TT = 0x04, + BATADV_TVLV_ROAM= 0x05, + BATADV_TVLV_MCAST = 0x06, + BATADV_TVLV_MCAST_TRACKER = 0x07, }; #pragma pack(2) @@ -487,6 +493,25 @@ struct batadv_bcast_packet { */ }; +/** + * struct batadv_mcast_packet - multicast packet for network payload + * @packet_type: batman-adv packet type, part of the general header + * @version: batman-adv protocol version, part of the general header + * @ttl: time to live for this packet, part of the general header + * @reserved: reserved byte for alignment + * @tvlv_len: length of the appended tvlv buffer (in bytes) + */ +struct batadv_mcast_packet { + __u8 packet_type; + __u8 version; + __u8 ttl; + __u8 reserved; + __be16 tvlv_len; + /* "4 bytes boundary + 2 bytes" long to make the payload after the +* following ethernet header again 4 bytes boundary aligned +*/ +}; + /** * struct batadv_coded_packet - network coded packet * @packet_type: batman-adv packet type, part of the general header @@ -628,6 +653,14 @@ struct batadv_tvlv_mcast_data { __u8 reserved[3]; }; +/** + * struct batadv_tvlv_mcast_tracker - payload of a multicast tracker tvlv + * @num_dests: number of subsequent destination originator MAC addresses + */ +struct batadv_tvlv_mcast_tracker { + __be16 num_dests; +}; + #pragma pack() #endif /* _UAPI_LINUX_BATADV_PACKET_H_ */ diff --git a/net/batman-adv/Makefile b/net/batman-adv/Makefile index 3bd
[PATCH 1/6] batman-adv: Start new development cycle
This version will contain all the (major or even only minor) changes for Linux 6.8. 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). Signed-off-by: Simon Wunderlich --- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 10007c5894a1..870dcd7f1786 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -13,7 +13,7 @@ #define BATADV_DRIVER_DEVICE "batman-adv" #ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2023.3" +#define BATADV_SOURCE_VERSION "2024.0" #endif /* B.A.T.M.A.N. parameters */ -- 2.39.2
[PATCH 0/6] pull request for net-next: batman-adv 2023-11-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 89cdf9d556016a54ff6ddd62324aa5ec790c05cc: Merge tag 'net-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net (2023-11-09 17:09:35 -0800) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-next-pullrequest-20231115 for you to fetch changes up to c3ed16a64c0b0a5b116c9753bf48496d49daffb5: batman-adv: Switch to linux/array_size.h (2023-11-14 08:16:34 +0100) This feature/cleanup patchset includes the following patches: - bump version strings, by Simon Wunderlich - Implement new multicast packet type, including its transmission, forwarding and parsing, by Linus Lüssing (3 patches) - Switch to new headers for sprintf and array size, by Sven Eckelmann (2 patches) Linus Lüssing (3): batman-adv: mcast: implement multicast packet reception and forwarding batman-adv: mcast: implement multicast packet generation batman-adv: mcast: shrink tracker packet after scrubbing Simon Wunderlich (1): batman-adv: Start new development cycle Sven Eckelmann (2): batman-adv: Switch to linux/sprintf.h batman-adv: Switch to linux/array_size.h include/uapi/linux/batadv_packet.h | 45 +- net/batman-adv/Makefile|1 + net/batman-adv/bridge_loop_avoidance.c |2 +- net/batman-adv/fragmentation.c |8 +- net/batman-adv/gateway_client.c|2 +- net/batman-adv/main.c |5 +- net/batman-adv/main.h |2 +- net/batman-adv/multicast.c | 129 +++- net/batman-adv/multicast.h | 30 +- net/batman-adv/multicast_forw.c| 1178 net/batman-adv/netlink.c |2 +- net/batman-adv/originator.c| 28 + net/batman-adv/originator.h|3 + net/batman-adv/routing.c | 70 ++ net/batman-adv/routing.h | 11 + net/batman-adv/soft-interface.c| 18 +- net/batman-adv/types.h | 70 ++ 17 files changed, 1572 insertions(+), 32 deletions(-) create mode 100644 net/batman-adv/multicast_forw.c
Re: [PATCH v7 0/3] Implementation of a Stateless Multicast Packet Type
On Sunday, September 24, 2023 12:47:34 PM CET Sven Eckelmann wrote: > @Simon, can you please also check the remaining code changes? To quickly > identify modifications, you can use > > pipx install b4 > # in you batman-adv repo > b4 diff -- 20230907010910.22427-2-linus.luess...@c0d3.blue Sorry for the delay, this actually slipped through the cracks on my end ... thanks Sven for reminding. I've checked especially against the points I raised last time. I think batadv_mcast_forw_shrink_pack_dests() looks much better now. batadv_mcast_forw_scrub_dests() is still quite hard to comprehend, but better than before - and good enough to be adopted in my opinion. We'll make sure to direct bug reports from that to Linus in any case. ;) So I'd give for this series: Acked-by: Simon Wunderlich Thank you! Simon
Re: Inquiry about Communication Issue between Nodes in "ONLY two nodes mesh network" with batman-adv
On Monday, October 16, 2023 4:12:41 PM CEST XU Yang wrote: > Dear maintainer, > > I am a developer currently using the batman-adv library in research and have > encountered some issues that I hope you might be able to assist with. > In setting up a mesh network using batman-adv, I've noticed that when only > two nodes are present in the network, they are unable to communicate with > each other. However, once a third node is introduced, all nodes can > communicate normally. Further testing has revealed that even with two > nodes, despite good ad-hoc wifi connection quality, the nodes remain > invisible to each other. > Here are the system and configuration details: > > Hardware: Jetson Orin NX with rtl8822ce > Operating System: L4T r35.3.1 Ubuntu20.04 > batman-adv version: 2023.2-9-g5fecd4a3 > > The configuration code we use is in the attachment. > > > I appreciate your time in reading this email and look forward to your > response. I hope you might be able to help me understand the cause of this > issue and suggest possible methods to resolve it. Hi Young Xu, this sounds like a underlying Wi-Fi driver issue. You may want to set up IP addresses on the base Wi-Fi interfaces (e.g. wlan0) and try to ping between the nodes directly, without batman-adv. You may also check further with "iw wlan0 station dump" (or similar) who receives packets by whom, or check with tcpdump if you see the OGM broadcasts. I haven't seen many Realtek Wi-Fi devices to use batman-adv, and at least in the past my experience with those devices not very positive, so also for that reason I'd look into driver related issues first. Cheers, Simon
[PATCH 7/7] batman-adv: Drop per algo GW section class code
From: Sven Eckelmann This code was only used in the past for the sysfs interface. But since this was replace with netlink, it was never executed. The function pointer was only checked to figure out whether the limit 255 (B.A.T.M.A.N. IV) or 2**32-1 (B.A.T.M.A.N. V) should be used as limit. So instead of keeping the function pointer, just store the limits directly in struct batadv_algo_gw_ops. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/bat_iv_ogm.c | 1 + net/batman-adv/bat_v.c | 23 +- net/batman-adv/gateway_common.c | 74 + net/batman-adv/gateway_common.h | 5 --- net/batman-adv/netlink.c| 5 +-- net/batman-adv/types.h | 7 ++-- 6 files changed, 8 insertions(+), 107 deletions(-) diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 828fb393ee94..74b49c35ddc1 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -2516,6 +2516,7 @@ static struct batadv_algo_ops batadv_batman_iv __read_mostly = { }, .gw = { .init_sel_class = batadv_iv_init_sel_class, + .sel_class_max = BATADV_TQ_MAX_VALUE, .get_best_gw_node = batadv_iv_gw_get_best_gw_node, .is_eligible = batadv_iv_gw_is_eligible, .dump = batadv_iv_gw_dump, diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c index 54e41fc709c3..ac11f1f08db0 100644 --- a/net/batman-adv/bat_v.c +++ b/net/batman-adv/bat_v.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -34,7 +35,6 @@ #include "bat_v_elp.h" #include "bat_v_ogm.h" #include "gateway_client.h" -#include "gateway_common.h" #include "hard-interface.h" #include "hash.h" #include "log.h" @@ -512,25 +512,6 @@ static void batadv_v_init_sel_class(struct batadv_priv *bat_priv) atomic_set(&bat_priv->gw.sel_class, 50); } -static ssize_t batadv_v_store_sel_class(struct batadv_priv *bat_priv, - char *buff, size_t count) -{ - u32 old_class, class; - - if (!batadv_parse_throughput(bat_priv->soft_iface, buff, -"B.A.T.M.A.N. V GW selection class", -&class)) - return -EINVAL; - - old_class = atomic_read(&bat_priv->gw.sel_class); - atomic_set(&bat_priv->gw.sel_class, class); - - if (old_class != class) - batadv_gw_reselect(bat_priv); - - return count; -} - /** * batadv_v_gw_throughput_get() - retrieve the GW-bandwidth for a given GW * @gw_node: the GW to retrieve the metric for @@ -818,7 +799,7 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { }, .gw = { .init_sel_class = batadv_v_init_sel_class, - .store_sel_class = batadv_v_store_sel_class, + .sel_class_max = U32_MAX, .get_best_gw_node = batadv_v_gw_get_best_gw_node, .is_eligible = batadv_v_gw_is_eligible, .dump = batadv_v_gw_dump, diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c index d9632607f92b..2dd36ef03c84 100644 --- a/net/batman-adv/gateway_common.c +++ b/net/batman-adv/gateway_common.c @@ -9,86 +9,14 @@ #include #include -#include -#include -#include -#include #include -#include +#include #include #include #include "gateway_client.h" -#include "log.h" #include "tvlv.h" -/** - * batadv_parse_throughput() - parse supplied string buffer to extract - * throughput information - * @net_dev: the soft interface net device - * @buff: string buffer to parse - * @description: text shown when throughput string cannot be parsed - * @throughput: pointer holding the returned throughput information - * - * Return: false on parse error and true otherwise. - */ -bool batadv_parse_throughput(struct net_device *net_dev, char *buff, -const char *description, u32 *throughput) -{ - enum batadv_bandwidth_units bw_unit_type = BATADV_BW_UNIT_KBIT; - u64 lthroughput; - char *tmp_ptr; - int ret; - - if (strlen(buff) > 4) { - tmp_ptr = buff + strlen(buff) - 4; - - if (strncasecmp(tmp_ptr, "mbit", 4) == 0) - bw_unit_type = BATADV_BW_UNIT_MBIT; - - if (strncasecmp(tmp_ptr, "kbit", 4) == 0 || - bw_unit_type == BATADV_BW_UNIT_MBIT) - *tmp_ptr = '\0'; - } - - ret = kstrtou64(buff, 10, <hroughput); - if (ret) { - batadv_err(net_dev, - "Invalid throughput speed for %s: %s\n", - description, bu
[PATCH 5/7] batman-adv: Drop unused function batadv_gw_bandwidth_set
From: Sven Eckelmann This function is no longer used since the sysfs support was removed from batman-adv. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/gateway_common.c | 88 - net/batman-adv/gateway_common.h | 2 - 2 files changed, 90 deletions(-) diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c index 6a964a773f57..d9632607f92b 100644 --- a/net/batman-adv/gateway_common.c +++ b/net/batman-adv/gateway_common.c @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -90,42 +89,6 @@ bool batadv_parse_throughput(struct net_device *net_dev, char *buff, return true; } -/** - * batadv_parse_gw_bandwidth() - parse supplied string buffer to extract - * download and upload bandwidth information - * @net_dev: the soft interface net device - * @buff: string buffer to parse - * @down: pointer holding the returned download bandwidth information - * @up: pointer holding the returned upload bandwidth information - * - * Return: false on parse error and true otherwise. - */ -static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff, - u32 *down, u32 *up) -{ - char *slash_ptr; - bool ret; - - slash_ptr = strchr(buff, '/'); - if (slash_ptr) - *slash_ptr = 0; - - ret = batadv_parse_throughput(net_dev, buff, "download gateway speed", - down); - if (!ret) - return false; - - /* we also got some upload info */ - if (slash_ptr) { - ret = batadv_parse_throughput(net_dev, slash_ptr + 1, - "upload gateway speed", up); - if (!ret) - return false; - } - - return true; -} - /** * batadv_gw_tvlv_container_update() - update the gw tvlv container after * gateway setting change @@ -155,57 +118,6 @@ void batadv_gw_tvlv_container_update(struct batadv_priv *bat_priv) } } -/** - * batadv_gw_bandwidth_set() - Parse and set download/upload gateway bandwidth - * from supplied string buffer - * @net_dev: netdev struct of the soft interface - * @buff: the buffer containing the user data - * @count: number of bytes in the buffer - * - * Return: 'count' on success or a negative error code in case of failure - */ -ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, - size_t count) -{ - struct batadv_priv *bat_priv = netdev_priv(net_dev); - u32 down_curr; - u32 up_curr; - u32 down_new = 0; - u32 up_new = 0; - bool ret; - - down_curr = (unsigned int)atomic_read(&bat_priv->gw.bandwidth_down); - up_curr = (unsigned int)atomic_read(&bat_priv->gw.bandwidth_up); - - ret = batadv_parse_gw_bandwidth(net_dev, buff, &down_new, &up_new); - if (!ret) - return -EINVAL; - - if (!down_new) - down_new = 1; - - if (!up_new) - up_new = down_new / 5; - - if (!up_new) - up_new = 1; - - if (down_curr == down_new && up_curr == up_new) - return count; - - batadv_gw_reselect(bat_priv); - batadv_info(net_dev, - "Changing gateway bandwidth from: '%u.%u/%u.%u MBit' to: '%u.%u/%u.%u MBit'\n", - down_curr / 10, down_curr % 10, up_curr / 10, up_curr % 10, - down_new / 10, down_new % 10, up_new / 10, up_new % 10); - - atomic_set(&bat_priv->gw.bandwidth_down, down_new); - atomic_set(&bat_priv->gw.bandwidth_up, up_new); - batadv_gw_tvlv_container_update(bat_priv); - - return count; -} - /** * batadv_gw_tvlv_ogm_handler_v1() - process incoming gateway tvlv container * @bat_priv: the bat priv with all the soft interface information diff --git a/net/batman-adv/gateway_common.h b/net/batman-adv/gateway_common.h index 87c37f907261..cb2e72d7ab14 100644 --- a/net/batman-adv/gateway_common.h +++ b/net/batman-adv/gateway_common.h @@ -27,8 +27,6 @@ enum batadv_bandwidth_units { #define BATADV_GW_MODE_CLIENT_NAME "client" #define BATADV_GW_MODE_SERVER_NAME "server" -ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, - size_t count); void batadv_gw_tvlv_container_update(struct batadv_priv *bat_priv); void batadv_gw_init(struct batadv_priv *bat_priv); void batadv_gw_free(struct batadv_priv *bat_priv); -- 2.39.2
[PATCH 3/7] batman-adv: Avoid magic value for minimum MTU
From: Sven Eckelmann The header linux/if_ether.h already defines a constant for the minimum MTU. So simply use it instead of having a magic constant in the code. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/soft-interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index d3fdf82282af..f7947fad06f2 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -154,7 +154,7 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) static int batadv_interface_change_mtu(struct net_device *dev, int new_mtu) { /* check ranges */ - if (new_mtu < 68 || new_mtu > batadv_hardif_min_mtu(dev)) + if (new_mtu < ETH_MIN_MTU || new_mtu > batadv_hardif_min_mtu(dev)) return -EINVAL; dev->mtu = new_mtu; -- 2.39.2
[PATCH 2/7] batman-adv: Remove unused declarations
From: YueHaibing Since commit 335fbe0f5d25 ("batman-adv: tvlv - convert tt query packet to use tvlv unicast packets") batadv_recv_tt_query() is not used. And commit 122edaa05940 ("batman-adv: tvlv - convert roaming adv packet to use tvlv unicast packets") left behind batadv_recv_roam_adv(). Signed-off-by: YueHaibing Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/routing.h | 4 1 file changed, 4 deletions(-) diff --git a/net/batman-adv/routing.h b/net/batman-adv/routing.h index 5f387786e9a7..afd15b3879f1 100644 --- a/net/batman-adv/routing.h +++ b/net/batman-adv/routing.h @@ -27,10 +27,6 @@ int batadv_recv_frag_packet(struct sk_buff *skb, struct batadv_hard_iface *iface); int batadv_recv_bcast_packet(struct sk_buff *skb, struct batadv_hard_iface *recv_if); -int batadv_recv_tt_query(struct sk_buff *skb, -struct batadv_hard_iface *recv_if); -int batadv_recv_roam_adv(struct sk_buff *skb, -struct batadv_hard_iface *recv_if); int batadv_recv_unicast_tvlv(struct sk_buff *skb, struct batadv_hard_iface *recv_if); int batadv_recv_unhandled_unicast_packet(struct sk_buff *skb, -- 2.39.2
[PATCH 6/7] batman-adv: Keep batadv_netlink_notify_* static
From: Sven Eckelmann The batadv_netlink_notify_*() functions are not used by any other source file. Just keep them local to netlink.c to get informed by the compiler when they are not used anymore. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/netlink.c | 10 +- net/batman-adv/netlink.h | 6 -- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c index ad5714f737be..b6c512ce6704 100644 --- a/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c @@ -377,7 +377,7 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg, * * Return: 0 on success, < 0 on error */ -int batadv_netlink_notify_mesh(struct batadv_priv *bat_priv) +static int batadv_netlink_notify_mesh(struct batadv_priv *bat_priv) { struct sk_buff *msg; int ret; @@ -858,8 +858,8 @@ static int batadv_netlink_hardif_fill(struct sk_buff *msg, * * Return: 0 on success, < 0 on error */ -int batadv_netlink_notify_hardif(struct batadv_priv *bat_priv, -struct batadv_hard_iface *hard_iface) +static int batadv_netlink_notify_hardif(struct batadv_priv *bat_priv, + struct batadv_hard_iface *hard_iface) { struct sk_buff *msg; int ret; @@ -1073,8 +1073,8 @@ static int batadv_netlink_vlan_fill(struct sk_buff *msg, * * Return: 0 on success, < 0 on error */ -int batadv_netlink_notify_vlan(struct batadv_priv *bat_priv, - struct batadv_softif_vlan *vlan) +static int batadv_netlink_notify_vlan(struct batadv_priv *bat_priv, + struct batadv_softif_vlan *vlan) { struct sk_buff *msg; int ret; diff --git a/net/batman-adv/netlink.h b/net/batman-adv/netlink.h index 48102cc7490c..876d2806a67d 100644 --- a/net/batman-adv/netlink.h +++ b/net/batman-adv/netlink.h @@ -21,12 +21,6 @@ int batadv_netlink_tpmeter_notify(struct batadv_priv *bat_priv, const u8 *dst, u8 result, u32 test_time, u64 total_bytes, u32 cookie); -int batadv_netlink_notify_mesh(struct batadv_priv *bat_priv); -int batadv_netlink_notify_hardif(struct batadv_priv *bat_priv, -struct batadv_hard_iface *hard_iface); -int batadv_netlink_notify_vlan(struct batadv_priv *bat_priv, - struct batadv_softif_vlan *vlan); - extern struct genl_family batadv_netlink_family; #endif /* _NET_BATMAN_ADV_NETLINK_H_ */ -- 2.39.2
[PATCH 1/7] batman-adv: Start new development cycle
This version will contain all the (major or even only minor) changes for Linux 6.6. 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). Signed-off-by: Simon Wunderlich --- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 156ed39eded1..10007c5894a1 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -13,7 +13,7 @@ #define BATADV_DRIVER_DEVICE "batman-adv" #ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2023.1" +#define BATADV_SOURCE_VERSION "2023.3" #endif /* B.A.T.M.A.N. parameters */ -- 2.39.2
[PATCH 0/7] pull request for net-next: batman-adv 2023-08-16
Hi Jakub, hi David, here is a 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 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5: Linux 6.5-rc1 (2023-07-09 13:53:13 -0700) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-next-pullrequest-20230816 for you to fetch changes up to 6f96d46f9a1ad1c02589b598c56ea881094129d8: batman-adv: Drop per algo GW section class code (2023-08-14 18:01:21 +0200) This cleanup patchset includes the following patches: - bump version strings, by Simon Wunderlich - Remove unused declarations, by Yue Haibing - Clean up MTU handling, by Sven Eckelmann (2 patches) - Clean up/remove (obsolete) functions, by Sven Eckelmann (3 patches) Simon Wunderlich (1): batman-adv: Start new development cycle Sven Eckelmann (5): batman-adv: Avoid magic value for minimum MTU batman-adv: Check hardif MTU against runtime MTU batman-adv: Drop unused function batadv_gw_bandwidth_set batman-adv: Keep batadv_netlink_notify_* static batman-adv: Drop per algo GW section class code YueHaibing (1): batman-adv: Remove unused declarations net/batman-adv/bat_iv_ogm.c | 1 + net/batman-adv/bat_v.c | 23 +- net/batman-adv/gateway_common.c | 162 +--- net/batman-adv/gateway_common.h | 7 -- net/batman-adv/hard-interface.c | 20 +++-- net/batman-adv/main.h | 2 +- net/batman-adv/netlink.c| 15 ++-- net/batman-adv/netlink.h| 6 -- net/batman-adv/routing.h| 4 - net/batman-adv/soft-interface.c | 2 +- net/batman-adv/types.h | 7 +- 11 files changed, 28 insertions(+), 221 deletions(-)
[PATCH 5/5] batman-adv: Fix batadv_v_ogm_aggr_send memory leak
From: Remi Pommarel When batadv_v_ogm_aggr_send is called for an inactive interface, the skb is silently dropped by batadv_v_ogm_send_to_if() but never freed causing the following memory leak: unreferenced object 0x0c164800 (size 512): comm "kworker/u8:1", pid 2648, jiffies 4295122303 (age 97.656s) hex dump (first 32 bytes): 00 80 af 09 00 00 ff ff e1 09 00 00 75 01 60 83 u.`. 1f 00 00 00 b8 00 00 00 15 00 05 00 da e3 d3 64 ...d backtrace: [<07ad20f6>] __kmalloc_track_caller+0x1a8/0x310 [<d1029e55>] kmalloc_reserve.constprop.0+0x70/0x13c [<8b9d4183>] __alloc_skb+0xec/0x1fc [<c7af5051>] __netdev_alloc_skb+0x48/0x23c [<642ee5f5>] batadv_v_ogm_aggr_send+0x50/0x36c [<88660bd7>] batadv_v_ogm_aggr_work+0x24/0x40 [<42fc2606>] process_one_work+0x3b0/0x610 [<2f2a0b1c>] worker_thread+0xa0/0x690 [<59fae5d4>] kthread+0x1fc/0x210 [<0c587d3a>] ret_from_fork+0x10/0x20 Free the skb in that case to fix this leak. Cc: sta...@vger.kernel.org Fixes: 0da0035942d4 ("batman-adv: OGMv2 - add basic infrastructure") Signed-off-by: Remi Pommarel Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/bat_v_ogm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index 84eac41d4658..e503ee0d896b 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -123,8 +123,10 @@ static void batadv_v_ogm_send_to_if(struct sk_buff *skb, { struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); - if (hard_iface->if_status != BATADV_IF_ACTIVE) + if (hard_iface->if_status != BATADV_IF_ACTIVE) { + kfree_skb(skb); return; + } batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_TX); batadv_add_counter(bat_priv, BATADV_CNT_MGMT_TX_BYTES, -- 2.39.2
[PATCH 4/5] batman-adv: Fix TT global entry leak when client roamed back
From: Remi Pommarel When a client roamed back to a node before it got time to destroy the pending local entry (i.e. within the same originator interval) the old global one is directly removed from hash table and left as such. But because this entry had an extra reference taken at lookup (i.e using batadv_tt_global_hash_find) there is no way its memory will be reclaimed at any time causing the following memory leak: unreferenced object 0x073c8000 (size 18560): comm "softirq", pid 0, jiffies 4294907738 (age 228.644s) hex dump (first 32 bytes): 06 31 ac 12 c7 7a 05 00 01 00 00 00 00 00 00 00 .1...z.. 2c ad be 08 00 80 ff ff 6c b6 be 08 00 80 ff ff ,...l... backtrace: [<ee6e0ffa>] kmem_cache_alloc+0x1b4/0x300 [<0ff2fdbc>] batadv_tt_global_add+0x700/0xe20 [<443897c7>] _batadv_tt_update_changes+0x21c/0x790 [<5dd90463>] batadv_tt_update_changes+0x3c/0x110 [<a2d7fc57>] batadv_tt_tvlv_unicast_handler_v1+0xafc/0xe10 [<11793f2a>] batadv_tvlv_containers_process+0x168/0x2b0 [<b7cbe2ef>] batadv_recv_unicast_tvlv+0xec/0x1f4 [<42aef1d8>] batadv_batman_skb_recv+0x25c/0x3a0 [<bbd8b0a2>] __netif_receive_skb_core.isra.0+0x7a8/0xe90 [<4033d428>] __netif_receive_skb_one_core+0x64/0x74 [<0f39a009>] __netif_receive_skb+0x48/0xe0 [<f2cd>] process_backlog+0x174/0x344 [<507d6564>] __napi_poll+0x58/0x1f4 [<b64ef9eb>] net_rx_action+0x504/0x590 [<056fa5e4>] _stext+0x1b8/0x418 [<878879d6>] run_ksoftirqd+0x74/0xa4 unreferenced object 0x0bae1a80 (size 56): comm "softirq", pid 0, jiffies 4294910888 (age 216.092s) hex dump (first 32 bytes): 00 78 b1 0b 00 00 ff ff 0d 50 00 00 00 00 00 00 .x...P.. 00 00 00 00 00 00 00 00 50 c8 3c 07 00 00 ff ff P.<. backtrace: [<ee6e0ffa>] kmem_cache_alloc+0x1b4/0x300 [<d9aaa49e>] batadv_tt_global_add+0x53c/0xe20 [<443897c7>] _batadv_tt_update_changes+0x21c/0x790 [<5dd90463>] batadv_tt_update_changes+0x3c/0x110 [<a2d7fc57>] batadv_tt_tvlv_unicast_handler_v1+0xafc/0xe10 [<11793f2a>] batadv_tvlv_containers_process+0x168/0x2b0 [<b7cbe2ef>] batadv_recv_unicast_tvlv+0xec/0x1f4 [<42aef1d8>] batadv_batman_skb_recv+0x25c/0x3a0 [<bbd8b0a2>] __netif_receive_skb_core.isra.0+0x7a8/0xe90 [<4033d428>] __netif_receive_skb_one_core+0x64/0x74 [<0f39a009>] __netif_receive_skb+0x48/0xe0 [<f2cd>] process_backlog+0x174/0x344 [<507d6564>] __napi_poll+0x58/0x1f4 [<b64ef9eb>] net_rx_action+0x504/0x590 [<056fa5e4>] _stext+0x1b8/0x418 [<878879d6>] run_ksoftirqd+0x74/0xa4 Releasing the extra reference from batadv_tt_global_hash_find even at roam back when batadv_tt_global_free is called fixes this memory leak. Cc: sta...@vger.kernel.org Fixes: 068ee6e204e1 ("batman-adv: roaming handling mechanism redesign") Signed-off-by: Remi Pommarel Signed-off-by; Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/translation-table.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 36ca31252a73..b95c36765d04 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -774,7 +774,6 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr, if (roamed_back) { batadv_tt_global_free(bat_priv, tt_global, "Roaming canceled"); - tt_global = NULL; } else { /* The global entry has to be marked as ROAMING and * has to be kept for consistency purpose -- 2.39.2
[PATCH 3/5] batman-adv: Do not get eth header before batadv_check_management_packet
From: Remi Pommarel If received skb in batadv_v_elp_packet_recv or batadv_v_ogm_packet_recv is either cloned or non linearized then its data buffer will be reallocated by batadv_check_management_packet when skb_cow or skb_linearize get called. Thus geting ethernet header address inside skb data buffer before batadv_check_management_packet had any chance to reallocate it could lead to the following kernel panic: Unable to handle kernel paging request at virtual address ff8020ab069a Mem abort info: ESR = 0x9607 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 FSC = 0x07: level 3 translation fault Data abort info: ISV = 0, ISS = 0x0007 CM = 0, WnR = 0 swapper pgtable: 4k pages, 39-bit VAs, pgdp=40f45000 [ff8020ab069a] pgd=18007fffa003, p4d=18007fffa003, pud=18007fffa003, pmd=18007fefe003, pte=006820ab0706 Internal error: Oops: 9607 [#1] SMP Modules linked in: ahci_mvebu libahci_platform libahci dvb_usb_af9035 dvb_usb_dib0700 dib0070 dib7000m dibx000_common ath11k_pci ath10k_pci ath10k_core mwl8k_new nf_nat_sip nf_conntrack_sip xhci_plat_hcd xhci_hcd nf_nat_pptp nf_conntrack_pptp at24 sbsa_gwdt CPU: 1 PID: 16 Comm: ksoftirqd/1 Not tainted 5.15.42-00066-g3242268d425c-dirty #550 Hardware name: A8k (DT) pstate: 6005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : batadv_is_my_mac+0x60/0xc0 lr : batadv_v_ogm_packet_recv+0x98/0x5d0 sp : ff8000183820 x29: ff8000183820 x28: 0001 x27: ff8014f9af00 x26: x25: 0543 x24: 0003 x23: ff8020ab0580 x22: 0110 x21: ff80168ae880 x20: x19: ff800b561000 x18: x17: x16: x15: 00dc098924ae0032 x14: 0f0405433e0054b0 x13: 0080 x12: 0041 x11: x10: x9 : x8 : x7 : ffc076dae000 x6 : ff8000183700 x5 : ffc00955e698 x4 : ff80168ae000 x3 : ff80059cf000 x2 : ff800b561000 x1 : ff8020ab0696 x0 : ff80168ae880 Call trace: batadv_is_my_mac+0x60/0xc0 batadv_v_ogm_packet_recv+0x98/0x5d0 batadv_batman_skb_recv+0x1b8/0x244 __netif_receive_skb_core.isra.0+0x440/0xc74 __netif_receive_skb_one_core+0x14/0x20 netif_receive_skb+0x68/0x140 br_pass_frame_up+0x70/0x80 br_handle_frame_finish+0x108/0x284 br_handle_frame+0x190/0x250 __netif_receive_skb_core.isra.0+0x240/0xc74 __netif_receive_skb_list_core+0x6c/0x90 netif_receive_skb_list_internal+0x1f4/0x310 napi_complete_done+0x64/0x1d0 gro_cell_poll+0x7c/0xa0 __napi_poll+0x34/0x174 net_rx_action+0xf8/0x2a0 _stext+0x12c/0x2ac run_ksoftirqd+0x4c/0x7c smpboot_thread_fn+0x120/0x210 kthread+0x140/0x150 ret_from_fork+0x10/0x20 Code: f9403844 eb03009f 54fffee1 f94 Thus ethernet header address should only be fetched after batadv_check_management_packet has been called. Fixes: 0da0035942d4 ("batman-adv: OGMv2 - add basic infrastructure") Cc: sta...@vger.kernel.org Signed-off-by: Remi Pommarel Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/bat_v_elp.c | 3 ++- net/batman-adv/bat_v_ogm.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c index acff565849ae..1d704574e6bf 100644 --- a/net/batman-adv/bat_v_elp.c +++ b/net/batman-adv/bat_v_elp.c @@ -505,7 +505,7 @@ int batadv_v_elp_packet_recv(struct sk_buff *skb, struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface); struct batadv_elp_packet *elp_packet; struct batadv_hard_iface *primary_if; - struct ethhdr *ethhdr = (struct ethhdr *)skb_mac_header(skb); + struct ethhdr *ethhdr; bool res; int ret = NET_RX_DROP; @@ -513,6 +513,7 @@ int batadv_v_elp_packet_recv(struct sk_buff *skb, if (!res) goto free_skb; + ethhdr = eth_hdr(skb); if (batadv_is_my_mac(bat_priv, ethhdr->h_source)) goto free_skb; diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index e710e9afe78f..84eac41d4658 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -985,7 +985,7 @@ int batadv_v_ogm_packet_recv(struct sk_buff *skb, { struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface); struct batadv_ogm2_packet *ogm_packet; - struct ethhdr *ethhdr = eth_hdr(skb); + struct ethhdr *ethhdr; int ogm_offset; u8 *packet_pos; int ret = NET_RX_DROP; @@ -999,6 +999,7 @@ int batadv_v_ogm_packet_recv(struct sk_buff *skb, if (!batadv_check_management_packet(skb, if_incoming, BATADV_OGM2_HLEN)) goto free_skb; + ethhdr = eth_hdr(skb); if (batadv_is_my_mac(bat_pri
[PATCH 2/5] batman-adv: Don't increase MTU when set by user
From: Sven Eckelmann If the user set an MTU value, it usually means that there are special requirements for the MTU. But if an interface gots activated, the MTU was always recalculated and then the user set value was overwritten. The only reason why this user set value has to be overwritten, is when the MTU has to be decreased because batman-adv is not able to transfer packets with the user specified size. Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol") Cc: sta...@vger.kernel.org Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/hard-interface.c | 14 +- net/batman-adv/soft-interface.c | 3 +++ net/batman-adv/types.h | 6 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index ae5762af0146..24c9c0c3f316 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -630,7 +630,19 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface) */ void batadv_update_min_mtu(struct net_device *soft_iface) { - dev_set_mtu(soft_iface, batadv_hardif_min_mtu(soft_iface)); + struct batadv_priv *bat_priv = netdev_priv(soft_iface); + int limit_mtu; + int mtu; + + mtu = batadv_hardif_min_mtu(soft_iface); + + if (bat_priv->mtu_set_by_user) + limit_mtu = bat_priv->mtu_set_by_user; + else + limit_mtu = ETH_DATA_LEN; + + mtu = min(mtu, limit_mtu); + dev_set_mtu(soft_iface, mtu); /* Check if the local translate table should be cleaned up to match a * new (and smaller) MTU. diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index d3fdf82282af..85d00dc9ce32 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -153,11 +153,14 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) static int batadv_interface_change_mtu(struct net_device *dev, int new_mtu) { + struct batadv_priv *bat_priv = netdev_priv(dev); + /* check ranges */ if (new_mtu < 68 || new_mtu > batadv_hardif_min_mtu(dev)) return -EINVAL; dev->mtu = new_mtu; + bat_priv->mtu_set_by_user = new_mtu; return 0; } diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index ca9449ec9836..cf1a0eafe3ab 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -1546,6 +1546,12 @@ struct batadv_priv { /** @soft_iface: net device which holds this struct as private data */ struct net_device *soft_iface; + /** +* @mtu_set_by_user: MTU was set once by user +* protected by rtnl_lock +*/ + int mtu_set_by_user; + /** * @bat_counters: mesh internal traffic statistic counters (see * batadv_counters) -- 2.39.2
[PATCH 1/5] batman-adv: Trigger events for auto adjusted MTU
From: Sven Eckelmann If an interface changes the MTU, it is expected that an NETDEV_PRECHANGEMTU and NETDEV_CHANGEMTU notification events is triggered. This worked fine for .ndo_change_mtu based changes because core networking code took care of it. But for auto-adjustments after hard-interfaces changes, these events were simply missing. Due to this problem, non-batman-adv components weren't aware of MTU changes and thus couldn't perform their own tasks correctly. Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol") Cc: sta...@vger.kernel.org Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/hard-interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 41c1ad33d009..ae5762af0146 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -630,7 +630,7 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface) */ void batadv_update_min_mtu(struct net_device *soft_iface) { - soft_iface->mtu = batadv_hardif_min_mtu(soft_iface); + dev_set_mtu(soft_iface, batadv_hardif_min_mtu(soft_iface)); /* Check if the local translate table should be cleaned up to match a * new (and smaller) MTU. -- 2.39.2
[PATCH 0/5] pull request for net: batman-adv 2023-08-16
Hi David, hi Jakub, here are a few bugfixes for batman-adv which we would like to have integrated into net. Please pull or let me know of any problem! Thank you, Simon The following changes since commit 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5: Linux 6.5-rc1 (2023-07-09 13:53:13 -0700) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-net-pullrequest-20230816 for you to fetch changes up to 421d467dc2d483175bad4fb76a31b9e5a3d744cf: batman-adv: Fix batadv_v_ogm_aggr_send memory leak (2023-08-09 17:33:03 +0200) Here are some batman-adv bugfixes: - Fix issues with adjusted MTUs (2 patches), by Sven Eckelmann - Fix header access for memory reallocation case, by Remi Pommarel - Fix two memory leaks (2 patches), by Remi Pommarel Remi Pommarel (3): batman-adv: Do not get eth header before batadv_check_management_packet batman-adv: Fix TT global entry leak when client roamed back batman-adv: Fix batadv_v_ogm_aggr_send memory leak Sven Eckelmann (2): batman-adv: Trigger events for auto adjusted MTU batman-adv: Don't increase MTU when set by user net/batman-adv/bat_v_elp.c | 3 ++- net/batman-adv/bat_v_ogm.c | 7 +-- net/batman-adv/hard-interface.c| 14 +- net/batman-adv/soft-interface.c| 3 +++ net/batman-adv/translation-table.c | 1 - net/batman-adv/types.h | 6 ++ 6 files changed, 29 insertions(+), 5 deletions(-)
Re: [PATCH v6 3/3] batman-adv: mcast: shrink tracker packet after scrubbing
On Thursday, July 20, 2023 6:35:55 AM CEST Linus Lüssing wrote: > Remove all zero MAC address entries (00:00:00:00:00:00) from a multicast > packet's tracker TVLV before transmitting it and update all headers > accordingly. This way, instead of keeping the multicast packet at a > constant size throughout its journey through the mesh, it will become > more lightweight, smaller with every interested receiver on the way and > on each splitting intersection. Which can save some valuable bandwidth. > > Signed-off-by: Linus Lüssing > --- > net/batman-adv/multicast_forw.c | 195 > 1 file changed, 195 insertions(+) > > diff --git a/net/batman-adv/multicast_forw.c > b/net/batman-adv/multicast_forw.c index d0f75a63de2a..d7b1aabd4b72 100644 > --- a/net/batman-adv/multicast_forw.c > +++ b/net/batman-adv/multicast_forw.c > @@ -712,6 +712,200 @@ batadv_mcast_forw_scrub_dests(struct batadv_priv > *bat_priv, } > } > > +/** > + * batadv_mcast_forw_shrink_pack_dests() - pack destinations of a tracker > TVLV + * @skb: the batman-adv multicast packet to compact destinations in + > * > + * Compacts the originator destination MAC addresses in the multicast > tracker + * TVLV of the given multicast packet. This is done by moving all > non-zero + * MAC addresses in direction of the skb head and all zero MAC > addresses in skb + * tail direction, within the multicast tracker TVLV. > + * > + * Return: The number of consecutive zero MAC address destinations which > are + * now at the end of the multicast tracker TVLV. > + */ > +static int batadv_mcast_forw_shrink_pack_dests(struct sk_buff *skb) > +{ > + struct batadv_tvlv_mcast_tracker *mcast_tracker; > + u16 num_dests_slot, num_dests_filler; > + unsigned char *skb_net_hdr; > + u8 *slot, *filler; > + > + skb_net_hdr = skb_network_header(skb); > + mcast_tracker = (struct batadv_tvlv_mcast_tracker *)skb_net_hdr; > + num_dests_slot = ntohs(mcast_tracker->num_dests); > + > + slot = (u8 *)mcast_tracker + sizeof(*mcast_tracker); > + > + if (!num_dests_slot) > + return 0; > + > + num_dests_filler = num_dests_slot - 1; > + filler = slot + ETH_ALEN; > + > + batadv_mcast_forw_tracker_for_each_dest(slot, num_dests_slot) { > + /* find an empty slot */ > + if (!is_zero_ether_addr(slot)) > + continue; > + > + /* keep filler ahead of slot */ > + if (filler <= slot) { > + num_dests_filler = num_dests_slot - 1; > + filler = slot + ETH_ALEN; > + } > + > + /* find a candidate to fill the empty slot */ > + batadv_mcast_forw_tracker_for_each_dest(filler, > + num_dests_filler) { > + if (is_zero_ether_addr(filler)) > + continue; > + > + ether_addr_copy(slot, filler); > + eth_zero_addr(filler); > + goto cont_next_slot; goto is redundant, just continue > + } > + > + /* could not find a filler, we can stop > + * - and must not advance the slot pointer! > + */ > + if (!num_dests_filler) > + break; > + This label can then be removed as well. I'm wondering why we need to keep all those pointers and do the pointer magic in the first place? can't we just make two nested functions like this: for (all entries) if zero-entry: for (all entries) if non-zero-entry swap() (I find this current function very hard to read) Cheers, Simon signature.asc Description: This is a digitally signed message part.
Re: [PATCH v6 1/3] batman-adv: mcast: implement multicast packet reception and forwarding
On Monday, August 14, 2023 5:35:28 PM CEST Simon Wunderlich wrote: > I've read through that multiple times now, and I don't understand why > next_dest isn't getting incremented within each iteration in the same way > as dest. Is this a bug or am I missing something? Might be nicer to use one > counter which is increased instead of two pointeres, e.g. &dest[counter] > and &next_dest[counter] or similar to avoid those kind of bugs. > > [...] Discussed with Sven, next_dest is actually the iterator so it should be incremented at the other place. I still think this is very hard to read, both Sven and I spent quite some time with pen and paper to understand this function. I would appreciate if it could be simplified. > > +/** > > + * batadv_mcast_forw_tracker_tvlv_handler() - handle an mcast tracker > > tvlv > > + * @bat_priv: the bat priv with all the soft interface information > > + * @skb: the received batman-adv multicast packet > > + * > > + * Parses the tracker TVLV of an incoming batman-adv multicast packet and > > + * forwards the packet as indicated in this TVLV. > > + * > > + * Caller needs to set the skb network header to the start of the > > multicast + * tracker TVLV (excluding the generic TVLV header) and the > > skb transport header + * to the next byte after this multicast tracker > > TVLV. > > + * > > + * Caller needs to free the skb. > > + * > > + * Return: NET_RX_SUCCESS or NET_RX_DROP on success or a negative error > > + * code on failure. NET_RX_SUCCESS if the received packet is supposed to > > be + * decapsulated and forwarded to the own soft interface, NET_RX_DROP > > otherwise. + */ > > +int batadv_mcast_forw_tracker_tvlv_handler(struct batadv_priv *bat_priv, > > + struct sk_buff *skb) > > +{ > > + return batadv_mcast_forw_packet(bat_priv, skb, false); > > +} > > diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c > > index 34903df4fe93..e46ce83c516a 100644 > > --- a/net/batman-adv/originator.c > > +++ b/net/batman-adv/originator.c > > @@ -942,6 +942,7 @@ struct batadv_orig_node *batadv_orig_node_new(struct > > batadv_priv *bat_priv, #ifdef CONFIG_BATMAN_ADV_MCAST > > orig_node->mcast_flags = BATADV_MCAST_WANT_NO_RTR4; > > orig_node->mcast_flags |= BATADV_MCAST_WANT_NO_RTR6; > > + orig_node->mcast_flags |= BATADV_MCAST_HAVE_MC_PTYPE_CAPA; > > INIT_HLIST_NODE(&orig_node->mcast_want_all_unsnoopables_node); > > INIT_HLIST_NODE(&orig_node->mcast_want_all_ipv4_node); > > INIT_HLIST_NODE(&orig_node->mcast_want_all_ipv6_node); > > diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c > > index 163cd43c4821..f1061985149f 100644 > > --- a/net/batman-adv/routing.c > > +++ b/net/batman-adv/routing.c > > @@ -1270,3 +1270,73 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, > > batadv_orig_node_put(orig_node); > > return ret; > > } > > + > > +#ifdef CONFIG_BATMAN_ADV_MCAST > > +/** > > + * batadv_recv_mcast_packet() - process received batman-adv multicast > > packet + * @skb: the received batman-adv multicast packet > > + * @recv_if: interface that the skb is received on > > + * > > + * Parses the given, received batman-adv multicast packet. Depending on > > the + * contents of its TVLV forwards it and/or decapsulates it to hand > > it to the + * soft interface. > > + * > > + * Return: NET_RX_DROP if the skb is not consumed, NET_RX_SUCCESS > > otherwise. + */ > > +int batadv_recv_mcast_packet(struct sk_buff *skb, > > +struct batadv_hard_iface *recv_if) > > +{ > > + struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); > > + struct batadv_mcast_packet *mcast_packet; > > + int hdr_size = sizeof(*mcast_packet); > > + unsigned char *tvlv_buff; > > + int ret = NET_RX_DROP; > > + u16 tvlv_buff_len; > > + > > + if (batadv_check_unicast_packet(bat_priv, skb, hdr_size) < 0) > > + goto free_skb; > > + > > + /* create a copy of the skb, if needed, to modify it. */ > > + if (skb_cow(skb, ETH_HLEN) < 0) > > + goto free_skb; > > + > > + /* packet needs to be linearized to access the tvlv content */ > > + if (skb_linearize(skb) < 0) > > + goto free_skb; > > + > > + mcast_packet = (struct batadv_mcast_packet *)skb->data; > > + if (mcast_packet->ttl-- < 2) > > + goto free_skb; > > More of a nit (since we do the same check in broadcasts), but if ttl == 0 on > the incoming packet, then we will actually forward it with ttl =255 and > that's a bit stupid ... Mistake on my end on this one, the original value should be used for the comparison so this is okay. Cheers, Simon signature.asc Description: This is a digitally signed message part.
Re: [PATCH v6 1/3] batman-adv: mcast: implement multicast packet reception and forwarding
On Thursday, July 20, 2023 6:35:53 AM CEST Linus Lüssing wrote: > [...] > + > +/** > + * batadv_mcast_forw_orig_to_neigh() - get next hop neighbor to an orig > address + * @bat_priv: the bat priv with all the soft interface information > + * @orig_addr: the originator MAC address to search the best next hop > router for + * > + * Return: A neighbor node which is the best router towards the given > originator + * address. > + */ > +static struct batadv_neigh_node * > +batadv_mcast_forw_orig_to_neigh(struct batadv_priv *bat_priv, u8 > *orig_addr) +{ > + struct batadv_neigh_node *neigh_node; > + struct batadv_orig_node *orig_node; > + > + orig_node = batadv_orig_hash_find(bat_priv, orig_addr); > + if (!orig_node) > + return NULL; > + > + neigh_node = batadv_find_router(bat_priv, orig_node, NULL); > + batadv_orig_node_put(orig_node); > + > + return neigh_node; > +} I was wondering if this shouldn't be a generic function rather than a multicast-specific function. It doesn't do anything multicast specific. I couldn't find something similar in other code though. > + > +/** > + * batadv_mcast_forw_scrub_dests() - scrub destinations in a tracker TVLV > + * @bat_priv: the bat priv with all the soft interface information > + * @comp_neigh: next hop neighbor to scrub+collect destinations for > + * @dest: start MAC entry in original skb's tracker TVLV > + * @next_dest: start MAC entry in to be sent skb's tracker TVLV > + * @num_dests: number of remaining destination MAC entries to iterate over > + * > + * This sorts destination entries into either the original batman-adv > + * multicast packet or the skb (copy) that is going to be sent to > comp_neigh + * next. > + * > + * In preparation for the next, to be (unicast) transmitted batman-adv > multicast + * packet skb to be sent to the given neighbor node, tries to > collect all + * originator MAC addresses that have the given neighbor node > as their next hop + * in the to be transmitted skb (copy), which next_dest > points into. That is we + * zero all destination entries in next_dest which > do not have comp_neigh as + * their next hop. And zero all destination > entries in the original skb that + * would have comp_neigh as their next > hop (to avoid redundant transmissions and + * duplicated payload later). > + */ > +static void > +batadv_mcast_forw_scrub_dests(struct batadv_priv *bat_priv, > + struct batadv_neigh_node *comp_neigh, u8 *dest, > + u8 *next_dest, u16 num_dests) > +{ > + struct batadv_neigh_node *next_neigh; > + > + /* skip first entry, this is what we are comparing with */ > + eth_zero_addr(dest); > + dest += ETH_ALEN; > + next_dest += ETH_ALEN; > + num_dests--; > + > + batadv_mcast_forw_tracker_for_each_dest(next_dest, num_dests) { > + if (is_zero_ether_addr(next_dest)) > + goto scrub_next; > + > + if (is_multicast_ether_addr(next_dest)) { > + eth_zero_addr(dest); > + eth_zero_addr(next_dest); > + goto scrub_next; > + } > + > + next_neigh = batadv_mcast_forw_orig_to_neigh(bat_priv, > + next_dest); > + if (!next_neigh) { > + eth_zero_addr(next_dest); > + goto scrub_next; > + } > + > + /* Is this for our next packet to transmit? */ > + if (batadv_compare_eth(next_neigh->addr, comp_neigh->addr)) > + eth_zero_addr(dest); > + else > + eth_zero_addr(next_dest); > + > + batadv_neigh_node_put(next_neigh); > +scrub_next: > + dest += ETH_ALEN; I've read through that multiple times now, and I don't understand why next_dest isn't getting incremented within each iteration in the same way as dest. Is this a bug or am I missing something? Might be nicer to use one counter which is increased instead of two pointeres, e.g. &dest[counter] and &next_dest[counter] or similar to avoid those kind of bugs. > [...] > +/** > + * batadv_mcast_forw_tracker_tvlv_handler() - handle an mcast tracker tvlv > + * @bat_priv: the bat priv with all the soft interface information > + * @skb: the received batman-adv multicast packet > + * > + * Parses the tracker TVLV of an incoming batman-adv multicast packet and > + * forwards the packet as indicated in this TVLV. > + * > + * Caller needs to set the skb network header to the start of the multicast > + * tracker TVLV (excluding the generic TVLV header) and the skb transport > header + * to the next byte after this multicast tracker TVLV. > + * > + * Caller needs to free the skb. > + * > + * Return: NET_RX_SUCCESS or NET_RX_DROP on success or a negative error > + * code on failure. NET_RX_SUCCESS if the received packet is supposed to be > + * decapsulated and forwarded
Re: Using BATMAN over ppp interfaces.
Hi Peter, you have to create a Layer 2 interface somehow on top of your serial link - L2TP on PPP may be one way to do it, but you stack quite a bit of headers and can't really use the broadcast nature of the medium as you say. I'm not an expert on those serial drone radios, there may be some better readily available solutions. You could send the Ethernet frame as is with some checksumming I guess. Channel access is probably not ideal either (there is no CSMA/CA or arbitration). How fast is your drone radio? I hope its more than 9600 baud ... :) Cheers, Simon On Wednesday, July 12, 2023 2:14:48 PM CEST Peter Milani wrote: > Thanks Simon, > > So to clarify, PPP relies on a higher level layer than what BATMAN uses? So > you have to create an ethernet layer 2 interface using l2tp. But are more > or less restricted to point to point routing in that case which l2tp will > be travelling across. > So there's no alternate method you're aware of that can make use of the > general broadcast nature of the underlying radio... e.g.. from an > application perspective, I can transmit a serial message from one radio and > pick that message with multiple receivers? > > cheers > Peter > > > > On Wed, 12 Jul 2023 at 21:55, Simon Wunderlich > > wrote: > > On Wednesday, July 12, 2023 6:29:50 AM CEST petermilan...@gmail.com wrote: > > > Hi All, > > > > > > I've just started using batman and was trying to see if I could get it > > > to > > > work over a serial radio link such as the simple serial devices commonly > > > used in cheap drone telemetry. The goal here is to enable low bandwidth > > > > but > > > > > adhoc ip networking. > > > > > > I had set up a pair of radios to connect using pppd and I was wondering > > > > if I > > > > > could utilise batman to try and create a mesh. An example of setting up > > > > the > > > > > serial ports as ppp interfaces: > > > > > > $ sudo pppd /dev/ttyUSB0 57600 noauth nodetach 10.42.5.5: > > > > > > That works fine but applying batman to that interface was unsuccessful. > > > I > > > think that was due to limitations in the ppp and interfaces created by > > > pppd: e.g. > > > > > > $ sudo batctl if add ppp0 > > > Error - failed to add interface ppp0: Invalid argument > > > > > > The interface ppp0 was specified as POINTTOPOINT e.g. > > > > > > $ ip link > > > $ ppp0: mtu 1500 qdisc > > > > fq_codel > > > > > state UNKNOWN mode DEFAULT group default qlen 3 > > > > > > I'm not an expert in this so don't have full visibility of all the tools > > > available. I was wondering if there were better ways to set this up, > > > possibly not using pppd? Any guidance would be appreciated. > > > > > > cheers > > > Peter > > > > Hi Peter, > > > > batman-adv requires an Ethernet compatible interface (Layer 2) to operate. > > PPP > > interfaces are Layer 3 interfaces (IP Layer), so that will not work. You > > could > > make a L2 tunnel over your PPP interface such as l2tp or vxlan and use > > that. > > Or perhaps there is a different/better way to enable an Ethernet Link over > > your > > drone radio directly > > > > Cheers, > > > > Simon signature.asc Description: This is a digitally signed message part.
Re: Using BATMAN over ppp interfaces.
On Wednesday, July 12, 2023 6:29:50 AM CEST petermilan...@gmail.com wrote: > Hi All, > > I've just started using batman and was trying to see if I could get it to > work over a serial radio link such as the simple serial devices commonly > used in cheap drone telemetry. The goal here is to enable low bandwidth but > adhoc ip networking. > > I had set up a pair of radios to connect using pppd and I was wondering if I > could utilise batman to try and create a mesh. An example of setting up the > serial ports as ppp interfaces: > > $ sudo pppd /dev/ttyUSB0 57600 noauth nodetach 10.42.5.5: > > That works fine but applying batman to that interface was unsuccessful. I > think that was due to limitations in the ppp and interfaces created by > pppd: e.g. > > $ sudo batctl if add ppp0 > Error - failed to add interface ppp0: Invalid argument > > The interface ppp0 was specified as POINTTOPOINT e.g. > > $ ip link > $ ppp0: mtu 1500 qdisc fq_codel > state UNKNOWN mode DEFAULT group default qlen 3 > > I'm not an expert in this so don't have full visibility of all the tools > available. I was wondering if there were better ways to set this up, > possibly not using pppd? Any guidance would be appreciated. > > cheers > Peter Hi Peter, batman-adv requires an Ethernet compatible interface (Layer 2) to operate. PPP interfaces are Layer 3 interfaces (IP Layer), so that will not work. You could make a L2 tunnel over your PPP interface such as l2tp or vxlan and use that. Or perhaps there is a different/better way to enable an Ethernet Link over your drone radio directly Cheers, Simon signature.asc Description: This is a digitally signed message part.
[PATCH 0/1] pull request for net: batman-adv 2023-06-07
Hi David, hi Jakub, here is a bugfix for batman-adv which we would like to have integrated into net. Please pull or let me know of any problem! Thank you, Simon The following changes since commit 44c026a73be8038f03dbdeef028b642880cf1511: Linux 6.4-rc3 (2023-05-21 14:05:48 -0700) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-net-pullrequest-20230607 for you to fetch changes up to abac3ac97fe8734b620e7322a116450d7f90aa43: batman-adv: Broken sync while rescheduling delayed work (2023-05-26 23:14:49 +0200) Here is a batman-adv bugfix: - fix a broken sync while rescheduling delayed work, by Vladislav Efanov Vladislav Efanov (1): batman-adv: Broken sync while rescheduling delayed work net/batman-adv/distributed-arp-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH 5/5] batman-adv: tvlv: prepare for tvlv enabled multicast packet type
From: Linus Lüssing Prepare TVLV infrastructure for more packet types, in particular the upcoming batman-adv multicast packet type. For that swap the OGM vs. unicast-tvlv packet boolean indicator to an explicit unsigned integer packet type variable. And provide the skb to a call to batadv_tvlv_containers_process(), as later the multicast packet's TVLV handler will need to have access not only to the TVLV but the full skb for forwarding. Forwarding will be invoked from the multicast packet's TVLVs' contents later. Signed-off-by: Linus Lüssing Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- include/uapi/linux/batadv_packet.h | 2 + net/batman-adv/bat_v_ogm.c | 4 +- net/batman-adv/distributed-arp-table.c | 2 +- net/batman-adv/gateway_common.c| 2 +- net/batman-adv/multicast.c | 2 +- net/batman-adv/network-coding.c| 2 +- net/batman-adv/routing.c | 7 ++- net/batman-adv/translation-table.c | 4 +- net/batman-adv/tvlv.c | 71 ++ net/batman-adv/tvlv.h | 9 ++-- net/batman-adv/types.h | 6 +++ 11 files changed, 74 insertions(+), 37 deletions(-) diff --git a/include/uapi/linux/batadv_packet.h b/include/uapi/linux/batadv_packet.h index ea4692c339ce..9204e4494b25 100644 --- a/include/uapi/linux/batadv_packet.h +++ b/include/uapi/linux/batadv_packet.h @@ -26,6 +26,7 @@ * @BATADV_CODED: network coded packets * @BATADV_ELP: echo location packets for B.A.T.M.A.N. V * @BATADV_OGM2: originator messages for B.A.T.M.A.N. V + * @BATADV_MCAST: multicast packet with multiple destination addresses * * @BATADV_UNICAST: unicast packets carrying unicast payload traffic * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original @@ -42,6 +43,7 @@ enum batadv_packettype { BATADV_CODED= 0x02, BATADV_ELP = 0x03, BATADV_OGM2 = 0x04, + BATADV_MCAST= 0x05, /* 0x40 - 0x7f: unicast */ #define BATADV_UNICAST_MIN 0x40 BATADV_UNICAST = 0x40, diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index 96e027364ddd..e710e9afe78f 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -799,8 +799,8 @@ batadv_v_ogm_process_per_outif(struct batadv_priv *bat_priv, /* only unknown & newer OGMs contain TVLVs we are interested in */ if (seqno_age > 0 && if_outgoing == BATADV_IF_DEFAULT) - batadv_tvlv_containers_process(bat_priv, true, orig_node, - NULL, NULL, + batadv_tvlv_containers_process(bat_priv, BATADV_OGM2, orig_node, + NULL, (unsigned char *)(ogm2 + 1), ntohs(ogm2->tvlv_len)); diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index fefb51a5f606..6968e55eb971 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c @@ -822,7 +822,7 @@ int batadv_dat_init(struct batadv_priv *bat_priv) batadv_dat_start_timer(bat_priv); batadv_tvlv_handler_register(bat_priv, batadv_dat_tvlv_ogm_handler_v1, -NULL, BATADV_TVLV_DAT, 1, +NULL, NULL, BATADV_TVLV_DAT, 1, BATADV_TVLV_HANDLER_OGM_CIFNOTFND); batadv_dat_tvlv_container_update(bat_priv); return 0; diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c index 9349c76f30c5..6a964a773f57 100644 --- a/net/batman-adv/gateway_common.c +++ b/net/batman-adv/gateway_common.c @@ -259,7 +259,7 @@ void batadv_gw_init(struct batadv_priv *bat_priv) atomic_set(&bat_priv->gw.sel_class, 1); batadv_tvlv_handler_register(bat_priv, batadv_gw_tvlv_ogm_handler_v1, -NULL, BATADV_TVLV_GW, 1, +NULL, NULL, BATADV_TVLV_GW, 1, BATADV_TVLV_HANDLER_OGM_CIFNOTFND); } diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index 7e2822c01e00..315394f12c55 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -1818,7 +1818,7 @@ static void batadv_mcast_tvlv_ogm_handler(struct batadv_priv *bat_priv, void batadv_mcast_init(struct batadv_priv *bat_priv) { batadv_tvlv_handler_register(bat_priv, batadv_mcast_tvlv_ogm_handler, -NULL, BATADV_TVLV_MCAST, 2, +NULL, NULL, BATADV_TVLV_MCAST, 2, BATADV_TVLV_HANDLER_OGM_CIFNOTFND); INIT_DELAYED_WORK(&bat_priv->mcast.work, batadv_mcast_m
[PATCH 4/5] batman-adv: mcast: remove now redundant single ucast forwarding
From: Linus Lüssing The multicast code to send a multicast packet via multiple batman-adv unicast packets is not only capable of sending to multiple but also to a single node. Therefore we can safely remove the old, specialized, now redundant multicast-to-single-unicast code. The only functional change of this simplification is that the edge case of allowing a multicast packet with an unsnoopable destination address (224.0.0.0/24 or ff02::1) where only a single node has signaled interest in it via the batman-adv want-all-unsnoopables multicast flag is now transmitted via a batman-adv broadcast instead of a batman-adv unicast packet. Maintaining this edge case feature does not seem worth the extra lines of code and people should just not expect to be able to snoop and optimize such unsnoopable multicast addresses when bridges are involved. While at it also renaming a few items in the batadv_forw_mode enum to prepare for the new batman-adv multicast packet type. Signed-off-by: Linus Lüssing Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/multicast.c | 249 ++-- net/batman-adv/multicast.h | 38 + net/batman-adv/soft-interface.c | 26 ++-- 3 files changed, 33 insertions(+), 280 deletions(-) diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index b238455913df..7e2822c01e00 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -1136,223 +1135,20 @@ static int batadv_mcast_forw_rtr_count(struct batadv_priv *bat_priv, } } -/** - * batadv_mcast_forw_tt_node_get() - get a multicast tt node - * @bat_priv: the bat priv with all the soft interface information - * @ethhdr: the ether header containing the multicast destination - * - * Return: an orig_node matching the multicast address provided by ethhdr - * via a translation table lookup. This increases the returned nodes refcount. - */ -static struct batadv_orig_node * -batadv_mcast_forw_tt_node_get(struct batadv_priv *bat_priv, - struct ethhdr *ethhdr) -{ - return batadv_transtable_search(bat_priv, NULL, ethhdr->h_dest, - BATADV_NO_FLAGS); -} - -/** - * batadv_mcast_forw_ipv4_node_get() - get a node with an ipv4 flag - * @bat_priv: the bat priv with all the soft interface information - * - * Return: an orig_node which has the BATADV_MCAST_WANT_ALL_IPV4 flag set and - * increases its refcount. - */ -static struct batadv_orig_node * -batadv_mcast_forw_ipv4_node_get(struct batadv_priv *bat_priv) -{ - struct batadv_orig_node *tmp_orig_node, *orig_node = NULL; - - rcu_read_lock(); - hlist_for_each_entry_rcu(tmp_orig_node, -&bat_priv->mcast.want_all_ipv4_list, -mcast_want_all_ipv4_node) { - if (!kref_get_unless_zero(&tmp_orig_node->refcount)) - continue; - - orig_node = tmp_orig_node; - break; - } - rcu_read_unlock(); - - return orig_node; -} - -/** - * batadv_mcast_forw_ipv6_node_get() - get a node with an ipv6 flag - * @bat_priv: the bat priv with all the soft interface information - * - * Return: an orig_node which has the BATADV_MCAST_WANT_ALL_IPV6 flag set - * and increases its refcount. - */ -static struct batadv_orig_node * -batadv_mcast_forw_ipv6_node_get(struct batadv_priv *bat_priv) -{ - struct batadv_orig_node *tmp_orig_node, *orig_node = NULL; - - rcu_read_lock(); - hlist_for_each_entry_rcu(tmp_orig_node, -&bat_priv->mcast.want_all_ipv6_list, -mcast_want_all_ipv6_node) { - if (!kref_get_unless_zero(&tmp_orig_node->refcount)) - continue; - - orig_node = tmp_orig_node; - break; - } - rcu_read_unlock(); - - return orig_node; -} - -/** - * batadv_mcast_forw_ip_node_get() - get a node with an ipv4/ipv6 flag - * @bat_priv: the bat priv with all the soft interface information - * @ethhdr: an ethernet header to determine the protocol family from - * - * Return: an orig_node which has the BATADV_MCAST_WANT_ALL_IPV4 or - * BATADV_MCAST_WANT_ALL_IPV6 flag, depending on the provided ethhdr, sets and - * increases its refcount. - */ -static struct batadv_orig_node * -batadv_mcast_forw_ip_node_get(struct batadv_priv *bat_priv, - struct ethhdr *ethhdr) -{ - switch (ntohs(ethhdr->h_proto)) { - case ETH_P_IP: - return batadv_mcast_forw_ipv4_node_get(bat_priv); - case ETH_P_IPV6: - return batadv_mcast_forw_ipv6_node_get(bat_priv); - default: - /* we shouldn't be here... */ - return NULL; - } -} - -/**
[PATCH 3/5] batman-adv: Fix mailing list address
From: Sven Eckelmann Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- Documentation/networking/batman-adv.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/networking/batman-adv.rst b/Documentation/networking/batman-adv.rst index b85563ea3682..8a0dcb1894b4 100644 --- a/Documentation/networking/batman-adv.rst +++ b/Documentation/networking/batman-adv.rst @@ -159,7 +159,7 @@ Please send us comments, experiences, questions, anything :) IRC: #batadv on ircs://irc.hackint.org/ Mailing-list: - b.a.t.m@open-mesh.org (optional subscription at + b.a.t.m.a.n@lists.open-mesh.org (optional subscription at https://lists.open-mesh.org/mailman3/postorius/lists/b.a.t.m.a.n.lists.open-mesh.org/) You can also contact the Authors: -- 2.30.2
[PATCH 2/5] batman-adv: Drop prandom.h includes
From: Sven Eckelmann The commit 8032bf1233a7 ("treewide: use get_random_u32_below() instead of deprecated function") replaced the prandom.h function prandom_u32_max with the random.h function get_random_u32_below. There is no need to still include prandom.h. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/bat_iv_ogm.c | 1 - net/batman-adv/bat_v_elp.c | 1 - net/batman-adv/bat_v_ogm.c | 1 - net/batman-adv/network-coding.c | 2 +- 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 114ee5da261f..828fb393ee94 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c index f9a58fb5442e..acff565849ae 100644 --- a/net/batman-adv/bat_v_elp.c +++ b/net/batman-adv/bat_v_elp.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index addfd8c4fe95..96e027364ddd 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index bf29fba4dde5..ecd871abda34 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c @@ -25,8 +25,8 @@ #include #include #include -#include #include +#include #include #include #include -- 2.30.2
[PATCH 1/5] batman-adv: Start new development cycle
This version will contain all the (major or even only minor) changes for Linux 6.3. 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). Signed-off-by: Simon Wunderlich --- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index c48803b32bb0..156ed39eded1 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -13,7 +13,7 @@ #define BATADV_DRIVER_DEVICE "batman-adv" #ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2022.3" +#define BATADV_SOURCE_VERSION "2023.1" #endif /* B.A.T.M.A.N. parameters */ -- 2.30.2
[PATCH 0/5] pull request for net-next: batman-adv 2023-01-27
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 88603b6dc419445847923fcb7fe5080067a30f98: Linux 6.2-rc2 (2023-01-01 13:53:16 -0800) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-next-pullrequest-20230127 for you to fetch changes up to 0c4061c0d0e2c381ffe4d8b7c62ea69ad8132071: batman-adv: tvlv: prepare for tvlv enabled multicast packet type (2023-01-21 19:01:59 +0100) This feature/cleanup patchset includes the following patches: - bump version strings, by Simon Wunderlich - drop prandom.h includes, by Sven Eckelmann - fix mailing list address, by Sven Eckelmann - multicast feature preparation, by Linus Lüssing (2 patches) Linus Lüssing (2): batman-adv: mcast: remove now redundant single ucast forwarding batman-adv: tvlv: prepare for tvlv enabled multicast packet type Simon Wunderlich (1): batman-adv: Start new development cycle Sven Eckelmann (2): batman-adv: Drop prandom.h includes batman-adv: Fix mailing list address Documentation/networking/batman-adv.rst | 2 +- include/uapi/linux/batadv_packet.h | 2 + net/batman-adv/bat_iv_ogm.c | 1 - net/batman-adv/bat_v_elp.c | 1 - net/batman-adv/bat_v_ogm.c | 5 +- net/batman-adv/distributed-arp-table.c | 2 +- net/batman-adv/gateway_common.c | 2 +- net/batman-adv/main.h | 2 +- net/batman-adv/multicast.c | 251 ++-- net/batman-adv/multicast.h | 38 + net/batman-adv/network-coding.c | 4 +- net/batman-adv/routing.c| 7 +- net/batman-adv/soft-interface.c | 26 ++-- net/batman-adv/translation-table.c | 4 +- net/batman-adv/tvlv.c | 71 ++--- net/batman-adv/tvlv.h | 9 +- net/batman-adv/types.h | 6 + 17 files changed, 110 insertions(+), 323 deletions(-)
Re: [PATCH v4 3/5] batman-adv: mcast: implement multicast packet reception and forwarding
On Tuesday, December 27, 2022 8:34:07 PM CET Linus Lüssing wrote: > +/** > + * struct batadv_tvlv_mcast_tracker - payload of a multicast tracker tvlv > + * @num_dests: number of subsequent destination originator MAC addresses > + * @align: (optional) alignment bytes to make the tracker TVLV 4 bytes > aligned, + * present if num_dests are even, not present if odd > + */ > +struct batadv_tvlv_mcast_tracker { > + __be16 num_dests; > + __u8align[2]; > +}; > + The one thing which I really don't like is to have the alignment in the beginning, and depending on the number of entries. Normally, such alignments should be at the end of the structure so it is straight forward for a parser to omit it. My understanding is that the alignment is due to technical reasons (mac address list is assembled by pushing the data to the front), perhaps to save another memove/memcpy. However, the data is collected by traversing various lists, and if performance would be a concern, then this data should be cached and this "technicality" wouldn't be needed either. So please, skip the alignment in the front and have it in the back. The rest of the packet format looks good from what I've seen. Cheers, Simon signature.asc Description: This is a digitally signed message part.
[PATCH 4/4] batman-adv: remove unused struct definitions
From: Marek Lindner Signed-off-by: Marek Lindner Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/types.h | 39 --- 1 file changed, 39 deletions(-) diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 2be5d4a712c5..758cd797a063 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -1740,45 +1740,6 @@ struct batadv_priv { #endif }; -/** - * struct batadv_socket_client - layer2 icmp socket client data - */ -struct batadv_socket_client { - /** -* @queue_list: packet queue for packets destined for this socket client -*/ - struct list_head queue_list; - - /** @queue_len: number of packets in the packet queue (queue_list) */ - unsigned int queue_len; - - /** @index: socket client's index in the batadv_socket_client_hash */ - unsigned char index; - - /** @lock: lock protecting queue_list, queue_len & index */ - spinlock_t lock; - - /** @queue_wait: socket client's wait queue */ - wait_queue_head_t queue_wait; - - /** @bat_priv: pointer to soft_iface this client belongs to */ - struct batadv_priv *bat_priv; -}; - -/** - * struct batadv_socket_packet - layer2 icmp packet for socket client - */ -struct batadv_socket_packet { - /** @list: list node for &batadv_socket_client.queue_list */ - struct list_head list; - - /** @icmp_len: size of the layer2 icmp packet */ - size_t icmp_len; - - /** @icmp_packet: layer2 icmp packet */ - u8 icmp_packet[BATADV_ICMP_MAX_PACKET_SIZE]; -}; - #ifdef CONFIG_BATMAN_ADV_BLA /** -- 2.30.2
[PATCH 1/4] batman-adv: Start new development cycle
This version will contain all the (major or even only minor) changes for Linux 6.1. 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). Signed-off-by: Simon Wunderlich --- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 23f3d53f4b51..c48803b32bb0 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -13,7 +13,7 @@ #define BATADV_DRIVER_DEVICE "batman-adv" #ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2022.2" +#define BATADV_SOURCE_VERSION "2022.3" #endif /* B.A.T.M.A.N. parameters */ -- 2.30.2
[PATCH 0/4] pull request for net-next: batman-adv 2022-09-16
Hi Jakub, hi David, here is a little 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 568035b01cfb107af8d2e4bd2fb9aea22cf5b868: Linux 6.0-rc1 (2022-08-14 15:50:18 -0700) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-next-pullrequest-20220916 for you to fetch changes up to 76af7483b3c7c42571aae767b553ef7d436305e9: batman-adv: remove unused struct definitions (2022-09-15 08:16:05 +0200) This cleanup patchset includes the following patches: - bump version strings, by Simon Wunderlich - drop unused headers in trace.h, by Sven Eckelmann - drop initialization of flexible ethtool_link_ksettings, by Sven Eckelmann - remove unused struct definitions, by Marek Lindner Marek Lindner (1): batman-adv: remove unused struct definitions Simon Wunderlich (1): batman-adv: Start new development cycle Sven Eckelmann (2): batman-adv: Drop unused headers in trace.h batman-adv: Drop initialization of flexible ethtool_link_ksettings net/batman-adv/bat_v_elp.c | 1 - net/batman-adv/main.h | 2 +- net/batman-adv/trace.h | 2 -- net/batman-adv/types.h | 39 --- 4 files changed, 1 insertion(+), 43 deletions(-)
[PATCH 2/4] batman-adv: Drop unused headers in trace.h
From: Sven Eckelmann The commit 9abc291812d7 ("batman-adv: tracing: Use the new __vstring() helper") removed the usage of WARN_ON_ONCE and __dynamic_array in this file. But it was forgotten to adjust the headers accordingly (dropping the now no longer used ones). Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/trace.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/batman-adv/trace.h b/net/batman-adv/trace.h index 31c8f922651d..5dd52bc5cabb 100644 --- a/net/batman-adv/trace.h +++ b/net/batman-adv/trace.h @@ -9,8 +9,6 @@ #include "main.h" -#include -#include #include #include #include -- 2.30.2
[PATCH 3/4] batman-adv: Drop initialization of flexible ethtool_link_ksettings
From: Sven Eckelmann The commit 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with flexible-array members") changed various structures from using 0-length arrays to flexible arrays net/batman-adv/bat_v_elp.c: note: in included file: ./include/linux/ethtool.h:148:38: warning: nested flexible array net/batman-adv/bat_v_elp.c:128:9: warning: using sizeof on a flexible structure In theory, this could be worked around by using {} as initializer for the variable on the stack. But this variable doesn't has to be initialized at all by the caller of __ethtool_get_link_ksettings - everything will be initialized by the callee when no error occurs. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/bat_v_elp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c index b6db999abf75..f1741fbfb617 100644 --- a/net/batman-adv/bat_v_elp.c +++ b/net/batman-adv/bat_v_elp.c @@ -125,7 +125,6 @@ static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh) /* if not a wifi interface, check if this device provides data via * ethtool (e.g. an Ethernet adapter) */ - memset(&link_settings, 0, sizeof(link_settings)); rtnl_lock(); ret = __ethtool_get_link_ksettings(hard_iface->net_dev, &link_settings); rtnl_unlock(); -- 2.30.2
[PATCH 1/1] batman-adv: Fix hang up with small MTU hard-interface
From: Shigeru Yoshida The system hangs up when batman-adv soft-interface is created on hard-interface with small MTU. For example, the following commands create batman-adv soft-interface on dummy interface with zero MTU: # ip link add name dummy0 type dummy # ip link set mtu 0 dev dummy0 # ip link set up dev dummy0 # ip link add name bat0 type batadv # ip link set dev dummy0 master bat0 These commands cause the system hang up with the following messages: [ 90.578925][ T6689] batman_adv: bat0: Adding interface: dummy0 [ 90.580884][ T6689] batman_adv: bat0: The MTU of interface dummy0 is too small (0) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to 1560 would solve the problem. [ 90.586264][ T6689] batman_adv: bat0: Interface activated: dummy0 [ 90.590061][ T6689] batman_adv: bat0: Forced to purge local tt entries to fit new maximum fragment MTU (-320) [ 90.595517][ T6689] batman_adv: bat0: Forced to purge local tt entries to fit new maximum fragment MTU (-320) [ 90.598499][ T6689] batman_adv: bat0: Forced to purge local tt entries to fit new maximum fragment MTU (-320) This patch fixes this issue by returning error when enabling hard-interface with small MTU size. Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol") Signed-off-by: Shigeru Yoshida Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/hard-interface.c | 4 1 file changed, 4 insertions(+) diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index b8f8da7ee3de..41c1ad33d009 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -700,6 +701,9 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, int max_header_len = batadv_max_header_len(); int ret; + if (hard_iface->net_dev->mtu < ETH_MIN_MTU + max_header_len) + return -EINVAL; + if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) goto out; -- 2.30.2
[PATCH 0/1] pull request for net: batman-adv 2022-09-16
Hi David, hi Jakub, here is a bugfix for batman-adv which we would like to have integrated into net. Please pull or let me know of any problem! Thank you, Simon The following changes since commit 568035b01cfb107af8d2e4bd2fb9aea22cf5b868: Linux 6.0-rc1 (2022-08-14 15:50:18 -0700) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-net-pullrequest-20220916 for you to fetch changes up to b1cb8a71f1eaec4eb77051590f7f561f25b15e32: batman-adv: Fix hang up with small MTU hard-interface (2022-08-20 14:17:45 +0200) Here is a batman-adv bugfix: - Fix hang up with small MTU hard-interface, by Shigeru Yoshida Shigeru Yoshida (1): batman-adv: Fix hang up with small MTU hard-interface net/batman-adv/hard-interface.c | 4 1 file changed, 4 insertions(+)
Re: Question about batman for ARM
On Friday, June 17, 2022 10:45:48 AM CEST Sven Eckelmann wrote: > On Friday, 17 June 2022 10:41:46 CEST cch...@creonexsystems.com wrote: > [...] > > > We would like to use batman with a custom radio and are trying to figure > > out what part of the source code we may need to modify to allow batman to > > work with a custom radio. Custom radio means that the radio is not a > > commercial radio, such as wi-fi or Bluetooth. > batman-adv (especially with the B.A.T.M.A.N. IV algo) only requires that the > device itself can transport ethernet frames (with proper unicast and > broadcast behavior). If you need something else then you either need a > virtual interface which does the translation from $whatever to ethernet > (and back) - or you need to reimplement the B.A.T.M.A.N. IV/V algorithms > yourself. In other words, if your radio comes up as a regular Ethernet interface in Linux (like WiFi, for example), then you can easily run batman-adv on top of it. If that's not the case, then you can write a driver to present a (virtual) interface to the system like Sven suggested. Cheers, Simon signature.asc Description: This is a digitally signed message part.
[PATCH 2/2] batman-adv: remove unnecessary type castings
From: Yu Zhe remove unnecessary void* type castings. Signed-off-by: Yu Zhe [s...@narfation.org: Fix missing const in batadv_choose* functions] Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/bridge_loop_avoidance.c | 4 ++-- net/batman-adv/translation-table.c | 12 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 7f8a14d99cdb..37ce6cfb3520 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -65,7 +65,7 @@ batadv_bla_send_announce(struct batadv_priv *bat_priv, */ static inline u32 batadv_choose_claim(const void *data, u32 size) { - struct batadv_bla_claim *claim = (struct batadv_bla_claim *)data; + const struct batadv_bla_claim *claim = data; u32 hash = 0; hash = jhash(&claim->addr, sizeof(claim->addr), hash); @@ -86,7 +86,7 @@ static inline u32 batadv_choose_backbone_gw(const void *data, u32 size) const struct batadv_bla_backbone_gw *gw; u32 hash = 0; - gw = (struct batadv_bla_backbone_gw *)data; + gw = data; hash = jhash(&gw->orig, sizeof(gw->orig), hash); hash = jhash(&gw->vid, sizeof(gw->vid), hash); diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 8478034d3abf..01d30c1e412c 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -103,10 +103,10 @@ static bool batadv_compare_tt(const struct hlist_node *node, const void *data2) */ static inline u32 batadv_choose_tt(const void *data, u32 size) { - struct batadv_tt_common_entry *tt; + const struct batadv_tt_common_entry *tt; u32 hash = 0; - tt = (struct batadv_tt_common_entry *)data; + tt = data; hash = jhash(&tt->addr, ETH_ALEN, hash); hash = jhash(&tt->vid, sizeof(tt->vid), hash); @@ -2766,7 +2766,7 @@ static void batadv_tt_tvlv_generate(struct batadv_priv *bat_priv, u32 i; tt_tot = batadv_tt_entries(tt_len); - tt_change = (struct batadv_tvlv_tt_change *)tvlv_buff; + tt_change = tvlv_buff; if (!valid_cb) return; @@ -3994,7 +3994,7 @@ static void batadv_tt_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv, if (tvlv_value_len < sizeof(*tt_data)) return; - tt_data = (struct batadv_tvlv_tt_data *)tvlv_value; + tt_data = tvlv_value; tvlv_value_len -= sizeof(*tt_data); num_vlan = ntohs(tt_data->num_vlan); @@ -4037,7 +4037,7 @@ static int batadv_tt_tvlv_unicast_handler_v1(struct batadv_priv *bat_priv, if (tvlv_value_len < sizeof(*tt_data)) return NET_RX_SUCCESS; - tt_data = (struct batadv_tvlv_tt_data *)tvlv_value; + tt_data = tvlv_value; tvlv_value_len -= sizeof(*tt_data); tt_vlan_len = sizeof(struct batadv_tvlv_tt_vlan_data); @@ -4129,7 +4129,7 @@ static int batadv_roam_tvlv_unicast_handler_v1(struct batadv_priv *bat_priv, goto out; batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_RX); - roaming_adv = (struct batadv_tvlv_roam_adv *)tvlv_value; + roaming_adv = tvlv_value; batadv_dbg(BATADV_DBG_TT, bat_priv, "Received ROAMING_ADV from %pM (client %pM)\n", -- 2.30.2
[PATCH 0/2] pull request for net-next: batman-adv 2022-05-08
Hi Jakub, hi David, here is a very little 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 3123109284176b1532874591f7c81f3837bbdc17: Linux 5.18-rc1 (2022-04-03 14:08:21 -0700) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-next-pullrequest-20220508 for you to fetch changes up to 8864d2fcf04385cabb8c8bb159f1f2ba5790cf71: batman-adv: remove unnecessary type castings (2022-04-22 11:23:46 +0200) This cleanup patchset includes the following patches: - bump version strings, by Simon Wunderlich - remove unnecessary type castings, by Yu Zhe Simon Wunderlich (1): batman-adv: Start new development cycle Yu Zhe (1): batman-adv: remove unnecessary type castings net/batman-adv/bridge_loop_avoidance.c | 4 ++-- net/batman-adv/main.h | 2 +- net/batman-adv/translation-table.c | 12 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)
[PATCH 1/2] batman-adv: Start new development cycle
This version will contain all the (major or even only minor) changes for Linux 5.19. 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). Signed-off-by: Simon Wunderlich --- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index f3be82999f1f..23f3d53f4b51 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -13,7 +13,7 @@ #define BATADV_DRIVER_DEVICE "batman-adv" #ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2022.1" +#define BATADV_SOURCE_VERSION "2022.2" #endif /* B.A.T.M.A.N. parameters */ -- 2.30.2
[PATCH 1/1] batman-adv: Don't skb_split skbuffs with frag_list
From: Sven Eckelmann The receiving interface might have used GRO to receive more fragments than MAX_SKB_FRAGS fragments. In this case, these will not be stored in skb_shinfo(skb)->frags but merged into the frag list. batman-adv relies on the function skb_split to split packets up into multiple smaller packets which are not larger than the MTU on the outgoing interface. But this function cannot handle frag_list entries and is only operating on skb_shinfo(skb)->frags. If it is still trying to split such an skb and xmit'ing it on an interface without support for NETIF_F_FRAGLIST, then validate_xmit_skb() will try to linearize it. But this fails due to inconsistent information. And __pskb_pull_tail will trigger a BUG_ON after skb_copy_bits() returns an error. In case of entries in frag_list, just linearize the skb before operating on it with skb_split(). Reported-by: Felix Kaechele Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol") Signed-off-by: Sven Eckelmann Tested-by: Felix Kaechele Signed-off-by: Simon Wunderlich --- net/batman-adv/fragmentation.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c index 0899a729a23f..c120c7c6d25f 100644 --- a/net/batman-adv/fragmentation.c +++ b/net/batman-adv/fragmentation.c @@ -475,6 +475,17 @@ int batadv_frag_send_packet(struct sk_buff *skb, goto free_skb; } + /* GRO might have added fragments to the fragment list instead of +* frags[]. But this is not handled by skb_split and must be +* linearized to avoid incorrect length information after all +* batman-adv fragments were created and submitted to the +* hard-interface +*/ + if (skb_has_frag_list(skb) && __skb_linearize(skb)) { + ret = -ENOMEM; + goto free_skb; + } + /* Create one header to be copied to all fragments */ frag_header.packet_type = BATADV_UNICAST_FRAG; frag_header.version = BATADV_COMPAT_VERSION; -- 2.30.2
[PATCH 0/1] pull request for net: batman-adv 2022-05-08
Hi David, hi Jakub, here is a bugfix for batman-adv which we would like to have integrated into net. Please pull or let me know of any problem! Thank you, Simon The following changes since commit 3123109284176b1532874591f7c81f3837bbdc17: Linux 5.18-rc1 (2022-04-03 14:08:21 -0700) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-net-pullrequest-20220508 for you to fetch changes up to a063f2fba3fa633a599253b62561051ac185fa99: batman-adv: Don't skb_split skbuffs with frag_list (2022-04-17 23:41:44 +0200) Here is a batman-adv bugfix: - Don't skb_split skbuffs with frag_list, by Sven Eckelmann Sven Eckelmann (1): batman-adv: Don't skb_split skbuffs with frag_list net/batman-adv/fragmentation.c | 11 +++ 1 file changed, 11 insertions(+)
[PATCH 4/4] batman-adv: Demote batadv-on-batadv skip error message
From: Sven Eckelmann The error message "Cannot find parent device" was shown for users of macvtap (on batadv devices) whenever the macvtap was moved to a different netns. This happens because macvtap doesn't provide an implementation for rtnl_link_ops->get_link_net. The situation for which this message is printed is actually not an error but just a warning that the optional sanity check was skipped. So demote the message from error to warning and adjust the text to better explain what happened. Reported-by: Leonardo Mörlein Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/hard-interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 59d19097a54c..b25afc7ff59c 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -165,9 +165,9 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev) /* recurse over the parent device */ parent_dev = __dev_get_by_index((struct net *)parent_net, dev_get_iflink(net_dev)); - /* if we got a NULL parent_dev there is something broken.. */ if (!parent_dev) { - pr_err("Cannot find parent device\n"); + pr_warn("Cannot find parent device. Skipping batadv-on-batadv check for %s\n", + net_dev->name); return false; } -- 2.30.2
[PATCH 3/4] batman-adv: Migrate to linux/container_of.h
From: Sven Eckelmann The commit d2a8ebbf8192 ("kernel.h: split out container_of() and typeof_member() macros") introduced a new header for the container_of related macros from (previously) linux/kernel.h. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/bat_iv_ogm.c| 2 +- net/batman-adv/bat_v_elp.c | 2 +- net/batman-adv/bat_v_ogm.c | 2 +- net/batman-adv/bridge_loop_avoidance.c | 1 + net/batman-adv/distributed-arp-table.c | 2 +- net/batman-adv/gateway_client.c| 1 + net/batman-adv/hard-interface.c| 2 +- net/batman-adv/main.c | 1 + net/batman-adv/multicast.c | 1 + net/batman-adv/network-coding.c| 2 +- net/batman-adv/originator.c| 2 +- net/batman-adv/send.c | 2 +- net/batman-adv/soft-interface.c| 2 +- net/batman-adv/tp_meter.c | 2 +- net/batman-adv/translation-table.c | 2 +- net/batman-adv/tvlv.c | 2 +- 16 files changed, 16 insertions(+), 12 deletions(-) diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index f94f538fa382..7f6a7c96ac92 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -13,13 +13,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include #include #include diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c index 71999e13f729..b6db999abf75 100644 --- a/net/batman-adv/bat_v_elp.c +++ b/net/batman-adv/bat_v_elp.c @@ -10,13 +10,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include #include #include diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index 1d750f3cb2e4..033639df96d8 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -9,12 +9,12 @@ #include #include +#include #include #include #include #include #include -#include #include #include #include diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 2ed9496fc41f..337e20b6586d 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index 2f008e329007..fefb51a5f606 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -20,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index b7466136e292..d26124bc27e1 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 8a2b78f9c4b2..59d19097a54c 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -9,11 +9,11 @@ #include #include +#include #include #include #include #include -#include #include #include #include diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 8f1b724d0412..e8a449915566 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index f4004cf0ff6f..1860de735661 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index 974d726fabb9..5f4aeeb60dc4 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -19,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index aadc653ca1d8..34903df4fe93 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -8,11 +8,11 @@ #include "main.h" #include +#include #include #include #include #include -#include #include #include #include diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index 477d85a3b558..0379b126865d 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -10,13 +10,13 @@ #include #include #include +#include #include #include #include #include #include #include
[PATCH 2/4] batman-adv: Remove redundant 'flush_workqueue()' calls
From: Christophe JAILLET 'destroy_workqueue()' already drains the queue before destroying it, so there is no need to flush it explicitly. Remove the redundant 'flush_workqueue()' calls. This was generated with coccinelle: @@ expression E; @@ - flush_workqueue(E); destroy_workqueue(E); Signed-off-by: Christophe JAILLET Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 5207cd8d6ad8..8f1b724d0412 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -132,7 +132,6 @@ static void __exit batadv_exit(void) rtnl_link_unregister(&batadv_link_ops); unregister_netdevice_notifier(&batadv_hard_if_notifier); - flush_workqueue(batadv_event_workqueue); destroy_workqueue(batadv_event_workqueue); batadv_event_workqueue = NULL; -- 2.30.2
[PATCH 1/4] batman-adv: Start new development cycle
This version will contain all the (major or even only minor) changes for Linux 5.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). Signed-off-by: Simon Wunderlich --- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 494d1ebecac2..f3be82999f1f 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -13,7 +13,7 @@ #define BATADV_DRIVER_DEVICE "batman-adv" #ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2022.0" +#define BATADV_SOURCE_VERSION "2022.1" #endif /* B.A.T.M.A.N. parameters */ -- 2.30.2
[PATCH 0/4] pull request for net-next: batman-adv 2022-03-02
Hi Jakub, hi David, here is a little cleanup pull request of batman-adv to go into net-next. Please pull or let me know of any problem! There might be a small merge conflict between the net and net-next pull requests which I both send today, specifically those two commits: * (batadv/net) 690bb6fb64f5 ("batman-adv: Request iflink once in batadv-on-batadv check") * (batadv/net-next) 6ee3c393eeb7 ("batman-adv: Demote batadv-on-batadv skip error message") They should be resolved like this: --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -167,13 +167,7 @@ return false; /* recurse over the parent device */ -<<<<<<< - parent_dev = __dev_get_by_index((struct net *)parent_net, - dev_get_iflink(net_dev)); -=== parent_dev = __dev_get_by_index((struct net *)parent_net, iflink); - /* if we got a NULL parent_dev there is something broken.. */ ->>>>>>> if (!parent_dev) { pr_warn("Cannot find parent device. Skipping batadv-on-batadv check for %s\n", net_dev->name); Thank you, Simon The following changes since commit e783362eb54cd99b2cac8b3a9aeac942e6f6ac07: Linux 5.17-rc1 (2022-01-23 10:12:53 +0200) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-next-pullrequest-20220302 for you to fetch changes up to 6ee3c393eeb7d16a3c228c4fa23913b76c7e7df3: batman-adv: Demote batadv-on-batadv skip error message (2022-03-02 09:00:17 +0100) This cleanup patchset includes the following patches: - bump version strings, by Simon Wunderlich - Remove redundant 'flush_workqueue()' calls, by Christophe JAILLET - Migrate to linux/container_of.h, by Sven Eckelmann - Demote batadv-on-batadv skip error message, by Sven Eckelmann Christophe JAILLET (1): batman-adv: Remove redundant 'flush_workqueue()' calls Simon Wunderlich (1): batman-adv: Start new development cycle Sven Eckelmann (2): batman-adv: Migrate to linux/container_of.h batman-adv: Demote batadv-on-batadv skip error message net/batman-adv/bat_iv_ogm.c| 2 +- net/batman-adv/bat_v_elp.c | 2 +- net/batman-adv/bat_v_ogm.c | 2 +- net/batman-adv/bridge_loop_avoidance.c | 1 + net/batman-adv/distributed-arp-table.c | 2 +- net/batman-adv/gateway_client.c| 1 + net/batman-adv/hard-interface.c| 6 +++--- net/batman-adv/main.c | 2 +- net/batman-adv/main.h | 2 +- net/batman-adv/multicast.c | 1 + net/batman-adv/network-coding.c| 2 +- net/batman-adv/originator.c| 2 +- net/batman-adv/send.c | 2 +- net/batman-adv/soft-interface.c| 2 +- net/batman-adv/tp_meter.c | 2 +- net/batman-adv/translation-table.c | 2 +- net/batman-adv/tvlv.c | 2 +- 17 files changed, 19 insertions(+), 16 deletions(-)
[PATCH 3/3] batman-adv: Don't expect inter-netns unique iflink indices
From: Sven Eckelmann The ifindex doesn't have to be unique for multiple network namespaces on the same machine. $ ip netns add test1 $ ip -net test1 link add dummy1 type dummy $ ip netns add test2 $ ip -net test2 link add dummy2 type dummy $ ip -net test1 link show dev dummy1 6: dummy1: mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 96:81:55:1e:dd:85 brd ff:ff:ff:ff:ff:ff $ ip -net test2 link show dev dummy2 6: dummy2: mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 5a:3c:af:35:07:c3 brd ff:ff:ff:ff:ff:ff But the batman-adv code to walk through the various layers of virtual interfaces uses this assumption because dev_get_iflink handles it internally and doesn't return the actual netns of the iflink. And dev_get_iflink only documents the situation where ifindex == iflink for physical devices. But only checking for dev->netdev_ops->ndo_get_iflink is also not an option because ipoib_get_iflink implements it even when it sometimes returns an iflink != ifindex and sometimes iflink == ifindex. The caller must therefore make sure itself to check both netns and iflink + ifindex for equality. Only when they are equal, a "physical" interface was detected which should stop the traversal. On the other hand, vxcan_get_iflink can also return 0 in case there was currently no valid peer. In this case, it is still necessary to stop. Fixes: b7eddd0b3950 ("batman-adv: prevent using any virtual device created on batman-adv as hard-interface") Fixes: 5ed4a460a1d3 ("batman-adv: additional checks for virtual interfaces on top of WiFi") Reported-by: Sabrina Dubroca Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/hard-interface.c | 19 ++- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index e2760cfce190..35fadb924849 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -157,13 +157,15 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev) return true; iflink = dev_get_iflink(net_dev); - - /* no more parents..stop recursion */ - if (iflink == 0 || iflink == net_dev->ifindex) + if (iflink == 0) return false; parent_net = batadv_getlink_net(net_dev, net); + /* iflink to itself, most likely physical device */ + if (net == parent_net && iflink == net_dev->ifindex) + return false; + /* recurse over the parent device */ parent_dev = __dev_get_by_index((struct net *)parent_net, iflink); /* if we got a NULL parent_dev there is something broken.. */ @@ -223,8 +225,7 @@ static struct net_device *batadv_get_real_netdevice(struct net_device *netdev) return NULL; iflink = dev_get_iflink(netdev); - - if (netdev->ifindex == iflink) { + if (iflink == 0) { dev_hold(netdev); return netdev; } @@ -235,6 +236,14 @@ static struct net_device *batadv_get_real_netdevice(struct net_device *netdev) net = dev_net(hard_iface->soft_iface); real_net = batadv_getlink_net(netdev, net); + + /* iflink to itself, most likely physical device */ + if (net == real_net && netdev->ifindex == iflink) { + real_netdev = netdev; + dev_hold(real_netdev); + goto out; + } + real_netdev = dev_get_by_index(real_net, iflink); out: -- 2.30.2
[PATCH 2/3] batman-adv: Request iflink once in batadv_get_real_netdevice
From: Sven Eckelmann There is no need to call dev_get_iflink multiple times for the same net_device in batadv_get_real_netdevice. And since some of the ndo_get_iflink callbacks are dynamic (for example via RCUs like in vxcan_get_iflink), it could easily happen that the returned values are not stable. The pre-checks before __dev_get_by_index are then of course bogus. Fixes: 5ed4a460a1d3 ("batman-adv: additional checks for virtual interfaces on top of WiFi") Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/hard-interface.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 35aa1122043b..e2760cfce190 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -215,14 +215,16 @@ static struct net_device *batadv_get_real_netdevice(struct net_device *netdev) struct net_device *real_netdev = NULL; struct net *real_net; struct net *net; - int ifindex; + int iflink; ASSERT_RTNL(); if (!netdev) return NULL; - if (netdev->ifindex == dev_get_iflink(netdev)) { + iflink = dev_get_iflink(netdev); + + if (netdev->ifindex == iflink) { dev_hold(netdev); return netdev; } @@ -232,9 +234,8 @@ static struct net_device *batadv_get_real_netdevice(struct net_device *netdev) goto out; net = dev_net(hard_iface->soft_iface); - ifindex = dev_get_iflink(netdev); real_net = batadv_getlink_net(netdev, net); - real_netdev = dev_get_by_index(real_net, ifindex); + real_netdev = dev_get_by_index(real_net, iflink); out: batadv_hardif_put(hard_iface); -- 2.30.2
[PATCH 1/3] batman-adv: Request iflink once in batadv-on-batadv check
From: Sven Eckelmann There is no need to call dev_get_iflink multiple times for the same net_device in batadv_is_on_batman_iface. And since some of the .ndo_get_iflink callbacks are dynamic (for example via RCUs like in vxcan_get_iflink), it could easily happen that the returned values are not stable. The pre-checks before __dev_get_by_index are then of course bogus. Fixes: b7eddd0b3950 ("batman-adv: prevent using any virtual device created on batman-adv as hard-interface") Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/hard-interface.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 8a2b78f9c4b2..35aa1122043b 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -149,22 +149,23 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev) struct net *net = dev_net(net_dev); struct net_device *parent_dev; struct net *parent_net; + int iflink; bool ret; /* check if this is a batman-adv mesh interface */ if (batadv_softif_is_valid(net_dev)) return true; + iflink = dev_get_iflink(net_dev); + /* no more parents..stop recursion */ - if (dev_get_iflink(net_dev) == 0 || - dev_get_iflink(net_dev) == net_dev->ifindex) + if (iflink == 0 || iflink == net_dev->ifindex) return false; parent_net = batadv_getlink_net(net_dev, net); /* recurse over the parent device */ - parent_dev = __dev_get_by_index((struct net *)parent_net, - dev_get_iflink(net_dev)); + parent_dev = __dev_get_by_index((struct net *)parent_net, iflink); /* if we got a NULL parent_dev there is something broken.. */ if (!parent_dev) { pr_err("Cannot find parent device\n"); -- 2.30.2
[PATCH 0/3] pull request for net: batman-adv 2022-03-02
Hi David, hi Jakub, here are some bugfixes for batman-adv which we would like to have integrated into net. Please pull or let me know of any problem! There might be a small merge conflict between the net and net-next pull requests which I both send today, specifically those two commits: * (batadv/net) 690bb6fb64f5 ("batman-adv: Request iflink once in batadv-on-batadv check") * (batadv/net-next) 6ee3c393eeb7 ("batman-adv: Demote batadv-on-batadv skip error message") They should be resolved like this: --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -167,13 +167,7 @@ return false; /* recurse over the parent device */ -<<< - parent_dev = __dev_get_by_index((struct net *)parent_net, - dev_get_iflink(net_dev)); -=== parent_dev = __dev_get_by_index((struct net *)parent_net, iflink); - /* if we got a NULL parent_dev there is something broken.. */ ->>> if (!parent_dev) { pr_warn("Cannot find parent device. Skipping batadv-on-batadv check for %s\n", net_dev->name); Thank you, Simon The following changes since commit e783362eb54cd99b2cac8b3a9aeac942e6f6ac07: Linux 5.17-rc1 (2022-01-23 10:12:53 +0200) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-net-pullrequest-20220302 for you to fetch changes up to 6c1f41afc1dbe59d9d3c8bb0d80b749c119aa334: batman-adv: Don't expect inter-netns unique iflink indices (2022-03-02 09:24:55 +0100) Here are some batman-adv bugfixes: - Remove redundant iflink requests, by Sven Eckelmann (2 patches) - Don't expect inter-netns unique iflink indices, by Sven Eckelmann Sven Eckelmann (3): batman-adv: Request iflink once in batadv-on-batadv check batman-adv: Request iflink once in batadv_get_real_netdevice batman-adv: Don't expect inter-netns unique iflink indices net/batman-adv/hard-interface.c | 29 - 1 file changed, 20 insertions(+), 9 deletions(-)
[PATCH 3/3] batman-adv: remove unneeded variable in batadv_nc_init
From: Minghao Chi Return status directly from function called. Reported-by: Zeal Robot Signed-off-by: Minghao Chi Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/network-coding.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index 0a7f1d36a6a8..974d726fabb9 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c @@ -58,13 +58,9 @@ static int batadv_nc_recv_coded_packet(struct sk_buff *skb, */ int __init batadv_nc_init(void) { - int ret; - /* Register our packet type */ - ret = batadv_recv_handler_register(BATADV_CODED, - batadv_nc_recv_coded_packet); - - return ret; + return batadv_recv_handler_register(BATADV_CODED, + batadv_nc_recv_coded_packet); } /** -- 2.30.2
[PATCH 2/3] batman-adv: allow netlink usage in unprivileged containers
From: Linus Lüssing Currently, creating a batman-adv interface in an unprivileged LXD container and attaching secondary interfaces to it with "ip" or "batctl" works fine. However all batctl debug and configuration commands fail: root@container:~# batctl originators Error received: Operation not permitted root@container:~# batctl orig_interval 1000 root@container:~# batctl orig_interval 2000 root@container:~# batctl orig_interval 1000 To fix this change the generic netlink permissions from GENL_ADMIN_PERM to GENL_UNS_ADMIN_PERM. This way a batman-adv interface is fully maintainable as root from within a user namespace, from an unprivileged container. All except one batman-adv netlink setting are per interface and do not leak information or change settings from the host system and are therefore save to retrieve or modify as root from within an unprivileged container. "batctl routing_algo" / BATADV_CMD_GET_ROUTING_ALGOS is the only exception: It provides the batman-adv kernel module wide default routing algorithm. However it is read-only from netlink and an unprivileged container is still not allowed to modify /sys/module/batman_adv/parameters/routing_algo. Instead it is advised to use the newly introduced "batctl if create routing_algo RA_NAME" / IFLA_BATADV_ALGO_NAME to set the routing algorithm on interface creation, which already works fine in an unprivileged container. Cc: Tycho Andersen Signed-off-by: Linus Lüssing Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/netlink.c | 30 +++--- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c index 29276284d281..00875e1d8c44 100644 --- a/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c @@ -1368,21 +1368,21 @@ static const struct genl_small_ops batadv_netlink_ops[] = { { .cmd = BATADV_CMD_TP_METER, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .flags = GENL_ADMIN_PERM, + .flags = GENL_UNS_ADMIN_PERM, .doit = batadv_netlink_tp_meter_start, .internal_flags = BATADV_FLAG_NEED_MESH, }, { .cmd = BATADV_CMD_TP_METER_CANCEL, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .flags = GENL_ADMIN_PERM, + .flags = GENL_UNS_ADMIN_PERM, .doit = batadv_netlink_tp_meter_cancel, .internal_flags = BATADV_FLAG_NEED_MESH, }, { .cmd = BATADV_CMD_GET_ROUTING_ALGOS, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .flags = GENL_ADMIN_PERM, + .flags = GENL_UNS_ADMIN_PERM, .dumpit = batadv_algo_dump, }, { @@ -1397,68 +1397,68 @@ static const struct genl_small_ops batadv_netlink_ops[] = { { .cmd = BATADV_CMD_GET_TRANSTABLE_LOCAL, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .flags = GENL_ADMIN_PERM, + .flags = GENL_UNS_ADMIN_PERM, .dumpit = batadv_tt_local_dump, }, { .cmd = BATADV_CMD_GET_TRANSTABLE_GLOBAL, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .flags = GENL_ADMIN_PERM, + .flags = GENL_UNS_ADMIN_PERM, .dumpit = batadv_tt_global_dump, }, { .cmd = BATADV_CMD_GET_ORIGINATORS, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .flags = GENL_ADMIN_PERM, + .flags = GENL_UNS_ADMIN_PERM, .dumpit = batadv_orig_dump, }, { .cmd = BATADV_CMD_GET_NEIGHBORS, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .flags = GENL_ADMIN_PERM, + .flags = GENL_UNS_ADMIN_PERM, .dumpit = batadv_hardif_neigh_dump, }, { .cmd = BATADV_CMD_GET_GATEWAYS, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .flags = GENL_ADMIN_PERM, + .flags = GENL_UNS_ADMIN_PERM, .dumpit = batadv_gw_dump, }, { .cmd = BATADV_CMD_GET_BLA_CLAIM, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .flags = GENL_ADMIN_PERM, + .flags = GENL_UNS_ADMIN_PERM, .dumpit = batadv_bla_claim_dump, }, { .cmd = BATADV_CMD_GET_BLA_BACKBONE, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .flags = GENL_ADMIN_PERM, + .flags = GENL_UNS_ADMIN_PERM,
[PATCH 0/3] pull request for net-next: batman-adv 2022-01-03
Hi Jakub, hi David, here is a little 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 66f4beaa6c1d28161f534471484b2daa2de1dce0: Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 (2021-11-12 12:35:46 -0800) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-next-pullrequest-20220103 for you to fetch changes up to cde3fac565a7df8805a4e0e28d84a0f90177099a: batman-adv: remove unneeded variable in batadv_nc_init (2021-12-10 08:52:52 +0100) This cleanup patchset includes the following patches: - bump version strings, by Simon Wunderlich - allow netlink usage in unprivileged containers, by Linus Lüssing - remove unneeded variable, by Minghao Chi Linus Lüssing (1): batman-adv: allow netlink usage in unprivileged containers Minghao Chi (1): batman-adv: remove unneeded variable in batadv_nc_init Simon Wunderlich (1): batman-adv: Start new development cycle net/batman-adv/main.h | 2 +- net/batman-adv/netlink.c| 30 +++--- net/batman-adv/network-coding.c | 8 ++-- 3 files changed, 18 insertions(+), 22 deletions(-)
[PATCH 1/3] batman-adv: Start new development cycle
This version will contain all the (major or even only minor) changes for Linux 5.17. 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). Signed-off-by: Simon Wunderlich --- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 058b8f2eef65..494d1ebecac2 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -13,7 +13,7 @@ #define BATADV_DRIVER_DEVICE "batman-adv" #ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2021.3" +#define BATADV_SOURCE_VERSION "2022.0" #endif /* B.A.T.M.A.N. parameters */ -- 2.30.2
[PATCH 1/1] batman-adv: mcast: don't send link-local multicast to mcast routers
From: Linus Lüssing The addition of routable multicast TX handling introduced a bug/regression for packets with a link-local multicast destination: These packets would be sent to all batman-adv nodes with a multicast router and to all batman-adv nodes with an old version without multicast router detection. This even disregards the batman-adv multicast fanout setting, which can potentially lead to an unwanted, high number of unicast transmissions or even congestion. Fixing this by avoiding to send link-local multicast packets to nodes in the multicast router list. Fixes: 11d458c1cb9b ("batman-adv: mcast: apply optimizations for routable packets, too") Signed-off-by: Linus Lüssing Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/multicast.c | 15 ++- net/batman-adv/multicast.h | 10 ++ net/batman-adv/soft-interface.c | 7 +-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index 433901dcf0c3..f4004cf0ff6f 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -1339,6 +1339,7 @@ batadv_mcast_forw_rtr_node_get(struct batadv_priv *bat_priv, * @bat_priv: the bat priv with all the soft interface information * @skb: The multicast packet to check * @orig: an originator to be set to forward the skb to + * @is_routable: stores whether the destination is routable * * Return: the forwarding mode as enum batadv_forw_mode and in case of * BATADV_FORW_SINGLE set the orig to the single originator the skb @@ -1346,17 +1347,16 @@ batadv_mcast_forw_rtr_node_get(struct batadv_priv *bat_priv, */ enum batadv_forw_mode batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, - struct batadv_orig_node **orig) + struct batadv_orig_node **orig, int *is_routable) { int ret, tt_count, ip_count, unsnoop_count, total_count; bool is_unsnoopable = false; unsigned int mcast_fanout; struct ethhdr *ethhdr; - int is_routable = 0; int rtr_count = 0; ret = batadv_mcast_forw_mode_check(bat_priv, skb, &is_unsnoopable, - &is_routable); + is_routable); if (ret == -ENOMEM) return BATADV_FORW_NONE; else if (ret < 0) @@ -1369,7 +1369,7 @@ batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, ip_count = batadv_mcast_forw_want_all_ip_count(bat_priv, ethhdr); unsnoop_count = !is_unsnoopable ? 0 : atomic_read(&bat_priv->mcast.num_want_all_unsnoopables); - rtr_count = batadv_mcast_forw_rtr_count(bat_priv, is_routable); + rtr_count = batadv_mcast_forw_rtr_count(bat_priv, *is_routable); total_count = tt_count + ip_count + unsnoop_count + rtr_count; @@ -1689,6 +1689,7 @@ batadv_mcast_forw_want_rtr(struct batadv_priv *bat_priv, * @bat_priv: the bat priv with all the soft interface information * @skb: the multicast packet to transmit * @vid: the vlan identifier + * @is_routable: stores whether the destination is routable * * Sends copies of a frame with multicast destination to any node that signaled * interest in it, that is either via the translation table or the according @@ -1701,7 +1702,7 @@ batadv_mcast_forw_want_rtr(struct batadv_priv *bat_priv, * is neither IPv4 nor IPv6. NET_XMIT_SUCCESS otherwise. */ int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb, - unsigned short vid) + unsigned short vid, int is_routable) { int ret; @@ -1717,12 +1718,16 @@ int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb, return ret; } + if (!is_routable) + goto skip_mc_router; + ret = batadv_mcast_forw_want_rtr(bat_priv, skb, vid); if (ret != NET_XMIT_SUCCESS) { kfree_skb(skb); return ret; } +skip_mc_router: consume_skb(skb); return ret; } diff --git a/net/batman-adv/multicast.h b/net/batman-adv/multicast.h index 9fee5da08311..8aec818d0bf6 100644 --- a/net/batman-adv/multicast.h +++ b/net/batman-adv/multicast.h @@ -43,7 +43,8 @@ enum batadv_forw_mode { enum batadv_forw_mode batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, - struct batadv_orig_node **mcast_single_orig); + struct batadv_orig_node **mcast_single_orig, + int *is_routable); int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv, struct sk_buff *skb, @@ -51,7 +52,7 @@ int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv, struct batadv_orig_node *orig_node); int b
[PATCH 0/1] pull request for net: batman-adv 2022-01-03
Hi David, hi Jakub, happy new year! Here is a bugfix for batman-adv which we would like to have integrated into net. Please pull or let me know of any problem! Thank you, Simon The following changes since commit 66f4beaa6c1d28161f534471484b2daa2de1dce0: Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 (2021-11-12 12:35:46 -0800) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-net-pullrequest-20220103 for you to fetch changes up to 938f2e0b57ffe8a6df71e1e177b2978b1b33fe5e: batman-adv: mcast: don't send link-local multicast to mcast routers (2022-01-02 09:31:17 +0100) Here is a batman-adv bugfix: - avoid sending link-local multicast to multicast routers, by Linus Lüssing Linus Lüssing (1): batman-adv: mcast: don't send link-local multicast to mcast routers net/batman-adv/multicast.c | 15 ++- net/batman-adv/multicast.h | 10 ++ net/batman-adv/soft-interface.c | 7 +-- 3 files changed, 21 insertions(+), 11 deletions(-)
Re: Bonding Alternating
Hi Brian, please see inline: On Tuesday, September 21, 2021 5:41:07 PM CEST Edmisten, Brian wrote: > Simon, > > The current scenario we are working with we have two different radio systems > that already provide a layer 2 mesh network each. To the user they look > like two Ethernet interfaces one for one wave form and one for the other. > BATMAN so far is making it more stable in that the convergence of the > network is much faster. There is an opportunity for 3 different radio > systems, but the third vendor is unconfirmed. There was an ask to try to > increase bandwidth if the nodes were known to be close together. We were > trying out BATMAN's bonding features as using it could simplify our setup > and reduce some of the overhead we are getting with the layers or software > we are currently using. Thank you for elaborating! Are these radios providing the same throughput? One thing I noted when doing tests back then is that the slower link will slow down the combined link, since it is sending packets in a round robin fashion. In other words, with two links, if the slow link has half the throughput of the fast link, you will not have any benefit. > > When you say one hop, do you mean one BATMAN hop or something else? If it > makes a difference my testing was direct but I think the radios will > actually look like there is a switch between the nodes. Whether there is a switch or not doesn't matter to BATMAN. By one hop I meant they are directly connected via Layer 2, there is no intermediate BATMAN hop acting as a relay. Since you will be using Ethernet links and not WiFi links, BATMAN will not be able to detect that you are actually using radio links, since its only checking kernel internal structures (whether the device uses cfg80211 or wext). I'm adding a patch to generally treat interfaces like wireless interfaces from a routing perspective, this could also make a difference for your VM tests. > > Thank you for looking in to this for me. BATMAN is doing great for our > first use case. Great to hear :) Good luck using it and thank you for your feedback! Cheers, Simon > > Thank you, > Brian Edmisten > > -Original Message- > From: Simon Wunderlich [mailto:s...@simonwunderlich.de] > Sent: Tuesday, September 21, 2021 7:16 AM > To: b.a.t.m.a.n@lists.open-mesh.org; Edmisten, Brian > > Subject: Re: Bonding Alternating > > Hi Brian, > > I've checked it out and can confirm your issues. The bonding code as > currently implemented is trying to use a different router from each routing > table towards the same originator[1]. However, with 1-hop Ethernet links > those routers are always the same in all the routing tables. With WiFi that > would be a bit different (I've commented out the WiFi penalty check), but > even then it only alternates between two of the three interfaces. > > At this point I don't have a straight forward fix for this. Will you use > three Ethernet devices in your later deployment, or will those be WiFi > interfaces? > Also, would it be useful for you to consider bonding/teams interfaces of the > Linux kernel to bond the link, and give that to batman-adv? > > Cheers, >Simon > > [1] > https://www.open-mesh.org/projects/batman-adv/wiki/Network-wide-multi-link-o > ptimization > > On Wednesday, September 15, 2021 4:58:58 PM CEST Edmisten, Brian wrote: > > Simon, > > > > Thank you. I appreciate you looking at this. > > > > Regards, > > Brian Edmisten > > > > -Original Message- > > From: Simon Wunderlich [mailto:s...@simonwunderlich.de] > > Sent: Wednesday, September 15, 2021 12:26 AM > > To: b.a.t.m.a.n@lists.open-mesh.org; Edmisten, Brian > > > > Subject: Re: Bonding Alternating > > > > Hi Brian, > > > > hmm, I see. I will try to set up this scenario over the next few days > > and let you know. I haven't used bonding for quite a while now, but I > > also don't think that we had changes in the code which would break it. > > > > Anyway, will test and let you know. > > > > Cheers, > > > > Simon > > > > On Tuesday, September 14, 2021 6:57:37 PM CEST Edmisten, Brian wrote: > > > Simon, > > > > > > I did check again. batctl bonding responds with enabled. > > > > > > Cheers, > > > Brian Edmisten >From ef45b1f2462ee40843b7607c5342eae4f1595772 Mon Sep 17 00:00:00 2001 From: Simon Wunderlich Date: Wed, 22 Sep 2021 09:51:11 +0200 Subject: [PATCH] batman-adv: apply WiFi penalty on all interfaces Signed-off-by: Simon Wunderlich --- net/batman-adv/bat_iv_ogm.c | 3 +-- net/batman-adv/bat_v_ogm.c | 4 +--
Re: Bonding Alternating
Hi Brian, I've checked it out and can confirm your issues. The bonding code as currently implemented is trying to use a different router from each routing table towards the same originator[1]. However, with 1-hop Ethernet links those routers are always the same in all the routing tables. With WiFi that would be a bit different (I've commented out the WiFi penalty check), but even then it only alternates between two of the three interfaces. At this point I don't have a straight forward fix for this. Will you use three Ethernet devices in your later deployment, or will those be WiFi interfaces? Also, would it be useful for you to consider bonding/teams interfaces of the Linux kernel to bond the link, and give that to batman-adv? Cheers, Simon [1] https://www.open-mesh.org/projects/batman-adv/wiki/Network-wide-multi-link-optimization On Wednesday, September 15, 2021 4:58:58 PM CEST Edmisten, Brian wrote: > Simon, > > Thank you. I appreciate you looking at this. > > Regards, > Brian Edmisten > > -----Original Message- > From: Simon Wunderlich [mailto:s...@simonwunderlich.de] > Sent: Wednesday, September 15, 2021 12:26 AM > To: b.a.t.m.a.n@lists.open-mesh.org; Edmisten, Brian > > Subject: Re: Bonding Alternating > > Hi Brian, > > hmm, I see. I will try to set up this scenario over the next few days and > let you know. I haven't used bonding for quite a while now, but I also don't > think that we had changes in the code which would break it. > > Anyway, will test and let you know. > > Cheers, > Simon > > On Tuesday, September 14, 2021 6:57:37 PM CEST Edmisten, Brian wrote: > > Simon, > > > > I did check again. batctl bonding responds with enabled. > > > > Cheers, > > Brian Edmisten signature.asc Description: This is a digitally signed message part.
Re: Bonding Alternating
Hi Brian, hmm, I see. I will try to set up this scenario over the next few days and let you know. I haven't used bonding for quite a while now, but I also don't think that we had changes in the code which would break it. Anyway, will test and let you know. Cheers, Simon On Tuesday, September 14, 2021 6:57:37 PM CEST Edmisten, Brian wrote: > Simon, > > I did check again. batctl bonding responds with enabled. > > Cheers, > Brian Edmisten signature.asc Description: This is a digitally signed message part.
Re: Bonding Alternating
On Friday, September 10, 2021 7:59:54 PM CEST brian.edmis...@viasat.com wrote: > Simon, > > Thanks for responding. We are trying out some different solutions for > bonding these radios. For scenarios BATMAN seems really well suited for > the problem but we wanted to test this one and see how much work we need to > put into it. I saw the same behavior with IV but I'll switch back and > check on it. While its up though here is what I am seeing with V. > > batctl o > [B.A.T.M.A.N. adv 2019.4, MainIF/MAC: eth0/00:0c:29:c5:d2:da > (bat0/de:8b:cc:39:d0:69 BATMAN_V)] Originatorlast-seen ( > throughput) Nexthop [outgoingIF] 00:0c:29:53:f8:c90.320s ( > 1.0) 00:0c:29:53:f8:dd [ eth2] 00:0c:29:53:f8:c90.320s ( > 1.0) 00:0c:29:53:f8:d3 [ eth1] * 00:0c:29:53:f8:c90.320s ( > 1.0) 00:0c:29:53:f8:c9 [ eth0] > > batctl n > [B.A.T.M.A.N. adv 2019.4, MainIF/MAC: eth0/00:0c:29:c5:d2:da > (bat0/de:8b:cc:39:d0:69 BATMAN_V)] IF Neighbor > last-seen > 00:0c:29:53:f8:c90.436s (1.0) [ eth0] > 00:0c:29:53:f8:d30.340s (1.0) [ eth1] > 00:0c:29:53:f8:dd0.116s (1.0) [ eth2] > > batctl tg > [B.A.T.M.A.N. adv 2019.4, MainIF/MAC: eth0/00:0c:29:c5:d2:da > (bat0/de:8b:cc:39:d0:69 BATMAN_V)] Client VID Flags Last ttvn > Viattvn (CRC ) * 33:33:00:00:00:02 -1 [] ( 1) > 00:0c:29:53:f8:c9 ( 2) (0x6b62ac80) * 01:00:5e:00:00:01 -1 [] ( 2) > 00:0c:29:53:f8:c9 ( 2) (0x6b62ac80) * 4e:b3:25:58:bd:15 -1 [] ( 1) > 00:0c:29:53:f8:c9 ( 2) (0x6b62ac80) * 33:33:00:00:00:01 -1 [] ( 1) > 00:0c:29:53:f8:c9 ( 2) (0x6b62ac80) > > I do not directly see any of the commands outputting transmit quality I > would expect the three ethernet nics to be the same but it is an > assumption. > > Here is the same info under IV > batctl o > [B.A.T.M.A.N. adv 2019.4, MainIF/MAC: eth2/00:0c:29:c5:d2:ee > (bat0/f2:49:86:e6:ea:aa BATMAN_IV)] Originatorlast-seen (#/255) > Nexthop [outgoingIF] * 00:0c:29:53:f8:d30.976s (255) > 00:0c:29:53:f8:d3 [ eth1] * 00:0c:29:53:f8:c90.944s (251) > 00:0c:29:53:f8:c9 [ eth0] * 00:0c:29:53:f8:dd0.368s (255) > 00:0c:29:53:f8:c9 [ eth0] 00:0c:29:53:f8:dd0.368s (255) > 00:0c:29:53:f8:d3 [ eth1] 00:0c:29:53:f8:dd0.368s (252) > 00:0c:29:53:f8:dd [ eth2] > > batctl n > [B.A.T.M.A.N. adv 2019.4, MainIF/MAC: eth2/00:0c:29:c5:d2:ee > (bat0/f2:49:86:e6:ea:aa BATMAN_IV)] IF Neighbor > last-seen > eth0 00:0c:29:53:f8:c90.032s > eth1 00:0c:29:53:f8:d30.992s > eth2 00:0c:29:53:f8:dd0.384s > > batctl tg > [B.A.T.M.A.N. adv 2019.4, MainIF/MAC: eth2/00:0c:29:c5:d2:ee > (bat0/f2:49:86:e6:ea:aa BATMAN_IV)] Client VID Flags Last ttvn >Viattvn (CRC ) * 33:33:00:00:00:02 -1 [] ( 2) > 00:0c:29:53:f8:dd ( 3) (0x9339b660) * 01:00:5e:00:00:01 -1 [] ( 3) > 00:0c:29:53:f8:dd ( 3) (0x9339b660) * 2a:78:9d:5f:f3:f6 -1 [] ( 1) > 00:0c:29:53:f8:dd ( 3) (0x9339b660) * 33:33:00:00:00:01 -1 [] ( 2) > 00:0c:29:53:f8:dd ( 3) (0x9339b660) > > Hi Brian, thank you very much for providing that output. There is only "TQ" (transmit quality) in BATMAN IV, BATMAN V uses througput based metric instead (in kbit/ s). For Ethernet, it tries to read the Ethernet speed directl, therefore you see those 1 values. Anyway, in BATMAN IV the values look close enough (they need to be within 50 TQ points). Just as sanity check, did you enable bonding? It is disabled by default. You can use batctl b 1 to enable it. Unfortunately there is not really logging code for debugging, so let's try checking the settings. If that doesn't work, I could rebuild and verify ... Cheers, Simon signature.asc Description: This is a digitally signed message part.
Re: Bonding Alternating
On Thursday, September 9, 2021 10:09:39 PM CEST brian.edmis...@viasat.com wrote: > Before Adding radios to my setup I connected to computers with three NICs > each. I added all three interfaces to the mesh interface bat0 on each. I > then run iperf across it and all the traffic seems to go on one interface. > I run iperf3 with -p 4 so there are multiple streams. Changing it to > bonding does not seem to change the behavior. batctl o - shows all three > interfaces > batctl n - shows three interfaces -This I thought seemed odd as its one > neighbor across three links batctl tg - shows all clients Via one address > > If anyone can point me at what to look at next or what might be wrong would > help. > > I am using BATMAN_V version 2019.4 in kernel 5.4.68. Hi Brian, can you perhaps post the output of those commands? If bonding works, it would even spread one iperf stream among the multiple links. For bonding to work, the TQ values must be on a similar level, otherwise it will not be activated. I haven't really tried bonding with BATMAN V, you may want to try with BATMAN IV instead. Please note that bonding will schedule the packets over the available interfaces, but will not perform any reordering on the receiver side. This can upset TCP which handles reordering as losses. In experiments with WiFi links, I often actually got degraded performance because the queue depths of the WiFi links were growing differently, therefore causing reodering ... Cheers, Simon signature.asc Description: This is a digitally signed message part.
[PATCH 6/6] batman-adv: bcast: remove remaining skb-copy calls
From: Linus Lüssing We currently have two code paths for broadcast packets: A) self-generated, via batadv_interface_tx()-> batadv_send_bcast_packet(). B) received/forwarded, via batadv_recv_bcast_packet()-> batadv_forw_bcast_packet(). For A), self-generated broadcast packets: The only modifications to the skb data is the ethernet header which is added/pushed to the skb in batadv_send_broadcast_skb()->batadv_send_skb_packet(). However before doing so, batadv_skb_head_push() is called which calls skb_cow_head() to unshare the space for the to be pushed ethernet header. So for this case, it is safe to use skb clones. For B), received/forwarded packets: The same applies as in A) for the to be forwarded packets. Only the ethernet header is added. However after (queueing for) forwarding the packet in batadv_recv_bcast_packet()->batadv_forw_bcast_packet(), a packet is additionally decapsulated and is sent up the stack through batadv_recv_bcast_packet()->batadv_interface_rx(). Protocols higher up the stack are already required to check if the packet is shared and create a copy for further modifications. When the next (protocol) layer works correctly, it cannot happen that it tries to operate on the data behind the skb clone which is still queued up for forwarding. Co-authored-by: Sven Eckelmann Signed-off-by: Sven Eckelmann Signed-off-by: Linus Lüssing Signed-off-by: Simon Wunderlich --- net/batman-adv/send.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index 2a33458be65c..477d85a3b558 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -742,6 +742,10 @@ void batadv_forw_packet_ogmv1_queue(struct batadv_priv *bat_priv, * Adds a broadcast packet to the queue and sets up timers. Broadcast packets * are sent multiple times to increase probability for being received. * + * This call clones the given skb, hence the caller needs to take into + * account that the data segment of the original skb might not be + * modifiable anymore. + * * Return: NETDEV_TX_OK on success and NETDEV_TX_BUSY on errors. */ static int batadv_forw_bcast_packet_to_list(struct batadv_priv *bat_priv, @@ -755,7 +759,7 @@ static int batadv_forw_bcast_packet_to_list(struct batadv_priv *bat_priv, unsigned long send_time = jiffies; struct sk_buff *newskb; - newskb = skb_copy(skb, GFP_ATOMIC); + newskb = skb_clone(skb, GFP_ATOMIC); if (!newskb) goto err; @@ -794,6 +798,10 @@ static int batadv_forw_bcast_packet_to_list(struct batadv_priv *bat_priv, * or if a delay is given after that. Furthermore, queues additional * retransmissions if this interface is a wireless one. * + * This call clones the given skb, hence the caller needs to take into + * account that the data segment of the original skb might not be + * modifiable anymore. + * * Return: NETDEV_TX_OK on success and NETDEV_TX_BUSY on errors. */ static int batadv_forw_bcast_packet_if(struct batadv_priv *bat_priv, @@ -808,7 +816,7 @@ static int batadv_forw_bcast_packet_if(struct batadv_priv *bat_priv, int ret = NETDEV_TX_OK; if (!delay) { - newskb = skb_copy(skb, GFP_ATOMIC); + newskb = skb_clone(skb, GFP_ATOMIC); if (!newskb) return NETDEV_TX_BUSY; -- 2.20.1
[PATCH 5/6] batman-adv: Drop NULL check before dropping references
From: Sven Eckelmann The check if a batman-adv related object is NULL or not is now directly in the batadv_*_put functions. It is not needed anymore to perform this check outside these function: The changes were generated using a coccinelle semantic patch: @@ expression E; @@ - if (likely(E != NULL)) ( batadv_backbone_gw_put | batadv_claim_put | batadv_dat_entry_put | batadv_gw_node_put | batadv_hardif_neigh_put | batadv_hardif_put | batadv_nc_node_put | batadv_nc_path_put | batadv_neigh_ifinfo_put | batadv_neigh_node_put | batadv_orig_ifinfo_put | batadv_orig_node_put | batadv_orig_node_vlan_put | batadv_softif_vlan_put | batadv_tp_vars_put | batadv_tt_global_entry_put | batadv_tt_local_entry_put | batadv_tt_orig_list_entry_put | batadv_tt_req_node_put | batadv_tvlv_container_put | batadv_tvlv_handler_put )(E); Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/bat_iv_ogm.c| 75 + net/batman-adv/bat_v.c | 30 -- net/batman-adv/bat_v_elp.c | 9 +-- net/batman-adv/bat_v_ogm.c | 39 + net/batman-adv/bridge_loop_avoidance.c | 27 +++-- net/batman-adv/distributed-arp-table.c | 21 +++ net/batman-adv/fragmentation.c | 6 +- net/batman-adv/gateway_client.c| 45 +-- net/batman-adv/hard-interface.c| 21 +++ net/batman-adv/multicast.c | 2 +- net/batman-adv/netlink.c | 6 +- net/batman-adv/network-coding.c| 18 ++ net/batman-adv/originator.c| 30 -- net/batman-adv/routing.c | 39 + net/batman-adv/send.c | 21 +++ net/batman-adv/soft-interface.c| 12 ++-- net/batman-adv/tp_meter.c | 24 +++- net/batman-adv/translation-table.c | 78 +- net/batman-adv/tvlv.c | 3 +- 19 files changed, 169 insertions(+), 337 deletions(-) diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 12022378f892..f94f538fa382 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -519,8 +519,7 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet, } out: - if (primary_if) - batadv_hardif_put(primary_if); + batadv_hardif_put(primary_if); return res; } @@ -857,8 +856,7 @@ static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface) rcu_read_unlock(); out: - if (primary_if) - batadv_hardif_put(primary_if); + batadv_hardif_put(primary_if); } static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) @@ -1046,14 +1044,10 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv, unlock: rcu_read_unlock(); out: - if (neigh_node) - batadv_neigh_node_put(neigh_node); - if (router) - batadv_neigh_node_put(router); - if (neigh_ifinfo) - batadv_neigh_ifinfo_put(neigh_ifinfo); - if (router_ifinfo) - batadv_neigh_ifinfo_put(router_ifinfo); + batadv_neigh_node_put(neigh_node); + batadv_neigh_node_put(router); + batadv_neigh_ifinfo_put(neigh_ifinfo); + batadv_neigh_ifinfo_put(router_ifinfo); } /** @@ -1194,8 +1188,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node, ret = true; out: - if (neigh_node) - batadv_neigh_node_put(neigh_node); + batadv_neigh_node_put(neigh_node); return ret; } @@ -1496,16 +1489,11 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff *skb, int ogm_offset, if (orig_neigh_node && !is_single_hop_neigh) batadv_orig_node_put(orig_neigh_node); out: - if (router_ifinfo) - batadv_neigh_ifinfo_put(router_ifinfo); - if (router) - batadv_neigh_node_put(router); - if (router_router) - batadv_neigh_node_put(router_router); - if (orig_neigh_router) - batadv_neigh_node_put(orig_neigh_router); - if (hardif_neigh) - batadv_hardif_neigh_put(hardif_neigh); + batadv_neigh_ifinfo_put(router_ifinfo); + batadv_neigh_node_put(router); + batadv_neigh_node_put(router_router); + batadv_neigh_node_put(orig_neigh_router); + batadv_hardif_neigh_put(hardif_neigh); consume_skb(skb_priv); } @@ -1926,8 +1914,7 @@ batadv_iv_ogm_orig_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, } out: - if (neigh_node_best) - batadv_neigh_node_put(neigh_node_best); + batadv_neigh_node_put(neigh_node_best); *sub_s = 0; return 0; @@ -2049,10 +2036,8 @@ static bool batadv_iv_ogm_neigh_diff(struct batadv_neigh_node
[PATCH 4/6] batman-adv: Check ptr for NULL before reducing its refcnt
From: Sven Eckelmann The commit b37a46683739 ("netdevice: add the case if dev is NULL") changed the way how the NULL check for net_devices have to be handled when trying to reduce its reference counter. Before this commit, it was the responsibility of the caller to check whether the object is NULL or not. But it was changed to behave more like kfree. Now the callee has to handle the NULL-case. The batman-adv code was scanned via cocinelle for similar places. These were changed to use the paradigm @@ identifier E, T, R, C; identifier put; @@ void put(struct T *E) { + if (!E) + return; kref_put(&E->C, R); } Functions which were used in other sources files were moved to the header to allow the compiler to inline the NULL check and the kref_put call. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/bridge_loop_avoidance.c | 6 ++ net/batman-adv/distributed-arp-table.c | 3 + net/batman-adv/gateway_client.c| 12 +--- net/batman-adv/gateway_client.h| 16 - net/batman-adv/hard-interface.h| 3 + net/batman-adv/network-coding.c| 6 ++ net/batman-adv/originator.c| 72 ++- net/batman-adv/originator.h| 96 -- net/batman-adv/soft-interface.c| 15 +--- net/batman-adv/soft-interface.h| 16 - net/batman-adv/tp_meter.c | 3 + net/batman-adv/translation-table.c | 22 +++--- net/batman-adv/translation-table.h | 18 - net/batman-adv/tvlv.c | 6 ++ 14 files changed, 181 insertions(+), 113 deletions(-) diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 2b639c8b0ded..134db98a4606 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -162,6 +162,9 @@ static void batadv_backbone_gw_release(struct kref *ref) */ static void batadv_backbone_gw_put(struct batadv_bla_backbone_gw *backbone_gw) { + if (!backbone_gw) + return; + kref_put(&backbone_gw->refcount, batadv_backbone_gw_release); } @@ -197,6 +200,9 @@ static void batadv_claim_release(struct kref *ref) */ static void batadv_claim_put(struct batadv_bla_claim *claim) { + if (!claim) + return; + kref_put(&claim->refcount, batadv_claim_release); } diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index 7976a0435662..60f1ae1abd81 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c @@ -127,6 +127,9 @@ static void batadv_dat_entry_release(struct kref *ref) */ static void batadv_dat_entry_put(struct batadv_dat_entry *dat_entry) { + if (!dat_entry) + return; + kref_put(&dat_entry->refcount, batadv_dat_entry_release); } diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index 36a98d3cefe0..c36a813249a9 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -59,7 +59,7 @@ * after rcu grace period * @ref: kref pointer of the gw_node */ -static void batadv_gw_node_release(struct kref *ref) +void batadv_gw_node_release(struct kref *ref) { struct batadv_gw_node *gw_node; @@ -69,16 +69,6 @@ static void batadv_gw_node_release(struct kref *ref) kfree_rcu(gw_node, rcu); } -/** - * batadv_gw_node_put() - decrement the gw_node refcounter and possibly release - * it - * @gw_node: gateway node to free - */ -void batadv_gw_node_put(struct batadv_gw_node *gw_node) -{ - kref_put(&gw_node->refcount, batadv_gw_node_release); -} - /** * batadv_gw_get_selected_gw_node() - Get currently selected gateway * @bat_priv: the bat priv with all the soft interface information diff --git a/net/batman-adv/gateway_client.h b/net/batman-adv/gateway_client.h index 2ae5846ef958..95c2ccdaa554 100644 --- a/net/batman-adv/gateway_client.h +++ b/net/batman-adv/gateway_client.h @@ -9,6 +9,7 @@ #include "main.h" +#include #include #include #include @@ -27,7 +28,7 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv, void batadv_gw_node_delete(struct batadv_priv *bat_priv, struct batadv_orig_node *orig_node); void batadv_gw_node_free(struct batadv_priv *bat_priv); -void batadv_gw_node_put(struct batadv_gw_node *gw_node); +void batadv_gw_node_release(struct kref *ref); struct batadv_gw_node * batadv_gw_get_selected_gw_node(struct batadv_priv *bat_priv); int batadv_gw_dump(struct sk_buff *msg, struct netlink_callback *cb); @@ -38,4 +39,17 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len, struct batadv_gw_node *batadv_gw_node_get(struct batadv_priv *bat_priv, struct batadv_orig_node *orig_node); +/** + * batadv_gw_nod
[PATCH 3/6] batman-adv: Switch to kstrtox.h for kstrtou64
From: Sven Eckelmann The commit 4c52729377ea ("kernel.h: split out kstrtox() and simple_strtox() to a separate header") moved the kstrtou64 function to a new header called linux/kstrtox.h. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/gateway_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c index fdde305a198e..9349c76f30c5 100644 --- a/net/batman-adv/gateway_common.c +++ b/net/batman-adv/gateway_common.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include -- 2.20.1
[PATCH 2/6] batman-adv: Move IRC channel to hackint.org
From: Sven Eckelmann Due to recent developments around the Freenode.org IRC network, the opinions about the usage of this service shifted dramatically. The majority of the still active users of the #batman channel prefers a move to the hackint.org network. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- Documentation/networking/batman-adv.rst | 2 +- MAINTAINERS | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/networking/batman-adv.rst b/Documentation/networking/batman-adv.rst index 74821d29a22f..b85563ea3682 100644 --- a/Documentation/networking/batman-adv.rst +++ b/Documentation/networking/batman-adv.rst @@ -157,7 +157,7 @@ Contact Please send us comments, experiences, questions, anything :) IRC: - #batman on irc.freenode.org + #batadv on ircs://irc.hackint.org/ Mailing-list: b.a.t.m@open-mesh.org (optional subscription at https://lists.open-mesh.org/mailman3/postorius/lists/b.a.t.m.a.n.lists.open-mesh.org/) diff --git a/MAINTAINERS b/MAINTAINERS index 41fcfdb24a81..b8971a2f5a7e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3197,7 +3197,7 @@ S:Maintained W: https://www.open-mesh.org/ Q: https://patchwork.open-mesh.org/project/batman/list/ B: https://www.open-mesh.org/projects/batman-adv/issues -C: irc://chat.freenode.net/batman +C: ircs://irc.hackint.org/batadv T: git https://git.open-mesh.org/linux-merge.git F: Documentation/networking/batman-adv.rst F: include/uapi/linux/batadv_packet.h -- 2.20.1
[PATCH 1/6] batman-adv: Start new development cycle
This version will contain all the (major or even only minor) changes for Linux 5.15. 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). Signed-off-by: Simon Wunderlich --- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 014235fd4681..058b8f2eef65 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -13,7 +13,7 @@ #define BATADV_DRIVER_DEVICE "batman-adv" #ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2021.2" +#define BATADV_SOURCE_VERSION "2021.3" #endif /* B.A.T.M.A.N. parameters */ -- 2.20.1
[PATCH 0/6] (updated) pull request for net-next: batman-adv 2021-08-20
Hi Jakub, here is the updated pull request of batman-adv, with the missing sign-off added which you pointed out yesterday. Please pull or let me know of any problem! Thank you, Simon The following changes since commit b37a466837393af72fe8bcb8f1436410f3f173f3: netdevice: add the case if dev is NULL (2021-08-05 13:29:26 +0100) are available in the Git repository at: git://git.open-mesh.org/linux-merge.git tags/batadv-next-pullrequest-20210820 for you to fetch changes up to a006aa51ea27fa64afc7990f8f100ff0baa92413: batman-adv: bcast: remove remaining skb-copy calls (2021-08-20 08:17:10 +0200) This (updated) cleanup patchset includes the following patches: - bump version strings, by Simon Wunderlich - update docs about move IRC channel away from freenode, by Sven Eckelmann (updated, added missing sign-off) - Switch to kstrtox.h for kstrtou64, by Sven Eckelmann - Update NULL checks, by Sven Eckelmann (2 patches) - remove remaining skb-copy calls for broadcast packets, by Linus Lüssing Linus Lüssing (1): batman-adv: bcast: remove remaining skb-copy calls Simon Wunderlich (1): batman-adv: Start new development cycle Sven Eckelmann (4): batman-adv: Move IRC channel to hackint.org batman-adv: Switch to kstrtox.h for kstrtou64 batman-adv: Check ptr for NULL before reducing its refcnt batman-adv: Drop NULL check before dropping references Documentation/networking/batman-adv.rst | 2 +- MAINTAINERS | 2 +- net/batman-adv/bat_iv_ogm.c | 75 --- net/batman-adv/bat_v.c | 30 -- net/batman-adv/bat_v_elp.c | 9 +-- net/batman-adv/bat_v_ogm.c | 39 net/batman-adv/bridge_loop_avoidance.c | 33 +-- net/batman-adv/distributed-arp-table.c | 24 net/batman-adv/fragmentation.c | 6 +- net/batman-adv/gateway_client.c | 57 +- net/batman-adv/gateway_client.h | 16 - net/batman-adv/gateway_common.c | 2 +- net/batman-adv/hard-interface.c | 21 +++ net/batman-adv/hard-interface.h | 3 + net/batman-adv/main.h | 2 +- net/batman-adv/multicast.c | 2 +- net/batman-adv/netlink.c| 6 +- net/batman-adv/network-coding.c | 24 net/batman-adv/originator.c | 102 +--- net/batman-adv/originator.h | 96 +++--- net/batman-adv/routing.c| 39 net/batman-adv/send.c | 33 ++- net/batman-adv/soft-interface.c | 27 ++--- net/batman-adv/soft-interface.h | 16 - net/batman-adv/tp_meter.c | 27 - net/batman-adv/translation-table.c | 100 +++ net/batman-adv/translation-table.h | 18 +- net/batman-adv/tvlv.c | 9 ++- 28 files changed, 364 insertions(+), 456 deletions(-)
[PATCH 6/6] batman-adv: bcast: remove remaining skb-copy calls
From: Linus Lüssing We currently have two code paths for broadcast packets: A) self-generated, via batadv_interface_tx()-> batadv_send_bcast_packet(). B) received/forwarded, via batadv_recv_bcast_packet()-> batadv_forw_bcast_packet(). For A), self-generated broadcast packets: The only modifications to the skb data is the ethernet header which is added/pushed to the skb in batadv_send_broadcast_skb()->batadv_send_skb_packet(). However before doing so, batadv_skb_head_push() is called which calls skb_cow_head() to unshare the space for the to be pushed ethernet header. So for this case, it is safe to use skb clones. For B), received/forwarded packets: The same applies as in A) for the to be forwarded packets. Only the ethernet header is added. However after (queueing for) forwarding the packet in batadv_recv_bcast_packet()->batadv_forw_bcast_packet(), a packet is additionally decapsulated and is sent up the stack through batadv_recv_bcast_packet()->batadv_interface_rx(). Protocols higher up the stack are already required to check if the packet is shared and create a copy for further modifications. When the next (protocol) layer works correctly, it cannot happen that it tries to operate on the data behind the skb clone which is still queued up for forwarding. Co-authored-by: Sven Eckelmann Signed-off-by: Sven Eckelmann Signed-off-by: Linus Lüssing Signed-off-by: Simon Wunderlich --- net/batman-adv/send.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index 2a33458be65c..477d85a3b558 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -742,6 +742,10 @@ void batadv_forw_packet_ogmv1_queue(struct batadv_priv *bat_priv, * Adds a broadcast packet to the queue and sets up timers. Broadcast packets * are sent multiple times to increase probability for being received. * + * This call clones the given skb, hence the caller needs to take into + * account that the data segment of the original skb might not be + * modifiable anymore. + * * Return: NETDEV_TX_OK on success and NETDEV_TX_BUSY on errors. */ static int batadv_forw_bcast_packet_to_list(struct batadv_priv *bat_priv, @@ -755,7 +759,7 @@ static int batadv_forw_bcast_packet_to_list(struct batadv_priv *bat_priv, unsigned long send_time = jiffies; struct sk_buff *newskb; - newskb = skb_copy(skb, GFP_ATOMIC); + newskb = skb_clone(skb, GFP_ATOMIC); if (!newskb) goto err; @@ -794,6 +798,10 @@ static int batadv_forw_bcast_packet_to_list(struct batadv_priv *bat_priv, * or if a delay is given after that. Furthermore, queues additional * retransmissions if this interface is a wireless one. * + * This call clones the given skb, hence the caller needs to take into + * account that the data segment of the original skb might not be + * modifiable anymore. + * * Return: NETDEV_TX_OK on success and NETDEV_TX_BUSY on errors. */ static int batadv_forw_bcast_packet_if(struct batadv_priv *bat_priv, @@ -808,7 +816,7 @@ static int batadv_forw_bcast_packet_if(struct batadv_priv *bat_priv, int ret = NETDEV_TX_OK; if (!delay) { - newskb = skb_copy(skb, GFP_ATOMIC); + newskb = skb_clone(skb, GFP_ATOMIC); if (!newskb) return NETDEV_TX_BUSY; -- 2.20.1
[PATCH 3/6] batman-adv: Switch to kstrtox.h for kstrtou64
From: Sven Eckelmann The commit 4c52729377ea ("kernel.h: split out kstrtox() and simple_strtox() to a separate header") moved the kstrtou64 function to a new header called linux/kstrtox.h. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/gateway_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c index fdde305a198e..9349c76f30c5 100644 --- a/net/batman-adv/gateway_common.c +++ b/net/batman-adv/gateway_common.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include -- 2.20.1