Skip to content

Commit

Permalink
Merge branch 'batman-adv/next' of git://git.open-mesh.org/ecsv/linux-…
Browse files Browse the repository at this point in the history
…merge
  • Loading branch information
David S. Miller committed May 8, 2011
2 parents c5216cc + 27aea21 commit 02e73c1
Show file tree
Hide file tree
Showing 20 changed files with 712 additions and 557 deletions.
11 changes: 6 additions & 5 deletions Documentation/networking/batman-adv.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[state: 27-01-2011]
[state: 17-04-2011]

BATMAN-ADV
----------
Expand All @@ -19,6 +19,7 @@ duce the overhead to a minimum. It does not depend on any (other)
network driver, and can be used on wifi as well as ethernet lan,
vpn, etc ... (anything with ethernet-style layer 2).


CONFIGURATION
-------------

Expand Down Expand Up @@ -160,13 +161,13 @@ face. Each entry can/has to have the following values:
-> "TQ mac value" - src mac's link quality towards mac address
of a neighbor originator's interface which
is being used for routing
-> "HNA mac" - HNA announced by source mac
-> "TT mac" - TT announced by source mac
-> "PRIMARY" - this is a primary interface
-> "SEC mac" - secondary mac address of source
(requires preceding PRIMARY)

The TQ value has a range from 4 to 255 with 255 being the best.
The HNA entries are showing which hosts are connected to the mesh
The TT entries are showing which hosts are connected to the mesh
via bat0 or being bridged into the mesh network. The PRIMARY/SEC
values are only applied on primary interfaces

Expand Down Expand Up @@ -199,15 +200,15 @@ abled during run time. Following log_levels are defined:

0 - All debug output disabled
1 - Enable messages related to routing / flooding / broadcasting
2 - Enable route or hna added / changed / deleted
2 - Enable route or tt entry added / changed / deleted
3 - Enable all messages

The debug output can be changed at runtime using the file
/sys/class/net/bat0/mesh/log_level. e.g.

# echo 2 > /sys/class/net/bat0/mesh/log_level

will enable debug messages for when routes or HNAs change.
will enable debug messages for when routes or TTs change.


BATCTL
Expand Down
16 changes: 8 additions & 8 deletions net/batman-adv/aggregation.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
#include "send.h"
#include "routing.h"

/* calculate the size of the hna information for a given packet */
static int hna_len(struct batman_packet *batman_packet)
/* calculate the size of the tt information for a given packet */
static int tt_len(struct batman_packet *batman_packet)
{
return batman_packet->num_hna * ETH_ALEN;
return batman_packet->num_tt * ETH_ALEN;
}

/* return true if new_packet can be aggregated with forw_packet */
Expand Down Expand Up @@ -250,7 +250,7 @@ void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff,
{
struct batman_packet *batman_packet;
int buff_pos = 0;
unsigned char *hna_buff;
unsigned char *tt_buff;

batman_packet = (struct batman_packet *)packet_buff;

Expand All @@ -259,14 +259,14 @@ void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff,
orig_interval. */
batman_packet->seqno = ntohl(batman_packet->seqno);

hna_buff = packet_buff + buff_pos + BAT_PACKET_LEN;
tt_buff = packet_buff + buff_pos + BAT_PACKET_LEN;
receive_bat_packet(ethhdr, batman_packet,
hna_buff, hna_len(batman_packet),
tt_buff, tt_len(batman_packet),
if_incoming);

buff_pos += BAT_PACKET_LEN + hna_len(batman_packet);
buff_pos += BAT_PACKET_LEN + tt_len(batman_packet);
batman_packet = (struct batman_packet *)
(packet_buff + buff_pos);
} while (aggregated_packet(buff_pos, packet_len,
batman_packet->num_hna));
batman_packet->num_tt));
}
4 changes: 2 additions & 2 deletions net/batman-adv/aggregation.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
#include "main.h"

/* is there another aggregated packet here? */
static inline int aggregated_packet(int buff_pos, int packet_len, int num_hna)
static inline int aggregated_packet(int buff_pos, int packet_len, int num_tt)
{
int next_buff_pos = buff_pos + BAT_PACKET_LEN + (num_hna * ETH_ALEN);
int next_buff_pos = buff_pos + BAT_PACKET_LEN + (num_tt * ETH_ALEN);

return (next_buff_pos <= packet_len) &&
(next_buff_pos <= MAX_AGGREGATION_BYTES);
Expand Down
4 changes: 2 additions & 2 deletions net/batman-adv/bat_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,13 @@ static int softif_neigh_open(struct inode *inode, struct file *file)
static int transtable_global_open(struct inode *inode, struct file *file)
{
struct net_device *net_dev = (struct net_device *)inode->i_private;
return single_open(file, hna_global_seq_print_text, net_dev);
return single_open(file, tt_global_seq_print_text, net_dev);
}

static int transtable_local_open(struct inode *inode, struct file *file)
{
struct net_device *net_dev = (struct net_device *)inode->i_private;
return single_open(file, hna_local_seq_print_text, net_dev);
return single_open(file, tt_local_seq_print_text, net_dev);
}

static int vis_data_open(struct inode *inode, struct file *file)
Expand Down
16 changes: 9 additions & 7 deletions net/batman-adv/bat_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,22 +488,24 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
(strncmp(hard_iface->soft_iface->name, buff, IFNAMSIZ) == 0))
goto out;

