From: Simon Wunderlich <sw@simonwunderlich.de> Date: 2023-08-16 16:40:23
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(-)
From: Simon Wunderlich <sw@simonwunderlich.de> Date: 2023-08-16 16:41:08
From: Remi Pommarel <redacted>
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 0xffff0000073c8000 (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:
[<00000000ee6e0ffa>] kmem_cache_alloc+0x1b4/0x300
[<000000000ff2fdbc>] batadv_tt_global_add+0x700/0xe20
[<00000000443897c7>] _batadv_tt_update_changes+0x21c/0x790
[<000000005dd90463>] batadv_tt_update_changes+0x3c/0x110
[<00000000a2d7fc57>] batadv_tt_tvlv_unicast_handler_v1+0xafc/0xe10
[<0000000011793f2a>] batadv_tvlv_containers_process+0x168/0x2b0
[<00000000b7cbe2ef>] batadv_recv_unicast_tvlv+0xec/0x1f4
[<0000000042aef1d8>] batadv_batman_skb_recv+0x25c/0x3a0
[<00000000bbd8b0a2>] __netif_receive_skb_core.isra.0+0x7a8/0xe90
[<000000004033d428>] __netif_receive_skb_one_core+0x64/0x74
[<000000000f39a009>] __netif_receive_skb+0x48/0xe0
[<00000000f2cd8888>] process_backlog+0x174/0x344
[<00000000507d6564>] __napi_poll+0x58/0x1f4
[<00000000b64ef9eb>] net_rx_action+0x504/0x590
[<00000000056fa5e4>] _stext+0x1b8/0x418
[<00000000878879d6>] run_ksoftirqd+0x74/0xa4
unreferenced object 0xffff00000bae1a80 (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:
[<00000000ee6e0ffa>] kmem_cache_alloc+0x1b4/0x300
[<00000000d9aaa49e>] batadv_tt_global_add+0x53c/0xe20
[<00000000443897c7>] _batadv_tt_update_changes+0x21c/0x790
[<000000005dd90463>] batadv_tt_update_changes+0x3c/0x110
[<00000000a2d7fc57>] batadv_tt_tvlv_unicast_handler_v1+0xafc/0xe10
[<0000000011793f2a>] batadv_tvlv_containers_process+0x168/0x2b0
[<00000000b7cbe2ef>] batadv_recv_unicast_tvlv+0xec/0x1f4
[<0000000042aef1d8>] batadv_batman_skb_recv+0x25c/0x3a0
[<00000000bbd8b0a2>] __netif_receive_skb_core.isra.0+0x7a8/0xe90
[<000000004033d428>] __netif_receive_skb_one_core+0x64/0x74
[<000000000f39a009>] __netif_receive_skb+0x48/0xe0
[<00000000f2cd8888>] process_backlog+0x174/0x344
[<00000000507d6564>] __napi_poll+0x58/0x1f4
[<00000000b64ef9eb>] net_rx_action+0x504/0x590
[<00000000056fa5e4>] _stext+0x1b8/0x418
[<00000000878879d6>] 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: stable@vger.kernel.org
Fixes: 068ee6e204e1 ("batman-adv: roaming handling mechanism redesign")
Signed-off-by: Remi Pommarel <redacted>
Signed-off-by; Sven Eckelmann [off-list ref]
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 1 -
1 file changed, 1 deletion(-)
@@ -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*hastobekeptforconsistencypurpose
From: Simon Wunderlich <sw@simonwunderlich.de> Date: 2023-08-16 16:41:08
From: Sven Eckelmann <sven@narfation.org>
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: stable@vger.kernel.org
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/hard-interface.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -630,7 +630,7 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)*/voidbatadv_update_min_mtu(structnet_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(andsmaller)MTU.
From: Simon Wunderlich <sw@simonwunderlich.de> Date: 2023-08-16 16:41:08
From: Sven Eckelmann <sven@narfation.org>
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: stable@vger.kernel.org
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
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(-)
@@ -630,7 +630,19 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)*/voidbatadv_update_min_mtu(structnet_device*soft_iface){-dev_set_mtu(soft_iface,batadv_hardif_min_mtu(soft_iface));+structbatadv_priv*bat_priv=netdev_priv(soft_iface);+intlimit_mtu;+intmtu;++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(andsmaller)MTU.
@@ -1546,6 +1546,12 @@ struct batadv_priv {/** @soft_iface: net device which holds this struct as private data */structnet_device*soft_iface;+/**+*@mtu_set_by_user:MTUwassetoncebyuser+*protectedbyrtnl_lock+*/+intmtu_set_by_user;+/***@bat_counters:meshinternaltrafficstatisticcounters(see*batadv_counters)
Hello:
This series was applied to netdev/net.git (main)
by Simon Wunderlich [off-list ref]:
On Wed, 16 Aug 2023 18:33:14 +0200 you wrote:
From: Sven Eckelmann <sven@narfation.org>
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.
[...]