Skip to content

Commit

Permalink
batman-adv: OGMv2 - add basic infrastructure
Browse files Browse the repository at this point in the history
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 <antonio@open-mesh.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
  • Loading branch information
ordex committed Feb 29, 2016
1 parent 7f136cd commit 0da0035
Show file tree
Hide file tree
Showing 9 changed files with 427 additions and 3 deletions.
1 change: 1 addition & 0 deletions net/batman-adv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ obj-$(CONFIG_BATMAN_ADV) += batman-adv.o
batman-adv-y += bat_iv_ogm.o
batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v.o
batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v_elp.o
batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v_ogm.o
batman-adv-y += bitarray.o
batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o
batman-adv-$(CONFIG_DEBUG_FS) += debugfs.o
Expand Down
13 changes: 13 additions & 0 deletions net/batman-adv/bat_algo.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
#ifndef _NET_BATMAN_ADV_BAT_ALGO_H_
#define _NET_BATMAN_ADV_BAT_ALGO_H_

struct batadv_priv;

int batadv_iv_init(void);

#ifdef CONFIG_BATMAN_ADV_BATMAN_V

int batadv_v_init(void);
int batadv_v_mesh_init(struct batadv_priv *bat_priv);
void batadv_v_mesh_free(struct batadv_priv *bat_priv);

#else

Expand All @@ -31,6 +35,15 @@ static inline int batadv_v_init(void)
return 0;
}

static inline int batadv_v_mesh_init(struct batadv_priv *bat_priv)
{
return 0;
}

static inline void batadv_v_mesh_free(struct batadv_priv *bat_priv)
{
}

#endif /* CONFIG_BATMAN_ADV_BATMAN_V */

#endif /* _NET_BATMAN_ADV_BAT_ALGO_H_ */
51 changes: 48 additions & 3 deletions net/batman-adv/bat_v.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,22 @@
#include <linux/init.h>

#include "bat_v_elp.h"
#include "bat_v_ogm.h"
#include "packet.h"

static int batadv_v_iface_enable(struct batadv_hard_iface *hard_iface)
{
return batadv_v_elp_iface_enable(hard_iface);
int ret;

ret = batadv_v_elp_iface_enable(hard_iface);
if (ret < 0)
return ret;

ret = batadv_v_ogm_iface_enable(hard_iface);
if (ret < 0)
batadv_v_elp_iface_disable(hard_iface);

return ret;
}

static void batadv_v_iface_disable(struct batadv_hard_iface *hard_iface)
Expand All @@ -41,6 +52,7 @@ static void batadv_v_iface_update_mac(struct batadv_hard_iface *hard_iface)
static void batadv_v_primary_iface_set(struct batadv_hard_iface *hard_iface)
{
batadv_v_elp_primary_iface_set(hard_iface);
batadv_v_ogm_primary_iface_set(hard_iface);
}

static void
Expand Down Expand Up @@ -68,6 +80,27 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {
.bat_ogm_schedule = batadv_v_ogm_schedule,
};

/**
* batadv_v_mesh_init - initialize the B.A.T.M.A.N. V private resources for a
* mesh
* @bat_priv: the object representing the mesh interface to initialise
*
* Return: 0 on success or a negative error code otherwise
*/
int batadv_v_mesh_init(struct batadv_priv *bat_priv)
{
return batadv_v_ogm_init(bat_priv);
}

/**
* batadv_v_mesh_free - free the B.A.T.M.A.N. V private resources for a mesh
* @bat_priv: the object representing the mesh interface to free
*/
void batadv_v_mesh_free(struct batadv_priv *bat_priv)
{
batadv_v_ogm_free(bat_priv);
}

/**
* batadv_v_init - B.A.T.M.A.N. V initialization function
*
Expand All @@ -86,10 +119,22 @@ int __init batadv_v_init(void)
if (ret < 0)
return ret;

ret = batadv_algo_register(&batadv_batman_v);
ret = batadv_recv_handler_register(BATADV_OGM2,
batadv_v_ogm_packet_recv);
if (ret < 0)
goto elp_unregister;

ret = batadv_algo_register(&batadv_batman_v);
if (ret < 0)
batadv_recv_handler_unregister(BATADV_ELP);
goto ogm_unregister;

return ret;

ogm_unregister:
batadv_recv_handler_unregister(BATADV_OGM2);

elp_unregister:
batadv_recv_handler_unregister(BATADV_ELP);

return ret;
}
Loading

0 comments on commit 0da0035

Please sign in to comment.