if (!rtnl_trylock()) {
ret = -ERESTARTSYS;
goto out;
}

if (status_tmp == IF_NOT_IN_USE) {
rtnl_lock();
hardif_disable_interface(hard_iface);
rtnl_unlock();
goto out;
goto unlock;
}

/* if the interface already is in use */
if (hard_iface->if_status != IF_NOT_IN_USE) {
rtnl_lock();
if (hard_iface->if_status != IF_NOT_IN_USE)
hardif_disable_interface(hard_iface);
rtnl_unlock();
}

ret = hardif_enable_interface(hard_iface, buff);

unlock:
rtnl_unlock();
out:
hardif_free_ref(hard_iface);
return ret;
Expand Down
36 changes: 10 additions & 26 deletions net/batman-adv/hard-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@

#include <linux/if_arp.h>

/* protect update critical side of hardif_list - but not the content */
static DEFINE_SPINLOCK(hardif_list_lock);


static int batman_skb_recv(struct sk_buff *skb,
struct net_device *dev,
Expand Down Expand Up @@ -136,7 +133,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
struct hard_iface *curr_hard_iface;
struct batman_packet *batman_packet;

spin_lock_bh(&hardif_list_lock);
ASSERT_RTNL();

if (new_hard_iface && !atomic_inc_not_zero(&new_hard_iface->refcount))
new_hard_iface = NULL;
Expand All @@ -148,7 +145,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
hardif_free_ref(curr_hard_iface);

if (!new_hard_iface)
goto out;
return;

batman_packet = (struct batman_packet *)(new_hard_iface->packet_buff);
batman_packet->flags = PRIMARIES_FIRST_HOP;
Expand All @@ -157,13 +154,10 @@ static void primary_if_select(struct bat_priv *bat_priv,
primary_if_update_addr(bat_priv);

/***
* hacky trick to make sure that we send the HNA information via
* hacky trick to make sure that we send the TT information via
* our new primary interface
*/
atomic_set(&bat_priv->hna_local_changed, 1);

out:
spin_unlock_bh(&hardif_list_lock);
atomic_set(&bat_priv->tt_local_changed, 1);
}

static bool hardif_is_iface_up(struct hard_iface *hard_iface)
Expand Down Expand Up @@ -345,7 +339,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface, char *iface_name)
batman_packet->flags = 0;
batman_packet->ttl = 2;
batman_packet->tq = TQ_MAX_VALUE;
batman_packet->num_hna = 0;
batman_packet->num_tt = 0;

hard_iface->if_num = bat_priv->num_ifaces;
bat_priv->num_ifaces++;
Expand Down Expand Up @@ -456,6 +450,8 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
struct hard_iface *hard_iface;
int ret;

ASSERT_RTNL();

ret = is_valid_iface(net_dev);
if (ret != 1)
goto out;
Expand All @@ -482,10 +478,7 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
atomic_set(&hard_iface->refcount, 2);

check_known_mac_addr(hard_iface->net_dev);

spin_lock(&hardif_list_lock);
list_add_tail_rcu(&hard_iface->list, &hardif_list);
spin_unlock(&hardif_list_lock);

return hard_iface;

Expand All @@ -499,6 +492,8 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev)

