Skip to content

Commit b6cf5d4

Browse files
committed
batman-adv: B.A.T.M.A.N V - make sure iface is reactivated upon NETDEV_UP event
At the moment there is no explicit reactivation of an hard-interface upon NETDEV_UP event. In case of B.A.T.M.A.N. IV the interface is reactivated as soon as the next OGM is scheduled for sending, but this mechanism does not work with B.A.T.M.A.N. V. The latter does not rely on the same scheduling mechanism as its predecessor and for this reason the hard-interface remains deactivated forever after being brought down once. This patch fixes the reactivation mechanism by adding a new routing API which explicitly allows each algorithm to perform any needed operation upon interface re-activation. Such API is optional and is implemented by B.A.T.M.A.N. V only and it just takes care of setting the iface status to ACTIVE Signed-off-by: Antonio Quartulli <a@unstable.cc> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
1 parent 2871734 commit b6cf5d4

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

net/batman-adv/bat_v.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,21 @@
3232

3333
#include "bat_v_elp.h"
3434
#include "bat_v_ogm.h"
35+
#include "hard-interface.h"
3536
#include "hash.h"
3637
#include "originator.h"
3738
#include "packet.h"
3839

40+
static void batadv_v_iface_activate(struct batadv_hard_iface *hard_iface)
41+
{
42+
/* B.A.T.M.A.N. V does not use any queuing mechanism, therefore it can
43+
* set the interface as ACTIVE right away, without any risk of race
44+
* condition
45+
*/
46+
if (hard_iface->if_status == BATADV_IF_TO_BE_ACTIVATED)
47+
hard_iface->if_status = BATADV_IF_ACTIVE;
48+
}
49+
3950
static int batadv_v_iface_enable(struct batadv_hard_iface *hard_iface)
4051
{
4152
int ret;
@@ -274,6 +285,7 @@ static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1,
274285

275286
static struct batadv_algo_ops batadv_batman_v __read_mostly = {
276287
.name = "BATMAN_V",
288+
.bat_iface_activate = batadv_v_iface_activate,
277289
.bat_iface_enable = batadv_v_iface_enable,
278290
.bat_iface_disable = batadv_v_iface_disable,
279291
.bat_iface_update_mac = batadv_v_iface_update_mac,

net/batman-adv/hard-interface.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)
407407

408408
batadv_update_min_mtu(hard_iface->soft_iface);
409409

410+
if (bat_priv->bat_algo_ops->bat_iface_activate)
411+
bat_priv->bat_algo_ops->bat_iface_activate(hard_iface);
412+
410413
out:
411414
if (primary_if)
412415
batadv_hardif_put(primary_if);

net/batman-adv/types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,8 @@ struct batadv_forw_packet {
12501250
* struct batadv_algo_ops - mesh algorithm callbacks
12511251
* @list: list node for the batadv_algo_list
12521252
* @name: name of the algorithm
1253+
* @bat_iface_activate: start routing mechanisms when hard-interface is brought
1254+
* up
12531255
* @bat_iface_enable: init routing info when hard-interface is enabled
12541256
* @bat_iface_disable: de-init routing info when hard-interface is disabled
12551257
* @bat_iface_update_mac: (re-)init mac addresses of the protocol information
@@ -1277,6 +1279,7 @@ struct batadv_forw_packet {
12771279
struct batadv_algo_ops {
12781280
struct hlist_node list;
12791281
char *name;
1282+
void (*bat_iface_activate)(struct batadv_hard_iface *hard_iface);
12801283
int (*bat_iface_enable)(struct batadv_hard_iface *hard_iface);
12811284
void (*bat_iface_disable)(struct batadv_hard_iface *hard_iface);
12821285
void (*bat_iface_update_mac)(struct batadv_hard_iface *hard_iface);

0 commit comments

Comments
 (0)