Skip to content

Commit 7db682d

Browse files
Marek Lindnersimonwunderlich
authored andcommitted
batman-adv: init ELP tweaking options only once
The ELP interval and throughput override interface settings are initialized with default settings on every time an interface is added to a mesh. This patch prevents this behavior by moving the configuration init to the interface detection routine which runs only once per interface. Signed-off-by: Marek Lindner <[email protected]> [[email protected]: move initialization to batadv_v_hardif_init] Signed-off-by: Antonio Quartulli <[email protected]> Signed-off-by: Sven Eckelmann <[email protected]> Signed-off-by: Simon Wunderlich <[email protected]>
1 parent 3a24a63 commit 7db682d

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

net/batman-adv/bat_algo.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
#ifndef _NET_BATMAN_ADV_BAT_ALGO_H_
1919
#define _NET_BATMAN_ADV_BAT_ALGO_H_
2020

21-
struct batadv_priv;
21+
#include "main.h"
2222

2323
int batadv_iv_init(void);
2424

2525
#ifdef CONFIG_BATMAN_ADV_BATMAN_V
2626

2727
int batadv_v_init(void);
28+
void batadv_v_hardif_init(struct batadv_hard_iface *hardif);
2829
int batadv_v_mesh_init(struct batadv_priv *bat_priv);
2930
void batadv_v_mesh_free(struct batadv_priv *bat_priv);
3031

@@ -35,6 +36,10 @@ static inline int batadv_v_init(void)
3536
return 0;
3637
}
3738

39+
static inline void batadv_v_hardif_init(struct batadv_hard_iface *hardif)
40+
{
41+
}
42+
3843
static inline int batadv_v_mesh_init(struct batadv_priv *bat_priv)
3944
{
4045
return 0;

net/batman-adv/bat_v.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ static int batadv_v_iface_enable(struct batadv_hard_iface *hard_iface)
7070
if (ret < 0)
7171
batadv_v_elp_iface_disable(hard_iface);
7272

73-
/* enable link throughput auto-detection by setting the throughput
74-
* override to zero
75-
*/
76-
atomic_set(&hard_iface->bat_v.throughput_override, 0);
77-
7873
return ret;
7974
}
8075

@@ -338,6 +333,20 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {
338333
.bat_neigh_print = batadv_v_neigh_print,
339334
};
340335

336+
/**
337+
* batadv_v_hardif_init - initialize the algorithm specific fields in the
338+
* hard-interface object
339+
* @hard_iface: the hard-interface to initialize
340+
*/
341+
void batadv_v_hardif_init(struct batadv_hard_iface *hard_iface)
342+
{
343+
/* enable link throughput auto-detection by setting the throughput
344+
* override to zero
345+
*/
346+
atomic_set(&hard_iface->bat_v.throughput_override, 0);
347+
atomic_set(&hard_iface->bat_v.elp_interval, 500);
348+
}
349+
341350
/**
342351
* batadv_v_mesh_init - initialize the B.A.T.M.A.N. V private resources for a
343352
* mesh

net/batman-adv/bat_v_elp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface)
344344
/* randomize initial seqno to avoid collision */
345345
get_random_bytes(&random_seqno, sizeof(random_seqno));
346346
atomic_set(&hard_iface->bat_v.elp_seqno, random_seqno);
347-
atomic_set(&hard_iface->bat_v.elp_interval, 500);
348347

349348
/* assume full-duplex by default */
350349
hard_iface->bat_v.flags |= BATADV_FULL_DUPLEX;

net/batman-adv/hard-interface.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <linux/spinlock.h>
3838
#include <linux/workqueue.h>
3939

40+
#include "bat_algo.h"
4041
#include "bridge_loop_avoidance.h"
4142
#include "debugfs.h"
4243
#include "distributed-arp-table.h"
@@ -683,6 +684,8 @@ batadv_hardif_add_interface(struct net_device *net_dev)
683684
if (batadv_is_wifi_netdev(net_dev))
684685
hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS;
685686

687+
batadv_v_hardif_init(hard_iface);
688+
686689
/* extra reference for return */
687690
kref_init(&hard_iface->refcount);
688691
kref_get(&hard_iface->refcount);

0 commit comments

Comments
 (0)