static void hardif_remove_interface(struct hard_iface *hard_iface)
{
ASSERT_RTNL();

/* first deactivate interface */
if (hard_iface->if_status != IF_NOT_IN_USE)
hardif_disable_interface(hard_iface);
Expand All @@ -514,20 +509,11 @@ static void hardif_remove_interface(struct hard_iface *hard_iface)
void hardif_remove_interfaces(void)
{
struct hard_iface *hard_iface, *hard_iface_tmp;
struct list_head if_queue;

INIT_LIST_HEAD(&if_queue);

spin_lock(&hardif_list_lock);
rtnl_lock();
list_for_each_entry_safe(hard_iface, hard_iface_tmp,
&hardif_list, list) {
list_del_rcu(&hard_iface->list);
list_add_tail(&hard_iface->list, &if_queue);
}
spin_unlock(&hardif_list_lock);

rtnl_lock();
list_for_each_entry_safe(hard_iface, hard_iface_tmp, &if_queue, list) {
hardif_remove_interface(hard_iface);
}
rtnl_unlock();
Expand Down Expand Up @@ -556,9 +542,7 @@ static int hard_if_event(struct notifier_block *this,
hardif_deactivate_interface(hard_iface);
break;
case NETDEV_UNREGISTER:
spin_lock(&hardif_list_lock);
list_del_rcu(&hard_iface->list);
spin_unlock(&hardif_list_lock);

hardif_remove_interface(hard_iface);
break;
Expand Down
20 changes: 12 additions & 8 deletions net/batman-adv/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#include "vis.h"
#include "hash.h"


/* List manipulations on hardif_list have to be rtnl_lock()'ed,
* list traversals just rcu-locked */
struct list_head hardif_list;

unsigned char broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
Expand Down Expand Up @@ -81,28 +84,29 @@ int mesh_init(struct net_device *soft_iface)

spin_lock_init(&bat_priv->forw_bat_list_lock);
spin_lock_init(&bat_priv->forw_bcast_list_lock);
spin_lock_init(&bat_priv->hna_lhash_lock);
spin_lock_init(&bat_priv->hna_ghash_lock);
spin_lock_init(&bat_priv->tt_lhash_lock);
spin_lock_init(&bat_priv->tt_ghash_lock);
spin_lock_init(&bat_priv->gw_list_lock);
spin_lock_init(&bat_priv->vis_hash_lock);
spin_lock_init(&bat_priv->vis_list_lock);
spin_lock_init(&bat_priv->softif_neigh_lock);
spin_lock_init(&bat_priv->softif_neigh_vid_lock);

INIT_HLIST_HEAD(&bat_priv->forw_bat_list);
INIT_HLIST_HEAD(&bat_priv->forw_bcast_list);
INIT_HLIST_HEAD(&bat_priv->gw_list);
INIT_HLIST_HEAD(&bat_priv->softif_neigh_list);
INIT_HLIST_HEAD(&bat_priv->softif_neigh_vids);

if (originator_init(bat_priv) < 1)
goto err;

if (hna_local_init(bat_priv) < 1)
if (tt_local_init(bat_priv) < 1)
goto err;

if (hna_global_init(bat_priv) < 1)
if (tt_global_init(bat_priv) < 1)
goto err;

hna_local_add(soft_iface, soft_iface->dev_addr);
tt_local_add(soft_iface, soft_iface->dev_addr);

if (vis_init(bat_priv) < 1)
goto err;
Expand Down Expand Up @@ -133,8 +137,8 @@ void mesh_free(struct net_device *soft_iface)
gw_node_purge(bat_priv);
originator_free(bat_priv);

hna_local_free(bat_priv);
hna_global_free(bat_priv);
tt_local_free(bat_priv);
tt_global_free(bat_priv);

softif_neigh_purge(bat_priv);

Expand Down
42 changes: 22 additions & 20 deletions net/batman-adv/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@

#define TQ_MAX_VALUE 255
#define JITTER 20
#define TTL 50 /* Time To Live of broadcast messages */

#define PURGE_TIMEOUT 200 /* purge originators after time in seconds if no
* valid packet comes in -> TODO: check
* influence on TQ_LOCAL_WINDOW_SIZE */
#define LOCAL_HNA_TIMEOUT 3600 /* in seconds */
/* Time To Live of broadcast messages */
#define TTL 50

#define TQ_LOCAL_WINDOW_SIZE 64 /* sliding packet range of received originator
* messages in squence numbers (should be a
* multiple of our word size) */
/* purge originators after time in seconds if no valid packet comes in
* -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE */
#define PURGE_TIMEOUT 200
#define TT_LOCAL_TIMEOUT 3600 /* in seconds */

/* sliding packet range of received originator messages in squence numbers
* (should be a multiple of our word size) */
#define TQ_LOCAL_WINDOW_SIZE 64
#define TQ_GLOBAL_WINDOW_SIZE 5
#define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1
#define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1
Expand All @@ -55,21 +57,20 @@

#define VIS_INTERVAL 5000 /* 5 seconds */

/* how much worse secondary interfaces may be to
* to be considered as bonding candidates */

/* how much worse secondary interfaces may be to be considered as bonding
* candidates */
#define BONDING_TQ_THRESHOLD 50

#define MAX_AGGREGATION_BYTES 512 /* should not be bigger than 512 bytes or
* change the size of
* forw_packet->direct_link_flags */
/* should not be bigger than 512 bytes or change the size of
* forw_packet->direct_link_flags */
#define MAX_AGGREGATION_BYTES 512
#define MAX_AGGREGATION_MS 100

#define SOFTIF_NEIGH_TIMEOUT 180000 /* 3 minutes */

/* don't reset again within 30 seconds */
#define RESET_PROTECTION_MS 30000
#define EXPECTED_SEQNO_RANGE 65536
/* don't reset again within 30 seconds */

#define MESH_INACTIVE 0
#define MESH_ACTIVE 1
Expand All @@ -84,12 +85,13 @@
#ifdef pr_fmt
#undef pr_fmt
#endif
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt /* Append 'batman-adv: ' before
* kernel messages */
/* Append 'batman-adv: ' before kernel messages */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#define DBG_BATMAN 1 /* all messages related to routing / flooding /
* broadcasting / etc */
#define DBG_ROUTES 2 /* route or hna added / changed / deleted */
/* all messages related to routing / flooding / broadcasting / etc */
#define DBG_BATMAN 1
/* route or tt entry added / changed / deleted */
#define DBG_ROUTES 2
#define DBG_ALL 3


Expand Down
Loading

0 comments on commit 02e73c1

Please sign in to comment.