Skip to content

Commit 0da0035

Browse files
committed
batman-adv: OGMv2 - add basic infrastructure
This is the initial implementation of the new OGM protocol (version 2). It has been designed to work on top of the newly added ELP. In the previous version the OGM protocol was used to both measure link qualities and flood the network with the metric information. In this version the protocol is in charge of the latter task only, leaving the former to ELP. This means being able to decouple the interval used by the neighbor discovery from the OGM broadcasting, which revealed to be costly in dense networks and needed to be relaxed so leading to a less responsive routing protocol. Signed-off-by: Antonio Quartulli <[email protected]> Signed-off-by: Marek Lindner <[email protected]>
1 parent 7f136cd commit 0da0035

File tree

9 files changed

+427
-3
lines changed

9 files changed

+427
-3
lines changed

net/batman-adv/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ obj-$(CONFIG_BATMAN_ADV) += batman-adv.o
2020
batman-adv-y += bat_iv_ogm.o
2121
batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v.o
2222
batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v_elp.o
23+
batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v_ogm.o
2324
batman-adv-y += bitarray.o
2425
batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o
2526
batman-adv-$(CONFIG_DEBUG_FS) += debugfs.o

net/batman-adv/bat_algo.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@
1818
#ifndef _NET_BATMAN_ADV_BAT_ALGO_H_
1919
#define _NET_BATMAN_ADV_BAT_ALGO_H_
2020

21+
struct batadv_priv;
22+
2123
int batadv_iv_init(void);
2224

2325
#ifdef CONFIG_BATMAN_ADV_BATMAN_V
2426

2527
int batadv_v_init(void);
28+
int batadv_v_mesh_init(struct batadv_priv *bat_priv);
29+
void batadv_v_mesh_free(struct batadv_priv *bat_priv);
2630

2731
#else
2832

@@ -31,6 +35,15 @@ static inline int batadv_v_init(void)
3135
return 0;
3236
}
3337

38+
static inline int batadv_v_mesh_init(struct batadv_priv *bat_priv)
39+
{
40+
return 0;
41+
}
42+
43+
static inline void batadv_v_mesh_free(struct batadv_priv *bat_priv)
44+
{
45+
}
46+
3447
#endif /* CONFIG_BATMAN_ADV_BATMAN_V */
3548

3649
#endif /* _NET_BATMAN_ADV_BAT_ALGO_H_ */

net/batman-adv/bat_v.c

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,22 @@
2222
#include <linux/init.h>
2323

2424
#include "bat_v_elp.h"
25+
#include "bat_v_ogm.h"
2526
#include "packet.h"
2627

2728
static int batadv_v_iface_enable(struct batadv_hard_iface *hard_iface)
2829
{
29-
return batadv_v_elp_iface_enable(hard_iface);
30+
int ret;
31+
32+
ret = batadv_v_elp_iface_enable(hard_iface);
33+
if (ret < 0)
34+
return ret;
35+
36+
ret = batadv_v_ogm_iface_enable(hard_iface);
37+
if (ret < 0)
38+
batadv_v_elp_iface_disable(hard_iface);
39+
40+
return ret;
3041
}
3142

3243
static void batadv_v_iface_disable(struct batadv_hard_iface *hard_iface)
@@ -41,6 +52,7 @@ static void batadv_v_iface_update_mac(struct batadv_hard_iface *hard_iface)
4152
static void batadv_v_primary_iface_set(struct batadv_hard_iface *hard_iface)
4253
{
4354
batadv_v_elp_primary_iface_set(hard_iface);
55+
batadv_v_ogm_primary_iface_set(hard_iface);
4456
}
4557

4658
static void
@@ -68,6 +80,27 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {
6880
.bat_ogm_schedule = batadv_v_ogm_schedule,
6981
};
7082

83+
/**
84+
* batadv_v_mesh_init - initialize the B.A.T.M.A.N. V private resources for a
85+
* mesh
86+
* @bat_priv: the object representing the mesh interface to initialise
87+
*
88+
* Return: 0 on success or a negative error code otherwise
89+
*/
90+
int batadv_v_mesh_init(struct batadv_priv *bat_priv)
91+
{
92+
return batadv_v_ogm_init(bat_priv);
93+
}
94+
95+
/**
96+
* batadv_v_mesh_free - free the B.A.T.M.A.N. V private resources for a mesh
97+
* @bat_priv: the object representing the mesh interface to free
98+
*/
99+
void batadv_v_mesh_free(struct batadv_priv *bat_priv)
100+
{
101+
batadv_v_ogm_free(bat_priv);
102+
}
103+
71104
/**
72105
* batadv_v_init - B.A.T.M.A.N. V initialization function
73106
*
@@ -86,10 +119,22 @@ int __init batadv_v_init(void)
86119
if (ret < 0)
87120
return ret;
88121

89-
ret = batadv_algo_register(&batadv_batman_v);
122+
ret = batadv_recv_handler_register(BATADV_OGM2,
123+
batadv_v_ogm_packet_recv);
124+
if (ret < 0)
125+
goto elp_unregister;
90126

127+
ret = batadv_algo_register(&batadv_batman_v);
91128
if (ret < 0)
92-
batadv_recv_handler_unregister(BATADV_ELP);
129+
goto ogm_unregister;
130+
131+
return ret;
132+
133+
ogm_unregister:
134+
batadv_recv_handler_unregister(BATADV_OGM2);
135+
136+
elp_unregister:
137+
batadv_recv_handler_unregister(BATADV_ELP);
93138

94139
return ret;
95140
}

0 commit comments

Comments
 (0)