Commit 02e73c1e authored by David S. Miller's avatar David S. Miller

Merge branch 'batman-adv/next' of git://git.open-mesh.org/ecsv/linux-merge

parents c5216cc7 27aea212
[state: 27-01-2011] [state: 17-04-2011]
BATMAN-ADV BATMAN-ADV
---------- ----------
...@@ -19,6 +19,7 @@ duce the overhead to a minimum. It does not depend on any (other) ...@@ -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, network driver, and can be used on wifi as well as ethernet lan,
vpn, etc ... (anything with ethernet-style layer 2). vpn, etc ... (anything with ethernet-style layer 2).
CONFIGURATION CONFIGURATION
------------- -------------
...@@ -160,13 +161,13 @@ face. Each entry can/has to have the following values: ...@@ -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 -> "TQ mac value" - src mac's link quality towards mac address
of a neighbor originator's interface which of a neighbor originator's interface which
is being used for routing 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 -> "PRIMARY" - this is a primary interface
-> "SEC mac" - secondary mac address of source -> "SEC mac" - secondary mac address of source
(requires preceding PRIMARY) (requires preceding PRIMARY)
The TQ value has a range from 4 to 255 with 255 being the best. 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 via bat0 or being bridged into the mesh network. The PRIMARY/SEC
values are only applied on primary interfaces values are only applied on primary interfaces
...@@ -199,7 +200,7 @@ abled during run time. Following log_levels are defined: ...@@ -199,7 +200,7 @@ abled during run time. Following log_levels are defined:
0 - All debug output disabled 0 - All debug output disabled
1 - Enable messages related to routing / flooding / broadcasting 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 3 - Enable all messages
The debug output can be changed at runtime using the file The debug output can be changed at runtime using the file
...@@ -207,7 +208,7 @@ The debug output can be changed at runtime using the file ...@@ -207,7 +208,7 @@ The debug output can be changed at runtime using the file
# echo 2 > /sys/class/net/bat0/mesh/log_level # 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 BATCTL
......
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
#include "send.h" #include "send.h"
#include "routing.h" #include "routing.h"
/* calculate the size of the hna information for a given packet */ /* calculate the size of the tt information for a given packet */
static int hna_len(struct batman_packet *batman_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 */ /* return true if new_packet can be aggregated with forw_packet */
...@@ -250,7 +250,7 @@ void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff, ...@@ -250,7 +250,7 @@ void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff,
{ {
struct batman_packet *batman_packet; struct batman_packet *batman_packet;
int buff_pos = 0; int buff_pos = 0;
unsigned char *hna_buff; unsigned char *tt_buff;
batman_packet = (struct batman_packet *)packet_buff; batman_packet = (struct batman_packet *)packet_buff;
...@@ -259,14 +259,14 @@ void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff, ...@@ -259,14 +259,14 @@ void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff,
orig_interval. */ orig_interval. */
batman_packet->seqno = ntohl(batman_packet->seqno); 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, receive_bat_packet(ethhdr, batman_packet,
hna_buff, hna_len(batman_packet), tt_buff, tt_len(batman_packet),
if_incoming); 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 *) batman_packet = (struct batman_packet *)
(packet_buff + buff_pos); (packet_buff + buff_pos);
} while (aggregated_packet(buff_pos, packet_len, } while (aggregated_packet(buff_pos, packet_len,
batman_packet->num_hna)); batman_packet->num_tt));
} }
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
#include "main.h" #include "main.h"
/* is there another aggregated packet here? */ /* 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) && return (next_buff_pos <= packet_len) &&
(next_buff_pos <= MAX_AGGREGATION_BYTES); (next_buff_pos <= MAX_AGGREGATION_BYTES);
......
...@@ -241,13 +241,13 @@ static int softif_neigh_open(struct inode *inode, struct file *file) ...@@ -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) static int transtable_global_open(struct inode *inode, struct file *file)
{ {
struct net_device *net_dev = (struct net_device *)inode->i_private; 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) static int transtable_local_open(struct inode *inode, struct file *file)
{ {
struct net_device *net_dev = (struct net_device *)inode->i_private; 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) static int vis_data_open(struct inode *inode, struct file *file)
......
...@@ -488,22 +488,24 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr, ...@@ -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)) (strncmp(hard_iface->soft_iface->name, buff, IFNAMSIZ) == 0))
goto out; goto out;
if (!rtnl_trylock()) {
ret = -ERESTARTSYS;
goto out;
}
if (status_tmp == IF_NOT_IN_USE) { if (status_tmp == IF_NOT_IN_USE) {
rtnl_lock();
hardif_disable_interface(hard_iface); hardif_disable_interface(hard_iface);
rtnl_unlock(); goto unlock;
goto out;
} }
/* if the interface already is in use */ /* if the interface already is in use */
if (hard_iface->if_status != IF_NOT_IN_USE) { if (hard_iface->if_status != IF_NOT_IN_USE)
rtnl_lock();
hardif_disable_interface(hard_iface); hardif_disable_interface(hard_iface);
rtnl_unlock();
}
ret = hardif_enable_interface(hard_iface, buff); ret = hardif_enable_interface(hard_iface, buff);
unlock:
rtnl_unlock();
out: out:
hardif_free_ref(hard_iface); hardif_free_ref(hard_iface);
return ret; return ret;
......
...@@ -31,9 +31,6 @@ ...@@ -31,9 +31,6 @@
#include <linux/if_arp.h> #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, static int batman_skb_recv(struct sk_buff *skb,
struct net_device *dev, struct net_device *dev,
...@@ -136,7 +133,7 @@ static void primary_if_select(struct bat_priv *bat_priv, ...@@ -136,7 +133,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
struct hard_iface *curr_hard_iface; struct hard_iface *curr_hard_iface;
struct batman_packet *batman_packet; 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)) if (new_hard_iface && !atomic_inc_not_zero(&new_hard_iface->refcount))
new_hard_iface = NULL; new_hard_iface = NULL;
...@@ -148,7 +145,7 @@ static void primary_if_select(struct bat_priv *bat_priv, ...@@ -148,7 +145,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
hardif_free_ref(curr_hard_iface); hardif_free_ref(curr_hard_iface);
if (!new_hard_iface) if (!new_hard_iface)
goto out; return;
batman_packet = (struct batman_packet *)(new_hard_iface->packet_buff); batman_packet = (struct batman_packet *)(new_hard_iface->packet_buff);
batman_packet->flags = PRIMARIES_FIRST_HOP; batman_packet->flags = PRIMARIES_FIRST_HOP;
...@@ -157,13 +154,10 @@ static void primary_if_select(struct bat_priv *bat_priv, ...@@ -157,13 +154,10 @@ static void primary_if_select(struct bat_priv *bat_priv,
primary_if_update_addr(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 * our new primary interface
*/ */
atomic_set(&bat_priv->hna_local_changed, 1); atomic_set(&bat_priv->tt_local_changed, 1);
out:
spin_unlock_bh(&hardif_list_lock);
} }
static bool hardif_is_iface_up(struct hard_iface *hard_iface) static bool hardif_is_iface_up(struct hard_iface *hard_iface)
...@@ -345,7 +339,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface, char *iface_name) ...@@ -345,7 +339,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface, char *iface_name)
batman_packet->flags = 0; batman_packet->flags = 0;
batman_packet->ttl = 2; batman_packet->ttl = 2;
batman_packet->tq = TQ_MAX_VALUE; batman_packet->tq = TQ_MAX_VALUE;
batman_packet->num_hna = 0; batman_packet->num_tt = 0;
hard_iface->if_num = bat_priv->num_ifaces; hard_iface->if_num = bat_priv->num_ifaces;
bat_priv->num_ifaces++; bat_priv->num_ifaces++;
...@@ -456,6 +450,8 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev) ...@@ -456,6 +450,8 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
struct hard_iface *hard_iface; struct hard_iface *hard_iface;
int ret; int ret;
ASSERT_RTNL();
ret = is_valid_iface(net_dev); ret = is_valid_iface(net_dev);
if (ret != 1) if (ret != 1)
goto out; goto out;
...@@ -482,10 +478,7 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev) ...@@ -482,10 +478,7 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
atomic_set(&hard_iface->refcount, 2); atomic_set(&hard_iface->refcount, 2);
check_known_mac_addr(hard_iface->net_dev); check_known_mac_addr(hard_iface->net_dev);
spin_lock(&hardif_list_lock);
list_add_tail_rcu(&hard_iface->list, &hardif_list); list_add_tail_rcu(&hard_iface->list, &hardif_list);
spin_unlock(&hardif_list_lock);
return hard_iface; return hard_iface;
...@@ -499,6 +492,8 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev) ...@@ -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) static void hardif_remove_interface(struct hard_iface *hard_iface)
{ {
ASSERT_RTNL();
/* first deactivate interface */ /* first deactivate interface */
if (hard_iface->if_status != IF_NOT_IN_USE) if (hard_iface->if_status != IF_NOT_IN_USE)
hardif_disable_interface(hard_iface); hardif_disable_interface(hard_iface);
...@@ -514,20 +509,11 @@ static void hardif_remove_interface(struct hard_iface *hard_iface) ...@@ -514,20 +509,11 @@ static void hardif_remove_interface(struct hard_iface *hard_iface)
void hardif_remove_interfaces(void) void hardif_remove_interfaces(void)
{ {
struct hard_iface *hard_iface, *hard_iface_tmp; 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, list_for_each_entry_safe(hard_iface, hard_iface_tmp,
&hardif_list, list) { &hardif_list, list) {
list_del_rcu(&hard_iface->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); hardif_remove_interface(hard_iface);
} }
rtnl_unlock(); rtnl_unlock();
...@@ -556,9 +542,7 @@ static int hard_if_event(struct notifier_block *this, ...@@ -556,9 +542,7 @@ static int hard_if_event(struct notifier_block *this,
hardif_deactivate_interface(hard_iface); hardif_deactivate_interface(hard_iface);
break; break;
case NETDEV_UNREGISTER: case NETDEV_UNREGISTER:
spin_lock(&hardif_list_lock);
list_del_rcu(&hard_iface->list); list_del_rcu(&hard_iface->list);
spin_unlock(&hardif_list_lock);
hardif_remove_interface(hard_iface); hardif_remove_interface(hard_iface);
break; break;
......
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
#include "vis.h" #include "vis.h"
#include "hash.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; struct list_head hardif_list;
unsigned char broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; unsigned char broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
...@@ -81,28 +84,29 @@ int mesh_init(struct net_device *soft_iface) ...@@ -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_bat_list_lock);
spin_lock_init(&bat_priv->forw_bcast_list_lock); spin_lock_init(&bat_priv->forw_bcast_list_lock);
spin_lock_init(&bat_priv->hna_lhash_lock); spin_lock_init(&bat_priv->tt_lhash_lock);
spin_lock_init(&bat_priv->hna_ghash_lock); spin_lock_init(&bat_priv->tt_ghash_lock);
spin_lock_init(&bat_priv->gw_list_lock); spin_lock_init(&bat_priv->gw_list_lock);
spin_lock_init(&bat_priv->vis_hash_lock); spin_lock_init(&bat_priv->vis_hash_lock);
spin_lock_init(&bat_priv->vis_list_lock); spin_lock_init(&bat_priv->vis_list_lock);
spin_lock_init(&bat_priv->softif_neigh_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_bat_list);
INIT_HLIST_HEAD(&bat_priv->forw_bcast_list); INIT_HLIST_HEAD(&bat_priv->forw_bcast_list);
INIT_HLIST_HEAD(&bat_priv->gw_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) if (originator_init(bat_priv) < 1)
goto err; goto err;
if (hna_local_init(bat_priv) < 1) if (tt_local_init(bat_priv) < 1)
goto err; goto err;
if (hna_global_init(bat_priv) < 1) if (tt_global_init(bat_priv) < 1)
goto err; 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) if (vis_init(bat_priv) < 1)
goto err; goto err;
...@@ -133,8 +137,8 @@ void mesh_free(struct net_device *soft_iface) ...@@ -133,8 +137,8 @@ void mesh_free(struct net_device *soft_iface)
gw_node_purge(bat_priv); gw_node_purge(bat_priv);
originator_free(bat_priv); originator_free(bat_priv);
hna_local_free(bat_priv); tt_local_free(bat_priv);
hna_global_free(bat_priv); tt_global_free(bat_priv);
softif_neigh_purge(bat_priv); softif_neigh_purge(bat_priv);
......
...@@ -34,16 +34,18 @@ ...@@ -34,16 +34,18 @@
#define TQ_MAX_VALUE 255 #define TQ_MAX_VALUE 255
#define JITTER 20 #define JITTER 20
#define TTL 50 /* Time To Live of broadcast messages */
#define PURGE_TIMEOUT 200 /* purge originators after time in seconds if no /* Time To Live of broadcast messages */
* valid packet comes in -> TODO: check #define TTL 50
* influence on TQ_LOCAL_WINDOW_SIZE */
#define LOCAL_HNA_TIMEOUT 3600 /* in seconds */
#define TQ_LOCAL_WINDOW_SIZE 64 /* sliding packet range of received originator /* purge originators after time in seconds if no valid packet comes in
* messages in squence numbers (should be a * -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE */
* multiple of our word 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_GLOBAL_WINDOW_SIZE 5
#define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1 #define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1
#define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1 #define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1
...@@ -55,21 +57,20 @@ ...@@ -55,21 +57,20 @@
#define VIS_INTERVAL 5000 /* 5 seconds */ #define VIS_INTERVAL 5000 /* 5 seconds */
/* how much worse secondary interfaces may be to /* how much worse secondary interfaces may be to be considered as bonding
* to be considered as bonding candidates */ * candidates */
#define BONDING_TQ_THRESHOLD 50 #define BONDING_TQ_THRESHOLD 50
#define MAX_AGGREGATION_BYTES 512 /* should not be bigger than 512 bytes or /* should not be bigger than 512 bytes or change the size of
* change the size of
* forw_packet->direct_link_flags */ * forw_packet->direct_link_flags */
#define MAX_AGGREGATION_BYTES 512
#define MAX_AGGREGATION_MS 100 #define MAX_AGGREGATION_MS 100
#define SOFTIF_NEIGH_TIMEOUT 180000 /* 3 minutes */ #define SOFTIF_NEIGH_TIMEOUT 180000 /* 3 minutes */
/* don't reset again within 30 seconds */
#define RESET_PROTECTION_MS 30000 #define RESET_PROTECTION_MS 30000
#define EXPECTED_SEQNO_RANGE 65536 #define EXPECTED_SEQNO_RANGE 65536
/* don't reset again within 30 seconds */
#define MESH_INACTIVE 0 #define MESH_INACTIVE 0
#define MESH_ACTIVE 1 #define MESH_ACTIVE 1
...@@ -84,12 +85,13 @@ ...@@ -84,12 +85,13 @@
#ifdef pr_fmt #ifdef pr_fmt
#undef pr_fmt #undef pr_fmt
#endif #endif
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt /* Append 'batman-adv: ' before /* Append 'batman-adv: ' before kernel messages */
* kernel messages */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#define DBG_BATMAN 1 /* all messages related to routing / flooding / /* all messages related to routing / flooding / broadcasting / etc */
* broadcasting / etc */ #define DBG_BATMAN 1
#define DBG_ROUTES 2 /* route or hna added / changed / deleted */ /* route or tt entry added / changed / deleted */
#define DBG_ROUTES 2
#define DBG_ALL 3 #define DBG_ALL 3
......
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
* *
*/ */
/* increase the reference counter for this originator */
#include "main.h" #include "main.h"
#include "originator.h" #include "originator.h"
#include "hash.h" #include "hash.h"
...@@ -144,7 +142,7 @@ static void orig_node_free_rcu(struct rcu_head *rcu) ...@@ -144,7 +142,7 @@ static void orig_node_free_rcu(struct rcu_head *rcu)
spin_unlock_bh(&orig_node->neigh_list_lock); spin_unlock_bh(&orig_node->neigh_list_lock);
frag_list_free(&orig_node->frag_list); frag_list_free(&orig_node->frag_list);
hna_global_del_orig(orig_node->bat_priv, orig_node, tt_global_del_orig(orig_node->bat_priv, orig_node,
"originator timed out"); "originator timed out");
kfree(orig_node->bcast_own); kfree(orig_node->bcast_own);
...@@ -222,7 +220,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr) ...@@ -222,7 +220,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr)
orig_node->bat_priv = bat_priv; orig_node->bat_priv = bat_priv;
memcpy(orig_node->orig, addr, ETH_ALEN); memcpy(orig_node->orig, addr, ETH_ALEN);
orig_node->router = NULL; orig_node->router = NULL;
orig_node->hna_buff = NULL; orig_node->tt_buff = NULL;
orig_node->bcast_seqno_reset = jiffies - 1 orig_node->bcast_seqno_reset = jiffies - 1
- msecs_to_jiffies(RESET_PROTECTION_MS); - msecs_to_jiffies(RESET_PROTECTION_MS);
orig_node->batman_seqno_reset = jiffies - 1 orig_node->batman_seqno_reset = jiffies - 1
...@@ -333,8 +331,8 @@ static bool purge_orig_node(struct bat_priv *bat_priv, ...@@ -333,8 +331,8 @@ static bool purge_orig_node(struct bat_priv *bat_priv,
&best_neigh_node)) { &best_neigh_node)) {
update_routes(bat_priv, orig_node, update_routes(bat_priv, orig_node,
best_neigh_node, best_neigh_node,
orig_node->hna_buff, orig_node->tt_buff,
orig_node->hna_buff_len); orig_node->tt_buff_len);
} }
} }
......
...@@ -61,7 +61,7 @@ struct batman_packet { ...@@ -61,7 +61,7 @@ struct batman_packet {
uint8_t orig[6]; uint8_t orig[6];
uint8_t prev_sender[6]; uint8_t prev_sender[6];
uint8_t ttl; uint8_t ttl;
uint8_t num_hna; uint8_t num_tt;
uint8_t gw_flags; /* flags related to gateway class */ uint8_t gw_flags; /* flags related to gateway class */
uint8_t align; uint8_t align;
} __packed; } __packed;
...@@ -128,8 +128,7 @@ struct vis_packet { ...@@ -128,8 +128,7 @@ struct vis_packet {
uint8_t entries; /* number of entries behind this struct */ uint8_t entries; /* number of entries behind this struct */
uint32_t seqno; /* sequence number */ uint32_t seqno; /* sequence number */
uint8_t ttl; /* TTL */ uint8_t ttl; /* TTL */
uint8_t vis_orig[6]; /* originator that informs about its uint8_t vis_orig[6]; /* originator that announces its neighbors */
* neighbors */
uint8_t target_orig[6]; /* who should receive this packet */ uint8_t target_orig[6]; /* who should receive this packet */
uint8_t sender_orig[6]; /* who sent or rebroadcasted this packet */ uint8_t sender_orig[6]; /* who sent or rebroadcasted this packet */
} __packed; } __packed;
......
...@@ -64,28 +64,28 @@ void slide_own_bcast_window(struct hard_iface *hard_iface) ...@@ -64,28 +64,28 @@ void slide_own_bcast_window(struct hard_iface *hard_iface)
} }
} }
static void update_HNA(struct bat_priv *bat_priv, struct orig_node *orig_node, static void update_TT(struct bat_priv *bat_priv, struct orig_node *orig_node,
unsigned char *hna_buff, int hna_buff_len) unsigned char *tt_buff, int tt_buff_len)
{ {
if ((hna_buff_len != orig_node->hna_buff_len) || if ((tt_buff_len != orig_node->tt_buff_len) ||
((hna_buff_len > 0) && ((tt_buff_len > 0) &&
(orig_node->hna_buff_len > 0) && (orig_node->tt_buff_len > 0) &&
(memcmp(orig_node->hna_buff, hna_buff, hna_buff_len) != 0))) { (memcmp(orig_node->tt_buff, tt_buff, tt_buff_len) != 0))) {
if (orig_node->hna_buff_len > 0) if (orig_node->tt_buff_len > 0)
hna_global_del_orig(bat_priv, orig_node, tt_global_del_orig(bat_priv, orig_node,
"originator changed hna"); "originator changed tt");
if ((hna_buff_len > 0) && (hna_buff)) if ((tt_buff_len > 0) && (tt_buff))
hna_global_add_orig(bat_priv, orig_node, tt_global_add_orig(bat_priv, orig_node,
hna_buff, hna_buff_len); tt_buff, tt_buff_len);
} }
} }
static void update_route(struct bat_priv *bat_priv, static void update_route(struct bat_priv *bat_priv,
struct orig_node *orig_node, struct orig_node *orig_node,
struct neigh_node *neigh_node, struct neigh_node *neigh_node,
unsigned char *hna_buff, int hna_buff_len) unsigned char *tt_buff, int tt_buff_len)
{ {
struct neigh_node *curr_router; struct neigh_node *curr_router;
...@@ -96,7 +96,7 @@ static void update_route(struct bat_priv *bat_priv, ...@@ -96,7 +96,7 @@ static void update_route(struct bat_priv *bat_priv,
bat_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n", bat_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n",
orig_node->orig); orig_node->orig);
hna_global_del_orig(bat_priv, orig_node, tt_global_del_orig(bat_priv, orig_node,
"originator timed out"); "originator timed out");
/* route added */ /* route added */
...@@ -105,8 +105,8 @@ static void update_route(struct bat_priv *bat_priv, ...@@ -105,8 +105,8 @@ static void update_route(struct bat_priv *bat_priv,
bat_dbg(DBG_ROUTES, bat_priv, bat_dbg(DBG_ROUTES, bat_priv,
"Adding route towards: %pM (via %pM)\n", "Adding route towards: %pM (via %pM)\n",
orig_node->orig, neigh_node->addr); orig_node->orig, neigh_node->addr);
hna_global_add_orig(bat_priv, orig_node, tt_global_add_orig(bat_priv, orig_node,
hna_buff, hna_buff_len); tt_buff, tt_buff_len);
/* route changed */ /* route changed */
} else { } else {
...@@ -135,8 +135,8 @@ static void update_route(struct bat_priv *bat_priv, ...@@ -135,8 +135,8 @@ static void update_route(struct bat_priv *bat_priv,
void update_routes(struct bat_priv *bat_priv, struct orig_node *orig_node, void update_routes(struct bat_priv *bat_priv, struct orig_node *orig_node,
struct neigh_node *neigh_node, unsigned char *hna_buff, struct neigh_node *neigh_node, unsigned char *tt_buff,
int hna_buff_len) int tt_buff_len)
{ {
struct neigh_node *router = NULL; struct neigh_node *router = NULL;
...@@ -147,10 +147,10 @@ void update_routes(struct bat_priv *bat_priv, struct orig_node *orig_node, ...@@ -147,10 +147,10 @@ void update_routes(struct bat_priv *bat_priv, struct orig_node *orig_node,
if (router != neigh_node) if (router != neigh_node)
update_route(bat_priv, orig_node, neigh_node, update_route(bat_priv, orig_node, neigh_node,
hna_buff, hna_buff_len); tt_buff, tt_buff_len);
/* may be just HNA changed */ /* may be just TT changed */
else else
update_HNA(bat_priv, orig_node, hna_buff, hna_buff_len); update_TT(bat_priv, orig_node, tt_buff, tt_buff_len);
out: out:
if (router) if (router)
...@@ -169,42 +169,12 @@ static int is_bidirectional_neigh(struct orig_node *orig_node, ...@@ -169,42 +169,12 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
uint8_t orig_eq_count, neigh_rq_count, tq_own; uint8_t orig_eq_count, neigh_rq_count, tq_own;
int tq_asym_penalty, ret = 0; int tq_asym_penalty, ret = 0;
if (orig_node == orig_neigh_node) { /* find corresponding one hop neighbor */
rcu_read_lock();
hlist_for_each_entry_rcu(tmp_neigh_node, node,
&orig_node->neigh_list, list) {
if (!compare_eth(tmp_neigh_node->addr,
orig_neigh_node->orig))
continue;
if (tmp_neigh_node->if_incoming != if_incoming)
continue;
if (!atomic_inc_not_zero(&tmp_neigh_node->refcount))
continue;
neigh_node = tmp_neigh_node;
}
rcu_read_unlock();
if (!neigh_node)
neigh_node = create_neighbor(orig_node,
orig_neigh_node,
orig_neigh_node->orig,
if_incoming);
if (!neigh_node)
goto out;
neigh_node->last_valid = jiffies;
} else {
/* find packet count of corresponding one hop neighbor */
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(tmp_neigh_node, node, hlist_for_each_entry_rcu(tmp_neigh_node, node,
&orig_neigh_node->neigh_list, list) { &orig_neigh_node->neigh_list, list) {
if (!compare_eth(tmp_neigh_node->addr, if (!compare_eth(tmp_neigh_node->addr, orig_neigh_node->orig))
orig_neigh_node->orig))
continue; continue;
if (tmp_neigh_node->if_incoming != if_incoming) if (tmp_neigh_node->if_incoming != if_incoming)
...@@ -214,6 +184,7 @@ static int is_bidirectional_neigh(struct orig_node *orig_node, ...@@ -214,6 +184,7 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
continue; continue;
neigh_node = tmp_neigh_node; neigh_node = tmp_neigh_node;
break;
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -222,12 +193,17 @@ static int is_bidirectional_neigh(struct orig_node *orig_node, ...@@ -222,12 +193,17 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
orig_neigh_node, orig_neigh_node,
orig_neigh_node->orig, orig_neigh_node->orig,
if_incoming); if_incoming);
if (!neigh_node) if (!neigh_node)
goto out; goto out;
}
/* if orig_node is direct neighbour update neigh_node last_valid */
if (orig_node == orig_neigh_node)
neigh_node->last_valid = jiffies;
orig_node->last_valid = jiffies; orig_node->last_valid = jiffies;
/* find packet count of corresponding one hop neighbor */
spin_lock_bh(&orig_node->ogm_cnt_lock); spin_lock_bh(&orig_node->ogm_cnt_lock);
orig_eq_count = orig_neigh_node->bcast_own_sum[if_incoming->if_num]; orig_eq_count = orig_neigh_node->bcast_own_sum[if_incoming->if_num];
neigh_rq_count = neigh_node->real_packet_count; neigh_rq_count = neigh_node->real_packet_count;
...@@ -387,14 +363,14 @@ static void update_orig(struct bat_priv *bat_priv, ...@@ -387,14 +363,14 @@ static void update_orig(struct bat_priv *bat_priv,
struct ethhdr *ethhdr, struct ethhdr *ethhdr,
struct batman_packet *batman_packet, struct batman_packet *batman_packet,
struct hard_iface *if_incoming, struct hard_iface *if_incoming,
unsigned char *hna_buff, int hna_buff_len, unsigned char *tt_buff, int tt_buff_len,
char is_duplicate) char is_duplicate)
{ {
struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
struct neigh_node *router = NULL; struct neigh_node *router = NULL;
struct orig_node *orig_node_tmp; struct orig_node *orig_node_tmp;
struct hlist_node *node; struct hlist_node *node;
int tmp_hna_buff_len; int tmp_tt_buff_len;
uint8_t bcast_own_sum_orig, bcast_own_sum_neigh; uint8_t bcast_own_sum_orig, bcast_own_sum_neigh;
bat_dbg(DBG_BATMAN, bat_priv, "update_originator(): " bat_dbg(DBG_BATMAN, bat_priv, "update_originator(): "
...@@ -459,18 +435,18 @@ static void update_orig(struct bat_priv *bat_priv, ...@@ -459,18 +435,18 @@ static void update_orig(struct bat_priv *bat_priv,
bonding_candidate_add(orig_node, neigh_node); bonding_candidate_add(orig_node, neigh_node);
tmp_hna_buff_len = (hna_buff_len > batman_packet->num_hna * ETH_ALEN ? tmp_tt_buff_len = (tt_buff_len > batman_packet->num_tt * ETH_ALEN ?
batman_packet->num_hna * ETH_ALEN : hna_buff_len); batman_packet->num_tt * ETH_ALEN : tt_buff_len);
/* if this neighbor already is our next hop there is nothing /* if this neighbor already is our next hop there is nothing
* to change */ * to change */
router = orig_node_get_router(orig_node); router = orig_node_get_router(orig_node);
if (router == neigh_node) if (router == neigh_node)
goto update_hna; goto update_tt;
/* if this neighbor does not offer a better TQ we won't consider it */ /* if this neighbor does not offer a better TQ we won't consider it */
if (router && (router->tq_avg > neigh_node->tq_avg)) if (router && (router->tq_avg > neigh_node->tq_avg))
goto update_hna; goto update_tt;
/* if the TQ is the same and the link not more symetric we /* if the TQ is the same and the link not more symetric we
* won't consider it either */ * won't consider it either */
...@@ -488,16 +464,16 @@ static void update_orig(struct bat_priv *bat_priv, ...@@ -488,16 +464,16 @@ static void update_orig(struct bat_priv *bat_priv,
spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock); spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock);
if (bcast_own_sum_orig >= bcast_own_sum_neigh) if (bcast_own_sum_orig >= bcast_own_sum_neigh)
goto update_hna; goto update_tt;
} }
update_routes(bat_priv, orig_node, neigh_node, update_routes(bat_priv, orig_node, neigh_node,
hna_buff, tmp_hna_buff_len); tt_buff, tmp_tt_buff_len);
goto update_gw; goto update_gw;
update_hna: update_tt:
update_routes(bat_priv, orig_node, router, update_routes(bat_priv, orig_node, router,
hna_buff, tmp_hna_buff_len); tt_buff, tmp_tt_buff_len);
update_gw: update_gw:
if (orig_node->gw_flags != batman_packet->gw_flags) if (orig_node->gw_flags != batman_packet->gw_flags)
...@@ -621,7 +597,7 @@ static char count_real_packets(struct ethhdr *ethhdr, ...@@ -621,7 +597,7 @@ static char count_real_packets(struct ethhdr *ethhdr,
void receive_bat_packet(struct ethhdr *ethhdr, void receive_bat_packet(struct ethhdr *ethhdr,
struct batman_packet *batman_packet, struct batman_packet *batman_packet,
unsigned char *hna_buff, int hna_buff_len, unsigned char *tt_buff, int tt_buff_len,
struct hard_iface *if_incoming) struct hard_iface *if_incoming)
{ {
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
...@@ -818,14 +794,14 @@ void receive_bat_packet(struct ethhdr *ethhdr, ...@@ -818,14 +794,14 @@ void receive_bat_packet(struct ethhdr *ethhdr,
((orig_node->last_real_seqno == batman_packet->seqno) && ((orig_node->last_real_seqno == batman_packet->seqno) &&
(orig_node->last_ttl - 3 <= batman_packet->ttl)))) (orig_node->last_ttl - 3 <= batman_packet->ttl))))
update_orig(bat_priv, orig_node, ethhdr, batman_packet, update_orig(bat_priv, orig_node, ethhdr, batman_packet,
if_incoming, hna_buff, hna_buff_len, is_duplicate); if_incoming, tt_buff, tt_buff_len, is_duplicate);
/* is single hop (direct) neighbor */ /* is single hop (direct) neighbor */
if (is_single_hop_neigh) { if (is_single_hop_neigh) {
/* mark direct link on incoming interface */ /* mark direct link on incoming interface */
schedule_forward_packet(orig_node, ethhdr, batman_packet, schedule_forward_packet(orig_node, ethhdr, batman_packet,
1, hna_buff_len, if_incoming); 1, tt_buff_len, if_incoming);
bat_dbg(DBG_BATMAN, bat_priv, "Forwarding packet: " bat_dbg(DBG_BATMAN, bat_priv, "Forwarding packet: "
"rebroadcast neighbor packet with direct link flag\n"); "rebroadcast neighbor packet with direct link flag\n");
...@@ -848,7 +824,7 @@ void receive_bat_packet(struct ethhdr *ethhdr, ...@@ -848,7 +824,7 @@ void receive_bat_packet(struct ethhdr *ethhdr,
bat_dbg(DBG_BATMAN, bat_priv, bat_dbg(DBG_BATMAN, bat_priv,
"Forwarding packet: rebroadcast originator packet\n"); "Forwarding packet: rebroadcast originator packet\n");
schedule_forward_packet(orig_node, ethhdr, batman_packet, schedule_forward_packet(orig_node, ethhdr, batman_packet,
0, hna_buff_len, if_incoming); 0, tt_buff_len, if_incoming);
out_neigh: out_neigh:
if ((orig_neigh_node) && (!is_single_hop_neigh)) if ((orig_neigh_node) && (!is_single_hop_neigh))
...@@ -1213,7 +1189,7 @@ struct neigh_node *find_router(struct bat_priv *bat_priv, ...@@ -1213,7 +1189,7 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,
router = orig_node_get_router(orig_node); router = orig_node_get_router(orig_node);
if (!router) if (!router)
return NULL; goto err;
/* without bonding, the first node should /* without bonding, the first node should
* always choose the default router. */ * always choose the default router. */
...@@ -1222,10 +1198,8 @@ struct neigh_node *find_router(struct bat_priv *bat_priv, ...@@ -1222,10 +1198,8 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,
rcu_read_lock(); rcu_read_lock();
/* select default router to output */ /* select default router to output */
router_orig = router->orig_node; router_orig = router->orig_node;
if (!router_orig) { if (!router_orig)
rcu_read_unlock(); goto err_unlock;
return NULL;
}
if ((!recv_if) && (!bonding_enabled)) if ((!recv_if) && (!bonding_enabled))
goto return_router; goto return_router;
...@@ -1268,6 +1242,12 @@ struct neigh_node *find_router(struct bat_priv *bat_priv, ...@@ -1268,6 +1242,12 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,
return_router: return_router:
rcu_read_unlock(); rcu_read_unlock();
return router; return router;
err_unlock:
rcu_read_unlock();
err:
if (router)
neigh_node_free_ref(router);
return NULL;
} }
static int check_unicast_packet(struct sk_buff *skb, int hdr_size) static int check_unicast_packet(struct sk_buff *skb, int hdr_size)
......
...@@ -25,11 +25,11 @@ ...@@ -25,11 +25,11 @@
void slide_own_bcast_window(struct hard_iface *hard_iface); void slide_own_bcast_window(struct hard_iface *hard_iface);
void receive_bat_packet(struct ethhdr *ethhdr, void receive_bat_packet(struct ethhdr *ethhdr,
struct batman_packet *batman_packet, struct batman_packet *batman_packet,
unsigned char *hna_buff, int hna_buff_len, unsigned char *tt_buff, int tt_buff_len,
struct hard_iface *if_incoming); struct hard_iface *if_incoming);
void update_routes(struct bat_priv *bat_priv, struct orig_node *orig_node, void update_routes(struct bat_priv *bat_priv, struct orig_node *orig_node,
struct neigh_node *neigh_node, unsigned char *hna_buff, struct neigh_node *neigh_node, unsigned char *tt_buff,
int hna_buff_len); int tt_buff_len);
int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if); int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if);
int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if); int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if);
int recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if); int recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if);
......
...@@ -121,7 +121,7 @@ static void send_packet_to_if(struct forw_packet *forw_packet, ...@@ -121,7 +121,7 @@ static void send_packet_to_if(struct forw_packet *forw_packet,
/* adjust all flags and log packets */ /* adjust all flags and log packets */
while (aggregated_packet(buff_pos, while (aggregated_packet(buff_pos,
forw_packet->packet_len, forw_packet->packet_len,
batman_packet->num_hna)) { batman_packet->num_tt)) {
/* we might have aggregated direct link packets with an /* we might have aggregated direct link packets with an
* ordinary base packet */ * ordinary base packet */
...@@ -146,7 +146,7 @@ static void send_packet_to_if(struct forw_packet *forw_packet, ...@@ -146,7 +146,7 @@ static void send_packet_to_if(struct forw_packet *forw_packet,
hard_iface->net_dev->dev_addr); hard_iface->net_dev->dev_addr);
buff_pos += sizeof(struct batman_packet) + buff_pos += sizeof(struct batman_packet) +
(batman_packet->num_hna * ETH_ALEN); (batman_packet->num_tt * ETH_ALEN);
packet_num++; packet_num++;
batman_packet = (struct batman_packet *) batman_packet = (struct batman_packet *)
(forw_packet->skb->data + buff_pos); (forw_packet->skb->data + buff_pos);
...@@ -222,7 +222,7 @@ static void rebuild_batman_packet(struct bat_priv *bat_priv, ...@@ -222,7 +222,7 @@ static void rebuild_batman_packet(struct bat_priv *bat_priv,
struct batman_packet *batman_packet; struct batman_packet *batman_packet;
new_len = sizeof(struct batman_packet) + new_len = sizeof(struct batman_packet) +
(bat_priv->num_local_hna * ETH_ALEN); (bat_priv->num_local_tt * ETH_ALEN);
new_buff = kmalloc(new_len, GFP_ATOMIC); new_buff = kmalloc(new_len, GFP_ATOMIC);
/* keep old buffer if kmalloc should fail */ /* keep old buffer if kmalloc should fail */
...@@ -231,7 +231,7 @@ static void rebuild_batman_packet(struct bat_priv *bat_priv, ...@@ -231,7 +231,7 @@ static void rebuild_batman_packet(struct bat_priv *bat_priv,
sizeof(struct batman_packet)); sizeof(struct batman_packet));
batman_packet = (struct batman_packet *)new_buff; batman_packet = (struct batman_packet *)new_buff;
batman_packet->num_hna = hna_local_fill_buffer(bat_priv, batman_packet->num_tt = tt_local_fill_buffer(bat_priv,
new_buff + sizeof(struct batman_packet), new_buff + sizeof(struct batman_packet),
new_len - sizeof(struct batman_packet)); new_len - sizeof(struct batman_packet));
...@@ -266,8 +266,8 @@ void schedule_own_packet(struct hard_iface *hard_iface) ...@@ -266,8 +266,8 @@ void schedule_own_packet(struct hard_iface *hard_iface)
if (hard_iface->if_status == IF_TO_BE_ACTIVATED) if (hard_iface->if_status == IF_TO_BE_ACTIVATED)
hard_iface->if_status = IF_ACTIVE; hard_iface->if_status = IF_ACTIVE;
/* if local hna has changed and interface is a primary interface */ /* if local tt has changed and interface is a primary interface */
if ((atomic_read(&bat_priv->hna_local_changed)) && if ((atomic_read(&bat_priv->tt_local_changed)) &&
(hard_iface == primary_if)) (hard_iface == primary_if))
rebuild_batman_packet(bat_priv, hard_iface); rebuild_batman_packet(bat_priv, hard_iface);
...@@ -309,7 +309,7 @@ void schedule_own_packet(struct hard_iface *hard_iface) ...@@ -309,7 +309,7 @@ void schedule_own_packet(struct hard_iface *hard_iface)
void schedule_forward_packet(struct orig_node *orig_node, void schedule_forward_packet(struct orig_node *orig_node,
struct ethhdr *ethhdr, struct ethhdr *ethhdr,
struct batman_packet *batman_packet, struct batman_packet *batman_packet,
uint8_t directlink, int hna_buff_len, uint8_t directlink, int tt_buff_len,
struct hard_iface *if_incoming) struct hard_iface *if_incoming)
{ {
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
...@@ -369,7 +369,7 @@ void schedule_forward_packet(struct orig_node *orig_node, ...@@ -369,7 +369,7 @@ void schedule_forward_packet(struct orig_node *orig_node,
send_time = forward_send_time(); send_time = forward_send_time();
add_bat_packet_to_list(bat_priv, add_bat_packet_to_list(bat_priv,
(unsigned char *)batman_packet, (unsigned char *)batman_packet,
sizeof(struct batman_packet) + hna_buff_len, sizeof(struct batman_packet) + tt_buff_len,
if_incoming, 0, send_time); if_incoming, 0, send_time);
} }
......
...@@ -29,7 +29,7 @@ void schedule_own_packet(struct hard_iface *hard_iface); ...@@ -29,7 +29,7 @@ void schedule_own_packet(struct hard_iface *hard_iface);
void schedule_forward_packet(struct orig_node *orig_node, void schedule_forward_packet(struct orig_node *orig_node,
struct ethhdr *ethhdr, struct ethhdr *ethhdr,
struct batman_packet *batman_packet, struct batman_packet *batman_packet,
uint8_t directlink, int hna_buff_len, uint8_t directlink, int tt_buff_len,
struct hard_iface *if_outgoing); struct hard_iface *if_outgoing);
int add_bcast_packet_to_list(struct bat_priv *bat_priv, struct sk_buff *skb); int add_bcast_packet_to_list(struct bat_priv *bat_priv, struct sk_buff *skb);
void send_outstanding_bat_packet(struct work_struct *work); void send_outstanding_bat_packet(struct work_struct *work);
......
This diff is collapsed.
This diff is collapsed.
...@@ -22,22 +22,22 @@ ...@@ -22,22 +22,22 @@
#ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ #ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
#define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ #define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
int hna_local_init(struct bat_priv *bat_priv); int tt_local_init(struct bat_priv *bat_priv);
void hna_local_add(struct net_device *soft_iface, uint8_t *addr); void tt_local_add(struct net_device *soft_iface, uint8_t *addr);
void hna_local_remove(struct bat_priv *bat_priv, void tt_local_remove(struct bat_priv *bat_priv,
uint8_t *addr, char *message); uint8_t *addr, char *message);
int hna_local_fill_buffer(struct bat_priv *bat_priv, int tt_local_fill_buffer(struct bat_priv *bat_priv,
unsigned char *buff, int buff_len); unsigned char *buff, int buff_len);
int hna_local_seq_print_text(struct seq_file *seq, void *offset); int tt_local_seq_print_text(struct seq_file *seq, void *offset);
void hna_local_free(struct bat_priv *bat_priv); void tt_local_free(struct bat_priv *bat_priv);
int hna_global_init(struct bat_priv *bat_priv); int tt_global_init(struct bat_priv *bat_priv);
void hna_global_add_orig(struct bat_priv *bat_priv, void tt_global_add_orig(struct bat_priv *bat_priv,
struct orig_node *orig_node, struct orig_node *orig_node,
unsigned char *hna_buff, int hna_buff_len); unsigned char *tt_buff, int tt_buff_len);
int hna_global_seq_print_text(struct seq_file *seq, void *offset); int tt_global_seq_print_text(struct seq_file *seq, void *offset);
void hna_global_del_orig(struct bat_priv *bat_priv, void tt_global_del_orig(struct bat_priv *bat_priv,
struct orig_node *orig_node, char *message); struct orig_node *orig_node, char *message);
void hna_global_free(struct bat_priv *bat_priv); void tt_global_free(struct bat_priv *bat_priv);
struct orig_node *transtable_search(struct bat_priv *bat_priv, uint8_t *addr); struct orig_node *transtable_search(struct bat_priv *bat_priv, uint8_t *addr);
#endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */ #endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */
...@@ -75,8 +75,8 @@ struct orig_node { ...@@ -75,8 +75,8 @@ struct orig_node {
unsigned long batman_seqno_reset; unsigned long batman_seqno_reset;
uint8_t gw_flags; uint8_t gw_flags;
uint8_t flags; uint8_t flags;
unsigned char *hna_buff; unsigned char *tt_buff;
int16_t hna_buff_len; int16_t tt_buff_len;
uint32_t last_real_seqno; uint32_t last_real_seqno;
uint8_t last_ttl; uint8_t last_ttl;
unsigned long bcast_bits[NUM_WORDS]; unsigned long bcast_bits[NUM_WORDS];
...@@ -89,11 +89,11 @@ struct orig_node { ...@@ -89,11 +89,11 @@ struct orig_node {
struct hlist_node hash_entry; struct hlist_node hash_entry;
struct bat_priv *bat_priv; struct bat_priv *bat_priv;
unsigned long last_frag_packet; unsigned long last_frag_packet;
spinlock_t ogm_cnt_lock; /* protects: bcast_own, bcast_own_sum, /* ogm_cnt_lock protects: bcast_own, bcast_own_sum,
* neigh_node->real_bits, * neigh_node->real_bits, neigh_node->real_packet_count */
* neigh_node->real_packet_count */ spinlock_t ogm_cnt_lock;
spinlock_t bcast_seqno_lock; /* protects bcast_bits, /* bcast_seqno_lock protects bcast_bits, last_bcast_seqno */
* last_bcast_seqno */ spinlock_t bcast_seqno_lock;
atomic_t bond_candidates; atomic_t bond_candidates;
struct list_head bond_list; struct list_head bond_list;
}; };
...@@ -146,30 +146,30 @@ struct bat_priv { ...@@ -146,30 +146,30 @@ struct bat_priv {
atomic_t bcast_queue_left; atomic_t bcast_queue_left;
atomic_t batman_queue_left; atomic_t batman_queue_left;
char num_ifaces; char num_ifaces;
struct hlist_head softif_neigh_list;
struct softif_neigh __rcu *softif_neigh;
struct debug_log *debug_log; struct debug_log *debug_log;
struct kobject *mesh_obj; struct kobject *mesh_obj;
struct dentry *debug_dir; struct dentry *debug_dir;
struct hlist_head forw_bat_list; struct hlist_head forw_bat_list;
struct hlist_head forw_bcast_list; struct hlist_head forw_bcast_list;
struct hlist_head gw_list; struct hlist_head gw_list;
struct hlist_head softif_neigh_vids;
struct list_head vis_send_list; struct list_head vis_send_list;
struct hashtable_t *orig_hash; struct hashtable_t *orig_hash;
struct hashtable_t *hna_local_hash; struct hashtable_t *tt_local_hash;
struct hashtable_t *hna_global_hash; struct hashtable_t *tt_global_hash;
struct hashtable_t *vis_hash; struct hashtable_t *vis_hash;
spinlock_t forw_bat_list_lock; /* protects forw_bat_list */ spinlock_t forw_bat_list_lock; /* protects forw_bat_list */
spinlock_t forw_bcast_list_lock; /* protects */ spinlock_t forw_bcast_list_lock; /* protects */
spinlock_t hna_lhash_lock; /* protects hna_local_hash */ spinlock_t tt_lhash_lock; /* protects tt_local_hash */
spinlock_t hna_ghash_lock; /* protects hna_global_hash */ spinlock_t tt_ghash_lock; /* protects tt_global_hash */
spinlock_t gw_list_lock; /* protects gw_list and curr_gw */ spinlock_t gw_list_lock; /* protects gw_list and curr_gw */
spinlock_t vis_hash_lock; /* protects vis_hash */ spinlock_t vis_hash_lock; /* protects vis_hash */
spinlock_t vis_list_lock; /* protects vis_info::recv_list */ spinlock_t vis_list_lock; /* protects vis_info::recv_list */
spinlock_t softif_neigh_lock; /* protects soft-interface neigh list */ spinlock_t softif_neigh_lock; /* protects soft-interface neigh list */
int16_t num_local_hna; spinlock_t softif_neigh_vid_lock; /* protects soft-interface vid list */
atomic_t hna_local_changed; int16_t num_local_tt;
struct delayed_work hna_work; atomic_t tt_local_changed;
struct delayed_work tt_work;
struct delayed_work orig_work; struct delayed_work orig_work;
struct delayed_work vis_work; struct delayed_work vis_work;
struct gw_node __rcu *curr_gw; /* rcu protected pointer */ struct gw_node __rcu *curr_gw; /* rcu protected pointer */
...@@ -192,14 +192,14 @@ struct socket_packet { ...@@ -192,14 +192,14 @@ struct socket_packet {
struct icmp_packet_rr icmp_packet; struct icmp_packet_rr icmp_packet;
}; };
struct hna_local_entry { struct tt_local_entry {
uint8_t addr[ETH_ALEN]; uint8_t addr[ETH_ALEN];
unsigned long last_seen; unsigned long last_seen;
char never_purge; char never_purge;
struct hlist_node hash_entry; struct hlist_node hash_entry;
}; };
struct hna_global_entry { struct tt_global_entry {
uint8_t addr[ETH_ALEN]; uint8_t addr[ETH_ALEN];
struct orig_node *orig_node; struct orig_node *orig_node;
struct hlist_node hash_entry; struct hlist_node hash_entry;
...@@ -262,7 +262,7 @@ struct vis_info { ...@@ -262,7 +262,7 @@ struct vis_info {
struct vis_info_entry { struct vis_info_entry {
uint8_t src[ETH_ALEN]; uint8_t src[ETH_ALEN];
uint8_t dest[ETH_ALEN]; uint8_t dest[ETH_ALEN];
uint8_t quality; /* quality = 0 means HNA */ uint8_t quality; /* quality = 0 client */
} __packed; } __packed;
struct recvlist_node { struct recvlist_node {
...@@ -270,11 +270,20 @@ struct recvlist_node { ...@@ -270,11 +270,20 @@ struct recvlist_node {
uint8_t mac[ETH_ALEN]; uint8_t mac[ETH_ALEN];
}; };
struct softif_neigh_vid {
struct hlist_node list;
struct bat_priv *bat_priv;
short vid;
atomic_t refcount;
struct softif_neigh __rcu *softif_neigh;
struct rcu_head rcu;
struct hlist_head softif_neigh_list;
};
struct softif_neigh { struct softif_neigh {
struct hlist_node list; struct hlist_node list;
uint8_t addr[ETH_ALEN]; uint8_t addr[ETH_ALEN];
unsigned long last_seen; unsigned long last_seen;
short vid;
atomic_t refcount; atomic_t refcount;
struct rcu_head rcu; struct rcu_head rcu;
}; };
......
...@@ -300,7 +300,7 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv) ...@@ -300,7 +300,7 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
goto find_router; goto find_router;
} }
/* check for hna host - increases orig_node refcount */ /* check for tt host - increases orig_node refcount */
orig_node = transtable_search(bat_priv, ethhdr->h_dest); orig_node = transtable_search(bat_priv, ethhdr->h_dest);
find_router: find_router:
......
...@@ -194,7 +194,7 @@ static ssize_t vis_data_read_entry(char *buff, struct vis_info_entry *entry, ...@@ -194,7 +194,7 @@ static ssize_t vis_data_read_entry(char *buff, struct vis_info_entry *entry,
{ {
/* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */ /* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */
if (primary && entry->quality == 0) if (primary && entry->quality == 0)
return sprintf(buff, "HNA %pM, ", entry->dest); return sprintf(buff, "TT %pM, ", entry->dest);
else if (compare_eth(entry->src, src)) else if (compare_eth(entry->src, src))
return sprintf(buff, "TQ %pM %d, ", entry->dest, return sprintf(buff, "TQ %pM %d, ", entry->dest,
entry->quality); entry->quality);
...@@ -622,7 +622,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv) ...@@ -622,7 +622,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
struct vis_info *info = (struct vis_info *)bat_priv->my_vis_info; struct vis_info *info = (struct vis_info *)bat_priv->my_vis_info;
struct vis_packet *packet = (struct vis_packet *)info->skb_packet->data; struct vis_packet *packet = (struct vis_packet *)info->skb_packet->data;
struct vis_info_entry *entry; struct vis_info_entry *entry;
struct hna_local_entry *hna_local_entry; struct tt_local_entry *tt_local_entry;
int best_tq = -1, i; int best_tq = -1, i;
info->first_seen = jiffies; info->first_seen = jiffies;
...@@ -678,29 +678,29 @@ static int generate_vis_packet(struct bat_priv *bat_priv) ...@@ -678,29 +678,29 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
rcu_read_unlock(); rcu_read_unlock();
} }
hash = bat_priv->hna_local_hash; hash = bat_priv->tt_local_hash;
spin_lock_bh(&bat_priv->hna_lhash_lock); spin_lock_bh(&bat_priv->tt_lhash_lock);
for (i = 0; i < hash->size; i++) { for (i = 0; i < hash->size; i++) {
head = &hash->table[i]; head = &hash->table[i];
hlist_for_each_entry(hna_local_entry, node, head, hash_entry) { hlist_for_each_entry(tt_local_entry, node, head, hash_entry) {
entry = (struct vis_info_entry *) entry = (struct vis_info_entry *)
skb_put(info->skb_packet, skb_put(info->skb_packet,
sizeof(*entry)); sizeof(*entry));
memset(entry->src, 0, ETH_ALEN); memset(entry->src, 0, ETH_ALEN);
memcpy(entry->dest, hna_local_entry->addr, ETH_ALEN); memcpy(entry->dest, tt_local_entry->addr, ETH_ALEN);
entry->quality = 0; /* 0 means HNA */ entry->quality = 0; /* 0 means TT */
packet->entries++; packet->entries++;
if (vis_packet_full(info)) { if (vis_packet_full(info)) {
spin_unlock_bh(&bat_priv->hna_lhash_lock); spin_unlock_bh(&bat_priv->tt_lhash_lock);
return 0; return 0;
} }
} }
} }
spin_unlock_bh(&bat_priv->hna_lhash_lock); spin_unlock_bh(&bat_priv->tt_lhash_lock);
return 0; return 0;
unlock: unlock:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment