Commit 1d5873e9 authored by David S. Miller's avatar David S. Miller

Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge

Included changes:
- yet another batch of 'namespace cleaning' patches

Conflicts:
	net/batman-adv/translation-table.c
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 7665de15 a513088d
...@@ -32,25 +32,25 @@ ...@@ -32,25 +32,25 @@
#include "icmp_socket.h" #include "icmp_socket.h"
#include "bridge_loop_avoidance.h" #include "bridge_loop_avoidance.h"
static struct dentry *bat_debugfs; static struct dentry *batadv_debugfs;
#ifdef CONFIG_BATMAN_ADV_DEBUG #ifdef CONFIG_BATMAN_ADV_DEBUG
#define LOG_BUFF_MASK (log_buff_len-1) #define LOG_BUFF_MASK (batadv_log_buff_len - 1)
#define LOG_BUFF(idx) (debug_log->log_buff[(idx) & LOG_BUFF_MASK]) #define LOG_BUFF(idx) (debug_log->log_buff[(idx) & LOG_BUFF_MASK])
static int log_buff_len = LOG_BUF_LEN; static int batadv_log_buff_len = LOG_BUF_LEN;
static void emit_log_char(struct debug_log *debug_log, char c) static void batadv_emit_log_char(struct debug_log *debug_log, char c)
{ {
LOG_BUFF(debug_log->log_end) = c; LOG_BUFF(debug_log->log_end) = c;
debug_log->log_end++; debug_log->log_end++;
if (debug_log->log_end - debug_log->log_start > log_buff_len) if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len)
debug_log->log_start = debug_log->log_end - log_buff_len; debug_log->log_start = debug_log->log_end - batadv_log_buff_len;
} }
__printf(2, 3) __printf(2, 3)
static int fdebug_log(struct debug_log *debug_log, const char *fmt, ...) static int batadv_fdebug_log(struct debug_log *debug_log, const char *fmt, ...)
{ {
va_list args; va_list args;
static char debug_log_buf[256]; static char debug_log_buf[256];
...@@ -65,7 +65,7 @@ static int fdebug_log(struct debug_log *debug_log, const char *fmt, ...) ...@@ -65,7 +65,7 @@ static int fdebug_log(struct debug_log *debug_log, const char *fmt, ...)
va_end(args); va_end(args);
for (p = debug_log_buf; *p != 0; p++) for (p = debug_log_buf; *p != 0; p++)
emit_log_char(debug_log, *p); batadv_emit_log_char(debug_log, *p);
spin_unlock_bh(&debug_log->lock); spin_unlock_bh(&debug_log->lock);
...@@ -81,14 +81,14 @@ int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...) ...@@ -81,14 +81,14 @@ int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...)
va_start(args, fmt); va_start(args, fmt);
vscnprintf(tmp_log_buf, sizeof(tmp_log_buf), fmt, args); vscnprintf(tmp_log_buf, sizeof(tmp_log_buf), fmt, args);
fdebug_log(bat_priv->debug_log, "[%10u] %s", batadv_fdebug_log(bat_priv->debug_log, "[%10u] %s",
jiffies_to_msecs(jiffies), tmp_log_buf); jiffies_to_msecs(jiffies), tmp_log_buf);
va_end(args); va_end(args);
return 0; return 0;
} }
static int log_open(struct inode *inode, struct file *file) static int batadv_log_open(struct inode *inode, struct file *file)
{ {
nonseekable_open(inode, file); nonseekable_open(inode, file);
file->private_data = inode->i_private; file->private_data = inode->i_private;
...@@ -96,13 +96,13 @@ static int log_open(struct inode *inode, struct file *file) ...@@ -96,13 +96,13 @@ static int log_open(struct inode *inode, struct file *file)
return 0; return 0;
} }
static int log_release(struct inode *inode, struct file *file) static int batadv_log_release(struct inode *inode, struct file *file)
{ {
batadv_dec_module_count(); batadv_dec_module_count();
return 0; return 0;
} }
static ssize_t log_read(struct file *file, char __user *buf, static ssize_t batadv_log_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct bat_priv *bat_priv = file->private_data; struct bat_priv *bat_priv = file->private_data;
...@@ -156,7 +156,7 @@ static ssize_t log_read(struct file *file, char __user *buf, ...@@ -156,7 +156,7 @@ static ssize_t log_read(struct file *file, char __user *buf,
return error; return error;
} }
static unsigned int log_poll(struct file *file, poll_table *wait) static unsigned int batadv_log_poll(struct file *file, poll_table *wait)
{ {
struct bat_priv *bat_priv = file->private_data; struct bat_priv *bat_priv = file->private_data;
struct debug_log *debug_log = bat_priv->debug_log; struct debug_log *debug_log = bat_priv->debug_log;
...@@ -169,15 +169,15 @@ static unsigned int log_poll(struct file *file, poll_table *wait) ...@@ -169,15 +169,15 @@ static unsigned int log_poll(struct file *file, poll_table *wait)
return 0; return 0;
} }
static const struct file_operations log_fops = { static const struct file_operations batadv_log_fops = {
.open = log_open, .open = batadv_log_open,
.release = log_release, .release = batadv_log_release,
.read = log_read, .read = batadv_log_read,
.poll = log_poll, .poll = batadv_log_poll,
.llseek = no_llseek, .llseek = no_llseek,
}; };
static int debug_log_setup(struct bat_priv *bat_priv) static int batadv_debug_log_setup(struct bat_priv *bat_priv)
{ {
struct dentry *d; struct dentry *d;
...@@ -192,7 +192,8 @@ static int debug_log_setup(struct bat_priv *bat_priv) ...@@ -192,7 +192,8 @@ static int debug_log_setup(struct bat_priv *bat_priv)
init_waitqueue_head(&bat_priv->debug_log->queue_wait); init_waitqueue_head(&bat_priv->debug_log->queue_wait);
d = debugfs_create_file("log", S_IFREG | S_IRUSR, d = debugfs_create_file("log", S_IFREG | S_IRUSR,
bat_priv->debug_dir, bat_priv, &log_fops); bat_priv->debug_dir, bat_priv,
&batadv_log_fops);
if (!d) if (!d)
goto err; goto err;
...@@ -202,49 +203,49 @@ static int debug_log_setup(struct bat_priv *bat_priv) ...@@ -202,49 +203,49 @@ static int debug_log_setup(struct bat_priv *bat_priv)
return -ENOMEM; return -ENOMEM;
} }
static void debug_log_cleanup(struct bat_priv *bat_priv) static void batadv_debug_log_cleanup(struct bat_priv *bat_priv)
{ {
kfree(bat_priv->debug_log); kfree(bat_priv->debug_log);
bat_priv->debug_log = NULL; bat_priv->debug_log = NULL;
} }
#else /* CONFIG_BATMAN_ADV_DEBUG */ #else /* CONFIG_BATMAN_ADV_DEBUG */
static int debug_log_setup(struct bat_priv *bat_priv) static int batadv_debug_log_setup(struct bat_priv *bat_priv)
{ {
bat_priv->debug_log = NULL; bat_priv->debug_log = NULL;
return 0; return 0;
} }
static void debug_log_cleanup(struct bat_priv *bat_priv) static void batadv_debug_log_cleanup(struct bat_priv *bat_priv)
{ {
return; return;
} }
#endif #endif
static int bat_algorithms_open(struct inode *inode, struct file *file) static int batadv_algorithms_open(struct inode *inode, struct file *file)
{ {
return single_open(file, batadv_algo_seq_print_text, NULL); return single_open(file, batadv_algo_seq_print_text, NULL);
} }
static int originators_open(struct inode *inode, struct file *file) static int batadv_originators_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, batadv_orig_seq_print_text, net_dev); return single_open(file, batadv_orig_seq_print_text, net_dev);
} }
static int gateways_open(struct inode *inode, struct file *file) static int batadv_gateways_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, batadv_gw_client_seq_print_text, net_dev); return single_open(file, batadv_gw_client_seq_print_text, net_dev);
} }
static int transtable_global_open(struct inode *inode, struct file *file) static int batadv_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, batadv_tt_global_seq_print_text, net_dev); return single_open(file, batadv_tt_global_seq_print_text, net_dev);
} }
#ifdef CONFIG_BATMAN_ADV_BLA #ifdef CONFIG_BATMAN_ADV_BLA
static int bla_claim_table_open(struct inode *inode, struct file *file) static int batadv_bla_claim_table_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, batadv_bla_claim_table_seq_print_text, return single_open(file, batadv_bla_claim_table_seq_print_text,
...@@ -252,13 +253,13 @@ static int bla_claim_table_open(struct inode *inode, struct file *file) ...@@ -252,13 +253,13 @@ static int bla_claim_table_open(struct inode *inode, struct file *file)
} }
#endif #endif
static int transtable_local_open(struct inode *inode, struct file *file) static int batadv_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, batadv_tt_local_seq_print_text, net_dev); return single_open(file, batadv_tt_local_seq_print_text, net_dev);
} }
static int vis_data_open(struct inode *inode, struct file *file) static int batadv_vis_data_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, batadv_vis_seq_print_text, net_dev); return single_open(file, batadv_vis_seq_print_text, net_dev);
...@@ -270,7 +271,7 @@ struct bat_debuginfo { ...@@ -270,7 +271,7 @@ struct bat_debuginfo {
}; };
#define BAT_DEBUGINFO(_name, _mode, _open) \ #define BAT_DEBUGINFO(_name, _mode, _open) \
struct bat_debuginfo bat_debuginfo_##_name = { \ struct bat_debuginfo batadv_debuginfo_##_name = { \
.attr = { .name = __stringify(_name), \ .attr = { .name = __stringify(_name), \
.mode = _mode, }, \ .mode = _mode, }, \
.fops = { .owner = THIS_MODULE, \ .fops = { .owner = THIS_MODULE, \
...@@ -281,25 +282,25 @@ struct bat_debuginfo bat_debuginfo_##_name = { \ ...@@ -281,25 +282,25 @@ struct bat_debuginfo bat_debuginfo_##_name = { \
} \ } \
}; };
static BAT_DEBUGINFO(routing_algos, S_IRUGO, bat_algorithms_open); static BAT_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open);
static BAT_DEBUGINFO(originators, S_IRUGO, originators_open); static BAT_DEBUGINFO(originators, S_IRUGO, batadv_originators_open);
static BAT_DEBUGINFO(gateways, S_IRUGO, gateways_open); static BAT_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open);
static BAT_DEBUGINFO(transtable_global, S_IRUGO, transtable_global_open); static BAT_DEBUGINFO(transtable_global, S_IRUGO, batadv_transtable_global_open);
#ifdef CONFIG_BATMAN_ADV_BLA #ifdef CONFIG_BATMAN_ADV_BLA
static BAT_DEBUGINFO(bla_claim_table, S_IRUGO, bla_claim_table_open); static BAT_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open);
#endif #endif
static BAT_DEBUGINFO(transtable_local, S_IRUGO, transtable_local_open); static BAT_DEBUGINFO(transtable_local, S_IRUGO, batadv_transtable_local_open);
static BAT_DEBUGINFO(vis_data, S_IRUGO, vis_data_open); static BAT_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open);
static struct bat_debuginfo *mesh_debuginfos[] = { static struct bat_debuginfo *batadv_mesh_debuginfos[] = {
&bat_debuginfo_originators, &batadv_debuginfo_originators,
&bat_debuginfo_gateways, &batadv_debuginfo_gateways,
&bat_debuginfo_transtable_global, &batadv_debuginfo_transtable_global,
#ifdef CONFIG_BATMAN_ADV_BLA #ifdef CONFIG_BATMAN_ADV_BLA
&bat_debuginfo_bla_claim_table, &batadv_debuginfo_bla_claim_table,
#endif #endif
&bat_debuginfo_transtable_local, &batadv_debuginfo_transtable_local,
&bat_debuginfo_vis_data, &batadv_debuginfo_vis_data,
NULL, NULL,
}; };
...@@ -308,17 +309,17 @@ void batadv_debugfs_init(void) ...@@ -308,17 +309,17 @@ void batadv_debugfs_init(void)
struct bat_debuginfo *bat_debug; struct bat_debuginfo *bat_debug;
struct dentry *file; struct dentry *file;
bat_debugfs = debugfs_create_dir(DEBUGFS_BAT_SUBDIR, NULL); batadv_debugfs = debugfs_create_dir(DEBUGFS_BAT_SUBDIR, NULL);
if (bat_debugfs == ERR_PTR(-ENODEV)) if (batadv_debugfs == ERR_PTR(-ENODEV))
bat_debugfs = NULL; batadv_debugfs = NULL;
if (!bat_debugfs) if (!batadv_debugfs)
goto out; goto out;
bat_debug = &bat_debuginfo_routing_algos; bat_debug = &batadv_debuginfo_routing_algos;
file = debugfs_create_file(bat_debug->attr.name, file = debugfs_create_file(bat_debug->attr.name,
S_IFREG | bat_debug->attr.mode, S_IFREG | bat_debug->attr.mode,
bat_debugfs, NULL, &bat_debug->fops); batadv_debugfs, NULL, &bat_debug->fops);
if (!file) if (!file)
pr_err("Can't add debugfs file: %s\n", bat_debug->attr.name); pr_err("Can't add debugfs file: %s\n", bat_debug->attr.name);
...@@ -328,9 +329,9 @@ void batadv_debugfs_init(void) ...@@ -328,9 +329,9 @@ void batadv_debugfs_init(void)
void batadv_debugfs_destroy(void) void batadv_debugfs_destroy(void)
{ {
if (bat_debugfs) { if (batadv_debugfs) {
debugfs_remove_recursive(bat_debugfs); debugfs_remove_recursive(batadv_debugfs);
bat_debugfs = NULL; batadv_debugfs = NULL;
} }
} }
...@@ -340,20 +341,20 @@ int batadv_debugfs_add_meshif(struct net_device *dev) ...@@ -340,20 +341,20 @@ int batadv_debugfs_add_meshif(struct net_device *dev)
struct bat_debuginfo **bat_debug; struct bat_debuginfo **bat_debug;
struct dentry *file; struct dentry *file;
if (!bat_debugfs) if (!batadv_debugfs)
goto out; goto out;
bat_priv->debug_dir = debugfs_create_dir(dev->name, bat_debugfs); bat_priv->debug_dir = debugfs_create_dir(dev->name, batadv_debugfs);
if (!bat_priv->debug_dir) if (!bat_priv->debug_dir)
goto out; goto out;
if (batadv_socket_setup(bat_priv) < 0) if (batadv_socket_setup(bat_priv) < 0)
goto rem_attr; goto rem_attr;
if (debug_log_setup(bat_priv) < 0) if (batadv_debug_log_setup(bat_priv) < 0)
goto rem_attr; goto rem_attr;
for (bat_debug = mesh_debuginfos; *bat_debug; ++bat_debug) { for (bat_debug = batadv_mesh_debuginfos; *bat_debug; ++bat_debug) {
file = debugfs_create_file(((*bat_debug)->attr).name, file = debugfs_create_file(((*bat_debug)->attr).name,
S_IFREG | ((*bat_debug)->attr).mode, S_IFREG | ((*bat_debug)->attr).mode,
bat_priv->debug_dir, bat_priv->debug_dir,
...@@ -381,9 +382,9 @@ void batadv_debugfs_del_meshif(struct net_device *dev) ...@@ -381,9 +382,9 @@ void batadv_debugfs_del_meshif(struct net_device *dev)
{ {
struct bat_priv *bat_priv = netdev_priv(dev); struct bat_priv *bat_priv = netdev_priv(dev);
debug_log_cleanup(bat_priv); batadv_debug_log_cleanup(bat_priv);
if (bat_debugfs) { if (batadv_debugfs) {
debugfs_remove_recursive(bat_priv->debug_dir); debugfs_remove_recursive(bat_priv->debug_dir);
bat_priv->debug_dir = NULL; bat_priv->debug_dir = NULL;
} }
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "send.h" #include "send.h"
#include "bat_algo.h" #include "bat_algo.h"
static struct neigh_node *bat_iv_ogm_neigh_new(struct hard_iface *hard_iface, static struct neigh_node *batadv_iv_ogm_neigh_new(struct hard_iface *hard_iface,
const uint8_t *neigh_addr, const uint8_t *neigh_addr,
struct orig_node *orig_node, struct orig_node *orig_node,
struct orig_node *orig_neigh, struct orig_node *orig_neigh,
...@@ -54,7 +54,7 @@ static struct neigh_node *bat_iv_ogm_neigh_new(struct hard_iface *hard_iface, ...@@ -54,7 +54,7 @@ static struct neigh_node *bat_iv_ogm_neigh_new(struct hard_iface *hard_iface,
return neigh_node; return neigh_node;
} }
static int bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) static int batadv_iv_ogm_iface_enable(struct hard_iface *hard_iface)
{ {
struct batman_ogm_packet *batman_ogm_packet; struct batman_ogm_packet *batman_ogm_packet;
uint32_t random_seqno; uint32_t random_seqno;
...@@ -85,13 +85,13 @@ static int bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) ...@@ -85,13 +85,13 @@ static int bat_iv_ogm_iface_enable(struct hard_iface *hard_iface)
return res; return res;
} }
static void bat_iv_ogm_iface_disable(struct hard_iface *hard_iface) static void batadv_iv_ogm_iface_disable(struct hard_iface *hard_iface)
{ {
kfree(hard_iface->packet_buff); kfree(hard_iface->packet_buff);
hard_iface->packet_buff = NULL; hard_iface->packet_buff = NULL;
} }
static void bat_iv_ogm_iface_update_mac(struct hard_iface *hard_iface) static void batadv_iv_ogm_iface_update_mac(struct hard_iface *hard_iface)
{ {
struct batman_ogm_packet *batman_ogm_packet; struct batman_ogm_packet *batman_ogm_packet;
...@@ -102,7 +102,7 @@ static void bat_iv_ogm_iface_update_mac(struct hard_iface *hard_iface) ...@@ -102,7 +102,7 @@ static void bat_iv_ogm_iface_update_mac(struct hard_iface *hard_iface)
hard_iface->net_dev->dev_addr, ETH_ALEN); hard_iface->net_dev->dev_addr, ETH_ALEN);
} }
static void bat_iv_ogm_primary_iface_set(struct hard_iface *hard_iface) static void batadv_iv_ogm_primary_iface_set(struct hard_iface *hard_iface)
{ {
struct batman_ogm_packet *batman_ogm_packet; struct batman_ogm_packet *batman_ogm_packet;
...@@ -112,7 +112,8 @@ static void bat_iv_ogm_primary_iface_set(struct hard_iface *hard_iface) ...@@ -112,7 +112,8 @@ static void bat_iv_ogm_primary_iface_set(struct hard_iface *hard_iface)
} }
/* when do we schedule our own ogm to be sent */ /* when do we schedule our own ogm to be sent */
static unsigned long bat_iv_ogm_emit_send_time(const struct bat_priv *bat_priv) static unsigned long
batadv_iv_ogm_emit_send_time(const struct bat_priv *bat_priv)
{ {
return jiffies + msecs_to_jiffies( return jiffies + msecs_to_jiffies(
atomic_read(&bat_priv->orig_interval) - atomic_read(&bat_priv->orig_interval) -
...@@ -120,20 +121,20 @@ static unsigned long bat_iv_ogm_emit_send_time(const struct bat_priv *bat_priv) ...@@ -120,20 +121,20 @@ static unsigned long bat_iv_ogm_emit_send_time(const struct bat_priv *bat_priv)
} }
/* when do we schedule a ogm packet to be sent */ /* when do we schedule a ogm packet to be sent */
static unsigned long bat_iv_ogm_fwd_send_time(void) static unsigned long batadv_iv_ogm_fwd_send_time(void)
{ {
return jiffies + msecs_to_jiffies(random32() % (JITTER/2)); return jiffies + msecs_to_jiffies(random32() % (JITTER/2));
} }
/* apply hop penalty for a normal link */ /* apply hop penalty for a normal link */
static uint8_t hop_penalty(uint8_t tq, const struct bat_priv *bat_priv) static uint8_t batadv_hop_penalty(uint8_t tq, const struct bat_priv *bat_priv)
{ {
int hop_penalty = atomic_read(&bat_priv->hop_penalty); int hop_penalty = atomic_read(&bat_priv->hop_penalty);
return (tq * (TQ_MAX_VALUE - hop_penalty)) / (TQ_MAX_VALUE); return (tq * (TQ_MAX_VALUE - hop_penalty)) / (TQ_MAX_VALUE);
} }
/* is there another aggregated packet here? */ /* is there another aggregated packet here? */
static int bat_iv_ogm_aggr_packet(int buff_pos, int packet_len, static int batadv_iv_ogm_aggr_packet(int buff_pos, int packet_len,
int tt_num_changes) int tt_num_changes)
{ {
int next_buff_pos = 0; int next_buff_pos = 0;
...@@ -146,7 +147,7 @@ static int bat_iv_ogm_aggr_packet(int buff_pos, int packet_len, ...@@ -146,7 +147,7 @@ static int bat_iv_ogm_aggr_packet(int buff_pos, int packet_len,
} }
/* send a batman ogm to a given interface */ /* send a batman ogm to a given interface */
static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet, static void batadv_iv_ogm_send_to_if(struct forw_packet *forw_packet,
struct hard_iface *hard_iface) struct hard_iface *hard_iface)
{ {
struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
...@@ -164,7 +165,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet, ...@@ -164,7 +165,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data; batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data;
/* adjust all flags and log packets */ /* adjust all flags and log packets */
while (bat_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len, while (batadv_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len,
batman_ogm_packet->tt_num_changes)) { batman_ogm_packet->tt_num_changes)) {
/* we might have aggregated direct link packets with an /* we might have aggregated direct link packets with an
...@@ -179,7 +180,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet, ...@@ -179,7 +180,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
fwd_str = (packet_num > 0 ? "Forwarding" : (forw_packet->own ? fwd_str = (packet_num > 0 ? "Forwarding" : (forw_packet->own ?
"Sending own" : "Sending own" :
"Forwarding")); "Forwarding"));
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n", "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n",
fwd_str, (packet_num > 0 ? "aggregated " : ""), fwd_str, (packet_num > 0 ? "aggregated " : ""),
batman_ogm_packet->orig, batman_ogm_packet->orig,
...@@ -208,7 +209,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet, ...@@ -208,7 +209,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
} }
/* send a batman ogm packet */ /* send a batman ogm packet */
static void bat_iv_ogm_emit(struct forw_packet *forw_packet) static void batadv_iv_ogm_emit(struct forw_packet *forw_packet)
{ {
struct hard_iface *hard_iface; struct hard_iface *hard_iface;
struct net_device *soft_iface; struct net_device *soft_iface;
...@@ -232,7 +233,7 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet) ...@@ -232,7 +233,7 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
if (forw_packet->if_incoming->if_status != IF_ACTIVE) if (forw_packet->if_incoming->if_status != IF_ACTIVE)
goto out; goto out;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
...@@ -243,7 +244,7 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet) ...@@ -243,7 +244,7 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
(forw_packet->own && (forw_packet->if_incoming != primary_if))) { (forw_packet->own && (forw_packet->if_incoming != primary_if))) {
/* FIXME: what about aggregated packets ? */ /* FIXME: what about aggregated packets ? */
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"%s packet (originator %pM, seqno %u, TTL %d) on interface %s [%pM]\n", "%s packet (originator %pM, seqno %u, TTL %d) on interface %s [%pM]\n",
(forw_packet->own ? "Sending own" : "Forwarding"), (forw_packet->own ? "Sending own" : "Forwarding"),
batman_ogm_packet->orig, batman_ogm_packet->orig,
...@@ -267,18 +268,18 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet) ...@@ -267,18 +268,18 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
if (hard_iface->soft_iface != soft_iface) if (hard_iface->soft_iface != soft_iface)
continue; continue;
bat_iv_ogm_send_to_if(forw_packet, hard_iface); batadv_iv_ogm_send_to_if(forw_packet, hard_iface);
} }
rcu_read_unlock(); rcu_read_unlock();
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
} }
/* return true if new_packet can be aggregated with forw_packet */ /* return true if new_packet can be aggregated with forw_packet */
static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet static bool
*new_batman_ogm_packet, batadv_iv_ogm_can_aggregate(const struct batman_ogm_packet *new_bat_ogm_packet,
struct bat_priv *bat_priv, struct bat_priv *bat_priv,
int packet_len, unsigned long send_time, int packet_len, unsigned long send_time,
bool directlink, bool directlink,
...@@ -311,7 +312,7 @@ static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet ...@@ -311,7 +312,7 @@ static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet
* a "global" packet as well as the base * a "global" packet as well as the base
* packet * packet
*/ */
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
...@@ -335,7 +336,7 @@ static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet ...@@ -335,7 +336,7 @@ static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet
* interface only - we still can aggregate * interface only - we still can aggregate
*/ */
if ((directlink) && if ((directlink) &&
(new_batman_ogm_packet->header.ttl == 1) && (new_bat_ogm_packet->header.ttl == 1) &&
(forw_packet->if_incoming == if_incoming) && (forw_packet->if_incoming == if_incoming) &&
/* packets from direct neighbors or /* packets from direct neighbors or
...@@ -352,12 +353,12 @@ static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet ...@@ -352,12 +353,12 @@ static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
return res; return res;
} }
/* create a new aggregated packet and add this packet to it */ /* create a new aggregated packet and add this packet to it */
static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff, static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
int packet_len, unsigned long send_time, int packet_len, unsigned long send_time,
bool direct_link, bool direct_link,
struct hard_iface *if_incoming, struct hard_iface *if_incoming,
...@@ -373,7 +374,7 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff, ...@@ -373,7 +374,7 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
/* own packet should always be scheduled */ /* own packet should always be scheduled */
if (!own_packet) { if (!own_packet) {
if (!atomic_dec_not_zero(&bat_priv->batman_queue_left)) { if (!atomic_dec_not_zero(&bat_priv->batman_queue_left)) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"batman packet queue full\n"); "batman packet queue full\n");
goto out; goto out;
} }
...@@ -431,11 +432,11 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff, ...@@ -431,11 +432,11 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
return; return;
out: out:
hardif_free_ref(if_incoming); batadv_hardif_free_ref(if_incoming);
} }
/* aggregate a new packet into the existing ogm packet */ /* aggregate a new packet into the existing ogm packet */
static void bat_iv_ogm_aggregate(struct forw_packet *forw_packet_aggr, static void batadv_iv_ogm_aggregate(struct forw_packet *forw_packet_aggr,
const unsigned char *packet_buff, const unsigned char *packet_buff,
int packet_len, bool direct_link) int packet_len, bool direct_link)
{ {
...@@ -452,9 +453,10 @@ static void bat_iv_ogm_aggregate(struct forw_packet *forw_packet_aggr, ...@@ -452,9 +453,10 @@ static void bat_iv_ogm_aggregate(struct forw_packet *forw_packet_aggr,
(1 << forw_packet_aggr->num_packets); (1 << forw_packet_aggr->num_packets);
} }
static void bat_iv_ogm_queue_add(struct bat_priv *bat_priv, static void batadv_iv_ogm_queue_add(struct bat_priv *bat_priv,
unsigned char *packet_buff, unsigned char *packet_buff,
int packet_len, struct hard_iface *if_incoming, int packet_len,
struct hard_iface *if_incoming,
int own_packet, unsigned long send_time) int own_packet, unsigned long send_time)
{ {
/* _aggr -> pointer to the packet we want to aggregate with /* _aggr -> pointer to the packet we want to aggregate with
...@@ -474,7 +476,7 @@ static void bat_iv_ogm_queue_add(struct bat_priv *bat_priv, ...@@ -474,7 +476,7 @@ static void bat_iv_ogm_queue_add(struct bat_priv *bat_priv,
if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) { if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) {
hlist_for_each_entry(forw_packet_pos, tmp_node, hlist_for_each_entry(forw_packet_pos, tmp_node,
&bat_priv->forw_bat_list, list) { &bat_priv->forw_bat_list, list) {
if (bat_iv_ogm_can_aggregate(batman_ogm_packet, if (batadv_iv_ogm_can_aggregate(batman_ogm_packet,
bat_priv, packet_len, bat_priv, packet_len,
send_time, direct_link, send_time, direct_link,
if_incoming, if_incoming,
...@@ -500,17 +502,17 @@ static void bat_iv_ogm_queue_add(struct bat_priv *bat_priv, ...@@ -500,17 +502,17 @@ static void bat_iv_ogm_queue_add(struct bat_priv *bat_priv,
(atomic_read(&bat_priv->aggregated_ogms))) (atomic_read(&bat_priv->aggregated_ogms)))
send_time += msecs_to_jiffies(MAX_AGGREGATION_MS); send_time += msecs_to_jiffies(MAX_AGGREGATION_MS);
bat_iv_ogm_aggregate_new(packet_buff, packet_len, batadv_iv_ogm_aggregate_new(packet_buff, packet_len,
send_time, direct_link, send_time, direct_link,
if_incoming, own_packet); if_incoming, own_packet);
} else { } else {
bat_iv_ogm_aggregate(forw_packet_aggr, packet_buff, batadv_iv_ogm_aggregate(forw_packet_aggr, packet_buff,
packet_len, direct_link); packet_len, direct_link);
spin_unlock_bh(&bat_priv->forw_bat_list_lock); spin_unlock_bh(&bat_priv->forw_bat_list_lock);
} }
} }
static void bat_iv_ogm_forward(struct orig_node *orig_node, static void batadv_iv_ogm_forward(struct orig_node *orig_node,
const struct ethhdr *ethhdr, const struct ethhdr *ethhdr,
struct batman_ogm_packet *batman_ogm_packet, struct batman_ogm_packet *batman_ogm_packet,
bool is_single_hop_neigh, bool is_single_hop_neigh,
...@@ -521,7 +523,7 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node, ...@@ -521,7 +523,7 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node,
uint8_t tt_num_changes; uint8_t tt_num_changes;
if (batman_ogm_packet->header.ttl <= 1) { if (batman_ogm_packet->header.ttl <= 1) {
bat_dbg(DBG_BATMAN, bat_priv, "ttl exceeded\n"); batadv_dbg(DBG_BATMAN, bat_priv, "ttl exceeded\n");
return; return;
} }
...@@ -544,9 +546,10 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node, ...@@ -544,9 +546,10 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node,
memcpy(batman_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN); memcpy(batman_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN);
/* apply hop penalty */ /* apply hop penalty */
batman_ogm_packet->tq = hop_penalty(batman_ogm_packet->tq, bat_priv); batman_ogm_packet->tq = batadv_hop_penalty(batman_ogm_packet->tq,
bat_priv);
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Forwarding packet: tq: %i, ttl: %i\n", "Forwarding packet: tq: %i, ttl: %i\n",
batman_ogm_packet->tq, batman_ogm_packet->header.ttl); batman_ogm_packet->tq, batman_ogm_packet->header.ttl);
...@@ -557,12 +560,12 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node, ...@@ -557,12 +560,12 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node,
else else
batman_ogm_packet->flags &= ~DIRECTLINK; batman_ogm_packet->flags &= ~DIRECTLINK;
bat_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet, batadv_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet,
BATMAN_OGM_HLEN + batadv_tt_len(tt_num_changes), BATMAN_OGM_HLEN + batadv_tt_len(tt_num_changes),
if_incoming, 0, bat_iv_ogm_fwd_send_time()); if_incoming, 0, batadv_iv_ogm_fwd_send_time());
} }
static void bat_iv_ogm_schedule(struct hard_iface *hard_iface) static void batadv_iv_ogm_schedule(struct hard_iface *hard_iface)
{ {
struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
struct batman_ogm_packet *batman_ogm_packet; struct batman_ogm_packet *batman_ogm_packet;
...@@ -570,7 +573,7 @@ static void bat_iv_ogm_schedule(struct hard_iface *hard_iface) ...@@ -570,7 +573,7 @@ static void bat_iv_ogm_schedule(struct hard_iface *hard_iface)
int vis_server, tt_num_changes = 0; int vis_server, tt_num_changes = 0;
vis_server = atomic_read(&bat_priv->vis_mode); vis_server = atomic_read(&bat_priv->vis_mode);
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (hard_iface == primary_if) if (hard_iface == primary_if)
tt_num_changes = batadv_tt_append_diff(bat_priv, tt_num_changes = batadv_tt_append_diff(bat_priv,
...@@ -603,19 +606,19 @@ static void bat_iv_ogm_schedule(struct hard_iface *hard_iface) ...@@ -603,19 +606,19 @@ static void bat_iv_ogm_schedule(struct hard_iface *hard_iface)
batman_ogm_packet->gw_flags = NO_FLAGS; batman_ogm_packet->gw_flags = NO_FLAGS;
batadv_slide_own_bcast_window(hard_iface); batadv_slide_own_bcast_window(hard_iface);
bat_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff, batadv_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff,
hard_iface->packet_len, hard_iface, 1, hard_iface->packet_len, hard_iface, 1,
bat_iv_ogm_emit_send_time(bat_priv)); batadv_iv_ogm_emit_send_time(bat_priv));
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
} }
static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv, static void
batadv_iv_ogm_orig_update(struct bat_priv *bat_priv,
struct orig_node *orig_node, struct orig_node *orig_node,
const struct ethhdr *ethhdr, const struct ethhdr *ethhdr,
const struct batman_ogm_packet const struct batman_ogm_packet *batman_ogm_packet,
*batman_ogm_packet,
struct hard_iface *if_incoming, struct hard_iface *if_incoming,
const unsigned char *tt_buff, const unsigned char *tt_buff,
int is_duplicate) int is_duplicate)
...@@ -625,15 +628,17 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv, ...@@ -625,15 +628,17 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
struct orig_node *orig_node_tmp; struct orig_node *orig_node_tmp;
struct hlist_node *node; struct hlist_node *node;
uint8_t bcast_own_sum_orig, bcast_own_sum_neigh; uint8_t bcast_own_sum_orig, bcast_own_sum_neigh;
uint8_t *neigh_addr;
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"update_originator(): Searching and updating originator entry of received packet\n"); "update_originator(): Searching and updating originator entry of received packet\n");
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_node->neigh_list, list) { &orig_node->neigh_list, list) {
if (compare_eth(tmp_neigh_node->addr, ethhdr->h_source) && neigh_addr = tmp_neigh_node->addr;
(tmp_neigh_node->if_incoming == if_incoming) && if (batadv_compare_eth(neigh_addr, ethhdr->h_source) &&
tmp_neigh_node->if_incoming == if_incoming &&
atomic_inc_not_zero(&tmp_neigh_node->refcount)) { atomic_inc_not_zero(&tmp_neigh_node->refcount)) {
if (neigh_node) if (neigh_node)
batadv_neigh_node_free_ref(neigh_node); batadv_neigh_node_free_ref(neigh_node);
...@@ -659,7 +664,8 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv, ...@@ -659,7 +664,8 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
if (!orig_tmp) if (!orig_tmp)
goto unlock; goto unlock;
neigh_node = bat_iv_ogm_neigh_new(if_incoming, ethhdr->h_source, neigh_node = batadv_iv_ogm_neigh_new(if_incoming,
ethhdr->h_source,
orig_node, orig_tmp, orig_node, orig_tmp,
batman_ogm_packet->seqno); batman_ogm_packet->seqno);
...@@ -667,7 +673,7 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv, ...@@ -667,7 +673,7 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
if (!neigh_node) if (!neigh_node)
goto unlock; goto unlock;
} else } else
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Updating existing last-hop neighbor of originator\n"); "Updating existing last-hop neighbor of originator\n");
rcu_read_unlock(); rcu_read_unlock();
...@@ -757,7 +763,7 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv, ...@@ -757,7 +763,7 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
batadv_neigh_node_free_ref(router); batadv_neigh_node_free_ref(router);
} }
static int bat_iv_ogm_calc_tq(struct orig_node *orig_node, static int batadv_iv_ogm_calc_tq(struct orig_node *orig_node,
struct orig_node *orig_neigh_node, struct orig_node *orig_neigh_node,
struct batman_ogm_packet *batman_ogm_packet, struct batman_ogm_packet *batman_ogm_packet,
struct hard_iface *if_incoming) struct hard_iface *if_incoming)
...@@ -774,7 +780,8 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node, ...@@ -774,7 +780,8 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node,
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, orig_neigh_node->orig)) if (!batadv_compare_eth(tmp_neigh_node->addr,
orig_neigh_node->orig))
continue; continue;
if (tmp_neigh_node->if_incoming != if_incoming) if (tmp_neigh_node->if_incoming != if_incoming)
...@@ -789,7 +796,7 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node, ...@@ -789,7 +796,7 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node,
rcu_read_unlock(); rcu_read_unlock();
if (!neigh_node) if (!neigh_node)
neigh_node = bat_iv_ogm_neigh_new(if_incoming, neigh_node = batadv_iv_ogm_neigh_new(if_incoming,
orig_neigh_node->orig, orig_neigh_node->orig,
orig_neigh_node, orig_neigh_node,
orig_neigh_node, orig_neigh_node,
...@@ -844,10 +851,11 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node, ...@@ -844,10 +851,11 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node,
* tq_asym_penalty) / * tq_asym_penalty) /
(TQ_MAX_VALUE * TQ_MAX_VALUE)); (TQ_MAX_VALUE * TQ_MAX_VALUE));
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n", "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n",
orig_node->orig, orig_neigh_node->orig, total_count, orig_node->orig, orig_neigh_node->orig, total_count,
neigh_rq_count, tq_own, tq_asym_penalty, batman_ogm_packet->tq); neigh_rq_count, tq_own,
tq_asym_penalty, batman_ogm_packet->tq);
/* if link has the minimum required transmission quality /* if link has the minimum required transmission quality
* consider it bidirectional * consider it bidirectional
...@@ -869,9 +877,9 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node, ...@@ -869,9 +877,9 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node,
* -1 the packet is old and has been received while the seqno window * -1 the packet is old and has been received while the seqno window
* was protected. Caller should drop it. * was protected. Caller should drop it.
*/ */
static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, static int
const struct batman_ogm_packet batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
*batman_ogm_packet, const struct batman_ogm_packet *batman_ogm_packet,
const struct hard_iface *if_incoming) const 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);
...@@ -883,6 +891,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, ...@@ -883,6 +891,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
int need_update = 0; int need_update = 0;
int set_mark, ret = -1; int set_mark, ret = -1;
uint32_t seqno = ntohl(batman_ogm_packet->seqno); uint32_t seqno = ntohl(batman_ogm_packet->seqno);
uint8_t *neigh_addr;
orig_node = batadv_get_orig_node(bat_priv, batman_ogm_packet->orig); orig_node = batadv_get_orig_node(bat_priv, batman_ogm_packet->orig);
if (!orig_node) if (!orig_node)
...@@ -901,12 +910,13 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, ...@@ -901,12 +910,13 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
hlist_for_each_entry_rcu(tmp_neigh_node, node, hlist_for_each_entry_rcu(tmp_neigh_node, node,
&orig_node->neigh_list, list) { &orig_node->neigh_list, list) {
is_duplicate |= bat_test_bit(tmp_neigh_node->real_bits, is_duplicate |= batadv_test_bit(tmp_neigh_node->real_bits,
orig_node->last_real_seqno, orig_node->last_real_seqno,
seqno); seqno);
if (compare_eth(tmp_neigh_node->addr, ethhdr->h_source) && neigh_addr = tmp_neigh_node->addr;
(tmp_neigh_node->if_incoming == if_incoming)) if (batadv_compare_eth(neigh_addr, ethhdr->h_source) &&
tmp_neigh_node->if_incoming == if_incoming)
set_mark = 1; set_mark = 1;
else else
set_mark = 0; set_mark = 0;
...@@ -923,7 +933,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, ...@@ -923,7 +933,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
rcu_read_unlock(); rcu_read_unlock();
if (need_update) { if (need_update) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"updating last_seqno: old %u, new %u\n", "updating last_seqno: old %u, new %u\n",
orig_node->last_real_seqno, seqno); orig_node->last_real_seqno, seqno);
orig_node->last_real_seqno = seqno; orig_node->last_real_seqno = seqno;
...@@ -937,7 +947,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, ...@@ -937,7 +947,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
return ret; return ret;
} }
static void bat_iv_ogm_process(const struct ethhdr *ethhdr, static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
struct batman_ogm_packet *batman_ogm_packet, struct batman_ogm_packet *batman_ogm_packet,
const unsigned char *tt_buff, const unsigned char *tt_buff,
struct hard_iface *if_incoming) struct hard_iface *if_incoming)
...@@ -949,11 +959,12 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, ...@@ -949,11 +959,12 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
struct neigh_node *orig_neigh_router = NULL; struct neigh_node *orig_neigh_router = NULL;
int has_directlink_flag; int has_directlink_flag;
int is_my_addr = 0, is_my_orig = 0, is_my_oldorig = 0; int is_my_addr = 0, is_my_orig = 0, is_my_oldorig = 0;
int is_broadcast = 0, is_bidirectional; int is_broadcast = 0, is_bidirect;
bool is_single_hop_neigh = false; bool is_single_hop_neigh = false;
bool is_from_best_next_hop = false; bool is_from_best_next_hop = false;
int is_duplicate; int is_duplicate, sameseq, simlar_ttl;
uint32_t if_incoming_seqno; uint32_t if_incoming_seqno;
uint8_t *prev_sender;
/* Silently drop when the batman packet is actually not a /* Silently drop when the batman packet is actually not a
* correct packet. * correct packet.
...@@ -975,15 +986,16 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, ...@@ -975,15 +986,16 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
has_directlink_flag = (batman_ogm_packet->flags & DIRECTLINK ? 1 : 0); has_directlink_flag = (batman_ogm_packet->flags & DIRECTLINK ? 1 : 0);
if (compare_eth(ethhdr->h_source, batman_ogm_packet->orig)) if (batadv_compare_eth(ethhdr->h_source, batman_ogm_packet->orig))
is_single_hop_neigh = true; is_single_hop_neigh = true;
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n", "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n",
ethhdr->h_source, if_incoming->net_dev->name, ethhdr->h_source, if_incoming->net_dev->name,
if_incoming->net_dev->dev_addr, batman_ogm_packet->orig, if_incoming->net_dev->dev_addr, batman_ogm_packet->orig,
batman_ogm_packet->prev_sender, ntohl(batman_ogm_packet->seqno), batman_ogm_packet->prev_sender,
batman_ogm_packet->ttvn, ntohs(batman_ogm_packet->tt_crc), ntohl(batman_ogm_packet->seqno), batman_ogm_packet->ttvn,
ntohs(batman_ogm_packet->tt_crc),
batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq, batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq,
batman_ogm_packet->header.ttl, batman_ogm_packet->header.ttl,
batman_ogm_packet->header.version, has_directlink_flag); batman_ogm_packet->header.version, has_directlink_flag);
...@@ -996,15 +1008,15 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, ...@@ -996,15 +1008,15 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
if (hard_iface->soft_iface != if_incoming->soft_iface) if (hard_iface->soft_iface != if_incoming->soft_iface)
continue; continue;
if (compare_eth(ethhdr->h_source, if (batadv_compare_eth(ethhdr->h_source,
hard_iface->net_dev->dev_addr)) hard_iface->net_dev->dev_addr))
is_my_addr = 1; is_my_addr = 1;
if (compare_eth(batman_ogm_packet->orig, if (batadv_compare_eth(batman_ogm_packet->orig,
hard_iface->net_dev->dev_addr)) hard_iface->net_dev->dev_addr))
is_my_orig = 1; is_my_orig = 1;
if (compare_eth(batman_ogm_packet->prev_sender, if (batadv_compare_eth(batman_ogm_packet->prev_sender,
hard_iface->net_dev->dev_addr)) hard_iface->net_dev->dev_addr))
is_my_oldorig = 1; is_my_oldorig = 1;
...@@ -1014,21 +1026,21 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, ...@@ -1014,21 +1026,21 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
rcu_read_unlock(); rcu_read_unlock();
if (batman_ogm_packet->header.version != COMPAT_VERSION) { if (batman_ogm_packet->header.version != COMPAT_VERSION) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Drop packet: incompatible batman version (%i)\n", "Drop packet: incompatible batman version (%i)\n",
batman_ogm_packet->header.version); batman_ogm_packet->header.version);
return; return;
} }
if (is_my_addr) { if (is_my_addr) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Drop packet: received my own broadcast (sender: %pM)\n", "Drop packet: received my own broadcast (sender: %pM)\n",
ethhdr->h_source); ethhdr->h_source);
return; return;
} }
if (is_broadcast) { if (is_broadcast) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Drop packet: ignoring all packets with broadcast source addr (sender: %pM)\n", "Drop packet: ignoring all packets with broadcast source addr (sender: %pM)\n",
ethhdr->h_source); ethhdr->h_source);
return; return;
...@@ -1037,6 +1049,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, ...@@ -1037,6 +1049,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
if (is_my_orig) { if (is_my_orig) {
unsigned long *word; unsigned long *word;
int offset; int offset;
int32_t bit_pos;
orig_neigh_node = batadv_get_orig_node(bat_priv, orig_neigh_node = batadv_get_orig_node(bat_priv,
ethhdr->h_source); ethhdr->h_source);
...@@ -1048,35 +1061,35 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, ...@@ -1048,35 +1061,35 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
* save packet seqno for bidirectional check * save packet seqno for bidirectional check
*/ */
if (has_directlink_flag && if (has_directlink_flag &&
compare_eth(if_incoming->net_dev->dev_addr, batadv_compare_eth(if_incoming->net_dev->dev_addr,
batman_ogm_packet->orig)) { batman_ogm_packet->orig)) {
offset = if_incoming->if_num * NUM_WORDS; offset = if_incoming->if_num * NUM_WORDS;
spin_lock_bh(&orig_neigh_node->ogm_cnt_lock); spin_lock_bh(&orig_neigh_node->ogm_cnt_lock);
word = &(orig_neigh_node->bcast_own[offset]); word = &(orig_neigh_node->bcast_own[offset]);
bat_set_bit(word, bit_pos = if_incoming_seqno - 2;
if_incoming_seqno - bit_pos -= ntohl(batman_ogm_packet->seqno);
ntohl(batman_ogm_packet->seqno) - 2); batadv_set_bit(word, bit_pos);
orig_neigh_node->bcast_own_sum[if_incoming->if_num] = orig_neigh_node->bcast_own_sum[if_incoming->if_num] =
bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE); bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE);
spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock); spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock);
} }
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Drop packet: originator packet from myself (via neighbor)\n"); "Drop packet: originator packet from myself (via neighbor)\n");
batadv_orig_node_free_ref(orig_neigh_node); batadv_orig_node_free_ref(orig_neigh_node);
return; return;
} }
if (is_my_oldorig) { if (is_my_oldorig) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Drop packet: ignoring all rebroadcast echos (sender: %pM)\n", "Drop packet: ignoring all rebroadcast echos (sender: %pM)\n",
ethhdr->h_source); ethhdr->h_source);
return; return;
} }
if (batman_ogm_packet->flags & NOT_BEST_NEXT_HOP) { if (batman_ogm_packet->flags & NOT_BEST_NEXT_HOP) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Drop packet: ignoring all packets not forwarded from the best next hop (sender: %pM)\n", "Drop packet: ignoring all packets not forwarded from the best next hop (sender: %pM)\n",
ethhdr->h_source); ethhdr->h_source);
return; return;
...@@ -1086,18 +1099,18 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, ...@@ -1086,18 +1099,18 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
if (!orig_node) if (!orig_node)
return; return;
is_duplicate = bat_iv_ogm_update_seqnos(ethhdr, batman_ogm_packet, is_duplicate = batadv_iv_ogm_update_seqnos(ethhdr, batman_ogm_packet,
if_incoming); if_incoming);
if (is_duplicate == -1) { if (is_duplicate == -1) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Drop packet: packet within seqno protection time (sender: %pM)\n", "Drop packet: packet within seqno protection time (sender: %pM)\n",
ethhdr->h_source); ethhdr->h_source);
goto out; goto out;
} }
if (batman_ogm_packet->tq == 0) { if (batman_ogm_packet->tq == 0) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Drop packet: originator packet with tq equal 0\n"); "Drop packet: originator packet with tq equal 0\n");
goto out; goto out;
} }
...@@ -1107,16 +1120,16 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, ...@@ -1107,16 +1120,16 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
router_router = batadv_orig_node_get_router(router->orig_node); router_router = batadv_orig_node_get_router(router->orig_node);
if ((router && router->tq_avg != 0) && if ((router && router->tq_avg != 0) &&
(compare_eth(router->addr, ethhdr->h_source))) (batadv_compare_eth(router->addr, ethhdr->h_source)))
is_from_best_next_hop = true; is_from_best_next_hop = true;
prev_sender = batman_ogm_packet->prev_sender;
/* avoid temporary routing loops */ /* avoid temporary routing loops */
if (router && router_router && if (router && router_router &&
(compare_eth(router->addr, batman_ogm_packet->prev_sender)) && (batadv_compare_eth(router->addr, prev_sender)) &&
!(compare_eth(batman_ogm_packet->orig, !(batadv_compare_eth(batman_ogm_packet->orig, prev_sender)) &&
batman_ogm_packet->prev_sender)) && (batadv_compare_eth(router->addr, router_router->addr))) {
(compare_eth(router->addr, router_router->addr))) { batadv_dbg(DBG_BATMAN, bat_priv,
bat_dbg(DBG_BATMAN, bat_priv,
"Drop packet: ignoring all rebroadcast packets that may make me loop (sender: %pM)\n", "Drop packet: ignoring all rebroadcast packets that may make me loop (sender: %pM)\n",
ethhdr->h_source); ethhdr->h_source);
goto out; goto out;
...@@ -1137,12 +1150,12 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, ...@@ -1137,12 +1150,12 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
* don't route towards it * don't route towards it
*/ */
if (!is_single_hop_neigh && (!orig_neigh_router)) { if (!is_single_hop_neigh && (!orig_neigh_router)) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Drop packet: OGM via unknown neighbor!\n"); "Drop packet: OGM via unknown neighbor!\n");
goto out_neigh; goto out_neigh;
} }
is_bidirectional = bat_iv_ogm_calc_tq(orig_node, orig_neigh_node, is_bidirect = batadv_iv_ogm_calc_tq(orig_node, orig_neigh_node,
batman_ogm_packet, if_incoming); batman_ogm_packet, if_incoming);
batadv_bonding_save_primary(orig_node, orig_neigh_node, batadv_bonding_save_primary(orig_node, orig_neigh_node,
...@@ -1151,11 +1164,10 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, ...@@ -1151,11 +1164,10 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
/* update ranking if it is not a duplicate or has the same /* update ranking if it is not a duplicate or has the same
* seqno and similar ttl as the non-duplicate * seqno and similar ttl as the non-duplicate
*/ */
if (is_bidirectional && sameseq = orig_node->last_real_seqno == ntohl(batman_ogm_packet->seqno);
(!is_duplicate || simlar_ttl = orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl;
((orig_node->last_real_seqno == ntohl(batman_ogm_packet->seqno)) && if (is_bidirect && (!is_duplicate || (sameseq && simlar_ttl)))
(orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl)))) batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr,
bat_iv_ogm_orig_update(bat_priv, orig_node, ethhdr,
batman_ogm_packet, if_incoming, batman_ogm_packet, if_incoming,
tt_buff, is_duplicate); tt_buff, is_duplicate);
...@@ -1163,31 +1175,31 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, ...@@ -1163,31 +1175,31 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
if (is_single_hop_neigh) { if (is_single_hop_neigh) {
/* mark direct link on incoming interface */ /* mark direct link on incoming interface */
bat_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet, batadv_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet,
is_single_hop_neigh, is_from_best_next_hop, is_single_hop_neigh,
if_incoming); is_from_best_next_hop, if_incoming);
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Forwarding packet: rebroadcast neighbor packet with direct link flag\n"); "Forwarding packet: rebroadcast neighbor packet with direct link flag\n");
goto out_neigh; goto out_neigh;
} }
/* multihop originator */ /* multihop originator */
if (!is_bidirectional) { if (!is_bidirect) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Drop packet: not received via bidirectional link\n"); "Drop packet: not received via bidirectional link\n");
goto out_neigh; goto out_neigh;
} }
if (is_duplicate) { if (is_duplicate) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Drop packet: duplicate packet received\n"); "Drop packet: duplicate packet received\n");
goto out_neigh; goto out_neigh;
} }
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Forwarding packet: rebroadcast originator packet\n"); "Forwarding packet: rebroadcast originator packet\n");
bat_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet, batadv_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet,
is_single_hop_neigh, is_from_best_next_hop, is_single_hop_neigh, is_from_best_next_hop,
if_incoming); if_incoming);
...@@ -1205,7 +1217,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, ...@@ -1205,7 +1217,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
batadv_orig_node_free_ref(orig_node); batadv_orig_node_free_ref(orig_node);
} }
static int bat_iv_ogm_receive(struct sk_buff *skb, static int batadv_iv_ogm_receive(struct sk_buff *skb,
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);
...@@ -1222,7 +1234,7 @@ static int bat_iv_ogm_receive(struct sk_buff *skb, ...@@ -1222,7 +1234,7 @@ static int bat_iv_ogm_receive(struct sk_buff *skb,
/* did we receive a B.A.T.M.A.N. IV OGM packet on an interface /* did we receive a B.A.T.M.A.N. IV OGM packet on an interface
* that does not have B.A.T.M.A.N. IV enabled ? * that does not have B.A.T.M.A.N. IV enabled ?
*/ */
if (bat_priv->bat_algo_ops->bat_ogm_emit != bat_iv_ogm_emit) if (bat_priv->bat_algo_ops->bat_ogm_emit != batadv_iv_ogm_emit)
return NET_RX_DROP; return NET_RX_DROP;
batadv_inc_counter(bat_priv, BAT_CNT_MGMT_RX); batadv_inc_counter(bat_priv, BAT_CNT_MGMT_RX);
...@@ -1238,29 +1250,29 @@ static int bat_iv_ogm_receive(struct sk_buff *skb, ...@@ -1238,29 +1250,29 @@ static int bat_iv_ogm_receive(struct sk_buff *skb,
do { do {
tt_buff = packet_buff + buff_pos + BATMAN_OGM_HLEN; tt_buff = packet_buff + buff_pos + BATMAN_OGM_HLEN;
bat_iv_ogm_process(ethhdr, batman_ogm_packet, batadv_iv_ogm_process(ethhdr, batman_ogm_packet, tt_buff,
tt_buff, if_incoming); if_incoming);
buff_pos += BATMAN_OGM_HLEN; buff_pos += BATMAN_OGM_HLEN;
buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes); buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes);
batman_ogm_packet = (struct batman_ogm_packet *) batman_ogm_packet = (struct batman_ogm_packet *)
(packet_buff + buff_pos); (packet_buff + buff_pos);
} while (bat_iv_ogm_aggr_packet(buff_pos, packet_len, } while (batadv_iv_ogm_aggr_packet(buff_pos, packet_len,
batman_ogm_packet->tt_num_changes)); batman_ogm_packet->tt_num_changes));
kfree_skb(skb); kfree_skb(skb);
return NET_RX_SUCCESS; return NET_RX_SUCCESS;
} }
static struct bat_algo_ops batman_iv __read_mostly = { static struct bat_algo_ops batadv_batman_iv __read_mostly = {
.name = "BATMAN_IV", .name = "BATMAN_IV",
.bat_iface_enable = bat_iv_ogm_iface_enable, .bat_iface_enable = batadv_iv_ogm_iface_enable,
.bat_iface_disable = bat_iv_ogm_iface_disable, .bat_iface_disable = batadv_iv_ogm_iface_disable,
.bat_iface_update_mac = bat_iv_ogm_iface_update_mac, .bat_iface_update_mac = batadv_iv_ogm_iface_update_mac,
.bat_primary_iface_set = bat_iv_ogm_primary_iface_set, .bat_primary_iface_set = batadv_iv_ogm_primary_iface_set,
.bat_ogm_schedule = bat_iv_ogm_schedule, .bat_ogm_schedule = batadv_iv_ogm_schedule,
.bat_ogm_emit = bat_iv_ogm_emit, .bat_ogm_emit = batadv_iv_ogm_emit,
}; };
int __init batadv_iv_init(void) int __init batadv_iv_init(void)
...@@ -1268,11 +1280,11 @@ int __init batadv_iv_init(void) ...@@ -1268,11 +1280,11 @@ int __init batadv_iv_init(void)
int ret; int ret;
/* batman originator packet */ /* batman originator packet */
ret = batadv_recv_handler_register(BAT_IV_OGM, bat_iv_ogm_receive); ret = batadv_recv_handler_register(BAT_IV_OGM, batadv_iv_ogm_receive);
if (ret < 0) if (ret < 0)
goto out; goto out;
ret = batadv_algo_register(&batman_iv); ret = batadv_algo_register(&batadv_batman_iv);
if (ret < 0) if (ret < 0)
goto handler_unregister; goto handler_unregister;
......
...@@ -26,15 +26,15 @@ ...@@ -26,15 +26,15 @@
#include "gateway_client.h" #include "gateway_client.h"
#include "vis.h" #include "vis.h"
static struct net_device *kobj_to_netdev(struct kobject *obj) static struct net_device *batadv_kobj_to_netdev(struct kobject *obj)
{ {
struct device *dev = container_of(obj->parent, struct device, kobj); struct device *dev = container_of(obj->parent, struct device, kobj);
return to_net_dev(dev); return to_net_dev(dev);
} }
static struct bat_priv *kobj_to_batpriv(struct kobject *obj) static struct bat_priv *batadv_kobj_to_batpriv(struct kobject *obj)
{ {
struct net_device *net_dev = kobj_to_netdev(obj); struct net_device *net_dev = batadv_kobj_to_netdev(obj);
return netdev_priv(net_dev); return netdev_priv(net_dev);
} }
...@@ -42,19 +42,19 @@ static struct bat_priv *kobj_to_batpriv(struct kobject *obj) ...@@ -42,19 +42,19 @@ static struct bat_priv *kobj_to_batpriv(struct kobject *obj)
#define UEV_ACTION_VAR "BATACTION=" #define UEV_ACTION_VAR "BATACTION="
#define UEV_DATA_VAR "BATDATA=" #define UEV_DATA_VAR "BATDATA="
static char *uev_action_str[] = { static char *batadv_uev_action_str[] = {
"add", "add",
"del", "del",
"change" "change"
}; };
static char *uev_type_str[] = { static char *batadv_uev_type_str[] = {
"gw" "gw"
}; };
/* Use this, if you have customized show and store functions */ /* Use this, if you have customized show and store functions */
#define BAT_ATTR(_name, _mode, _show, _store) \ #define BAT_ATTR(_name, _mode, _show, _store) \
struct bat_attribute bat_attr_##_name = { \ struct bat_attribute batadv_attr_##_name = { \
.attr = {.name = __stringify(_name), \ .attr = {.name = __stringify(_name), \
.mode = _mode }, \ .mode = _mode }, \
.show = _show, \ .show = _show, \
...@@ -62,20 +62,21 @@ struct bat_attribute bat_attr_##_name = { \ ...@@ -62,20 +62,21 @@ struct bat_attribute bat_attr_##_name = { \
}; };
#define BAT_ATTR_SIF_STORE_BOOL(_name, _post_func) \ #define BAT_ATTR_SIF_STORE_BOOL(_name, _post_func) \
ssize_t store_##_name(struct kobject *kobj, struct attribute *attr, \ ssize_t batadv_store_##_name(struct kobject *kobj, \
char *buff, size_t count) \ struct attribute *attr, char *buff, \
size_t count) \
{ \ { \
struct net_device *net_dev = kobj_to_netdev(kobj); \ struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
struct bat_priv *bat_priv = netdev_priv(net_dev); \ struct bat_priv *bat_priv = netdev_priv(net_dev); \
return __store_bool_attr(buff, count, _post_func, attr, \ return __batadv_store_bool_attr(buff, count, _post_func, attr, \
&bat_priv->_name, net_dev); \ &bat_priv->_name, net_dev); \
} }
#define BAT_ATTR_SIF_SHOW_BOOL(_name) \ #define BAT_ATTR_SIF_SHOW_BOOL(_name) \
ssize_t show_##_name(struct kobject *kobj, \ ssize_t batadv_show_##_name(struct kobject *kobj, \
struct attribute *attr, char *buff) \ struct attribute *attr, char *buff) \
{ \ { \
struct bat_priv *bat_priv = kobj_to_batpriv(kobj); \ struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj); \
return sprintf(buff, "%s\n", \ return sprintf(buff, "%s\n", \
atomic_read(&bat_priv->_name) == 0 ? \ atomic_read(&bat_priv->_name) == 0 ? \
"disabled" : "enabled"); \ "disabled" : "enabled"); \
...@@ -87,24 +88,27 @@ ssize_t show_##_name(struct kobject *kobj, \ ...@@ -87,24 +88,27 @@ ssize_t show_##_name(struct kobject *kobj, \
#define BAT_ATTR_SIF_BOOL(_name, _mode, _post_func) \ #define BAT_ATTR_SIF_BOOL(_name, _mode, _post_func) \
static BAT_ATTR_SIF_STORE_BOOL(_name, _post_func) \ static BAT_ATTR_SIF_STORE_BOOL(_name, _post_func) \
static BAT_ATTR_SIF_SHOW_BOOL(_name) \ static BAT_ATTR_SIF_SHOW_BOOL(_name) \
static BAT_ATTR(_name, _mode, show_##_name, store_##_name) static BAT_ATTR(_name, _mode, batadv_show_##_name, \
batadv_store_##_name)
#define BAT_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \ #define BAT_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \
ssize_t store_##_name(struct kobject *kobj, struct attribute *attr, \ ssize_t batadv_store_##_name(struct kobject *kobj, \
char *buff, size_t count) \ struct attribute *attr, char *buff, \
size_t count) \
{ \ { \
struct net_device *net_dev = kobj_to_netdev(kobj); \ struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
struct bat_priv *bat_priv = netdev_priv(net_dev); \ struct bat_priv *bat_priv = netdev_priv(net_dev); \
return __store_uint_attr(buff, count, _min, _max, _post_func, \ return __batadv_store_uint_attr(buff, count, _min, _max, \
attr, &bat_priv->_name, net_dev); \ _post_func, attr, \
&bat_priv->_name, net_dev); \
} }
#define BAT_ATTR_SIF_SHOW_UINT(_name) \ #define BAT_ATTR_SIF_SHOW_UINT(_name) \
ssize_t show_##_name(struct kobject *kobj, \ ssize_t batadv_show_##_name(struct kobject *kobj, \
struct attribute *attr, char *buff) \ struct attribute *attr, char *buff) \
{ \ { \
struct bat_priv *bat_priv = kobj_to_batpriv(kobj); \ struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj); \
return sprintf(buff, "%i\n", atomic_read(&bat_priv->_name)); \ return sprintf(buff, "%i\n", atomic_read(&bat_priv->_name)); \
} \ } \
...@@ -114,14 +118,16 @@ ssize_t show_##_name(struct kobject *kobj, \ ...@@ -114,14 +118,16 @@ ssize_t show_##_name(struct kobject *kobj, \
#define BAT_ATTR_SIF_UINT(_name, _mode, _min, _max, _post_func) \ #define BAT_ATTR_SIF_UINT(_name, _mode, _min, _max, _post_func) \
static BAT_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \ static BAT_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \
static BAT_ATTR_SIF_SHOW_UINT(_name) \ static BAT_ATTR_SIF_SHOW_UINT(_name) \
static BAT_ATTR(_name, _mode, show_##_name, store_##_name) static BAT_ATTR(_name, _mode, batadv_show_##_name, \
batadv_store_##_name)
#define BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \ #define BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \
ssize_t store_##_name(struct kobject *kobj, struct attribute *attr, \ ssize_t batadv_store_##_name(struct kobject *kobj, \
char *buff, size_t count) \ struct attribute *attr, char *buff, \
size_t count) \
{ \ { \
struct net_device *net_dev = kobj_to_netdev(kobj); \ struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
struct hard_iface *hard_iface; \ struct hard_iface *hard_iface; \
ssize_t length; \ ssize_t length; \
\ \
...@@ -129,18 +135,19 @@ ssize_t store_##_name(struct kobject *kobj, struct attribute *attr, \ ...@@ -129,18 +135,19 @@ ssize_t store_##_name(struct kobject *kobj, struct attribute *attr, \
if (!hard_iface) \ if (!hard_iface) \
return 0; \ return 0; \
\ \
length = __store_uint_attr(buff, count, _min, _max, _post_func, \ length = __batadv_store_uint_attr(buff, count, _min, _max, \
attr, &hard_iface->_name, net_dev); \ _post_func, attr, \
&hard_iface->_name, net_dev); \
\ \
hardif_free_ref(hard_iface); \ batadv_hardif_free_ref(hard_iface); \
return length; \ return length; \
} }
#define BAT_ATTR_HIF_SHOW_UINT(_name) \ #define BAT_ATTR_HIF_SHOW_UINT(_name) \
ssize_t show_##_name(struct kobject *kobj, \ ssize_t batadv_show_##_name(struct kobject *kobj, \
struct attribute *attr, char *buff) \ struct attribute *attr, char *buff) \
{ \ { \
struct net_device *net_dev = kobj_to_netdev(kobj); \ struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
struct hard_iface *hard_iface; \ struct hard_iface *hard_iface; \
ssize_t length; \ ssize_t length; \
\ \
...@@ -150,7 +157,7 @@ ssize_t show_##_name(struct kobject *kobj, \ ...@@ -150,7 +157,7 @@ ssize_t show_##_name(struct kobject *kobj, \
\ \
length = sprintf(buff, "%i\n", atomic_read(&hard_iface->_name));\ length = sprintf(buff, "%i\n", atomic_read(&hard_iface->_name));\
\ \
hardif_free_ref(hard_iface); \ batadv_hardif_free_ref(hard_iface); \
return length; \ return length; \
} }
...@@ -160,10 +167,11 @@ ssize_t show_##_name(struct kobject *kobj, \ ...@@ -160,10 +167,11 @@ ssize_t show_##_name(struct kobject *kobj, \
#define BAT_ATTR_HIF_UINT(_name, _mode, _min, _max, _post_func) \ #define BAT_ATTR_HIF_UINT(_name, _mode, _min, _max, _post_func) \
static BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \ static BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \
static BAT_ATTR_HIF_SHOW_UINT(_name) \ static BAT_ATTR_HIF_SHOW_UINT(_name) \
static BAT_ATTR(_name, _mode, show_##_name, store_##_name) static BAT_ATTR(_name, _mode, batadv_show_##_name, \
batadv_store_##_name)
static int store_bool_attr(char *buff, size_t count, static int batadv_store_bool_attr(char *buff, size_t count,
struct net_device *net_dev, struct net_device *net_dev,
const char *attr_name, atomic_t *attr) const char *attr_name, atomic_t *attr)
{ {
...@@ -200,23 +208,27 @@ static int store_bool_attr(char *buff, size_t count, ...@@ -200,23 +208,27 @@ static int store_bool_attr(char *buff, size_t count,
return count; return count;
} }
static inline ssize_t __store_bool_attr(char *buff, size_t count, static inline ssize_t
__batadv_store_bool_attr(char *buff, size_t count,
void (*post_func)(struct net_device *), void (*post_func)(struct net_device *),
struct attribute *attr, struct attribute *attr,
atomic_t *attr_store, struct net_device *net_dev) atomic_t *attr_store, struct net_device *net_dev)
{ {
int ret; int ret;
ret = store_bool_attr(buff, count, net_dev, attr->name, attr_store); ret = batadv_store_bool_attr(buff, count, net_dev, attr->name,
attr_store);
if (post_func && ret) if (post_func && ret)
post_func(net_dev); post_func(net_dev);
return ret; return ret;
} }
static int store_uint_attr(const char *buff, size_t count, static int batadv_store_uint_attr(const char *buff, size_t count,
struct net_device *net_dev, const char *attr_name, struct net_device *net_dev,
unsigned int min, unsigned int max, atomic_t *attr) const char *attr_name,
unsigned int min, unsigned int max,
atomic_t *attr)
{ {
unsigned long uint_val; unsigned long uint_val;
int ret; int ret;
...@@ -251,7 +263,8 @@ static int store_uint_attr(const char *buff, size_t count, ...@@ -251,7 +263,8 @@ static int store_uint_attr(const char *buff, size_t count,
return count; return count;
} }
static inline ssize_t __store_uint_attr(const char *buff, size_t count, static inline ssize_t
__batadv_store_uint_attr(const char *buff, size_t count,
int min, int max, int min, int max,
void (*post_func)(struct net_device *), void (*post_func)(struct net_device *),
const struct attribute *attr, const struct attribute *attr,
...@@ -259,18 +272,18 @@ static inline ssize_t __store_uint_attr(const char *buff, size_t count, ...@@ -259,18 +272,18 @@ static inline ssize_t __store_uint_attr(const char *buff, size_t count,
{ {
int ret; int ret;
ret = store_uint_attr(buff, count, net_dev, attr->name, ret = batadv_store_uint_attr(buff, count, net_dev, attr->name, min, max,
min, max, attr_store); attr_store);
if (post_func && ret) if (post_func && ret)
post_func(net_dev); post_func(net_dev);
return ret; return ret;
} }
static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr, static ssize_t batadv_show_vis_mode(struct kobject *kobj,
char *buff) struct attribute *attr, char *buff)
{ {
struct bat_priv *bat_priv = kobj_to_batpriv(kobj); struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
int vis_mode = atomic_read(&bat_priv->vis_mode); int vis_mode = atomic_read(&bat_priv->vis_mode);
return sprintf(buff, "%s\n", return sprintf(buff, "%s\n",
...@@ -278,10 +291,11 @@ static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr, ...@@ -278,10 +291,11 @@ static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr,
"client" : "server"); "client" : "server");
} }
static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, static ssize_t batadv_store_vis_mode(struct kobject *kobj,
char *buff, size_t count) struct attribute *attr, char *buff,
size_t count)
{ {
struct net_device *net_dev = kobj_to_netdev(kobj); struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
struct bat_priv *bat_priv = netdev_priv(net_dev); struct bat_priv *bat_priv = netdev_priv(net_dev);
unsigned long val; unsigned long val;
int ret, vis_mode_tmp = -1; int ret, vis_mode_tmp = -1;
...@@ -319,23 +333,23 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, ...@@ -319,23 +333,23 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
return count; return count;
} }
static ssize_t show_bat_algo(struct kobject *kobj, struct attribute *attr, static ssize_t batadv_show_bat_algo(struct kobject *kobj,
char *buff) struct attribute *attr, char *buff)
{ {
struct bat_priv *bat_priv = kobj_to_batpriv(kobj); struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
return sprintf(buff, "%s\n", bat_priv->bat_algo_ops->name); return sprintf(buff, "%s\n", bat_priv->bat_algo_ops->name);
} }
static void post_gw_deselect(struct net_device *net_dev) static void batadv_post_gw_deselect(struct net_device *net_dev)
{ {
struct bat_priv *bat_priv = netdev_priv(net_dev); struct bat_priv *bat_priv = netdev_priv(net_dev);
batadv_gw_deselect(bat_priv); batadv_gw_deselect(bat_priv);
} }
static ssize_t show_gw_mode(struct kobject *kobj, struct attribute *attr, static ssize_t batadv_show_gw_mode(struct kobject *kobj, struct attribute *attr,
char *buff) char *buff)
{ {
struct bat_priv *bat_priv = kobj_to_batpriv(kobj); struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
int bytes_written; int bytes_written;
switch (atomic_read(&bat_priv->gw_mode)) { switch (atomic_read(&bat_priv->gw_mode)) {
...@@ -353,10 +367,11 @@ static ssize_t show_gw_mode(struct kobject *kobj, struct attribute *attr, ...@@ -353,10 +367,11 @@ static ssize_t show_gw_mode(struct kobject *kobj, struct attribute *attr,
return bytes_written; return bytes_written;
} }
static ssize_t store_gw_mode(struct kobject *kobj, struct attribute *attr, static ssize_t batadv_store_gw_mode(struct kobject *kobj,
char *buff, size_t count) struct attribute *attr, char *buff,
size_t count)
{ {
struct net_device *net_dev = kobj_to_netdev(kobj); struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
struct bat_priv *bat_priv = netdev_priv(net_dev); struct bat_priv *bat_priv = netdev_priv(net_dev);
char *curr_gw_mode_str; char *curr_gw_mode_str;
int gw_mode_tmp = -1; int gw_mode_tmp = -1;
...@@ -405,10 +420,10 @@ static ssize_t store_gw_mode(struct kobject *kobj, struct attribute *attr, ...@@ -405,10 +420,10 @@ static ssize_t store_gw_mode(struct kobject *kobj, struct attribute *attr,
return count; return count;
} }
static ssize_t show_gw_bwidth(struct kobject *kobj, struct attribute *attr, static ssize_t batadv_show_gw_bwidth(struct kobject *kobj,
char *buff) struct attribute *attr, char *buff)
{ {
struct bat_priv *bat_priv = kobj_to_batpriv(kobj); struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
int down, up; int down, up;
int gw_bandwidth = atomic_read(&bat_priv->gw_bandwidth); int gw_bandwidth = atomic_read(&bat_priv->gw_bandwidth);
...@@ -420,10 +435,11 @@ static ssize_t show_gw_bwidth(struct kobject *kobj, struct attribute *attr, ...@@ -420,10 +435,11 @@ static ssize_t show_gw_bwidth(struct kobject *kobj, struct attribute *attr,
(up > 2048 ? "MBit" : "KBit")); (up > 2048 ? "MBit" : "KBit"));
} }
static ssize_t store_gw_bwidth(struct kobject *kobj, struct attribute *attr, static ssize_t batadv_store_gw_bwidth(struct kobject *kobj,
char *buff, size_t count) struct attribute *attr, char *buff,
size_t count)
{ {
struct net_device *net_dev = kobj_to_netdev(kobj); struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
if (buff[count - 1] == '\n') if (buff[count - 1] == '\n')
buff[count - 1] = '\0'; buff[count - 1] = '\0';
...@@ -438,36 +454,38 @@ BAT_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL); ...@@ -438,36 +454,38 @@ BAT_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL);
#endif #endif
BAT_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu); BAT_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu);
BAT_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL); BAT_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL);
static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode); static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, batadv_show_vis_mode,
static BAT_ATTR(routing_algo, S_IRUGO, show_bat_algo, NULL); batadv_store_vis_mode);
static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, show_gw_mode, store_gw_mode); static BAT_ATTR(routing_algo, S_IRUGO, batadv_show_bat_algo, NULL);
static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, batadv_show_gw_mode,
batadv_store_gw_mode);
BAT_ATTR_SIF_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, NULL); BAT_ATTR_SIF_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, NULL);
BAT_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, TQ_MAX_VALUE, NULL); BAT_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, TQ_MAX_VALUE, NULL);
BAT_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, TQ_MAX_VALUE, BAT_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, TQ_MAX_VALUE,
post_gw_deselect); batadv_post_gw_deselect);
static BAT_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, show_gw_bwidth, static BAT_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth,
store_gw_bwidth); batadv_store_gw_bwidth);
#ifdef CONFIG_BATMAN_ADV_DEBUG #ifdef CONFIG_BATMAN_ADV_DEBUG
BAT_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, DBG_ALL, NULL); BAT_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, DBG_ALL, NULL);
#endif #endif
static struct bat_attribute *mesh_attrs[] = { static struct bat_attribute *batadv_mesh_attrs[] = {
&bat_attr_aggregated_ogms, &batadv_attr_aggregated_ogms,
&bat_attr_bonding, &batadv_attr_bonding,
#ifdef CONFIG_BATMAN_ADV_BLA #ifdef CONFIG_BATMAN_ADV_BLA
&bat_attr_bridge_loop_avoidance, &batadv_attr_bridge_loop_avoidance,
#endif #endif
&bat_attr_fragmentation, &batadv_attr_fragmentation,
&bat_attr_ap_isolation, &batadv_attr_ap_isolation,
&bat_attr_vis_mode, &batadv_attr_vis_mode,
&bat_attr_routing_algo, &batadv_attr_routing_algo,
&bat_attr_gw_mode, &batadv_attr_gw_mode,
&bat_attr_orig_interval, &batadv_attr_orig_interval,
&bat_attr_hop_penalty, &batadv_attr_hop_penalty,
&bat_attr_gw_sel_class, &batadv_attr_gw_sel_class,
&bat_attr_gw_bandwidth, &batadv_attr_gw_bandwidth,
#ifdef CONFIG_BATMAN_ADV_DEBUG #ifdef CONFIG_BATMAN_ADV_DEBUG
&bat_attr_log_level, &batadv_attr_log_level,
#endif #endif
NULL, NULL,
}; };
...@@ -487,7 +505,7 @@ int batadv_sysfs_add_meshif(struct net_device *dev) ...@@ -487,7 +505,7 @@ int batadv_sysfs_add_meshif(struct net_device *dev)
goto out; goto out;
} }
for (bat_attr = mesh_attrs; *bat_attr; ++bat_attr) { for (bat_attr = batadv_mesh_attrs; *bat_attr; ++bat_attr) {
err = sysfs_create_file(bat_priv->mesh_obj, err = sysfs_create_file(bat_priv->mesh_obj,
&((*bat_attr)->attr)); &((*bat_attr)->attr));
if (err) { if (err) {
...@@ -501,7 +519,7 @@ int batadv_sysfs_add_meshif(struct net_device *dev) ...@@ -501,7 +519,7 @@ int batadv_sysfs_add_meshif(struct net_device *dev)
return 0; return 0;
rem_attr: rem_attr:
for (bat_attr = mesh_attrs; *bat_attr; ++bat_attr) for (bat_attr = batadv_mesh_attrs; *bat_attr; ++bat_attr)
sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr)); sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr));
kobject_put(bat_priv->mesh_obj); kobject_put(bat_priv->mesh_obj);
...@@ -515,17 +533,17 @@ void batadv_sysfs_del_meshif(struct net_device *dev) ...@@ -515,17 +533,17 @@ void batadv_sysfs_del_meshif(struct net_device *dev)
struct bat_priv *bat_priv = netdev_priv(dev); struct bat_priv *bat_priv = netdev_priv(dev);
struct bat_attribute **bat_attr; struct bat_attribute **bat_attr;
for (bat_attr = mesh_attrs; *bat_attr; ++bat_attr) for (bat_attr = batadv_mesh_attrs; *bat_attr; ++bat_attr)
sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr)); sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr));
kobject_put(bat_priv->mesh_obj); kobject_put(bat_priv->mesh_obj);
bat_priv->mesh_obj = NULL; bat_priv->mesh_obj = NULL;
} }
static ssize_t show_mesh_iface(struct kobject *kobj, struct attribute *attr, static ssize_t batadv_show_mesh_iface(struct kobject *kobj,
char *buff) struct attribute *attr, char *buff)
{ {
struct net_device *net_dev = kobj_to_netdev(kobj); struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev); struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
ssize_t length; ssize_t length;
...@@ -535,15 +553,16 @@ static ssize_t show_mesh_iface(struct kobject *kobj, struct attribute *attr, ...@@ -535,15 +553,16 @@ static ssize_t show_mesh_iface(struct kobject *kobj, struct attribute *attr,
length = sprintf(buff, "%s\n", hard_iface->if_status == IF_NOT_IN_USE ? length = sprintf(buff, "%s\n", hard_iface->if_status == IF_NOT_IN_USE ?
"none" : hard_iface->soft_iface->name); "none" : hard_iface->soft_iface->name);
hardif_free_ref(hard_iface); batadv_hardif_free_ref(hard_iface);
return length; return length;
} }
static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr, static ssize_t batadv_store_mesh_iface(struct kobject *kobj,
char *buff, size_t count) struct attribute *attr, char *buff,
size_t count)
{ {
struct net_device *net_dev = kobj_to_netdev(kobj); struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev); struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
int status_tmp = -1; int status_tmp = -1;
int ret = count; int ret = count;
...@@ -557,7 +576,7 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr, ...@@ -557,7 +576,7 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
if (strlen(buff) >= IFNAMSIZ) { if (strlen(buff) >= IFNAMSIZ) {
pr_err("Invalid parameter for 'mesh_iface' setting received: interface name too long '%s'\n", pr_err("Invalid parameter for 'mesh_iface' setting received: interface name too long '%s'\n",
buff); buff);
hardif_free_ref(hard_iface); batadv_hardif_free_ref(hard_iface);
return -EINVAL; return -EINVAL;
} }
...@@ -592,14 +611,14 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr, ...@@ -592,14 +611,14 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
unlock: unlock:
rtnl_unlock(); rtnl_unlock();
out: out:
hardif_free_ref(hard_iface); batadv_hardif_free_ref(hard_iface);
return ret; return ret;
} }
static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr, static ssize_t batadv_show_iface_status(struct kobject *kobj,
char *buff) struct attribute *attr, char *buff)
{ {
struct net_device *net_dev = kobj_to_netdev(kobj); struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev); struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
ssize_t length; ssize_t length;
...@@ -625,18 +644,18 @@ static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr, ...@@ -625,18 +644,18 @@ static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr,
break; break;
} }
hardif_free_ref(hard_iface); batadv_hardif_free_ref(hard_iface);
return length; return length;
} }
static BAT_ATTR(mesh_iface, S_IRUGO | S_IWUSR, static BAT_ATTR(mesh_iface, S_IRUGO | S_IWUSR,
show_mesh_iface, store_mesh_iface); batadv_show_mesh_iface, batadv_store_mesh_iface);
static BAT_ATTR(iface_status, S_IRUGO, show_iface_status, NULL); static BAT_ATTR(iface_status, S_IRUGO, batadv_show_iface_status, NULL);
static struct bat_attribute *batman_attrs[] = { static struct bat_attribute *batadv_batman_attrs[] = {
&bat_attr_mesh_iface, &batadv_attr_mesh_iface,
&bat_attr_iface_status, &batadv_attr_iface_status,
NULL, NULL,
}; };
...@@ -655,7 +674,7 @@ int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev) ...@@ -655,7 +674,7 @@ int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
goto out; goto out;
} }
for (bat_attr = batman_attrs; *bat_attr; ++bat_attr) { for (bat_attr = batadv_batman_attrs; *bat_attr; ++bat_attr) {
err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr)); err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr));
if (err) { if (err) {
bat_err(dev, "Can't add sysfs file: %s/%s/%s\n", bat_err(dev, "Can't add sysfs file: %s/%s/%s\n",
...@@ -668,7 +687,7 @@ int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev) ...@@ -668,7 +687,7 @@ int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
return 0; return 0;
rem_attr: rem_attr:
for (bat_attr = batman_attrs; *bat_attr; ++bat_attr) for (bat_attr = batadv_batman_attrs; *bat_attr; ++bat_attr)
sysfs_remove_file(*hardif_obj, &((*bat_attr)->attr)); sysfs_remove_file(*hardif_obj, &((*bat_attr)->attr));
out: out:
return -ENOMEM; return -ENOMEM;
...@@ -688,27 +707,28 @@ int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type, ...@@ -688,27 +707,28 @@ int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
struct kobject *bat_kobj; struct kobject *bat_kobj;
char *uevent_env[4] = { NULL, NULL, NULL, NULL }; char *uevent_env[4] = { NULL, NULL, NULL, NULL };
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
bat_kobj = &primary_if->soft_iface->dev.kobj; bat_kobj = &primary_if->soft_iface->dev.kobj;
uevent_env[0] = kmalloc(strlen(UEV_TYPE_VAR) + uevent_env[0] = kmalloc(strlen(UEV_TYPE_VAR) +
strlen(uev_type_str[type]) + 1, strlen(batadv_uev_type_str[type]) + 1,
GFP_ATOMIC); GFP_ATOMIC);
if (!uevent_env[0]) if (!uevent_env[0])
goto out; goto out;
sprintf(uevent_env[0], "%s%s", UEV_TYPE_VAR, uev_type_str[type]); sprintf(uevent_env[0], "%s%s", UEV_TYPE_VAR, batadv_uev_type_str[type]);
uevent_env[1] = kmalloc(strlen(UEV_ACTION_VAR) + uevent_env[1] = kmalloc(strlen(UEV_ACTION_VAR) +
strlen(uev_action_str[action]) + 1, strlen(batadv_uev_action_str[action]) + 1,
GFP_ATOMIC); GFP_ATOMIC);
if (!uevent_env[1]) if (!uevent_env[1])
goto out; goto out;
sprintf(uevent_env[1], "%s%s", UEV_ACTION_VAR, uev_action_str[action]); sprintf(uevent_env[1], "%s%s", UEV_ACTION_VAR,
batadv_uev_action_str[action]);
/* If the event is DEL, ignore the data field */ /* If the event is DEL, ignore the data field */
if (action != UEV_DEL) { if (action != UEV_DEL) {
...@@ -727,12 +747,13 @@ int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type, ...@@ -727,12 +747,13 @@ int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
kfree(uevent_env[2]); kfree(uevent_env[2]);
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
if (ret) if (ret)
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Impossible to send uevent for (%s,%s,%s) event (err: %d)\n", "Impossible to send uevent for (%s,%s,%s) event (err: %d)\n",
uev_type_str[type], uev_action_str[action], batadv_uev_type_str[type],
batadv_uev_action_str[action],
(action == UEV_DEL ? "NULL" : data), ret); (action == UEV_DEL ? "NULL" : data), ret);
return ret; return ret;
} }
...@@ -48,7 +48,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, ...@@ -48,7 +48,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
*/ */
if ((seq_num_diff <= 0) && (seq_num_diff > -TQ_LOCAL_WINDOW_SIZE)) { if ((seq_num_diff <= 0) && (seq_num_diff > -TQ_LOCAL_WINDOW_SIZE)) {
if (set_mark) if (set_mark)
bat_set_bit(seq_bits, -seq_num_diff); batadv_set_bit(seq_bits, -seq_num_diff);
return 0; return 0;
} }
...@@ -59,19 +59,19 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, ...@@ -59,19 +59,19 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
batadv_bitmap_shift_left(seq_bits, seq_num_diff); batadv_bitmap_shift_left(seq_bits, seq_num_diff);
if (set_mark) if (set_mark)
bat_set_bit(seq_bits, 0); batadv_set_bit(seq_bits, 0);
return 1; return 1;
} }
/* sequence number is much newer, probably missed a lot of packets */ /* sequence number is much newer, probably missed a lot of packets */
if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) && if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) &&
(seq_num_diff < EXPECTED_SEQNO_RANGE)) { (seq_num_diff < EXPECTED_SEQNO_RANGE)) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"We missed a lot of packets (%i) !\n", "We missed a lot of packets (%i) !\n",
seq_num_diff - 1); seq_num_diff - 1);
bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE); bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE);
if (set_mark) if (set_mark)
bat_set_bit(seq_bits, 0); batadv_set_bit(seq_bits, 0);
return 1; return 1;
} }
...@@ -83,12 +83,12 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, ...@@ -83,12 +83,12 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) ||
(seq_num_diff >= EXPECTED_SEQNO_RANGE)) { (seq_num_diff >= EXPECTED_SEQNO_RANGE)) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Other host probably restarted!\n"); "Other host probably restarted!\n");
bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE); bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE);
if (set_mark) if (set_mark)
bat_set_bit(seq_bits, 0); batadv_set_bit(seq_bits, 0);
return 1; return 1;
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* returns true if the corresponding bit in the given seq_bits indicates true /* returns true if the corresponding bit in the given seq_bits indicates true
* and curr_seqno is within range of last_seqno * and curr_seqno is within range of last_seqno
*/ */
static inline int bat_test_bit(const unsigned long *seq_bits, static inline int batadv_test_bit(const unsigned long *seq_bits,
uint32_t last_seqno, uint32_t curr_seqno) uint32_t last_seqno, uint32_t curr_seqno)
{ {
int32_t diff; int32_t diff;
...@@ -36,7 +36,7 @@ static inline int bat_test_bit(const unsigned long *seq_bits, ...@@ -36,7 +36,7 @@ static inline int bat_test_bit(const unsigned long *seq_bits,
} }
/* turn corresponding bit on, so we can remember that we got the packet */ /* turn corresponding bit on, so we can remember that we got the packet */
static inline void bat_set_bit(unsigned long *seq_bits, int32_t n) static inline void batadv_set_bit(unsigned long *seq_bits, int32_t n)
{ {
/* if too old, just drop it */ /* if too old, just drop it */
if (n < 0 || n >= TQ_LOCAL_WINDOW_SIZE) if (n < 0 || n >= TQ_LOCAL_WINDOW_SIZE)
......
...@@ -31,14 +31,14 @@ ...@@ -31,14 +31,14 @@
#include <net/arp.h> #include <net/arp.h>
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
static const uint8_t announce_mac[4] = {0x43, 0x05, 0x43, 0x05}; static const uint8_t batadv_announce_mac[4] = {0x43, 0x05, 0x43, 0x05};
static void bla_periodic_work(struct work_struct *work); static void batadv_bla_periodic_work(struct work_struct *work);
static void bla_send_announce(struct bat_priv *bat_priv, static void batadv_bla_send_announce(struct bat_priv *bat_priv,
struct backbone_gw *backbone_gw); struct backbone_gw *backbone_gw);
/* return the index of the claim */ /* return the index of the claim */
static inline uint32_t choose_claim(const void *data, uint32_t size) static inline uint32_t batadv_choose_claim(const void *data, uint32_t size)
{ {
const unsigned char *key = data; const unsigned char *key = data;
uint32_t hash = 0; uint32_t hash = 0;
...@@ -58,7 +58,8 @@ static inline uint32_t choose_claim(const void *data, uint32_t size) ...@@ -58,7 +58,8 @@ static inline uint32_t choose_claim(const void *data, uint32_t size)
} }
/* return the index of the backbone gateway */ /* return the index of the backbone gateway */
static inline uint32_t choose_backbone_gw(const void *data, uint32_t size) static inline uint32_t batadv_choose_backbone_gw(const void *data,
uint32_t size)
{ {
const unsigned char *key = data; const unsigned char *key = data;
uint32_t hash = 0; uint32_t hash = 0;
...@@ -79,7 +80,8 @@ static inline uint32_t choose_backbone_gw(const void *data, uint32_t size) ...@@ -79,7 +80,8 @@ static inline uint32_t choose_backbone_gw(const void *data, uint32_t size)
/* compares address and vid of two backbone gws */ /* compares address and vid of two backbone gws */
static int compare_backbone_gw(const struct hlist_node *node, const void *data2) static int batadv_compare_backbone_gw(const struct hlist_node *node,
const void *data2)
{ {
const void *data1 = container_of(node, struct backbone_gw, const void *data1 = container_of(node, struct backbone_gw,
hash_entry); hash_entry);
...@@ -88,7 +90,8 @@ static int compare_backbone_gw(const struct hlist_node *node, const void *data2) ...@@ -88,7 +90,8 @@ static int compare_backbone_gw(const struct hlist_node *node, const void *data2)
} }
/* compares address and vid of two claims */ /* compares address and vid of two claims */
static int compare_claim(const struct hlist_node *node, const void *data2) static int batadv_compare_claim(const struct hlist_node *node,
const void *data2)
{ {
const void *data1 = container_of(node, struct claim, const void *data1 = container_of(node, struct claim,
hash_entry); hash_entry);
...@@ -97,28 +100,28 @@ static int compare_claim(const struct hlist_node *node, const void *data2) ...@@ -97,28 +100,28 @@ static int compare_claim(const struct hlist_node *node, const void *data2)
} }
/* free a backbone gw */ /* free a backbone gw */
static void backbone_gw_free_ref(struct backbone_gw *backbone_gw) static void batadv_backbone_gw_free_ref(struct backbone_gw *backbone_gw)
{ {
if (atomic_dec_and_test(&backbone_gw->refcount)) if (atomic_dec_and_test(&backbone_gw->refcount))
kfree_rcu(backbone_gw, rcu); kfree_rcu(backbone_gw, rcu);
} }
/* finally deinitialize the claim */ /* finally deinitialize the claim */
static void claim_free_rcu(struct rcu_head *rcu) static void batadv_claim_free_rcu(struct rcu_head *rcu)
{ {
struct claim *claim; struct claim *claim;
claim = container_of(rcu, struct claim, rcu); claim = container_of(rcu, struct claim, rcu);
backbone_gw_free_ref(claim->backbone_gw); batadv_backbone_gw_free_ref(claim->backbone_gw);
kfree(claim); kfree(claim);
} }
/* free a claim, call claim_free_rcu if its the last reference */ /* free a claim, call claim_free_rcu if its the last reference */
static void claim_free_ref(struct claim *claim) static void batadv_claim_free_ref(struct claim *claim)
{ {
if (atomic_dec_and_test(&claim->refcount)) if (atomic_dec_and_test(&claim->refcount))
call_rcu(&claim->rcu, claim_free_rcu); call_rcu(&claim->rcu, batadv_claim_free_rcu);
} }
/* @bat_priv: the bat priv with all the soft interface information /* @bat_priv: the bat priv with all the soft interface information
...@@ -127,7 +130,7 @@ static void claim_free_ref(struct claim *claim) ...@@ -127,7 +130,7 @@ static void claim_free_ref(struct claim *claim)
* looks for a claim in the hash, and returns it if found * looks for a claim in the hash, and returns it if found
* or NULL otherwise. * or NULL otherwise.
*/ */
static struct claim *claim_hash_find(struct bat_priv *bat_priv, static struct claim *batadv_claim_hash_find(struct bat_priv *bat_priv,
struct claim *data) struct claim *data)
{ {
struct hashtable_t *hash = bat_priv->claim_hash; struct hashtable_t *hash = bat_priv->claim_hash;
...@@ -140,12 +143,12 @@ static struct claim *claim_hash_find(struct bat_priv *bat_priv, ...@@ -140,12 +143,12 @@ static struct claim *claim_hash_find(struct bat_priv *bat_priv,
if (!hash) if (!hash)
return NULL; return NULL;
index = choose_claim(data, hash->size); index = batadv_choose_claim(data, hash->size);
head = &hash->table[index]; head = &hash->table[index];
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(claim, node, head, hash_entry) { hlist_for_each_entry_rcu(claim, node, head, hash_entry) {
if (!compare_claim(&claim->hash_entry, data)) if (!batadv_compare_claim(&claim->hash_entry, data))
continue; continue;
if (!atomic_inc_not_zero(&claim->refcount)) if (!atomic_inc_not_zero(&claim->refcount))
...@@ -166,7 +169,7 @@ static struct claim *claim_hash_find(struct bat_priv *bat_priv, ...@@ -166,7 +169,7 @@ static struct claim *claim_hash_find(struct bat_priv *bat_priv,
* looks for a claim in the hash, and returns it if found * looks for a claim in the hash, and returns it if found
* or NULL otherwise. * or NULL otherwise.
*/ */
static struct backbone_gw *backbone_hash_find(struct bat_priv *bat_priv, static struct backbone_gw *batadv_backbone_hash_find(struct bat_priv *bat_priv,
uint8_t *addr, short vid) uint8_t *addr, short vid)
{ {
struct hashtable_t *hash = bat_priv->backbone_hash; struct hashtable_t *hash = bat_priv->backbone_hash;
...@@ -182,12 +185,12 @@ static struct backbone_gw *backbone_hash_find(struct bat_priv *bat_priv, ...@@ -182,12 +185,12 @@ static struct backbone_gw *backbone_hash_find(struct bat_priv *bat_priv,
memcpy(search_entry.orig, addr, ETH_ALEN); memcpy(search_entry.orig, addr, ETH_ALEN);
search_entry.vid = vid; search_entry.vid = vid;
index = choose_backbone_gw(&search_entry, hash->size); index = batadv_choose_backbone_gw(&search_entry, hash->size);
head = &hash->table[index]; head = &hash->table[index];
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) {
if (!compare_backbone_gw(&backbone_gw->hash_entry, if (!batadv_compare_backbone_gw(&backbone_gw->hash_entry,
&search_entry)) &search_entry))
continue; continue;
...@@ -203,7 +206,7 @@ static struct backbone_gw *backbone_hash_find(struct bat_priv *bat_priv, ...@@ -203,7 +206,7 @@ static struct backbone_gw *backbone_hash_find(struct bat_priv *bat_priv,
} }
/* delete all claims for a backbone */ /* delete all claims for a backbone */
static void bla_del_backbone_claims(struct backbone_gw *backbone_gw) static void batadv_bla_del_backbone_claims(struct backbone_gw *backbone_gw)
{ {
struct hashtable_t *hash; struct hashtable_t *hash;
struct hlist_node *node, *node_tmp; struct hlist_node *node, *node_tmp;
...@@ -227,7 +230,7 @@ static void bla_del_backbone_claims(struct backbone_gw *backbone_gw) ...@@ -227,7 +230,7 @@ static void bla_del_backbone_claims(struct backbone_gw *backbone_gw)
if (claim->backbone_gw != backbone_gw) if (claim->backbone_gw != backbone_gw)
continue; continue;
claim_free_ref(claim); batadv_claim_free_ref(claim);
hlist_del_rcu(node); hlist_del_rcu(node);
} }
spin_unlock_bh(list_lock); spin_unlock_bh(list_lock);
...@@ -244,7 +247,7 @@ static void bla_del_backbone_claims(struct backbone_gw *backbone_gw) ...@@ -244,7 +247,7 @@ static void bla_del_backbone_claims(struct backbone_gw *backbone_gw)
* *
* sends a claim frame according to the provided info. * sends a claim frame according to the provided info.
*/ */
static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, static void batadv_bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
short vid, int claimtype) short vid, int claimtype)
{ {
struct sk_buff *skb; struct sk_buff *skb;
...@@ -255,7 +258,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, ...@@ -255,7 +258,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
struct bla_claim_dst local_claim_dest; struct bla_claim_dst local_claim_dest;
__be32 zeroip = 0; __be32 zeroip = 0;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
return; return;
...@@ -294,7 +297,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, ...@@ -294,7 +297,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
* set Ethernet SRC to the clients mac * set Ethernet SRC to the clients mac
*/ */
memcpy(ethhdr->h_source, mac, ETH_ALEN); memcpy(ethhdr->h_source, mac, ETH_ALEN);
bat_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
"bla_send_claim(): CLAIM %pM on vid %d\n", mac, vid); "bla_send_claim(): CLAIM %pM on vid %d\n", mac, vid);
break; break;
case CLAIM_TYPE_DEL: case CLAIM_TYPE_DEL:
...@@ -302,15 +305,16 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, ...@@ -302,15 +305,16 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
* set HW SRC to the clients mac * set HW SRC to the clients mac
*/ */
memcpy(hw_src, mac, ETH_ALEN); memcpy(hw_src, mac, ETH_ALEN);
bat_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
"bla_send_claim(): UNCLAIM %pM on vid %d\n", mac, vid); "bla_send_claim(): UNCLAIM %pM on vid %d\n", mac,
vid);
break; break;
case CLAIM_TYPE_ANNOUNCE: case CLAIM_TYPE_ANNOUNCE:
/* announcement frame /* announcement frame
* set HW SRC to the special mac containg the crc * set HW SRC to the special mac containg the crc
*/ */
memcpy(hw_src, mac, ETH_ALEN); memcpy(hw_src, mac, ETH_ALEN);
bat_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
"bla_send_claim(): ANNOUNCE of %pM on vid %d\n", "bla_send_claim(): ANNOUNCE of %pM on vid %d\n",
ethhdr->h_source, vid); ethhdr->h_source, vid);
break; break;
...@@ -320,7 +324,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, ...@@ -320,7 +324,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
*/ */
memcpy(hw_src, mac, ETH_ALEN); memcpy(hw_src, mac, ETH_ALEN);
memcpy(ethhdr->h_dest, mac, ETH_ALEN); memcpy(ethhdr->h_dest, mac, ETH_ALEN);
bat_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
"bla_send_claim(): REQUEST of %pM to %pMon vid %d\n", "bla_send_claim(): REQUEST of %pM to %pMon vid %d\n",
ethhdr->h_source, ethhdr->h_dest, vid); ethhdr->h_source, ethhdr->h_dest, vid);
break; break;
...@@ -339,7 +343,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, ...@@ -339,7 +343,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
netif_rx(skb); netif_rx(skb);
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
} }
/* @bat_priv: the bat priv with all the soft interface information /* @bat_priv: the bat priv with all the soft interface information
...@@ -349,19 +353,19 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, ...@@ -349,19 +353,19 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
* searches for the backbone gw or creates a new one if it could not * searches for the backbone gw or creates a new one if it could not
* be found. * be found.
*/ */
static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv, static struct backbone_gw *batadv_bla_get_backbone_gw(struct bat_priv *bat_priv,
uint8_t *orig, short vid) uint8_t *orig, short vid)
{ {
struct backbone_gw *entry; struct backbone_gw *entry;
struct orig_node *orig_node; struct orig_node *orig_node;
int hash_added; int hash_added;
entry = backbone_hash_find(bat_priv, orig, vid); entry = batadv_backbone_hash_find(bat_priv, orig, vid);
if (entry) if (entry)
return entry; return entry;
bat_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
"bla_get_backbone_gw(): not found (%pM, %d), creating new entry\n", "bla_get_backbone_gw(): not found (%pM, %d), creating new entry\n",
orig, vid); orig, vid);
...@@ -379,8 +383,10 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv, ...@@ -379,8 +383,10 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv,
/* one for the hash, one for returning */ /* one for the hash, one for returning */
atomic_set(&entry->refcount, 2); atomic_set(&entry->refcount, 2);
hash_added = hash_add(bat_priv->backbone_hash, compare_backbone_gw, hash_added = batadv_hash_add(bat_priv->backbone_hash,
choose_backbone_gw, entry, &entry->hash_entry); batadv_compare_backbone_gw,
batadv_choose_backbone_gw, entry,
&entry->hash_entry);
if (unlikely(hash_added != 0)) { if (unlikely(hash_added != 0)) {
/* hash failed, free the structure */ /* hash failed, free the structure */
...@@ -389,7 +395,7 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv, ...@@ -389,7 +395,7 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv,
} }
/* this is a gateway now, remove any tt entries */ /* this is a gateway now, remove any tt entries */
orig_node = orig_hash_find(bat_priv, orig); orig_node = batadv_orig_hash_find(bat_priv, orig);
if (orig_node) { if (orig_node) {
batadv_tt_global_del_orig(bat_priv, orig_node, batadv_tt_global_del_orig(bat_priv, orig_node,
"became a backbone gateway"); "became a backbone gateway");
...@@ -401,19 +407,20 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv, ...@@ -401,19 +407,20 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv,
/* update or add the own backbone gw to make sure we announce /* update or add the own backbone gw to make sure we announce
* where we receive other backbone gws * where we receive other backbone gws
*/ */
static void bla_update_own_backbone_gw(struct bat_priv *bat_priv, static void batadv_bla_update_own_backbone_gw(struct bat_priv *bat_priv,
struct hard_iface *primary_if, struct hard_iface *primary_if,
short vid) short vid)
{ {
struct backbone_gw *backbone_gw; struct backbone_gw *backbone_gw;
backbone_gw = bla_get_backbone_gw(bat_priv, backbone_gw = batadv_bla_get_backbone_gw(bat_priv,
primary_if->net_dev->dev_addr, vid); primary_if->net_dev->dev_addr,
vid);
if (unlikely(!backbone_gw)) if (unlikely(!backbone_gw))
return; return;
backbone_gw->lasttime = jiffies; backbone_gw->lasttime = jiffies;
backbone_gw_free_ref(backbone_gw); batadv_backbone_gw_free_ref(backbone_gw);
} }
/* @bat_priv: the bat priv with all the soft interface information /* @bat_priv: the bat priv with all the soft interface information
...@@ -422,7 +429,7 @@ static void bla_update_own_backbone_gw(struct bat_priv *bat_priv, ...@@ -422,7 +429,7 @@ static void bla_update_own_backbone_gw(struct bat_priv *bat_priv,
* Repeat all of our own claims, and finally send an ANNOUNCE frame * Repeat all of our own claims, and finally send an ANNOUNCE frame
* to allow the requester another check if the CRC is correct now. * to allow the requester another check if the CRC is correct now.
*/ */
static void bla_answer_request(struct bat_priv *bat_priv, static void batadv_bla_answer_request(struct bat_priv *bat_priv,
struct hard_iface *primary_if, short vid) struct hard_iface *primary_if, short vid)
{ {
struct hlist_node *node; struct hlist_node *node;
...@@ -432,11 +439,12 @@ static void bla_answer_request(struct bat_priv *bat_priv, ...@@ -432,11 +439,12 @@ static void bla_answer_request(struct bat_priv *bat_priv,
struct backbone_gw *backbone_gw; struct backbone_gw *backbone_gw;
int i; int i;
bat_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
"bla_answer_request(): received a claim request, send all of our own claims again\n"); "bla_answer_request(): received a claim request, send all of our own claims again\n");
backbone_gw = backbone_hash_find(bat_priv, backbone_gw = batadv_backbone_hash_find(bat_priv,
primary_if->net_dev->dev_addr, vid); primary_if->net_dev->dev_addr,
vid);
if (!backbone_gw) if (!backbone_gw)
return; return;
...@@ -450,15 +458,15 @@ static void bla_answer_request(struct bat_priv *bat_priv, ...@@ -450,15 +458,15 @@ static void bla_answer_request(struct bat_priv *bat_priv,
if (claim->backbone_gw != backbone_gw) if (claim->backbone_gw != backbone_gw)
continue; continue;
bla_send_claim(bat_priv, claim->addr, claim->vid, batadv_bla_send_claim(bat_priv, claim->addr, claim->vid,
CLAIM_TYPE_ADD); CLAIM_TYPE_ADD);
} }
rcu_read_unlock(); rcu_read_unlock();
} }
/* finally, send an announcement frame */ /* finally, send an announcement frame */
bla_send_announce(bat_priv, backbone_gw); batadv_bla_send_announce(bat_priv, backbone_gw);
backbone_gw_free_ref(backbone_gw); batadv_backbone_gw_free_ref(backbone_gw);
} }
/* @backbone_gw: the backbone gateway from whom we are out of sync /* @backbone_gw: the backbone gateway from whom we are out of sync
...@@ -467,17 +475,16 @@ static void bla_answer_request(struct bat_priv *bat_priv, ...@@ -467,17 +475,16 @@ static void bla_answer_request(struct bat_priv *bat_priv,
* After the request, it will repeat all of his own claims and finally * After the request, it will repeat all of his own claims and finally
* send an announcement claim with which we can check again. * send an announcement claim with which we can check again.
*/ */
static void bla_send_request(struct backbone_gw *backbone_gw) static void batadv_bla_send_request(struct backbone_gw *backbone_gw)
{ {
/* first, remove all old entries */ /* first, remove all old entries */
bla_del_backbone_claims(backbone_gw); batadv_bla_del_backbone_claims(backbone_gw);
bat_dbg(DBG_BLA, backbone_gw->bat_priv, batadv_dbg(DBG_BLA, backbone_gw->bat_priv, "Sending REQUEST to %pM\n",
"Sending REQUEST to %pM\n",
backbone_gw->orig); backbone_gw->orig);
/* send request */ /* send request */
bla_send_claim(backbone_gw->bat_priv, backbone_gw->orig, batadv_bla_send_claim(backbone_gw->bat_priv, backbone_gw->orig,
backbone_gw->vid, CLAIM_TYPE_REQUEST); backbone_gw->vid, CLAIM_TYPE_REQUEST);
/* no local broadcasts should be sent or received, for now. */ /* no local broadcasts should be sent or received, for now. */
...@@ -493,17 +500,18 @@ static void bla_send_request(struct backbone_gw *backbone_gw) ...@@ -493,17 +500,18 @@ static void bla_send_request(struct backbone_gw *backbone_gw)
* This function sends an announcement. It is called from multiple * This function sends an announcement. It is called from multiple
* places. * places.
*/ */
static void bla_send_announce(struct bat_priv *bat_priv, static void batadv_bla_send_announce(struct bat_priv *bat_priv,
struct backbone_gw *backbone_gw) struct backbone_gw *backbone_gw)
{ {
uint8_t mac[ETH_ALEN]; uint8_t mac[ETH_ALEN];
__be16 crc; __be16 crc;
memcpy(mac, announce_mac, 4); memcpy(mac, batadv_announce_mac, 4);
crc = htons(backbone_gw->crc); crc = htons(backbone_gw->crc);
memcpy(&mac[4], &crc, 2); memcpy(&mac[4], &crc, 2);
bla_send_claim(bat_priv, mac, backbone_gw->vid, CLAIM_TYPE_ANNOUNCE); batadv_bla_send_claim(bat_priv, mac, backbone_gw->vid,
CLAIM_TYPE_ANNOUNCE);
} }
...@@ -514,8 +522,9 @@ static void bla_send_announce(struct bat_priv *bat_priv, ...@@ -514,8 +522,9 @@ static void bla_send_announce(struct bat_priv *bat_priv,
* *
* Adds a claim in the claim hash. * Adds a claim in the claim hash.
*/ */
static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac, static void batadv_bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
const short vid, struct backbone_gw *backbone_gw) const short vid,
struct backbone_gw *backbone_gw)
{ {
struct claim *claim; struct claim *claim;
struct claim search_claim; struct claim search_claim;
...@@ -523,7 +532,7 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac, ...@@ -523,7 +532,7 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
memcpy(search_claim.addr, mac, ETH_ALEN); memcpy(search_claim.addr, mac, ETH_ALEN);
search_claim.vid = vid; search_claim.vid = vid;
claim = claim_hash_find(bat_priv, &search_claim); claim = batadv_claim_hash_find(bat_priv, &search_claim);
/* create a new claim entry if it does not exist yet. */ /* create a new claim entry if it does not exist yet. */
if (!claim) { if (!claim) {
...@@ -537,11 +546,13 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac, ...@@ -537,11 +546,13 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
claim->backbone_gw = backbone_gw; claim->backbone_gw = backbone_gw;
atomic_set(&claim->refcount, 2); atomic_set(&claim->refcount, 2);
bat_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
"bla_add_claim(): adding new entry %pM, vid %d to hash ...\n", "bla_add_claim(): adding new entry %pM, vid %d to hash ...\n",
mac, vid); mac, vid);
hash_added = hash_add(bat_priv->claim_hash, compare_claim, hash_added = batadv_hash_add(bat_priv->claim_hash,
choose_claim, claim, &claim->hash_entry); batadv_compare_claim,
batadv_choose_claim, claim,
&claim->hash_entry);
if (unlikely(hash_added != 0)) { if (unlikely(hash_added != 0)) {
/* only local changes happened. */ /* only local changes happened. */
...@@ -554,13 +565,13 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac, ...@@ -554,13 +565,13 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
/* no need to register a new backbone */ /* no need to register a new backbone */
goto claim_free_ref; goto claim_free_ref;
bat_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
"bla_add_claim(): changing ownership for %pM, vid %d\n", "bla_add_claim(): changing ownership for %pM, vid %d\n",
mac, vid); mac, vid);
claim->backbone_gw->crc ^= claim->backbone_gw->crc ^=
crc16(0, claim->addr, ETH_ALEN); crc16(0, claim->addr, ETH_ALEN);
backbone_gw_free_ref(claim->backbone_gw); batadv_backbone_gw_free_ref(claim->backbone_gw);
} }
/* set (new) backbone gw */ /* set (new) backbone gw */
...@@ -571,45 +582,48 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac, ...@@ -571,45 +582,48 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
backbone_gw->lasttime = jiffies; backbone_gw->lasttime = jiffies;
claim_free_ref: claim_free_ref:
claim_free_ref(claim); batadv_claim_free_ref(claim);
} }
/* Delete a claim from the claim hash which has the /* Delete a claim from the claim hash which has the
* given mac address and vid. * given mac address and vid.
*/ */
static void bla_del_claim(struct bat_priv *bat_priv, const uint8_t *mac, static void batadv_bla_del_claim(struct bat_priv *bat_priv, const uint8_t *mac,
const short vid) const short vid)
{ {
struct claim search_claim, *claim; struct claim search_claim, *claim;
memcpy(search_claim.addr, mac, ETH_ALEN); memcpy(search_claim.addr, mac, ETH_ALEN);
search_claim.vid = vid; search_claim.vid = vid;
claim = claim_hash_find(bat_priv, &search_claim); claim = batadv_claim_hash_find(bat_priv, &search_claim);
if (!claim) if (!claim)
return; return;
bat_dbg(DBG_BLA, bat_priv, "bla_del_claim(): %pM, vid %d\n", mac, vid); batadv_dbg(DBG_BLA, bat_priv, "bla_del_claim(): %pM, vid %d\n", mac,
vid);
hash_remove(bat_priv->claim_hash, compare_claim, choose_claim, claim); batadv_hash_remove(bat_priv->claim_hash, batadv_compare_claim,
claim_free_ref(claim); /* reference from the hash is gone */ batadv_choose_claim, claim);
batadv_claim_free_ref(claim); /* reference from the hash is gone */
claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN); claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
/* don't need the reference from hash_find() anymore */ /* don't need the reference from hash_find() anymore */
claim_free_ref(claim); batadv_claim_free_ref(claim);
} }
/* check for ANNOUNCE frame, return 1 if handled */ /* check for ANNOUNCE frame, return 1 if handled */
static int handle_announce(struct bat_priv *bat_priv, static int batadv_handle_announce(struct bat_priv *bat_priv,
uint8_t *an_addr, uint8_t *backbone_addr, short vid) uint8_t *an_addr, uint8_t *backbone_addr,
short vid)
{ {
struct backbone_gw *backbone_gw; struct backbone_gw *backbone_gw;
uint16_t crc; uint16_t crc;
if (memcmp(an_addr, announce_mac, 4) != 0) if (memcmp(an_addr, batadv_announce_mac, 4) != 0)
return 0; return 0;
backbone_gw = bla_get_backbone_gw(bat_priv, backbone_addr, vid); backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid);
if (unlikely(!backbone_gw)) if (unlikely(!backbone_gw))
return 1; return 1;
...@@ -619,17 +633,17 @@ static int handle_announce(struct bat_priv *bat_priv, ...@@ -619,17 +633,17 @@ static int handle_announce(struct bat_priv *bat_priv,
backbone_gw->lasttime = jiffies; backbone_gw->lasttime = jiffies;
crc = ntohs(*((__be16 *)(&an_addr[4]))); crc = ntohs(*((__be16 *)(&an_addr[4])));
bat_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
"handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = %04x\n", "handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = %04x\n",
vid, backbone_gw->orig, crc); vid, backbone_gw->orig, crc);
if (backbone_gw->crc != crc) { if (backbone_gw->crc != crc) {
bat_dbg(DBG_BLA, backbone_gw->bat_priv, batadv_dbg(DBG_BLA, backbone_gw->bat_priv,
"handle_announce(): CRC FAILED for %pM/%d (my = %04x, sent = %04x)\n", "handle_announce(): CRC FAILED for %pM/%d (my = %04x, sent = %04x)\n",
backbone_gw->orig, backbone_gw->vid, backbone_gw->crc, backbone_gw->orig, backbone_gw->vid,
crc); backbone_gw->crc, crc);
bla_send_request(backbone_gw); batadv_bla_send_request(backbone_gw);
} else { } else {
/* if we have sent a request and the crc was OK, /* if we have sent a request and the crc was OK,
* we can allow traffic again. * we can allow traffic again.
...@@ -640,36 +654,36 @@ static int handle_announce(struct bat_priv *bat_priv, ...@@ -640,36 +654,36 @@ static int handle_announce(struct bat_priv *bat_priv,
} }
} }
backbone_gw_free_ref(backbone_gw); batadv_backbone_gw_free_ref(backbone_gw);
return 1; return 1;
} }
/* check for REQUEST frame, return 1 if handled */ /* check for REQUEST frame, return 1 if handled */
static int handle_request(struct bat_priv *bat_priv, static int batadv_handle_request(struct bat_priv *bat_priv,
struct hard_iface *primary_if, struct hard_iface *primary_if,
uint8_t *backbone_addr, uint8_t *backbone_addr,
struct ethhdr *ethhdr, short vid) struct ethhdr *ethhdr, short vid)
{ {
/* check for REQUEST frame */ /* check for REQUEST frame */
if (!compare_eth(backbone_addr, ethhdr->h_dest)) if (!batadv_compare_eth(backbone_addr, ethhdr->h_dest))
return 0; return 0;
/* sanity check, this should not happen on a normal switch, /* sanity check, this should not happen on a normal switch,
* we ignore it in this case. * we ignore it in this case.
*/ */
if (!compare_eth(ethhdr->h_dest, primary_if->net_dev->dev_addr)) if (!batadv_compare_eth(ethhdr->h_dest, primary_if->net_dev->dev_addr))
return 1; return 1;
bat_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
"handle_request(): REQUEST vid %d (sent by %pM)...\n", "handle_request(): REQUEST vid %d (sent by %pM)...\n",
vid, ethhdr->h_source); vid, ethhdr->h_source);
bla_answer_request(bat_priv, primary_if, vid); batadv_bla_answer_request(bat_priv, primary_if, vid);
return 1; return 1;
} }
/* check for UNCLAIM frame, return 1 if handled */ /* check for UNCLAIM frame, return 1 if handled */
static int handle_unclaim(struct bat_priv *bat_priv, static int batadv_handle_unclaim(struct bat_priv *bat_priv,
struct hard_iface *primary_if, struct hard_iface *primary_if,
uint8_t *backbone_addr, uint8_t *backbone_addr,
uint8_t *claim_addr, short vid) uint8_t *claim_addr, short vid)
...@@ -677,47 +691,50 @@ static int handle_unclaim(struct bat_priv *bat_priv, ...@@ -677,47 +691,50 @@ static int handle_unclaim(struct bat_priv *bat_priv,
struct backbone_gw *backbone_gw; struct backbone_gw *backbone_gw;
/* unclaim in any case if it is our own */ /* unclaim in any case if it is our own */
if (primary_if && compare_eth(backbone_addr, if (primary_if && batadv_compare_eth(backbone_addr,
primary_if->net_dev->dev_addr)) primary_if->net_dev->dev_addr))
bla_send_claim(bat_priv, claim_addr, vid, CLAIM_TYPE_DEL); batadv_bla_send_claim(bat_priv, claim_addr, vid,
CLAIM_TYPE_DEL);
backbone_gw = backbone_hash_find(bat_priv, backbone_addr, vid); backbone_gw = batadv_backbone_hash_find(bat_priv, backbone_addr, vid);
if (!backbone_gw) if (!backbone_gw)
return 1; return 1;
/* this must be an UNCLAIM frame */ /* this must be an UNCLAIM frame */
bat_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
"handle_unclaim(): UNCLAIM %pM on vid %d (sent by %pM)...\n", "handle_unclaim(): UNCLAIM %pM on vid %d (sent by %pM)...\n",
claim_addr, vid, backbone_gw->orig); claim_addr, vid, backbone_gw->orig);
bla_del_claim(bat_priv, claim_addr, vid); batadv_bla_del_claim(bat_priv, claim_addr, vid);
backbone_gw_free_ref(backbone_gw); batadv_backbone_gw_free_ref(backbone_gw);
return 1; return 1;
} }
/* check for CLAIM frame, return 1 if handled */ /* check for CLAIM frame, return 1 if handled */
static int handle_claim(struct bat_priv *bat_priv, static int batadv_handle_claim(struct bat_priv *bat_priv,
struct hard_iface *primary_if, uint8_t *backbone_addr, struct hard_iface *primary_if,
uint8_t *claim_addr, short vid) uint8_t *backbone_addr, uint8_t *claim_addr,
short vid)
{ {
struct backbone_gw *backbone_gw; struct backbone_gw *backbone_gw;
/* register the gateway if not yet available, and add the claim. */ /* register the gateway if not yet available, and add the claim. */
backbone_gw = bla_get_backbone_gw(bat_priv, backbone_addr, vid); backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid);
if (unlikely(!backbone_gw)) if (unlikely(!backbone_gw))
return 1; return 1;
/* this must be a CLAIM frame */ /* this must be a CLAIM frame */
bla_add_claim(bat_priv, claim_addr, vid, backbone_gw); batadv_bla_add_claim(bat_priv, claim_addr, vid, backbone_gw);
if (compare_eth(backbone_addr, primary_if->net_dev->dev_addr)) if (batadv_compare_eth(backbone_addr, primary_if->net_dev->dev_addr))
bla_send_claim(bat_priv, claim_addr, vid, CLAIM_TYPE_ADD); batadv_bla_send_claim(bat_priv, claim_addr, vid,
CLAIM_TYPE_ADD);
/* TODO: we could call something like tt_local_del() here. */ /* TODO: we could call something like tt_local_del() here. */
backbone_gw_free_ref(backbone_gw); batadv_backbone_gw_free_ref(backbone_gw);
return 1; return 1;
} }
...@@ -735,7 +752,7 @@ static int handle_claim(struct bat_priv *bat_priv, ...@@ -735,7 +752,7 @@ static int handle_claim(struct bat_priv *bat_priv,
* 1 - if is a claim packet from another group * 1 - if is a claim packet from another group
* 0 - if it is not a claim packet * 0 - if it is not a claim packet
*/ */
static int check_claim_group(struct bat_priv *bat_priv, static int batadv_check_claim_group(struct bat_priv *bat_priv,
struct hard_iface *primary_if, struct hard_iface *primary_if,
uint8_t *hw_src, uint8_t *hw_dst, uint8_t *hw_src, uint8_t *hw_dst,
struct ethhdr *ethhdr) struct ethhdr *ethhdr)
...@@ -769,7 +786,7 @@ static int check_claim_group(struct bat_priv *bat_priv, ...@@ -769,7 +786,7 @@ static int check_claim_group(struct bat_priv *bat_priv,
} }
/* don't accept claim frames from ourselves */ /* don't accept claim frames from ourselves */
if (compare_eth(backbone_addr, primary_if->net_dev->dev_addr)) if (batadv_compare_eth(backbone_addr, primary_if->net_dev->dev_addr))
return 0; return 0;
/* if its already the same group, it is fine. */ /* if its already the same group, it is fine. */
...@@ -777,7 +794,7 @@ static int check_claim_group(struct bat_priv *bat_priv, ...@@ -777,7 +794,7 @@ static int check_claim_group(struct bat_priv *bat_priv,
return 2; return 2;
/* lets see if this originator is in our mesh */ /* lets see if this originator is in our mesh */
orig_node = orig_hash_find(bat_priv, backbone_addr); orig_node = batadv_orig_hash_find(bat_priv, backbone_addr);
/* dont accept claims from gateways which are not in /* dont accept claims from gateways which are not in
* the same mesh or group. * the same mesh or group.
...@@ -787,7 +804,7 @@ static int check_claim_group(struct bat_priv *bat_priv, ...@@ -787,7 +804,7 @@ static int check_claim_group(struct bat_priv *bat_priv,
/* if our mesh friends mac is bigger, use it for ourselves. */ /* if our mesh friends mac is bigger, use it for ourselves. */
if (ntohs(bla_dst->group) > ntohs(bla_dst_own->group)) { if (ntohs(bla_dst->group) > ntohs(bla_dst_own->group)) {
bat_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
"taking other backbones claim group: %04x\n", "taking other backbones claim group: %04x\n",
ntohs(bla_dst->group)); ntohs(bla_dst->group));
bla_dst_own->group = bla_dst->group; bla_dst_own->group = bla_dst->group;
...@@ -807,7 +824,7 @@ static int check_claim_group(struct bat_priv *bat_priv, ...@@ -807,7 +824,7 @@ static int check_claim_group(struct bat_priv *bat_priv,
* returns 1 if it was a claim frame, otherwise return 0 to * returns 1 if it was a claim frame, otherwise return 0 to
* tell the callee that it can use the frame on its own. * tell the callee that it can use the frame on its own.
*/ */
static int bla_process_claim(struct bat_priv *bat_priv, static int batadv_bla_process_claim(struct bat_priv *bat_priv,
struct hard_iface *primary_if, struct hard_iface *primary_if,
struct sk_buff *skb) struct sk_buff *skb)
{ {
...@@ -862,9 +879,10 @@ static int bla_process_claim(struct bat_priv *bat_priv, ...@@ -862,9 +879,10 @@ static int bla_process_claim(struct bat_priv *bat_priv,
bla_dst = (struct bla_claim_dst *)hw_dst; bla_dst = (struct bla_claim_dst *)hw_dst;
/* check if it is a claim frame. */ /* check if it is a claim frame. */
ret = check_claim_group(bat_priv, primary_if, hw_src, hw_dst, ethhdr); ret = batadv_check_claim_group(bat_priv, primary_if, hw_src, hw_dst,
ethhdr);
if (ret == 1) if (ret == 1)
bat_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
"bla_process_claim(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n", "bla_process_claim(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
ethhdr->h_source, vid, hw_src, hw_dst); ethhdr->h_source, vid, hw_src, hw_dst);
...@@ -872,32 +890,34 @@ static int bla_process_claim(struct bat_priv *bat_priv, ...@@ -872,32 +890,34 @@ static int bla_process_claim(struct bat_priv *bat_priv,
return ret; return ret;
/* become a backbone gw ourselves on this vlan if not happened yet */ /* become a backbone gw ourselves on this vlan if not happened yet */
bla_update_own_backbone_gw(bat_priv, primary_if, vid); batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
/* check for the different types of claim frames ... */ /* check for the different types of claim frames ... */
switch (bla_dst->type) { switch (bla_dst->type) {
case CLAIM_TYPE_ADD: case CLAIM_TYPE_ADD:
if (handle_claim(bat_priv, primary_if, hw_src, if (batadv_handle_claim(bat_priv, primary_if, hw_src,
ethhdr->h_source, vid)) ethhdr->h_source, vid))
return 1; return 1;
break; break;
case CLAIM_TYPE_DEL: case CLAIM_TYPE_DEL:
if (handle_unclaim(bat_priv, primary_if, if (batadv_handle_unclaim(bat_priv, primary_if,
ethhdr->h_source, hw_src, vid)) ethhdr->h_source, hw_src, vid))
return 1; return 1;
break; break;
case CLAIM_TYPE_ANNOUNCE: case CLAIM_TYPE_ANNOUNCE:
if (handle_announce(bat_priv, hw_src, ethhdr->h_source, vid)) if (batadv_handle_announce(bat_priv, hw_src, ethhdr->h_source,
vid))
return 1; return 1;
break; break;
case CLAIM_TYPE_REQUEST: case CLAIM_TYPE_REQUEST:
if (handle_request(bat_priv, primary_if, hw_src, ethhdr, vid)) if (batadv_handle_request(bat_priv, primary_if, hw_src, ethhdr,
vid))
return 1; return 1;
break; break;
} }
bat_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
"bla_process_claim(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n", "bla_process_claim(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
ethhdr->h_source, vid, hw_src, hw_dst); ethhdr->h_source, vid, hw_src, hw_dst);
return 1; return 1;
...@@ -906,7 +926,7 @@ static int bla_process_claim(struct bat_priv *bat_priv, ...@@ -906,7 +926,7 @@ static int bla_process_claim(struct bat_priv *bat_priv,
/* Check when we last heard from other nodes, and remove them in case of /* Check when we last heard from other nodes, and remove them in case of
* a time out, or clean all backbone gws if now is set. * a time out, or clean all backbone gws if now is set.
*/ */
static void bla_purge_backbone_gw(struct bat_priv *bat_priv, int now) static void batadv_bla_purge_backbone_gw(struct bat_priv *bat_priv, int now)
{ {
struct backbone_gw *backbone_gw; struct backbone_gw *backbone_gw;
struct hlist_node *node, *node_tmp; struct hlist_node *node, *node_tmp;
...@@ -928,11 +948,11 @@ static void bla_purge_backbone_gw(struct bat_priv *bat_priv, int now) ...@@ -928,11 +948,11 @@ static void bla_purge_backbone_gw(struct bat_priv *bat_priv, int now)
head, hash_entry) { head, hash_entry) {
if (now) if (now)
goto purge_now; goto purge_now;
if (!has_timed_out(backbone_gw->lasttime, if (!batadv_has_timed_out(backbone_gw->lasttime,
BLA_BACKBONE_TIMEOUT)) BLA_BACKBONE_TIMEOUT))
continue; continue;
bat_dbg(DBG_BLA, backbone_gw->bat_priv, batadv_dbg(DBG_BLA, backbone_gw->bat_priv,
"bla_purge_backbone_gw(): backbone gw %pM timed out\n", "bla_purge_backbone_gw(): backbone gw %pM timed out\n",
backbone_gw->orig); backbone_gw->orig);
...@@ -941,10 +961,10 @@ static void bla_purge_backbone_gw(struct bat_priv *bat_priv, int now) ...@@ -941,10 +961,10 @@ static void bla_purge_backbone_gw(struct bat_priv *bat_priv, int now)
if (atomic_read(&backbone_gw->request_sent)) if (atomic_read(&backbone_gw->request_sent))
atomic_dec(&bat_priv->bla_num_requests); atomic_dec(&bat_priv->bla_num_requests);
bla_del_backbone_claims(backbone_gw); batadv_bla_del_backbone_claims(backbone_gw);
hlist_del_rcu(node); hlist_del_rcu(node);
backbone_gw_free_ref(backbone_gw); batadv_backbone_gw_free_ref(backbone_gw);
} }
spin_unlock_bh(list_lock); spin_unlock_bh(list_lock);
} }
...@@ -957,7 +977,7 @@ static void bla_purge_backbone_gw(struct bat_priv *bat_priv, int now) ...@@ -957,7 +977,7 @@ static void bla_purge_backbone_gw(struct bat_priv *bat_priv, int now)
* Check when we heard last time from our own claims, and remove them in case of * Check when we heard last time from our own claims, and remove them in case of
* a time out, or clean all claims if now is set * a time out, or clean all claims if now is set
*/ */
static void bla_purge_claims(struct bat_priv *bat_priv, static void batadv_bla_purge_claims(struct bat_priv *bat_priv,
struct hard_iface *primary_if, int now) struct hard_iface *primary_if, int now)
{ {
struct claim *claim; struct claim *claim;
...@@ -977,19 +997,19 @@ static void bla_purge_claims(struct bat_priv *bat_priv, ...@@ -977,19 +997,19 @@ static void bla_purge_claims(struct bat_priv *bat_priv,
hlist_for_each_entry_rcu(claim, node, head, hash_entry) { hlist_for_each_entry_rcu(claim, node, head, hash_entry) {
if (now) if (now)
goto purge_now; goto purge_now;
if (!compare_eth(claim->backbone_gw->orig, if (!batadv_compare_eth(claim->backbone_gw->orig,
primary_if->net_dev->dev_addr)) primary_if->net_dev->dev_addr))
continue; continue;
if (!has_timed_out(claim->lasttime, if (!batadv_has_timed_out(claim->lasttime,
BLA_CLAIM_TIMEOUT)) BLA_CLAIM_TIMEOUT))
continue; continue;
bat_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
"bla_purge_claims(): %pM, vid %d, time out\n", "bla_purge_claims(): %pM, vid %d, time out\n",
claim->addr, claim->vid); claim->addr, claim->vid);
purge_now: purge_now:
handle_unclaim(bat_priv, primary_if, batadv_handle_unclaim(bat_priv, primary_if,
claim->backbone_gw->orig, claim->backbone_gw->orig,
claim->addr, claim->vid); claim->addr, claim->vid);
} }
...@@ -1018,8 +1038,8 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv, ...@@ -1018,8 +1038,8 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
htons(crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN)); htons(crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN));
if (!oldif) { if (!oldif) {
bla_purge_claims(bat_priv, NULL, 1); batadv_bla_purge_claims(bat_priv, NULL, 1);
bla_purge_backbone_gw(bat_priv, 1); batadv_bla_purge_backbone_gw(bat_priv, 1);
return; return;
} }
...@@ -1033,7 +1053,7 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv, ...@@ -1033,7 +1053,7 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) {
/* own orig still holds the old value. */ /* own orig still holds the old value. */
if (!compare_eth(backbone_gw->orig, if (!batadv_compare_eth(backbone_gw->orig,
oldif->net_dev->dev_addr)) oldif->net_dev->dev_addr))
continue; continue;
...@@ -1042,7 +1062,7 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv, ...@@ -1042,7 +1062,7 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
/* send an announce frame so others will ask for our /* send an announce frame so others will ask for our
* claims and update their tables. * claims and update their tables.
*/ */
bla_send_announce(bat_priv, backbone_gw); batadv_bla_send_announce(bat_priv, backbone_gw);
} }
rcu_read_unlock(); rcu_read_unlock();
} }
...@@ -1051,9 +1071,9 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv, ...@@ -1051,9 +1071,9 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
/* (re)start the timer */ /* (re)start the timer */
static void bla_start_timer(struct bat_priv *bat_priv) static void batadv_bla_start_timer(struct bat_priv *bat_priv)
{ {
INIT_DELAYED_WORK(&bat_priv->bla_work, bla_periodic_work); INIT_DELAYED_WORK(&bat_priv->bla_work, batadv_bla_periodic_work);
queue_delayed_work(batadv_event_workqueue, &bat_priv->bla_work, queue_delayed_work(batadv_event_workqueue, &bat_priv->bla_work,
msecs_to_jiffies(BLA_PERIOD_LENGTH)); msecs_to_jiffies(BLA_PERIOD_LENGTH));
} }
...@@ -1062,7 +1082,7 @@ static void bla_start_timer(struct bat_priv *bat_priv) ...@@ -1062,7 +1082,7 @@ static void bla_start_timer(struct bat_priv *bat_priv)
* * purge structures when they are too old * * purge structures when they are too old
* * send announcements * * send announcements
*/ */
static void bla_periodic_work(struct work_struct *work) static void batadv_bla_periodic_work(struct work_struct *work)
{ {
struct delayed_work *delayed_work = struct delayed_work *delayed_work =
container_of(work, struct delayed_work, work); container_of(work, struct delayed_work, work);
...@@ -1075,12 +1095,12 @@ static void bla_periodic_work(struct work_struct *work) ...@@ -1075,12 +1095,12 @@ static void bla_periodic_work(struct work_struct *work)
struct hard_iface *primary_if; struct hard_iface *primary_if;
int i; int i;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
bla_purge_claims(bat_priv, primary_if, 0); batadv_bla_purge_claims(bat_priv, primary_if, 0);
bla_purge_backbone_gw(bat_priv, 0); batadv_bla_purge_backbone_gw(bat_priv, 0);
if (!atomic_read(&bat_priv->bridge_loop_avoidance)) if (!atomic_read(&bat_priv->bridge_loop_avoidance))
goto out; goto out;
...@@ -1094,21 +1114,21 @@ static void bla_periodic_work(struct work_struct *work) ...@@ -1094,21 +1114,21 @@ static void bla_periodic_work(struct work_struct *work)
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) {
if (!compare_eth(backbone_gw->orig, if (!batadv_compare_eth(backbone_gw->orig,
primary_if->net_dev->dev_addr)) primary_if->net_dev->dev_addr))
continue; continue;
backbone_gw->lasttime = jiffies; backbone_gw->lasttime = jiffies;
bla_send_announce(bat_priv, backbone_gw); batadv_bla_send_announce(bat_priv, backbone_gw);
} }
rcu_read_unlock(); rcu_read_unlock();
} }
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
bla_start_timer(bat_priv); batadv_bla_start_timer(bat_priv);
} }
/* The hash for claim and backbone hash receive the same key because they /* The hash for claim and backbone hash receive the same key because they
...@@ -1116,8 +1136,8 @@ static void bla_periodic_work(struct work_struct *work) ...@@ -1116,8 +1136,8 @@ static void bla_periodic_work(struct work_struct *work)
* them with to different keys to allow nested locking without generating * them with to different keys to allow nested locking without generating
* lockdep warnings * lockdep warnings
*/ */
static struct lock_class_key claim_hash_lock_class_key; static struct lock_class_key batadv_claim_hash_lock_class_key;
static struct lock_class_key backbone_hash_lock_class_key; static struct lock_class_key batadv_backbone_hash_lock_class_key;
/* initialize all bla structures */ /* initialize all bla structures */
int batadv_bla_init(struct bat_priv *bat_priv) int batadv_bla_init(struct bat_priv *bat_priv)
...@@ -1126,17 +1146,17 @@ int batadv_bla_init(struct bat_priv *bat_priv) ...@@ -1126,17 +1146,17 @@ int batadv_bla_init(struct bat_priv *bat_priv)
uint8_t claim_dest[ETH_ALEN] = {0xff, 0x43, 0x05, 0x00, 0x00, 0x00}; uint8_t claim_dest[ETH_ALEN] = {0xff, 0x43, 0x05, 0x00, 0x00, 0x00};
struct hard_iface *primary_if; struct hard_iface *primary_if;
bat_dbg(DBG_BLA, bat_priv, "bla hash registering\n"); batadv_dbg(DBG_BLA, bat_priv, "bla hash registering\n");
/* setting claim destination address */ /* setting claim destination address */
memcpy(&bat_priv->claim_dest.magic, claim_dest, 3); memcpy(&bat_priv->claim_dest.magic, claim_dest, 3);
bat_priv->claim_dest.type = 0; bat_priv->claim_dest.type = 0;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (primary_if) { if (primary_if) {
bat_priv->claim_dest.group = bat_priv->claim_dest.group =
htons(crc16(0, primary_if->net_dev->dev_addr, htons(crc16(0, primary_if->net_dev->dev_addr,
ETH_ALEN)); ETH_ALEN));
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
} else { } else {
bat_priv->claim_dest.group = 0; /* will be set later */ bat_priv->claim_dest.group = 0; /* will be set later */
} }
...@@ -1157,13 +1177,13 @@ int batadv_bla_init(struct bat_priv *bat_priv) ...@@ -1157,13 +1177,13 @@ int batadv_bla_init(struct bat_priv *bat_priv)
return -ENOMEM; return -ENOMEM;
batadv_hash_set_lock_class(bat_priv->claim_hash, batadv_hash_set_lock_class(bat_priv->claim_hash,
&claim_hash_lock_class_key); &batadv_claim_hash_lock_class_key);
batadv_hash_set_lock_class(bat_priv->backbone_hash, batadv_hash_set_lock_class(bat_priv->backbone_hash,
&backbone_hash_lock_class_key); &batadv_backbone_hash_lock_class_key);
bat_dbg(DBG_BLA, bat_priv, "bla hashes initialized\n"); batadv_dbg(DBG_BLA, bat_priv, "bla hashes initialized\n");
bla_start_timer(bat_priv); batadv_bla_start_timer(bat_priv);
return 0; return 0;
} }
...@@ -1203,13 +1223,13 @@ int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, ...@@ -1203,13 +1223,13 @@ int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
/* we can stop searching if the entry is too old ; /* we can stop searching if the entry is too old ;
* later entries will be even older * later entries will be even older
*/ */
if (has_timed_out(entry->entrytime, DUPLIST_TIMEOUT)) if (batadv_has_timed_out(entry->entrytime, DUPLIST_TIMEOUT))
break; break;
if (entry->crc != crc) if (entry->crc != crc)
continue; continue;
if (compare_eth(entry->orig, bcast_packet->orig)) if (batadv_compare_eth(entry->orig, bcast_packet->orig))
continue; continue;
/* this entry seems to match: same crc, not too old, /* this entry seems to match: same crc, not too old,
...@@ -1257,7 +1277,7 @@ int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig) ...@@ -1257,7 +1277,7 @@ int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig)
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) {
if (compare_eth(backbone_gw->orig, orig)) { if (batadv_compare_eth(backbone_gw->orig, orig)) {
rcu_read_unlock(); rcu_read_unlock();
return 1; return 1;
} }
...@@ -1304,12 +1324,12 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb, ...@@ -1304,12 +1324,12 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb,
} }
/* see if this originator is a backbone gw for this VLAN */ /* see if this originator is a backbone gw for this VLAN */
backbone_gw = backbone_hash_find(orig_node->bat_priv, backbone_gw = batadv_backbone_hash_find(orig_node->bat_priv,
orig_node->orig, vid); orig_node->orig, vid);
if (!backbone_gw) if (!backbone_gw)
return 0; return 0;
backbone_gw_free_ref(backbone_gw); batadv_backbone_gw_free_ref(backbone_gw);
return 1; return 1;
} }
...@@ -1319,20 +1339,20 @@ void batadv_bla_free(struct bat_priv *bat_priv) ...@@ -1319,20 +1339,20 @@ void batadv_bla_free(struct bat_priv *bat_priv)
struct hard_iface *primary_if; struct hard_iface *primary_if;
cancel_delayed_work_sync(&bat_priv->bla_work); cancel_delayed_work_sync(&bat_priv->bla_work);
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (bat_priv->claim_hash) { if (bat_priv->claim_hash) {
bla_purge_claims(bat_priv, primary_if, 1); batadv_bla_purge_claims(bat_priv, primary_if, 1);
batadv_hash_destroy(bat_priv->claim_hash); batadv_hash_destroy(bat_priv->claim_hash);
bat_priv->claim_hash = NULL; bat_priv->claim_hash = NULL;
} }
if (bat_priv->backbone_hash) { if (bat_priv->backbone_hash) {
bla_purge_backbone_gw(bat_priv, 1); batadv_bla_purge_backbone_gw(bat_priv, 1);
batadv_hash_destroy(bat_priv->backbone_hash); batadv_hash_destroy(bat_priv->backbone_hash);
bat_priv->backbone_hash = NULL; bat_priv->backbone_hash = NULL;
} }
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
} }
/* @bat_priv: the bat priv with all the soft interface information /* @bat_priv: the bat priv with all the soft interface information
...@@ -1356,7 +1376,7 @@ int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) ...@@ -1356,7 +1376,7 @@ int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
ethhdr = (struct ethhdr *)skb_mac_header(skb); ethhdr = (struct ethhdr *)skb_mac_header(skb);
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto handled; goto handled;
...@@ -1371,20 +1391,20 @@ int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) ...@@ -1371,20 +1391,20 @@ int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
memcpy(search_claim.addr, ethhdr->h_source, ETH_ALEN); memcpy(search_claim.addr, ethhdr->h_source, ETH_ALEN);
search_claim.vid = vid; search_claim.vid = vid;
claim = claim_hash_find(bat_priv, &search_claim); claim = batadv_claim_hash_find(bat_priv, &search_claim);
if (!claim) { if (!claim) {
/* possible optimization: race for a claim */ /* possible optimization: race for a claim */
/* No claim exists yet, claim it for us! /* No claim exists yet, claim it for us!
*/ */
handle_claim(bat_priv, primary_if, batadv_handle_claim(bat_priv, primary_if,
primary_if->net_dev->dev_addr, primary_if->net_dev->dev_addr,
ethhdr->h_source, vid); ethhdr->h_source, vid);
goto allow; goto allow;
} }
/* if it is our own claim ... */ /* if it is our own claim ... */
if (compare_eth(claim->backbone_gw->orig, if (batadv_compare_eth(claim->backbone_gw->orig,
primary_if->net_dev->dev_addr)) { primary_if->net_dev->dev_addr)) {
/* ... allow it in any case */ /* ... allow it in any case */
claim->lasttime = jiffies; claim->lasttime = jiffies;
...@@ -1400,13 +1420,13 @@ int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) ...@@ -1400,13 +1420,13 @@ int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
* send a claim and update the claim table * send a claim and update the claim table
* immediately. * immediately.
*/ */
handle_claim(bat_priv, primary_if, batadv_handle_claim(bat_priv, primary_if,
primary_if->net_dev->dev_addr, primary_if->net_dev->dev_addr,
ethhdr->h_source, vid); ethhdr->h_source, vid);
goto allow; goto allow;
} }
allow: allow:
bla_update_own_backbone_gw(bat_priv, primary_if, vid); batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
ret = 0; ret = 0;
goto out; goto out;
...@@ -1416,9 +1436,9 @@ int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) ...@@ -1416,9 +1436,9 @@ int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
if (claim) if (claim)
claim_free_ref(claim); batadv_claim_free_ref(claim);
return ret; return ret;
} }
...@@ -1441,7 +1461,7 @@ int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) ...@@ -1441,7 +1461,7 @@ int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
struct hard_iface *primary_if; struct hard_iface *primary_if;
int ret = 0; int ret = 0;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
...@@ -1451,7 +1471,7 @@ int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) ...@@ -1451,7 +1471,7 @@ int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
/* in VLAN case, the mac header might not be set. */ /* in VLAN case, the mac header might not be set. */
skb_reset_mac_header(skb); skb_reset_mac_header(skb);
if (bla_process_claim(bat_priv, primary_if, skb)) if (batadv_bla_process_claim(bat_priv, primary_if, skb))
goto handled; goto handled;
ethhdr = (struct ethhdr *)skb_mac_header(skb); ethhdr = (struct ethhdr *)skb_mac_header(skb);
...@@ -1464,19 +1484,19 @@ int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) ...@@ -1464,19 +1484,19 @@ int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
memcpy(search_claim.addr, ethhdr->h_source, ETH_ALEN); memcpy(search_claim.addr, ethhdr->h_source, ETH_ALEN);
search_claim.vid = vid; search_claim.vid = vid;
claim = claim_hash_find(bat_priv, &search_claim); claim = batadv_claim_hash_find(bat_priv, &search_claim);
/* if no claim exists, allow it. */ /* if no claim exists, allow it. */
if (!claim) if (!claim)
goto allow; goto allow;
/* check if we are responsible. */ /* check if we are responsible. */
if (compare_eth(claim->backbone_gw->orig, if (batadv_compare_eth(claim->backbone_gw->orig,
primary_if->net_dev->dev_addr)) { primary_if->net_dev->dev_addr)) {
/* if yes, the client has roamed and we have /* if yes, the client has roamed and we have
* to unclaim it. * to unclaim it.
*/ */
handle_unclaim(bat_priv, primary_if, batadv_handle_unclaim(bat_priv, primary_if,
primary_if->net_dev->dev_addr, primary_if->net_dev->dev_addr,
ethhdr->h_source, vid); ethhdr->h_source, vid);
goto allow; goto allow;
...@@ -1495,16 +1515,16 @@ int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) ...@@ -1495,16 +1515,16 @@ int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
goto allow; goto allow;
} }
allow: allow:
bla_update_own_backbone_gw(bat_priv, primary_if, vid); batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
ret = 0; ret = 0;
goto out; goto out;
handled: handled:
ret = 1; ret = 1;
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
if (claim) if (claim)
claim_free_ref(claim); batadv_claim_free_ref(claim);
return ret; return ret;
} }
...@@ -1520,8 +1540,9 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset) ...@@ -1520,8 +1540,9 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
uint32_t i; uint32_t i;
bool is_own; bool is_own;
int ret = 0; int ret = 0;
uint8_t *primary_addr;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) { if (!primary_if) {
ret = seq_printf(seq, ret = seq_printf(seq,
"BATMAN mesh %s disabled - please specify interfaces to enable it\n", "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
...@@ -1536,9 +1557,10 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset) ...@@ -1536,9 +1557,10 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
goto out; goto out;
} }
primary_addr = primary_if->net_dev->dev_addr;
seq_printf(seq, seq_printf(seq,
"Claims announced for the mesh %s (orig %pM, group id %04x)\n", "Claims announced for the mesh %s (orig %pM, group id %04x)\n",
net_dev->name, primary_if->net_dev->dev_addr, net_dev->name, primary_addr,
ntohs(bat_priv->claim_dest.group)); ntohs(bat_priv->claim_dest.group));
seq_printf(seq, " %-17s %-5s %-17s [o] (%-4s)\n", seq_printf(seq, " %-17s %-5s %-17s [o] (%-4s)\n",
"Client", "VID", "Originator", "CRC"); "Client", "VID", "Originator", "CRC");
...@@ -1547,8 +1569,8 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset) ...@@ -1547,8 +1569,8 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(claim, node, head, hash_entry) { hlist_for_each_entry_rcu(claim, node, head, hash_entry) {
is_own = compare_eth(claim->backbone_gw->orig, is_own = batadv_compare_eth(claim->backbone_gw->orig,
primary_if->net_dev->dev_addr); primary_addr);
seq_printf(seq, " * %pM on % 5d by %pM [%c] (%04x)\n", seq_printf(seq, " * %pM on % 5d by %pM [%c] (%04x)\n",
claim->addr, claim->vid, claim->addr, claim->vid,
claim->backbone_gw->orig, claim->backbone_gw->orig,
...@@ -1559,6 +1581,6 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset) ...@@ -1559,6 +1581,6 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
} }
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
return ret; return ret;
} }
...@@ -36,13 +36,13 @@ ...@@ -36,13 +36,13 @@
#define DHCP_OPTIONS_OFFSET 240 #define DHCP_OPTIONS_OFFSET 240
#define DHCP_REQUEST 3 #define DHCP_REQUEST 3
static void gw_node_free_ref(struct gw_node *gw_node) static void batadv_gw_node_free_ref(struct gw_node *gw_node)
{ {
if (atomic_dec_and_test(&gw_node->refcount)) if (atomic_dec_and_test(&gw_node->refcount))
kfree_rcu(gw_node, rcu); kfree_rcu(gw_node, rcu);
} }
static struct gw_node *gw_get_selected_gw_node(struct bat_priv *bat_priv) static struct gw_node *batadv_gw_get_selected_gw_node(struct bat_priv *bat_priv)
{ {
struct gw_node *gw_node; struct gw_node *gw_node;
...@@ -64,7 +64,7 @@ struct orig_node *batadv_gw_get_selected_orig(struct bat_priv *bat_priv) ...@@ -64,7 +64,7 @@ struct orig_node *batadv_gw_get_selected_orig(struct bat_priv *bat_priv)
struct gw_node *gw_node; struct gw_node *gw_node;
struct orig_node *orig_node = NULL; struct orig_node *orig_node = NULL;
gw_node = gw_get_selected_gw_node(bat_priv); gw_node = batadv_gw_get_selected_gw_node(bat_priv);
if (!gw_node) if (!gw_node)
goto out; goto out;
...@@ -80,11 +80,12 @@ struct orig_node *batadv_gw_get_selected_orig(struct bat_priv *bat_priv) ...@@ -80,11 +80,12 @@ struct orig_node *batadv_gw_get_selected_orig(struct bat_priv *bat_priv)
rcu_read_unlock(); rcu_read_unlock();
out: out:
if (gw_node) if (gw_node)
gw_node_free_ref(gw_node); batadv_gw_node_free_ref(gw_node);
return orig_node; return orig_node;
} }
static void gw_select(struct bat_priv *bat_priv, struct gw_node *new_gw_node) static void batadv_gw_select(struct bat_priv *bat_priv,
struct gw_node *new_gw_node)
{ {
struct gw_node *curr_gw_node; struct gw_node *curr_gw_node;
...@@ -97,7 +98,7 @@ static void gw_select(struct bat_priv *bat_priv, struct gw_node *new_gw_node) ...@@ -97,7 +98,7 @@ static void gw_select(struct bat_priv *bat_priv, struct gw_node *new_gw_node)
rcu_assign_pointer(bat_priv->curr_gw, new_gw_node); rcu_assign_pointer(bat_priv->curr_gw, new_gw_node);
if (curr_gw_node) if (curr_gw_node)
gw_node_free_ref(curr_gw_node); batadv_gw_node_free_ref(curr_gw_node);
spin_unlock_bh(&bat_priv->gw_list_lock); spin_unlock_bh(&bat_priv->gw_list_lock);
} }
...@@ -107,7 +108,7 @@ void batadv_gw_deselect(struct bat_priv *bat_priv) ...@@ -107,7 +108,7 @@ void batadv_gw_deselect(struct bat_priv *bat_priv)
atomic_set(&bat_priv->gw_reselect, 1); atomic_set(&bat_priv->gw_reselect, 1);
} }
static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv) static struct gw_node *batadv_gw_get_best_gw_node(struct bat_priv *bat_priv)
{ {
struct neigh_node *router; struct neigh_node *router;
struct hlist_node *node; struct hlist_node *node;
...@@ -144,7 +145,7 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv) ...@@ -144,7 +145,7 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv)
((tmp_gw_factor == max_gw_factor) && ((tmp_gw_factor == max_gw_factor) &&
(router->tq_avg > max_tq))) { (router->tq_avg > max_tq))) {
if (curr_gw) if (curr_gw)
gw_node_free_ref(curr_gw); batadv_gw_node_free_ref(curr_gw);
curr_gw = gw_node; curr_gw = gw_node;
atomic_inc(&curr_gw->refcount); atomic_inc(&curr_gw->refcount);
} }
...@@ -159,7 +160,7 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv) ...@@ -159,7 +160,7 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv)
*/ */
if (router->tq_avg > max_tq) { if (router->tq_avg > max_tq) {
if (curr_gw) if (curr_gw)
gw_node_free_ref(curr_gw); batadv_gw_node_free_ref(curr_gw);
curr_gw = gw_node; curr_gw = gw_node;
atomic_inc(&curr_gw->refcount); atomic_inc(&curr_gw->refcount);
} }
...@@ -172,7 +173,7 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv) ...@@ -172,7 +173,7 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv)
if (tmp_gw_factor > max_gw_factor) if (tmp_gw_factor > max_gw_factor)
max_gw_factor = tmp_gw_factor; max_gw_factor = tmp_gw_factor;
gw_node_free_ref(gw_node); batadv_gw_node_free_ref(gw_node);
next: next:
batadv_neigh_node_free_ref(router); batadv_neigh_node_free_ref(router);
...@@ -199,9 +200,9 @@ void batadv_gw_election(struct bat_priv *bat_priv) ...@@ -199,9 +200,9 @@ void batadv_gw_election(struct bat_priv *bat_priv)
if (!atomic_dec_not_zero(&bat_priv->gw_reselect)) if (!atomic_dec_not_zero(&bat_priv->gw_reselect))
goto out; goto out;
curr_gw = gw_get_selected_gw_node(bat_priv); curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
next_gw = gw_get_best_gw_node(bat_priv); next_gw = batadv_gw_get_best_gw_node(bat_priv);
if (curr_gw == next_gw) if (curr_gw == next_gw)
goto out; goto out;
...@@ -217,30 +218,30 @@ void batadv_gw_election(struct bat_priv *bat_priv) ...@@ -217,30 +218,30 @@ void batadv_gw_election(struct bat_priv *bat_priv)
} }
if ((curr_gw) && (!next_gw)) { if ((curr_gw) && (!next_gw)) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Removing selected gateway - no gateway in range\n"); "Removing selected gateway - no gateway in range\n");
batadv_throw_uevent(bat_priv, UEV_GW, UEV_DEL, NULL); batadv_throw_uevent(bat_priv, UEV_GW, UEV_DEL, NULL);
} else if ((!curr_gw) && (next_gw)) { } else if ((!curr_gw) && (next_gw)) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Adding route to gateway %pM (gw_flags: %i, tq: %i)\n", "Adding route to gateway %pM (gw_flags: %i, tq: %i)\n",
next_gw->orig_node->orig, next_gw->orig_node->gw_flags, next_gw->orig_node->orig,
router->tq_avg); next_gw->orig_node->gw_flags, router->tq_avg);
batadv_throw_uevent(bat_priv, UEV_GW, UEV_ADD, gw_addr); batadv_throw_uevent(bat_priv, UEV_GW, UEV_ADD, gw_addr);
} else { } else {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Changing route to gateway %pM (gw_flags: %i, tq: %i)\n", "Changing route to gateway %pM (gw_flags: %i, tq: %i)\n",
next_gw->orig_node->orig, next_gw->orig_node->gw_flags, next_gw->orig_node->orig,
router->tq_avg); next_gw->orig_node->gw_flags, router->tq_avg);
batadv_throw_uevent(bat_priv, UEV_GW, UEV_CHANGE, gw_addr); batadv_throw_uevent(bat_priv, UEV_GW, UEV_CHANGE, gw_addr);
} }
gw_select(bat_priv, next_gw); batadv_gw_select(bat_priv, next_gw);
out: out:
if (curr_gw) if (curr_gw)
gw_node_free_ref(curr_gw); batadv_gw_node_free_ref(curr_gw);
if (next_gw) if (next_gw)
gw_node_free_ref(next_gw); batadv_gw_node_free_ref(next_gw);
if (router) if (router)
batadv_neigh_node_free_ref(router); batadv_neigh_node_free_ref(router);
} }
...@@ -282,7 +283,7 @@ void batadv_gw_check_election(struct bat_priv *bat_priv, ...@@ -282,7 +283,7 @@ void batadv_gw_check_election(struct bat_priv *bat_priv,
(orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_sel_class))) (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_sel_class)))
goto out; goto out;
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Restarting gateway selection: better gateway found (tq curr: %i, tq new: %i)\n", "Restarting gateway selection: better gateway found (tq curr: %i, tq new: %i)\n",
gw_tq_avg, orig_tq_avg); gw_tq_avg, orig_tq_avg);
...@@ -299,8 +300,9 @@ void batadv_gw_check_election(struct bat_priv *bat_priv, ...@@ -299,8 +300,9 @@ void batadv_gw_check_election(struct bat_priv *bat_priv,
return; return;
} }
static void gw_node_add(struct bat_priv *bat_priv, static void batadv_gw_node_add(struct bat_priv *bat_priv,
struct orig_node *orig_node, uint8_t new_gwflags) struct orig_node *orig_node,
uint8_t new_gwflags)
{ {
struct gw_node *gw_node; struct gw_node *gw_node;
int down, up; int down, up;
...@@ -318,7 +320,7 @@ static void gw_node_add(struct bat_priv *bat_priv, ...@@ -318,7 +320,7 @@ static void gw_node_add(struct bat_priv *bat_priv,
spin_unlock_bh(&bat_priv->gw_list_lock); spin_unlock_bh(&bat_priv->gw_list_lock);
batadv_gw_bandwidth_to_kbit(new_gwflags, &down, &up); batadv_gw_bandwidth_to_kbit(new_gwflags, &down, &up);
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Found new gateway %pM -> gw_class: %i - %i%s/%i%s\n", "Found new gateway %pM -> gw_class: %i - %i%s/%i%s\n",
orig_node->orig, new_gwflags, orig_node->orig, new_gwflags,
(down > 2048 ? down / 1024 : down), (down > 2048 ? down / 1024 : down),
...@@ -338,14 +340,14 @@ void batadv_gw_node_update(struct bat_priv *bat_priv, ...@@ -338,14 +340,14 @@ void batadv_gw_node_update(struct bat_priv *bat_priv,
* have this gateway in our list (duplication check!) even though we * have this gateway in our list (duplication check!) even though we
* have no currently selected gateway. * have no currently selected gateway.
*/ */
curr_gw = gw_get_selected_gw_node(bat_priv); curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) { hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) {
if (gw_node->orig_node != orig_node) if (gw_node->orig_node != orig_node)
continue; continue;
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Gateway class of originator %pM changed from %i to %i\n", "Gateway class of originator %pM changed from %i to %i\n",
orig_node->orig, gw_node->orig_node->gw_flags, orig_node->orig, gw_node->orig_node->gw_flags,
new_gwflags); new_gwflags);
...@@ -354,7 +356,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv, ...@@ -354,7 +356,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv,
if (new_gwflags == NO_FLAGS) { if (new_gwflags == NO_FLAGS) {
gw_node->deleted = jiffies; gw_node->deleted = jiffies;
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Gateway %pM removed from gateway list\n", "Gateway %pM removed from gateway list\n",
orig_node->orig); orig_node->orig);
...@@ -368,7 +370,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv, ...@@ -368,7 +370,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv,
if (new_gwflags == NO_FLAGS) if (new_gwflags == NO_FLAGS)
goto unlock; goto unlock;
gw_node_add(bat_priv, orig_node, new_gwflags); batadv_gw_node_add(bat_priv, orig_node, new_gwflags);
goto unlock; goto unlock;
deselect: deselect:
...@@ -377,7 +379,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv, ...@@ -377,7 +379,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv,
rcu_read_unlock(); rcu_read_unlock();
if (curr_gw) if (curr_gw)
gw_node_free_ref(curr_gw); batadv_gw_node_free_ref(curr_gw);
} }
void batadv_gw_node_delete(struct bat_priv *bat_priv, void batadv_gw_node_delete(struct bat_priv *bat_priv,
...@@ -393,7 +395,7 @@ void batadv_gw_node_purge(struct bat_priv *bat_priv) ...@@ -393,7 +395,7 @@ void batadv_gw_node_purge(struct bat_priv *bat_priv)
unsigned long timeout = msecs_to_jiffies(2 * PURGE_TIMEOUT); unsigned long timeout = msecs_to_jiffies(2 * PURGE_TIMEOUT);
int do_deselect = 0; int do_deselect = 0;
curr_gw = gw_get_selected_gw_node(bat_priv); curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
spin_lock_bh(&bat_priv->gw_list_lock); spin_lock_bh(&bat_priv->gw_list_lock);
...@@ -408,7 +410,7 @@ void batadv_gw_node_purge(struct bat_priv *bat_priv) ...@@ -408,7 +410,7 @@ void batadv_gw_node_purge(struct bat_priv *bat_priv)
do_deselect = 1; do_deselect = 1;
hlist_del_rcu(&gw_node->list); hlist_del_rcu(&gw_node->list);
gw_node_free_ref(gw_node); batadv_gw_node_free_ref(gw_node);
} }
spin_unlock_bh(&bat_priv->gw_list_lock); spin_unlock_bh(&bat_priv->gw_list_lock);
...@@ -418,11 +420,12 @@ void batadv_gw_node_purge(struct bat_priv *bat_priv) ...@@ -418,11 +420,12 @@ void batadv_gw_node_purge(struct bat_priv *bat_priv)
batadv_gw_deselect(bat_priv); batadv_gw_deselect(bat_priv);
if (curr_gw) if (curr_gw)
gw_node_free_ref(curr_gw); batadv_gw_node_free_ref(curr_gw);
} }
/* fails if orig_node has no router */ /* fails if orig_node has no router */
static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq, static int batadv_write_buffer_text(struct bat_priv *bat_priv,
struct seq_file *seq,
const struct gw_node *gw_node) const struct gw_node *gw_node)
{ {
struct gw_node *curr_gw; struct gw_node *curr_gw;
...@@ -435,7 +438,7 @@ static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq, ...@@ -435,7 +438,7 @@ static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq,
if (!router) if (!router)
goto out; goto out;
curr_gw = gw_get_selected_gw_node(bat_priv); curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
ret = seq_printf(seq, "%s %pM (%3i) %pM [%10s]: %3i - %i%s/%i%s\n", ret = seq_printf(seq, "%s %pM (%3i) %pM [%10s]: %3i - %i%s/%i%s\n",
(curr_gw == gw_node ? "=>" : " "), (curr_gw == gw_node ? "=>" : " "),
...@@ -450,7 +453,7 @@ static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq, ...@@ -450,7 +453,7 @@ static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq,
batadv_neigh_node_free_ref(router); batadv_neigh_node_free_ref(router);
if (curr_gw) if (curr_gw)
gw_node_free_ref(curr_gw); batadv_gw_node_free_ref(curr_gw);
out: out:
return ret; return ret;
} }
...@@ -464,7 +467,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) ...@@ -464,7 +467,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
struct hlist_node *node; struct hlist_node *node;
int gw_count = 0, ret = 0; int gw_count = 0, ret = 0;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) { if (!primary_if) {
ret = seq_printf(seq, ret = seq_printf(seq,
"BATMAN mesh %s disabled - please specify interfaces to enable it\n", "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
...@@ -491,7 +494,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) ...@@ -491,7 +494,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
continue; continue;
/* fails if orig_node has no router */ /* fails if orig_node has no router */
if (_write_buffer_text(bat_priv, seq, gw_node) < 0) if (batadv_write_buffer_text(bat_priv, seq, gw_node) < 0)
continue; continue;
gw_count++; gw_count++;
...@@ -503,11 +506,11 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) ...@@ -503,11 +506,11 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
return ret; return ret;
} }
static bool is_type_dhcprequest(struct sk_buff *skb, int header_len) static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len)
{ {
int ret = false; int ret = false;
unsigned char *p; unsigned char *p;
...@@ -655,7 +658,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv, ...@@ -655,7 +658,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
if (!orig_dst_node->gw_flags) if (!orig_dst_node->gw_flags)
goto out; goto out;
ret = is_type_dhcprequest(skb, header_len); ret = batadv_is_type_dhcprequest(skb, header_len);
if (!ret) if (!ret)
goto out; goto out;
...@@ -667,7 +670,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv, ...@@ -667,7 +670,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
curr_tq_avg = TQ_MAX_VALUE; curr_tq_avg = TQ_MAX_VALUE;
break; break;
case GW_MODE_CLIENT: case GW_MODE_CLIENT:
curr_gw = gw_get_selected_gw_node(bat_priv); curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
if (!curr_gw) if (!curr_gw)
goto out; goto out;
...@@ -702,7 +705,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv, ...@@ -702,7 +705,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
if (orig_dst_node) if (orig_dst_node)
batadv_orig_node_free_ref(orig_dst_node); batadv_orig_node_free_ref(orig_dst_node);
if (curr_gw) if (curr_gw)
gw_node_free_ref(curr_gw); batadv_gw_node_free_ref(curr_gw);
if (neigh_old) if (neigh_old)
batadv_neigh_node_free_ref(neigh_old); batadv_neigh_node_free_ref(neigh_old);
if (neigh_curr) if (neigh_curr)
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "gateway_client.h" #include "gateway_client.h"
/* calculates the gateway class from kbit */ /* calculates the gateway class from kbit */
static void kbit_to_gw_bandwidth(int down, int up, long *gw_srv_class) static void batadv_kbit_to_gw_bandwidth(int down, int up, long *gw_srv_class)
{ {
int mdown = 0, tdown, tup, difference; int mdown = 0, tdown, tup, difference;
uint8_t sbit, part; uint8_t sbit, part;
...@@ -73,7 +73,7 @@ void batadv_gw_bandwidth_to_kbit(uint8_t gw_srv_class, int *down, int *up) ...@@ -73,7 +73,7 @@ void batadv_gw_bandwidth_to_kbit(uint8_t gw_srv_class, int *down, int *up)
*up = ((upart + 1) * (*down)) / 8; *up = ((upart + 1) * (*down)) / 8;
} }
static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff, static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
int *up, int *down) int *up, int *down)
{ {
int ret, multi = 1; int ret, multi = 1;
...@@ -142,7 +142,7 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, ...@@ -142,7 +142,7 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
int up = 0, down = 0; int up = 0, down = 0;
bool ret; bool ret;
ret = parse_gw_bandwidth(net_dev, buff, &up, &down); ret = batadv_parse_gw_bandwidth(net_dev, buff, &up, &down);
if (!ret) if (!ret)
goto end; goto end;
...@@ -152,7 +152,7 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, ...@@ -152,7 +152,7 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
if (!up) if (!up)
up = down / 5; up = down / 5;
kbit_to_gw_bandwidth(down, up, &gw_bandwidth_tmp); batadv_kbit_to_gw_bandwidth(down, up, &gw_bandwidth_tmp);
/* the gw bandwidth we guessed above might not match the given /* the gw bandwidth we guessed above might not match the given
* speeds, hence we need to calculate it back to show the number * speeds, hence we need to calculate it back to show the number
......
...@@ -57,7 +57,7 @@ struct hard_iface *batadv_hardif_get_by_netdev(const struct net_device *net_dev) ...@@ -57,7 +57,7 @@ struct hard_iface *batadv_hardif_get_by_netdev(const struct net_device *net_dev)
return hard_iface; return hard_iface;
} }
static int is_valid_iface(const struct net_device *net_dev) static int batadv_is_valid_iface(const struct net_device *net_dev)
{ {
if (net_dev->flags & IFF_LOOPBACK) if (net_dev->flags & IFF_LOOPBACK)
return 0; return 0;
...@@ -75,7 +75,8 @@ static int is_valid_iface(const struct net_device *net_dev) ...@@ -75,7 +75,8 @@ static int is_valid_iface(const struct net_device *net_dev)
return 1; return 1;
} }
static struct hard_iface *hardif_get_active(const struct net_device *soft_iface) static struct hard_iface *
batadv_hardif_get_active(const struct net_device *soft_iface)
{ {
struct hard_iface *hard_iface; struct hard_iface *hard_iface;
...@@ -96,13 +97,13 @@ static struct hard_iface *hardif_get_active(const struct net_device *soft_iface) ...@@ -96,13 +97,13 @@ static struct hard_iface *hardif_get_active(const struct net_device *soft_iface)
return hard_iface; return hard_iface;
} }
static void primary_if_update_addr(struct bat_priv *bat_priv, static void batadv_primary_if_update_addr(struct bat_priv *bat_priv,
struct hard_iface *oldif) struct hard_iface *oldif)
{ {
struct vis_packet *vis_packet; struct vis_packet *vis_packet;
struct hard_iface *primary_if; struct hard_iface *primary_if;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
...@@ -115,10 +116,10 @@ static void primary_if_update_addr(struct bat_priv *bat_priv, ...@@ -115,10 +116,10 @@ static void primary_if_update_addr(struct bat_priv *bat_priv,
batadv_bla_update_orig_address(bat_priv, primary_if, oldif); batadv_bla_update_orig_address(bat_priv, primary_if, oldif);
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
} }
static void primary_if_select(struct bat_priv *bat_priv, static void batadv_primary_if_select(struct bat_priv *bat_priv,
struct hard_iface *new_hard_iface) struct hard_iface *new_hard_iface)
{ {
struct hard_iface *curr_hard_iface; struct hard_iface *curr_hard_iface;
...@@ -135,14 +136,14 @@ static void primary_if_select(struct bat_priv *bat_priv, ...@@ -135,14 +136,14 @@ static void primary_if_select(struct bat_priv *bat_priv,
goto out; goto out;
bat_priv->bat_algo_ops->bat_primary_iface_set(new_hard_iface); bat_priv->bat_algo_ops->bat_primary_iface_set(new_hard_iface);
primary_if_update_addr(bat_priv, curr_hard_iface); batadv_primary_if_update_addr(bat_priv, curr_hard_iface);
out: out:
if (curr_hard_iface) if (curr_hard_iface)
hardif_free_ref(curr_hard_iface); batadv_hardif_free_ref(curr_hard_iface);
} }
static bool hardif_is_iface_up(const struct hard_iface *hard_iface) static bool batadv_hardif_is_iface_up(const struct hard_iface *hard_iface)
{ {
if (hard_iface->net_dev->flags & IFF_UP) if (hard_iface->net_dev->flags & IFF_UP)
return true; return true;
...@@ -150,7 +151,7 @@ static bool hardif_is_iface_up(const struct hard_iface *hard_iface) ...@@ -150,7 +151,7 @@ static bool hardif_is_iface_up(const struct hard_iface *hard_iface)
return false; return false;
} }
static void check_known_mac_addr(const struct net_device *net_dev) static void batadv_check_known_mac_addr(const struct net_device *net_dev)
{ {
const struct hard_iface *hard_iface; const struct hard_iface *hard_iface;
...@@ -163,7 +164,7 @@ static void check_known_mac_addr(const struct net_device *net_dev) ...@@ -163,7 +164,7 @@ static void check_known_mac_addr(const struct net_device *net_dev)
if (hard_iface->net_dev == net_dev) if (hard_iface->net_dev == net_dev)
continue; continue;
if (!compare_eth(hard_iface->net_dev->dev_addr, if (!batadv_compare_eth(hard_iface->net_dev->dev_addr,
net_dev->dev_addr)) net_dev->dev_addr))
continue; continue;
...@@ -213,7 +214,7 @@ void batadv_update_min_mtu(struct net_device *soft_iface) ...@@ -213,7 +214,7 @@ void batadv_update_min_mtu(struct net_device *soft_iface)
soft_iface->mtu = min_mtu; soft_iface->mtu = min_mtu;
} }
static void hardif_activate_interface(struct hard_iface *hard_iface) static void batadv_hardif_activate_interface(struct hard_iface *hard_iface)
{ {
struct bat_priv *bat_priv; struct bat_priv *bat_priv;
struct hard_iface *primary_if = NULL; struct hard_iface *primary_if = NULL;
...@@ -229,9 +230,9 @@ static void hardif_activate_interface(struct hard_iface *hard_iface) ...@@ -229,9 +230,9 @@ static void hardif_activate_interface(struct hard_iface *hard_iface)
/* the first active interface becomes our primary interface or /* the first active interface becomes our primary interface or
* the next active interface after the old primary interface was removed * the next active interface after the old primary interface was removed
*/ */
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
primary_if_select(bat_priv, hard_iface); batadv_primary_if_select(bat_priv, hard_iface);
bat_info(hard_iface->soft_iface, "Interface activated: %s\n", bat_info(hard_iface->soft_iface, "Interface activated: %s\n",
hard_iface->net_dev->name); hard_iface->net_dev->name);
...@@ -240,10 +241,10 @@ static void hardif_activate_interface(struct hard_iface *hard_iface) ...@@ -240,10 +241,10 @@ static void hardif_activate_interface(struct hard_iface *hard_iface)
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
} }
static void hardif_deactivate_interface(struct hard_iface *hard_iface) static void batadv_hardif_deactivate_interface(struct hard_iface *hard_iface)
{ {
if ((hard_iface->if_status != IF_ACTIVE) && if ((hard_iface->if_status != IF_ACTIVE) &&
(hard_iface->if_status != IF_TO_BE_ACTIVATED)) (hard_iface->if_status != IF_TO_BE_ACTIVATED))
...@@ -331,8 +332,8 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface, ...@@ -331,8 +332,8 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
hard_iface->net_dev->name, hard_iface->net_dev->mtu, hard_iface->net_dev->name, hard_iface->net_dev->mtu,
ETH_DATA_LEN + BAT_HEADER_LEN); ETH_DATA_LEN + BAT_HEADER_LEN);
if (hardif_is_iface_up(hard_iface)) if (batadv_hardif_is_iface_up(hard_iface))
hardif_activate_interface(hard_iface); batadv_hardif_activate_interface(hard_iface);
else else
bat_err(hard_iface->soft_iface, bat_err(hard_iface->soft_iface,
"Not using interface %s (retrying later): interface not active\n", "Not using interface %s (retrying later): interface not active\n",
...@@ -347,7 +348,7 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface, ...@@ -347,7 +348,7 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
err_dev: err_dev:
dev_put(soft_iface); dev_put(soft_iface);
err: err:
hardif_free_ref(hard_iface); batadv_hardif_free_ref(hard_iface);
return ret; return ret;
} }
...@@ -357,7 +358,7 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface) ...@@ -357,7 +358,7 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface)
struct hard_iface *primary_if = NULL; struct hard_iface *primary_if = NULL;
if (hard_iface->if_status == IF_ACTIVE) if (hard_iface->if_status == IF_ACTIVE)
hardif_deactivate_interface(hard_iface); batadv_hardif_deactivate_interface(hard_iface);
if (hard_iface->if_status != IF_INACTIVE) if (hard_iface->if_status != IF_INACTIVE)
goto out; goto out;
...@@ -369,15 +370,15 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface) ...@@ -369,15 +370,15 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface)
bat_priv->num_ifaces--; bat_priv->num_ifaces--;
batadv_orig_hash_del_if(hard_iface, bat_priv->num_ifaces); batadv_orig_hash_del_if(hard_iface, bat_priv->num_ifaces);
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (hard_iface == primary_if) { if (hard_iface == primary_if) {
struct hard_iface *new_if; struct hard_iface *new_if;
new_if = hardif_get_active(hard_iface->soft_iface); new_if = batadv_hardif_get_active(hard_iface->soft_iface);
primary_if_select(bat_priv, new_if); batadv_primary_if_select(bat_priv, new_if);
if (new_if) if (new_if)
hardif_free_ref(new_if); batadv_hardif_free_ref(new_if);
} }
bat_priv->bat_algo_ops->bat_iface_disable(hard_iface); bat_priv->bat_algo_ops->bat_iface_disable(hard_iface);
...@@ -393,21 +394,22 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface) ...@@ -393,21 +394,22 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface)
batadv_softif_destroy(hard_iface->soft_iface); batadv_softif_destroy(hard_iface->soft_iface);
hard_iface->soft_iface = NULL; hard_iface->soft_iface = NULL;
hardif_free_ref(hard_iface); batadv_hardif_free_ref(hard_iface);
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
} }
static struct hard_iface *hardif_add_interface(struct net_device *net_dev) static struct hard_iface *
batadv_hardif_add_interface(struct net_device *net_dev)
{ {
struct hard_iface *hard_iface; struct hard_iface *hard_iface;
int ret; int ret;
ASSERT_RTNL(); ASSERT_RTNL();
ret = is_valid_iface(net_dev); ret = batadv_is_valid_iface(net_dev);
if (ret != 1) if (ret != 1)
goto out; goto out;
...@@ -429,7 +431,7 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev) ...@@ -429,7 +431,7 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
/* extra reference for return */ /* extra reference for return */
atomic_set(&hard_iface->refcount, 2); atomic_set(&hard_iface->refcount, 2);
check_known_mac_addr(hard_iface->net_dev); batadv_check_known_mac_addr(hard_iface->net_dev);
list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list); list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list);
/* This can't be called via a bat_priv callback because /* This can't be called via a bat_priv callback because
...@@ -448,7 +450,7 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev) ...@@ -448,7 +450,7 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
return NULL; return NULL;
} }
static void hardif_remove_interface(struct hard_iface *hard_iface) static void batadv_hardif_remove_interface(struct hard_iface *hard_iface)
{ {
ASSERT_RTNL(); ASSERT_RTNL();
...@@ -461,7 +463,7 @@ static void hardif_remove_interface(struct hard_iface *hard_iface) ...@@ -461,7 +463,7 @@ static void hardif_remove_interface(struct hard_iface *hard_iface)
hard_iface->if_status = IF_TO_BE_REMOVED; hard_iface->if_status = IF_TO_BE_REMOVED;
batadv_sysfs_del_hardif(&hard_iface->hardif_obj); batadv_sysfs_del_hardif(&hard_iface->hardif_obj);
hardif_free_ref(hard_iface); batadv_hardif_free_ref(hard_iface);
} }
void batadv_hardif_remove_interfaces(void) void batadv_hardif_remove_interfaces(void)
...@@ -472,12 +474,12 @@ void batadv_hardif_remove_interfaces(void) ...@@ -472,12 +474,12 @@ void batadv_hardif_remove_interfaces(void)
list_for_each_entry_safe(hard_iface, hard_iface_tmp, list_for_each_entry_safe(hard_iface, hard_iface_tmp,
&batadv_hardif_list, list) { &batadv_hardif_list, list) {
list_del_rcu(&hard_iface->list); list_del_rcu(&hard_iface->list);
hardif_remove_interface(hard_iface); batadv_hardif_remove_interface(hard_iface);
} }
rtnl_unlock(); rtnl_unlock();
} }
static int hard_if_event(struct notifier_block *this, static int batadv_hard_if_event(struct notifier_block *this,
unsigned long event, void *ptr) unsigned long event, void *ptr)
{ {
struct net_device *net_dev = ptr; struct net_device *net_dev = ptr;
...@@ -486,23 +488,23 @@ static int hard_if_event(struct notifier_block *this, ...@@ -486,23 +488,23 @@ static int hard_if_event(struct notifier_block *this,
struct bat_priv *bat_priv; struct bat_priv *bat_priv;
if (!hard_iface && event == NETDEV_REGISTER) if (!hard_iface && event == NETDEV_REGISTER)
hard_iface = hardif_add_interface(net_dev); hard_iface = batadv_hardif_add_interface(net_dev);
if (!hard_iface) if (!hard_iface)
goto out; goto out;
switch (event) { switch (event) {
case NETDEV_UP: case NETDEV_UP:
hardif_activate_interface(hard_iface); batadv_hardif_activate_interface(hard_iface);
break; break;
case NETDEV_GOING_DOWN: case NETDEV_GOING_DOWN:
case NETDEV_DOWN: case NETDEV_DOWN:
hardif_deactivate_interface(hard_iface); batadv_hardif_deactivate_interface(hard_iface);
break; break;
case NETDEV_UNREGISTER: case NETDEV_UNREGISTER:
list_del_rcu(&hard_iface->list); list_del_rcu(&hard_iface->list);
hardif_remove_interface(hard_iface); batadv_hardif_remove_interface(hard_iface);
break; break;
case NETDEV_CHANGEMTU: case NETDEV_CHANGEMTU:
if (hard_iface->soft_iface) if (hard_iface->soft_iface)
...@@ -512,27 +514,27 @@ static int hard_if_event(struct notifier_block *this, ...@@ -512,27 +514,27 @@ static int hard_if_event(struct notifier_block *this,
if (hard_iface->if_status == IF_NOT_IN_USE) if (hard_iface->if_status == IF_NOT_IN_USE)
goto hardif_put; goto hardif_put;
check_known_mac_addr(hard_iface->net_dev); batadv_check_known_mac_addr(hard_iface->net_dev);
bat_priv = netdev_priv(hard_iface->soft_iface); bat_priv = netdev_priv(hard_iface->soft_iface);
bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface); bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface);
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto hardif_put; goto hardif_put;
if (hard_iface == primary_if) if (hard_iface == primary_if)
primary_if_update_addr(bat_priv, NULL); batadv_primary_if_update_addr(bat_priv, NULL);
break; break;
default: default:
break; break;
} }
hardif_put: hardif_put:
hardif_free_ref(hard_iface); batadv_hardif_free_ref(hard_iface);
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
return NOTIFY_DONE; return NOTIFY_DONE;
} }
...@@ -569,5 +571,5 @@ bool batadv_is_wifi_iface(int ifindex) ...@@ -569,5 +571,5 @@ bool batadv_is_wifi_iface(int ifindex)
} }
struct notifier_block batadv_hard_if_notifier = { struct notifier_block batadv_hard_if_notifier = {
.notifier_call = hard_if_event, .notifier_call = batadv_hard_if_event,
}; };
...@@ -42,14 +42,15 @@ void batadv_update_min_mtu(struct net_device *soft_iface); ...@@ -42,14 +42,15 @@ void batadv_update_min_mtu(struct net_device *soft_iface);
void batadv_hardif_free_rcu(struct rcu_head *rcu); void batadv_hardif_free_rcu(struct rcu_head *rcu);
bool batadv_is_wifi_iface(int ifindex); bool batadv_is_wifi_iface(int ifindex);
static inline void hardif_free_ref(struct hard_iface *hard_iface) static inline void
batadv_hardif_free_ref(struct hard_iface *hard_iface)
{ {
if (atomic_dec_and_test(&hard_iface->refcount)) if (atomic_dec_and_test(&hard_iface->refcount))
call_rcu(&hard_iface->rcu, batadv_hardif_free_rcu); call_rcu(&hard_iface->rcu, batadv_hardif_free_rcu);
} }
static inline struct hard_iface *primary_if_get_selected( static inline struct hard_iface *
struct bat_priv *bat_priv) batadv_primary_if_get_selected(struct bat_priv *bat_priv)
{ {
struct hard_iface *hard_iface; struct hard_iface *hard_iface;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "hash.h" #include "hash.h"
/* clears the hash */ /* clears the hash */
static void hash_init(struct hashtable_t *hash) static void batadv_hash_init(struct hashtable_t *hash)
{ {
uint32_t i; uint32_t i;
...@@ -58,7 +58,7 @@ struct hashtable_t *batadv_hash_new(uint32_t size) ...@@ -58,7 +58,7 @@ struct hashtable_t *batadv_hash_new(uint32_t size)
goto free_table; goto free_table;
hash->size = size; hash->size = size;
hash_init(hash); batadv_hash_init(hash);
return hash; return hash;
free_table: free_table:
......
...@@ -54,7 +54,7 @@ void batadv_hash_destroy(struct hashtable_t *hash); ...@@ -54,7 +54,7 @@ void batadv_hash_destroy(struct hashtable_t *hash);
* called to remove the elements inside of the hash. if you don't remove the * called to remove the elements inside of the hash. if you don't remove the
* elements, memory might be leaked. * elements, memory might be leaked.
*/ */
static inline void hash_delete(struct hashtable_t *hash, static inline void batadv_hash_delete(struct hashtable_t *hash,
hashdata_free_cb free_cb, void *arg) hashdata_free_cb free_cb, void *arg)
{ {
struct hlist_head *head; struct hlist_head *head;
...@@ -89,10 +89,11 @@ static inline void hash_delete(struct hashtable_t *hash, ...@@ -89,10 +89,11 @@ static inline void hash_delete(struct hashtable_t *hash,
* Returns 0 on success, 1 if the element already is in the hash * Returns 0 on success, 1 if the element already is in the hash
* and -1 on error. * and -1 on error.
*/ */
static inline int hash_add(struct hashtable_t *hash, static inline int batadv_hash_add(struct hashtable_t *hash,
hashdata_compare_cb compare, hashdata_compare_cb compare,
hashdata_choose_cb choose, hashdata_choose_cb choose,
const void *data, struct hlist_node *data_node) const void *data,
struct hlist_node *data_node)
{ {
uint32_t index; uint32_t index;
int ret = -1; int ret = -1;
...@@ -133,7 +134,7 @@ static inline int hash_add(struct hashtable_t *hash, ...@@ -133,7 +134,7 @@ static inline int hash_add(struct hashtable_t *hash,
* structure you use with just the key filled, we just need the key for * structure you use with just the key filled, we just need the key for
* comparing. * comparing.
*/ */
static inline void *hash_remove(struct hashtable_t *hash, static inline void *batadv_hash_remove(struct hashtable_t *hash,
hashdata_compare_cb compare, hashdata_compare_cb compare,
hashdata_choose_cb choose, void *data) hashdata_choose_cb choose, void *data)
{ {
......
...@@ -26,18 +26,18 @@ ...@@ -26,18 +26,18 @@
#include "originator.h" #include "originator.h"
#include "hard-interface.h" #include "hard-interface.h"
static struct socket_client *socket_client_hash[256]; static struct socket_client *batadv_socket_client_hash[256];
static void bat_socket_add_packet(struct socket_client *socket_client, static void batadv_socket_add_packet(struct socket_client *socket_client,
struct icmp_packet_rr *icmp_packet, struct icmp_packet_rr *icmp_packet,
size_t icmp_len); size_t icmp_len);
void batadv_socket_init(void) void batadv_socket_init(void)
{ {
memset(socket_client_hash, 0, sizeof(socket_client_hash)); memset(batadv_socket_client_hash, 0, sizeof(batadv_socket_client_hash));
} }
static int bat_socket_open(struct inode *inode, struct file *file) static int batadv_socket_open(struct inode *inode, struct file *file)
{ {
unsigned int i; unsigned int i;
struct socket_client *socket_client; struct socket_client *socket_client;
...@@ -49,14 +49,14 @@ static int bat_socket_open(struct inode *inode, struct file *file) ...@@ -49,14 +49,14 @@ static int bat_socket_open(struct inode *inode, struct file *file)
if (!socket_client) if (!socket_client)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < ARRAY_SIZE(socket_client_hash); i++) { for (i = 0; i < ARRAY_SIZE(batadv_socket_client_hash); i++) {
if (!socket_client_hash[i]) { if (!batadv_socket_client_hash[i]) {
socket_client_hash[i] = socket_client; batadv_socket_client_hash[i] = socket_client;
break; break;
} }
} }
if (i == ARRAY_SIZE(socket_client_hash)) { if (i == ARRAY_SIZE(batadv_socket_client_hash)) {
pr_err("Error - can't add another packet client: maximum number of clients reached\n"); pr_err("Error - can't add another packet client: maximum number of clients reached\n");
kfree(socket_client); kfree(socket_client);
return -EXFULL; return -EXFULL;
...@@ -75,7 +75,7 @@ static int bat_socket_open(struct inode *inode, struct file *file) ...@@ -75,7 +75,7 @@ static int bat_socket_open(struct inode *inode, struct file *file)
return 0; return 0;
} }
static int bat_socket_release(struct inode *inode, struct file *file) static int batadv_socket_release(struct inode *inode, struct file *file)
{ {
struct socket_client *socket_client = file->private_data; struct socket_client *socket_client = file->private_data;
struct socket_packet *socket_packet; struct socket_packet *socket_packet;
...@@ -92,7 +92,7 @@ static int bat_socket_release(struct inode *inode, struct file *file) ...@@ -92,7 +92,7 @@ static int bat_socket_release(struct inode *inode, struct file *file)
kfree(socket_packet); kfree(socket_packet);
} }
socket_client_hash[socket_client->index] = NULL; batadv_socket_client_hash[socket_client->index] = NULL;
spin_unlock_bh(&socket_client->lock); spin_unlock_bh(&socket_client->lock);
kfree(socket_client); kfree(socket_client);
...@@ -101,7 +101,7 @@ static int bat_socket_release(struct inode *inode, struct file *file) ...@@ -101,7 +101,7 @@ static int bat_socket_release(struct inode *inode, struct file *file)
return 0; return 0;
} }
static ssize_t bat_socket_read(struct file *file, char __user *buf, static ssize_t batadv_socket_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct socket_client *socket_client = file->private_data; struct socket_client *socket_client = file->private_data;
...@@ -144,7 +144,7 @@ static ssize_t bat_socket_read(struct file *file, char __user *buf, ...@@ -144,7 +144,7 @@ static ssize_t bat_socket_read(struct file *file, char __user *buf,
return packet_len; return packet_len;
} }
static ssize_t bat_socket_write(struct file *file, const char __user *buff, static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
size_t len, loff_t *off) size_t len, loff_t *off)
{ {
struct socket_client *socket_client = file->private_data; struct socket_client *socket_client = file->private_data;
...@@ -158,12 +158,12 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, ...@@ -158,12 +158,12 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
size_t packet_len = sizeof(struct icmp_packet); size_t packet_len = sizeof(struct icmp_packet);
if (len < sizeof(struct icmp_packet)) { if (len < sizeof(struct icmp_packet)) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Error - can't send packet from char device: invalid packet size\n"); "Error - can't send packet from char device: invalid packet size\n");
return -EINVAL; return -EINVAL;
} }
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) { if (!primary_if) {
len = -EFAULT; len = -EFAULT;
...@@ -188,14 +188,14 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, ...@@ -188,14 +188,14 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
} }
if (icmp_packet->header.packet_type != BAT_ICMP) { if (icmp_packet->header.packet_type != BAT_ICMP) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n"); "Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n");
len = -EINVAL; len = -EINVAL;
goto free_skb; goto free_skb;
} }
if (icmp_packet->msg_type != ECHO_REQUEST) { if (icmp_packet->msg_type != ECHO_REQUEST) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n"); "Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n");
len = -EINVAL; len = -EINVAL;
goto free_skb; goto free_skb;
...@@ -206,14 +206,15 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, ...@@ -206,14 +206,15 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
if (icmp_packet->header.version != COMPAT_VERSION) { if (icmp_packet->header.version != COMPAT_VERSION) {
icmp_packet->msg_type = PARAMETER_PROBLEM; icmp_packet->msg_type = PARAMETER_PROBLEM;
icmp_packet->header.version = COMPAT_VERSION; icmp_packet->header.version = COMPAT_VERSION;
bat_socket_add_packet(socket_client, icmp_packet, packet_len); batadv_socket_add_packet(socket_client, icmp_packet,
packet_len);
goto free_skb; goto free_skb;
} }
if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE) if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE)
goto dst_unreach; goto dst_unreach;
orig_node = orig_hash_find(bat_priv, icmp_packet->dst); orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->dst);
if (!orig_node) if (!orig_node)
goto dst_unreach; goto dst_unreach;
...@@ -239,12 +240,12 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, ...@@ -239,12 +240,12 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
dst_unreach: dst_unreach:
icmp_packet->msg_type = DESTINATION_UNREACHABLE; icmp_packet->msg_type = DESTINATION_UNREACHABLE;
bat_socket_add_packet(socket_client, icmp_packet, packet_len); batadv_socket_add_packet(socket_client, icmp_packet, packet_len);
free_skb: free_skb:
kfree_skb(skb); kfree_skb(skb);
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
if (neigh_node) if (neigh_node)
batadv_neigh_node_free_ref(neigh_node); batadv_neigh_node_free_ref(neigh_node);
if (orig_node) if (orig_node)
...@@ -252,7 +253,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, ...@@ -252,7 +253,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
return len; return len;
} }
static unsigned int bat_socket_poll(struct file *file, poll_table *wait) static unsigned int batadv_socket_poll(struct file *file, poll_table *wait)
{ {
struct socket_client *socket_client = file->private_data; struct socket_client *socket_client = file->private_data;
...@@ -264,13 +265,13 @@ static unsigned int bat_socket_poll(struct file *file, poll_table *wait) ...@@ -264,13 +265,13 @@ static unsigned int bat_socket_poll(struct file *file, poll_table *wait)
return 0; return 0;
} }
static const struct file_operations fops = { static const struct file_operations batadv_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = bat_socket_open, .open = batadv_socket_open,
.release = bat_socket_release, .release = batadv_socket_release,
.read = bat_socket_read, .read = batadv_socket_read,
.write = bat_socket_write, .write = batadv_socket_write,
.poll = bat_socket_poll, .poll = batadv_socket_poll,
.llseek = no_llseek, .llseek = no_llseek,
}; };
...@@ -282,7 +283,7 @@ int batadv_socket_setup(struct bat_priv *bat_priv) ...@@ -282,7 +283,7 @@ int batadv_socket_setup(struct bat_priv *bat_priv)
goto err; goto err;
d = debugfs_create_file(ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR, d = debugfs_create_file(ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR,
bat_priv->debug_dir, bat_priv, &fops); bat_priv->debug_dir, bat_priv, &batadv_fops);
if (!d) if (!d)
goto err; goto err;
...@@ -292,7 +293,7 @@ int batadv_socket_setup(struct bat_priv *bat_priv) ...@@ -292,7 +293,7 @@ int batadv_socket_setup(struct bat_priv *bat_priv)
return -ENOMEM; return -ENOMEM;
} }
static void bat_socket_add_packet(struct socket_client *socket_client, static void batadv_socket_add_packet(struct socket_client *socket_client,
struct icmp_packet_rr *icmp_packet, struct icmp_packet_rr *icmp_packet,
size_t icmp_len) size_t icmp_len)
{ {
...@@ -312,7 +313,7 @@ static void bat_socket_add_packet(struct socket_client *socket_client, ...@@ -312,7 +313,7 @@ static void bat_socket_add_packet(struct socket_client *socket_client,
/* while waiting for the lock the socket_client could have been /* while waiting for the lock the socket_client could have been
* deleted * deleted
*/ */
if (!socket_client_hash[icmp_packet->uid]) { if (!batadv_socket_client_hash[icmp_packet->uid]) {
spin_unlock_bh(&socket_client->lock); spin_unlock_bh(&socket_client->lock);
kfree(socket_packet); kfree(socket_packet);
return; return;
...@@ -338,8 +339,9 @@ static void bat_socket_add_packet(struct socket_client *socket_client, ...@@ -338,8 +339,9 @@ static void bat_socket_add_packet(struct socket_client *socket_client,
void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet, void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet,
size_t icmp_len) size_t icmp_len)
{ {
struct socket_client *hash = socket_client_hash[icmp_packet->uid]; struct socket_client *hash;
hash = batadv_socket_client_hash[icmp_packet->uid];
if (hash) if (hash)
bat_socket_add_packet(hash, icmp_packet, icmp_len); batadv_socket_add_packet(hash, icmp_packet, icmp_len);
} }
...@@ -180,7 +180,7 @@ int batadv_is_my_mac(const uint8_t *addr) ...@@ -180,7 +180,7 @@ int batadv_is_my_mac(const uint8_t *addr)
if (hard_iface->if_status != IF_ACTIVE) if (hard_iface->if_status != IF_ACTIVE)
continue; continue;
if (compare_eth(hard_iface->net_dev->dev_addr, addr)) { if (batadv_compare_eth(hard_iface->net_dev->dev_addr, addr)) {
rcu_read_unlock(); rcu_read_unlock();
return 1; return 1;
} }
...@@ -238,7 +238,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -238,7 +238,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
batman_ogm_packet = (struct batman_ogm_packet *)skb->data; batman_ogm_packet = (struct batman_ogm_packet *)skb->data;
if (batman_ogm_packet->header.version != COMPAT_VERSION) { if (batman_ogm_packet->header.version != COMPAT_VERSION) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Drop packet: incompatible batman version (%i)\n", "Drop packet: incompatible batman version (%i)\n",
batman_ogm_packet->header.version); batman_ogm_packet->header.version);
goto err_free; goto err_free;
......
...@@ -175,7 +175,7 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset); ...@@ -175,7 +175,7 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset);
int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...) int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...)
__printf(2, 3); __printf(2, 3);
#define bat_dbg(type, bat_priv, fmt, arg...) \ #define batadv_dbg(type, bat_priv, fmt, arg...) \
do { \ do { \
if (atomic_read(&bat_priv->log_level) & type) \ if (atomic_read(&bat_priv->log_level) & type) \
batadv_debug_log(bat_priv, fmt, ## arg);\ batadv_debug_log(bat_priv, fmt, ## arg);\
...@@ -183,7 +183,7 @@ __printf(2, 3); ...@@ -183,7 +183,7 @@ __printf(2, 3);
while (0) while (0)
#else /* !CONFIG_BATMAN_ADV_DEBUG */ #else /* !CONFIG_BATMAN_ADV_DEBUG */
__printf(3, 4) __printf(3, 4)
static inline void bat_dbg(int type __always_unused, static inline void batadv_dbg(int type __always_unused,
struct bat_priv *bat_priv __always_unused, struct bat_priv *bat_priv __always_unused,
const char *fmt __always_unused, ...) const char *fmt __always_unused, ...)
{ {
...@@ -194,14 +194,14 @@ static inline void bat_dbg(int type __always_unused, ...@@ -194,14 +194,14 @@ static inline void bat_dbg(int type __always_unused,
do { \ do { \
struct net_device *_netdev = (net_dev); \ struct net_device *_netdev = (net_dev); \
struct bat_priv *_batpriv = netdev_priv(_netdev); \ struct bat_priv *_batpriv = netdev_priv(_netdev); \
bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
pr_info("%s: " fmt, _netdev->name, ## arg); \ pr_info("%s: " fmt, _netdev->name, ## arg); \
} while (0) } while (0)
#define bat_err(net_dev, fmt, arg...) \ #define bat_err(net_dev, fmt, arg...) \
do { \ do { \
struct net_device *_netdev = (net_dev); \ struct net_device *_netdev = (net_dev); \
struct bat_priv *_batpriv = netdev_priv(_netdev); \ struct bat_priv *_batpriv = netdev_priv(_netdev); \
bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
pr_err("%s: " fmt, _netdev->name, ## arg); \ pr_err("%s: " fmt, _netdev->name, ## arg); \
} while (0) } while (0)
...@@ -209,7 +209,7 @@ static inline void bat_dbg(int type __always_unused, ...@@ -209,7 +209,7 @@ static inline void bat_dbg(int type __always_unused,
* *
* note: can't use compare_ether_addr() as it requires aligned memory * note: can't use compare_ether_addr() as it requires aligned memory
*/ */
static inline int compare_eth(const void *data1, const void *data2) static inline int batadv_compare_eth(const void *data1, const void *data2)
{ {
return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
} }
...@@ -220,7 +220,8 @@ static inline int compare_eth(const void *data1, const void *data2) ...@@ -220,7 +220,8 @@ static inline int compare_eth(const void *data1, const void *data2)
* *
* Returns true if current time is after timestamp + timeout * Returns true if current time is after timestamp + timeout
*/ */
static inline bool has_timed_out(unsigned long timestamp, unsigned int timeout) static inline bool batadv_has_timed_out(unsigned long timestamp,
unsigned int timeout)
{ {
return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout)); return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout));
} }
......
...@@ -28,17 +28,17 @@ ...@@ -28,17 +28,17 @@
#include "soft-interface.h" #include "soft-interface.h"
#include "bridge_loop_avoidance.h" #include "bridge_loop_avoidance.h"
static void purge_orig(struct work_struct *work); static void batadv_purge_orig(struct work_struct *work);
static void start_purge_timer(struct bat_priv *bat_priv) static void batadv_start_purge_timer(struct bat_priv *bat_priv)
{ {
INIT_DELAYED_WORK(&bat_priv->orig_work, purge_orig); INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig);
queue_delayed_work(batadv_event_workqueue, queue_delayed_work(batadv_event_workqueue,
&bat_priv->orig_work, msecs_to_jiffies(1000)); &bat_priv->orig_work, msecs_to_jiffies(1000));
} }
/* returns 1 if they are the same originator */ /* returns 1 if they are the same originator */
static int compare_orig(const struct hlist_node *node, const void *data2) static int batadv_compare_orig(const struct hlist_node *node, const void *data2)
{ {
const void *data1 = container_of(node, struct orig_node, hash_entry); const void *data1 = container_of(node, struct orig_node, hash_entry);
...@@ -55,7 +55,7 @@ int batadv_originator_init(struct bat_priv *bat_priv) ...@@ -55,7 +55,7 @@ int batadv_originator_init(struct bat_priv *bat_priv)
if (!bat_priv->orig_hash) if (!bat_priv->orig_hash)
goto err; goto err;
start_purge_timer(bat_priv); batadv_start_purge_timer(bat_priv);
return 0; return 0;
err: err:
...@@ -102,7 +102,7 @@ struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface, ...@@ -102,7 +102,7 @@ struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface,
/* extra reference for return */ /* extra reference for return */
atomic_set(&neigh_node->refcount, 2); atomic_set(&neigh_node->refcount, 2);
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Creating new neighbor %pM, initial seqno %d\n", "Creating new neighbor %pM, initial seqno %d\n",
neigh_addr, seqno); neigh_addr, seqno);
...@@ -110,7 +110,7 @@ struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface, ...@@ -110,7 +110,7 @@ struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface,
return neigh_node; return neigh_node;
} }
static void orig_node_free_rcu(struct rcu_head *rcu) static void batadv_orig_node_free_rcu(struct rcu_head *rcu)
{ {
struct hlist_node *node, *node_tmp; struct hlist_node *node, *node_tmp;
struct neigh_node *neigh_node, *tmp_neigh_node; struct neigh_node *neigh_node, *tmp_neigh_node;
...@@ -149,7 +149,7 @@ static void orig_node_free_rcu(struct rcu_head *rcu) ...@@ -149,7 +149,7 @@ static void orig_node_free_rcu(struct rcu_head *rcu)
void batadv_orig_node_free_ref(struct orig_node *orig_node) void batadv_orig_node_free_ref(struct orig_node *orig_node)
{ {
if (atomic_dec_and_test(&orig_node->refcount)) if (atomic_dec_and_test(&orig_node->refcount))
call_rcu(&orig_node->rcu, orig_node_free_rcu); call_rcu(&orig_node->rcu, batadv_orig_node_free_rcu);
} }
void batadv_originator_free(struct bat_priv *bat_priv) void batadv_originator_free(struct bat_priv *bat_priv)
...@@ -195,12 +195,12 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, ...@@ -195,12 +195,12 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
int size; int size;
int hash_added; int hash_added;
orig_node = orig_hash_find(bat_priv, addr); orig_node = batadv_orig_hash_find(bat_priv, addr);
if (orig_node) if (orig_node)
return orig_node; return orig_node;
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv, "Creating new originator: %pM\n",
"Creating new originator: %pM\n", addr); addr);
orig_node = kzalloc(sizeof(*orig_node), GFP_ATOMIC); orig_node = kzalloc(sizeof(*orig_node), GFP_ATOMIC);
if (!orig_node) if (!orig_node)
...@@ -248,8 +248,9 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, ...@@ -248,8 +248,9 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
if (!orig_node->bcast_own_sum) if (!orig_node->bcast_own_sum)
goto free_bcast_own; goto free_bcast_own;
hash_added = hash_add(bat_priv->orig_hash, compare_orig, hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig,
choose_orig, orig_node, &orig_node->hash_entry); batadv_choose_orig, orig_node,
&orig_node->hash_entry);
if (hash_added != 0) if (hash_added != 0)
goto free_bcast_own_sum; goto free_bcast_own_sum;
...@@ -263,7 +264,7 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, ...@@ -263,7 +264,7 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
return NULL; return NULL;
} }
static bool purge_orig_neighbors(struct bat_priv *bat_priv, static bool batadv_purge_orig_neighbors(struct bat_priv *bat_priv,
struct orig_node *orig_node, struct orig_node *orig_node,
struct neigh_node **best_neigh_node) struct neigh_node **best_neigh_node)
{ {
...@@ -271,6 +272,7 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, ...@@ -271,6 +272,7 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv,
struct neigh_node *neigh_node; struct neigh_node *neigh_node;
bool neigh_purged = false; bool neigh_purged = false;
unsigned long last_seen; unsigned long last_seen;
struct hard_iface *if_incoming;
*best_neigh_node = NULL; *best_neigh_node = NULL;
...@@ -280,25 +282,23 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, ...@@ -280,25 +282,23 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv,
hlist_for_each_entry_safe(neigh_node, node, node_tmp, hlist_for_each_entry_safe(neigh_node, node, node_tmp,
&orig_node->neigh_list, list) { &orig_node->neigh_list, list) {
if ((has_timed_out(neigh_node->last_seen, PURGE_TIMEOUT)) ||
(neigh_node->if_incoming->if_status == IF_INACTIVE) ||
(neigh_node->if_incoming->if_status == IF_NOT_IN_USE) ||
(neigh_node->if_incoming->if_status == IF_TO_BE_REMOVED)) {
last_seen = neigh_node->last_seen; last_seen = neigh_node->last_seen;
if_incoming = neigh_node->if_incoming;
if ((batadv_has_timed_out(last_seen, PURGE_TIMEOUT)) ||
(if_incoming->if_status == IF_INACTIVE) ||
(if_incoming->if_status == IF_NOT_IN_USE) ||
(if_incoming->if_status == IF_TO_BE_REMOVED)) {
if ((neigh_node->if_incoming->if_status == if ((if_incoming->if_status == IF_INACTIVE) ||
IF_INACTIVE) || (if_incoming->if_status == IF_NOT_IN_USE) ||
(neigh_node->if_incoming->if_status == (if_incoming->if_status == IF_TO_BE_REMOVED))
IF_NOT_IN_USE) || batadv_dbg(DBG_BATMAN, bat_priv,
(neigh_node->if_incoming->if_status ==
IF_TO_BE_REMOVED))
bat_dbg(DBG_BATMAN, bat_priv,
"neighbor purge: originator %pM, neighbor: %pM, iface: %s\n", "neighbor purge: originator %pM, neighbor: %pM, iface: %s\n",
orig_node->orig, neigh_node->addr, orig_node->orig, neigh_node->addr,
neigh_node->if_incoming->net_dev->name); if_incoming->net_dev->name);
else else
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"neighbor timeout: originator %pM, neighbor: %pM, last_seen: %u\n", "neighbor timeout: originator %pM, neighbor: %pM, last_seen: %u\n",
orig_node->orig, neigh_node->addr, orig_node->orig, neigh_node->addr,
jiffies_to_msecs(last_seen)); jiffies_to_msecs(last_seen));
...@@ -319,19 +319,19 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, ...@@ -319,19 +319,19 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv,
return neigh_purged; return neigh_purged;
} }
static bool purge_orig_node(struct bat_priv *bat_priv, static bool batadv_purge_orig_node(struct bat_priv *bat_priv,
struct orig_node *orig_node) struct orig_node *orig_node)
{ {
struct neigh_node *best_neigh_node; struct neigh_node *best_neigh_node;
if (has_timed_out(orig_node->last_seen, 2 * PURGE_TIMEOUT)) { if (batadv_has_timed_out(orig_node->last_seen, 2 * PURGE_TIMEOUT)) {
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"Originator timeout: originator %pM, last_seen %u\n", "Originator timeout: originator %pM, last_seen %u\n",
orig_node->orig, orig_node->orig,
jiffies_to_msecs(orig_node->last_seen)); jiffies_to_msecs(orig_node->last_seen));
return true; return true;
} else { } else {
if (purge_orig_neighbors(bat_priv, orig_node, if (batadv_purge_orig_neighbors(bat_priv, orig_node,
&best_neigh_node)) &best_neigh_node))
batadv_update_route(bat_priv, orig_node, batadv_update_route(bat_priv, orig_node,
best_neigh_node); best_neigh_node);
...@@ -340,7 +340,7 @@ static bool purge_orig_node(struct bat_priv *bat_priv, ...@@ -340,7 +340,7 @@ static bool purge_orig_node(struct bat_priv *bat_priv,
return false; return false;
} }
static void _purge_orig(struct bat_priv *bat_priv) static void _batadv_purge_orig(struct bat_priv *bat_priv)
{ {
struct hashtable_t *hash = bat_priv->orig_hash; struct hashtable_t *hash = bat_priv->orig_hash;
struct hlist_node *node, *node_tmp; struct hlist_node *node, *node_tmp;
...@@ -360,7 +360,7 @@ static void _purge_orig(struct bat_priv *bat_priv) ...@@ -360,7 +360,7 @@ static void _purge_orig(struct bat_priv *bat_priv)
spin_lock_bh(list_lock); spin_lock_bh(list_lock);
hlist_for_each_entry_safe(orig_node, node, node_tmp, hlist_for_each_entry_safe(orig_node, node, node_tmp,
head, hash_entry) { head, hash_entry) {
if (purge_orig_node(bat_priv, orig_node)) { if (batadv_purge_orig_node(bat_priv, orig_node)) {
if (orig_node->gw_flags) if (orig_node->gw_flags)
batadv_gw_node_delete(bat_priv, batadv_gw_node_delete(bat_priv,
orig_node); orig_node);
...@@ -369,7 +369,7 @@ static void _purge_orig(struct bat_priv *bat_priv) ...@@ -369,7 +369,7 @@ static void _purge_orig(struct bat_priv *bat_priv)
continue; continue;
} }
if (has_timed_out(orig_node->last_frag_packet, if (batadv_has_timed_out(orig_node->last_frag_packet,
FRAG_TIMEOUT)) FRAG_TIMEOUT))
batadv_frag_list_free(&orig_node->frag_list); batadv_frag_list_free(&orig_node->frag_list);
} }
...@@ -380,20 +380,20 @@ static void _purge_orig(struct bat_priv *bat_priv) ...@@ -380,20 +380,20 @@ static void _purge_orig(struct bat_priv *bat_priv)
batadv_gw_election(bat_priv); batadv_gw_election(bat_priv);
} }
static void purge_orig(struct work_struct *work) static void batadv_purge_orig(struct work_struct *work)
{ {
struct delayed_work *delayed_work = struct delayed_work *delayed_work =
container_of(work, struct delayed_work, work); container_of(work, struct delayed_work, work);
struct bat_priv *bat_priv = struct bat_priv *bat_priv =
container_of(delayed_work, struct bat_priv, orig_work); container_of(delayed_work, struct bat_priv, orig_work);
_purge_orig(bat_priv); _batadv_purge_orig(bat_priv);
start_purge_timer(bat_priv); batadv_start_purge_timer(bat_priv);
} }
void batadv_purge_orig_ref(struct bat_priv *bat_priv) void batadv_purge_orig_ref(struct bat_priv *bat_priv)
{ {
_purge_orig(bat_priv); _batadv_purge_orig(bat_priv);
} }
int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
...@@ -412,7 +412,7 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) ...@@ -412,7 +412,7 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
uint32_t i; uint32_t i;
int ret = 0; int ret = 0;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) { if (!primary_if) {
ret = seq_printf(seq, ret = seq_printf(seq,
...@@ -479,11 +479,11 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) ...@@ -479,11 +479,11 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
return ret; return ret;
} }
static int orig_node_add_if(struct orig_node *orig_node, int max_if_num) static int batadv_orig_node_add_if(struct orig_node *orig_node, int max_if_num)
{ {
void *data_ptr; void *data_ptr;
...@@ -528,7 +528,7 @@ int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num) ...@@ -528,7 +528,7 @@ int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num)
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
spin_lock_bh(&orig_node->ogm_cnt_lock); spin_lock_bh(&orig_node->ogm_cnt_lock);
ret = orig_node_add_if(orig_node, max_if_num); ret = batadv_orig_node_add_if(orig_node, max_if_num);
spin_unlock_bh(&orig_node->ogm_cnt_lock); spin_unlock_bh(&orig_node->ogm_cnt_lock);
if (ret == -ENOMEM) if (ret == -ENOMEM)
...@@ -544,7 +544,7 @@ int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num) ...@@ -544,7 +544,7 @@ int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num)
return -ENOMEM; return -ENOMEM;
} }
static int orig_node_del_if(struct orig_node *orig_node, static int batadv_orig_node_del_if(struct orig_node *orig_node,
int max_if_num, int del_if_num) int max_if_num, int del_if_num)
{ {
void *data_ptr = NULL; void *data_ptr = NULL;
...@@ -612,7 +612,7 @@ int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num) ...@@ -612,7 +612,7 @@ int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num)
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
spin_lock_bh(&orig_node->ogm_cnt_lock); spin_lock_bh(&orig_node->ogm_cnt_lock);
ret = orig_node_del_if(orig_node, max_if_num, ret = batadv_orig_node_del_if(orig_node, max_if_num,
hard_iface->if_num); hard_iface->if_num);
spin_unlock_bh(&orig_node->ogm_cnt_lock); spin_unlock_bh(&orig_node->ogm_cnt_lock);
......
...@@ -41,7 +41,7 @@ int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num); ...@@ -41,7 +41,7 @@ int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num);
/* hashfunction to choose an entry in a hash table of given size /* hashfunction to choose an entry in a hash table of given size
* hash algorithm from http://en.wikipedia.org/wiki/Hash_table * hash algorithm from http://en.wikipedia.org/wiki/Hash_table
*/ */
static inline uint32_t choose_orig(const void *data, uint32_t size) static inline uint32_t batadv_choose_orig(const void *data, uint32_t size)
{ {
const unsigned char *key = data; const unsigned char *key = data;
uint32_t hash = 0; uint32_t hash = 0;
...@@ -60,7 +60,7 @@ static inline uint32_t choose_orig(const void *data, uint32_t size) ...@@ -60,7 +60,7 @@ static inline uint32_t choose_orig(const void *data, uint32_t size)
return hash % size; return hash % size;
} }
static inline struct orig_node *orig_hash_find(struct bat_priv *bat_priv, static inline struct orig_node *batadv_orig_hash_find(struct bat_priv *bat_priv,
const void *data) const void *data)
{ {
struct hashtable_t *hash = bat_priv->orig_hash; struct hashtable_t *hash = bat_priv->orig_hash;
...@@ -72,12 +72,12 @@ static inline struct orig_node *orig_hash_find(struct bat_priv *bat_priv, ...@@ -72,12 +72,12 @@ static inline struct orig_node *orig_hash_find(struct bat_priv *bat_priv,
if (!hash) if (!hash)
return NULL; return NULL;
index = choose_orig(data, hash->size); index = batadv_choose_orig(data, hash->size);
head = &hash->table[index]; head = &hash->table[index];
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
if (!compare_eth(orig_node, data)) if (!batadv_compare_eth(orig_node, data))
continue; continue;
if (!atomic_inc_not_zero(&orig_node->refcount)) if (!atomic_inc_not_zero(&orig_node->refcount))
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "unicast.h" #include "unicast.h"
#include "bridge_loop_avoidance.h" #include "bridge_loop_avoidance.h"
static int route_unicast_packet(struct sk_buff *skb, static int batadv_route_unicast_packet(struct sk_buff *skb,
struct hard_iface *recv_if); struct hard_iface *recv_if);
void batadv_slide_own_bcast_window(struct hard_iface *hard_iface) void batadv_slide_own_bcast_window(struct hard_iface *hard_iface)
...@@ -61,7 +61,7 @@ void batadv_slide_own_bcast_window(struct hard_iface *hard_iface) ...@@ -61,7 +61,7 @@ void batadv_slide_own_bcast_window(struct hard_iface *hard_iface)
} }
} }
static void _update_route(struct bat_priv *bat_priv, static void _batadv_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)
{ {
...@@ -71,7 +71,7 @@ static void _update_route(struct bat_priv *bat_priv, ...@@ -71,7 +71,7 @@ static void _update_route(struct bat_priv *bat_priv,
/* route deleted */ /* route deleted */
if ((curr_router) && (!neigh_node)) { if ((curr_router) && (!neigh_node)) {
bat_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n", batadv_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n",
orig_node->orig); orig_node->orig);
batadv_tt_global_del_orig(bat_priv, orig_node, batadv_tt_global_del_orig(bat_priv, orig_node,
"Deleted route towards originator"); "Deleted route towards originator");
...@@ -79,12 +79,12 @@ static void _update_route(struct bat_priv *bat_priv, ...@@ -79,12 +79,12 @@ static void _update_route(struct bat_priv *bat_priv,
/* route added */ /* route added */
} else if ((!curr_router) && (neigh_node)) { } else if ((!curr_router) && (neigh_node)) {
bat_dbg(DBG_ROUTES, bat_priv, batadv_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);
/* route changed */ /* route changed */
} else if (neigh_node && curr_router) { } else if (neigh_node && curr_router) {
bat_dbg(DBG_ROUTES, bat_priv, batadv_dbg(DBG_ROUTES, bat_priv,
"Changing route towards: %pM (now via %pM - was via %pM)\n", "Changing route towards: %pM (now via %pM - was via %pM)\n",
orig_node->orig, neigh_node->addr, orig_node->orig, neigh_node->addr,
curr_router->addr); curr_router->addr);
...@@ -117,7 +117,7 @@ void batadv_update_route(struct bat_priv *bat_priv, struct orig_node *orig_node, ...@@ -117,7 +117,7 @@ void batadv_update_route(struct bat_priv *bat_priv, struct orig_node *orig_node,
router = batadv_orig_node_get_router(orig_node); router = batadv_orig_node_get_router(orig_node);
if (router != neigh_node) if (router != neigh_node)
_update_route(bat_priv, orig_node, neigh_node); _batadv_update_route(bat_priv, orig_node, neigh_node);
out: out:
if (router) if (router)
...@@ -151,7 +151,7 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node, ...@@ -151,7 +151,7 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node,
spin_lock_bh(&orig_node->neigh_list_lock); spin_lock_bh(&orig_node->neigh_list_lock);
/* only consider if it has the same primary address ... */ /* only consider if it has the same primary address ... */
if (!compare_eth(orig_node->orig, if (!batadv_compare_eth(orig_node->orig,
neigh_node->orig_node->primary_addr)) neigh_node->orig_node->primary_addr))
goto candidate_del; goto candidate_del;
...@@ -180,7 +180,8 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node, ...@@ -180,7 +180,8 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node,
continue; continue;
if ((neigh_node->if_incoming == tmp_neigh_node->if_incoming) || if ((neigh_node->if_incoming == tmp_neigh_node->if_incoming) ||
(compare_eth(neigh_node->addr, tmp_neigh_node->addr))) { (batadv_compare_eth(neigh_node->addr,
tmp_neigh_node->addr))) {
interference_candidate = 1; interference_candidate = 1;
break; break;
} }
...@@ -233,11 +234,11 @@ int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, ...@@ -233,11 +234,11 @@ int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
{ {
if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) ||
(seq_num_diff >= EXPECTED_SEQNO_RANGE)) { (seq_num_diff >= EXPECTED_SEQNO_RANGE)) {
if (!has_timed_out(*last_reset, RESET_PROTECTION_MS)) if (!batadv_has_timed_out(*last_reset, RESET_PROTECTION_MS))
return 1; return 1;
*last_reset = jiffies; *last_reset = jiffies;
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"old packet received, start protection\n"); "old packet received, start protection\n");
} }
...@@ -275,7 +276,7 @@ bool batadv_check_management_packet(struct sk_buff *skb, ...@@ -275,7 +276,7 @@ bool batadv_check_management_packet(struct sk_buff *skb,
return true; return true;
} }
static int recv_my_icmp_packet(struct bat_priv *bat_priv, static int batadv_recv_my_icmp_packet(struct bat_priv *bat_priv,
struct sk_buff *skb, size_t icmp_len) struct sk_buff *skb, size_t icmp_len)
{ {
struct hard_iface *primary_if = NULL; struct hard_iface *primary_if = NULL;
...@@ -292,13 +293,13 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv, ...@@ -292,13 +293,13 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
goto out; goto out;
} }
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
/* answer echo request (ping) */ /* answer echo request (ping) */
/* get routing information */ /* get routing information */
orig_node = orig_hash_find(bat_priv, icmp_packet->orig); orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->orig);
if (!orig_node) if (!orig_node)
goto out; goto out;
...@@ -322,7 +323,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv, ...@@ -322,7 +323,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
if (router) if (router)
batadv_neigh_node_free_ref(router); batadv_neigh_node_free_ref(router);
if (orig_node) if (orig_node)
...@@ -330,7 +331,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv, ...@@ -330,7 +331,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
return ret; return ret;
} }
static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, static int batadv_recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct hard_iface *primary_if = NULL; struct hard_iface *primary_if = NULL;
...@@ -348,12 +349,12 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, ...@@ -348,12 +349,12 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
goto out; goto out;
} }
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
/* get routing information */ /* get routing information */
orig_node = orig_hash_find(bat_priv, icmp_packet->orig); orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->orig);
if (!orig_node) if (!orig_node)
goto out; goto out;
...@@ -377,7 +378,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, ...@@ -377,7 +378,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
if (router) if (router)
batadv_neigh_node_free_ref(router); batadv_neigh_node_free_ref(router);
if (orig_node) if (orig_node)
...@@ -430,14 +431,14 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -430,14 +431,14 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
/* packet for me */ /* packet for me */
if (batadv_is_my_mac(icmp_packet->dst)) if (batadv_is_my_mac(icmp_packet->dst))
return recv_my_icmp_packet(bat_priv, skb, hdr_size); return batadv_recv_my_icmp_packet(bat_priv, skb, hdr_size);
/* TTL exceeded */ /* TTL exceeded */
if (icmp_packet->header.ttl < 2) if (icmp_packet->header.ttl < 2)
return recv_icmp_ttl_exceeded(bat_priv, skb); return batadv_recv_icmp_ttl_exceeded(bat_priv, skb);
/* get routing information */ /* get routing information */
orig_node = orig_hash_find(bat_priv, icmp_packet->dst); orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->dst);
if (!orig_node) if (!orig_node)
goto out; goto out;
...@@ -472,7 +473,8 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -472,7 +473,8 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
* This method rotates the bonding list and increases the * This method rotates the bonding list and increases the
* returned router's refcount. * returned router's refcount.
*/ */
static struct neigh_node *find_bond_router(struct orig_node *primary_orig, static struct neigh_node *
batadv_find_bond_router(struct orig_node *primary_orig,
const struct hard_iface *recv_if) const struct hard_iface *recv_if)
{ {
struct neigh_node *tmp_neigh_node; struct neigh_node *tmp_neigh_node;
...@@ -526,7 +528,8 @@ static struct neigh_node *find_bond_router(struct orig_node *primary_orig, ...@@ -526,7 +528,8 @@ static struct neigh_node *find_bond_router(struct orig_node *primary_orig,
* *
* Increases the returned router's refcount * Increases the returned router's refcount
*/ */
static struct neigh_node *find_ifalter_router(struct orig_node *primary_orig, static struct neigh_node *
batadv_find_ifalter_router(struct orig_node *primary_orig,
const struct hard_iface *recv_if) const struct hard_iface *recv_if)
{ {
struct neigh_node *tmp_neigh_node; struct neigh_node *tmp_neigh_node;
...@@ -578,6 +581,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -578,6 +581,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
struct tt_query_packet *tt_query; struct tt_query_packet *tt_query;
uint16_t tt_size; uint16_t tt_size;
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
char tt_flag;
/* drop packet if it has not necessary minimum size */ /* drop packet if it has not necessary minimum size */
if (unlikely(!pskb_may_pull(skb, sizeof(struct tt_query_packet)))) if (unlikely(!pskb_may_pull(skb, sizeof(struct tt_query_packet))))
...@@ -607,11 +611,12 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -607,11 +611,12 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
* forwarded * forwarded
*/ */
if (!batadv_send_tt_response(bat_priv, tt_query)) { if (!batadv_send_tt_response(bat_priv, tt_query)) {
bat_dbg(DBG_TT, bat_priv, tt_flag = tt_query->flags & TT_FULL_TABLE ? 'F' : '.';
batadv_dbg(DBG_TT, bat_priv,
"Routing TT_REQUEST to %pM [%c]\n", "Routing TT_REQUEST to %pM [%c]\n",
tt_query->dst, tt_query->dst,
(tt_query->flags & TT_FULL_TABLE ? 'F' : '.')); tt_flag);
return route_unicast_packet(skb, recv_if); return batadv_route_unicast_packet(skb, recv_if);
} }
break; break;
case TT_RESPONSE: case TT_RESPONSE:
...@@ -635,11 +640,12 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -635,11 +640,12 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
batadv_handle_tt_response(bat_priv, tt_query); batadv_handle_tt_response(bat_priv, tt_query);
} else { } else {
bat_dbg(DBG_TT, bat_priv, tt_flag = tt_query->flags & TT_FULL_TABLE ? 'F' : '.';
batadv_dbg(DBG_TT, bat_priv,
"Routing TT_RESPONSE to %pM [%c]\n", "Routing TT_RESPONSE to %pM [%c]\n",
tt_query->dst, tt_query->dst,
(tt_query->flags & TT_FULL_TABLE ? 'F' : '.')); tt_flag);
return route_unicast_packet(skb, recv_if); return batadv_route_unicast_packet(skb, recv_if);
} }
break; break;
} }
...@@ -675,7 +681,7 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -675,7 +681,7 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
roam_adv_packet = (struct roam_adv_packet *)skb->data; roam_adv_packet = (struct roam_adv_packet *)skb->data;
if (!batadv_is_my_mac(roam_adv_packet->dst)) if (!batadv_is_my_mac(roam_adv_packet->dst))
return route_unicast_packet(skb, recv_if); return batadv_route_unicast_packet(skb, recv_if);
/* check if it is a backbone gateway. we don't accept /* check if it is a backbone gateway. we don't accept
* roaming advertisement from it, as it has the same * roaming advertisement from it, as it has the same
...@@ -684,11 +690,11 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -684,11 +690,11 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
if (batadv_bla_is_backbone_gw_orig(bat_priv, roam_adv_packet->src)) if (batadv_bla_is_backbone_gw_orig(bat_priv, roam_adv_packet->src))
goto out; goto out;
orig_node = orig_hash_find(bat_priv, roam_adv_packet->src); orig_node = batadv_orig_hash_find(bat_priv, roam_adv_packet->src);
if (!orig_node) if (!orig_node)
goto out; goto out;
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Received ROAMING_ADV from %pM (client %pM)\n", "Received ROAMING_ADV from %pM (client %pM)\n",
roam_adv_packet->src, roam_adv_packet->client); roam_adv_packet->src, roam_adv_packet->client);
...@@ -721,6 +727,7 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv, ...@@ -721,6 +727,7 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv,
struct neigh_node *router; struct neigh_node *router;
static uint8_t zero_mac[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; static uint8_t zero_mac[ETH_ALEN] = {0, 0, 0, 0, 0, 0};
int bonding_enabled; int bonding_enabled;
uint8_t *primary_addr;
if (!orig_node) if (!orig_node)
return NULL; return NULL;
...@@ -743,20 +750,22 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv, ...@@ -743,20 +750,22 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv,
if ((!recv_if) && (!bonding_enabled)) if ((!recv_if) && (!bonding_enabled))
goto return_router; goto return_router;
primary_addr = router_orig->primary_addr;
/* if we have something in the primary_addr, we can search /* if we have something in the primary_addr, we can search
* for a potential bonding candidate. * for a potential bonding candidate.
*/ */
if (compare_eth(router_orig->primary_addr, zero_mac)) if (batadv_compare_eth(primary_addr, zero_mac))
goto return_router; goto return_router;
/* find the orig_node which has the primary interface. might /* find the orig_node which has the primary interface. might
* even be the same as our router_orig in many cases * even be the same as our router_orig in many cases
*/ */
if (compare_eth(router_orig->primary_addr, router_orig->orig)) { if (batadv_compare_eth(primary_addr, router_orig->orig)) {
primary_orig_node = router_orig; primary_orig_node = router_orig;
} else { } else {
primary_orig_node = orig_hash_find(bat_priv, primary_orig_node = batadv_orig_hash_find(bat_priv,
router_orig->primary_addr); primary_addr);
if (!primary_orig_node) if (!primary_orig_node)
goto return_router; goto return_router;
...@@ -776,9 +785,9 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv, ...@@ -776,9 +785,9 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv,
batadv_neigh_node_free_ref(router); batadv_neigh_node_free_ref(router);
if (bonding_enabled) if (bonding_enabled)
router = find_bond_router(primary_orig_node, recv_if); router = batadv_find_bond_router(primary_orig_node, recv_if);
else else
router = find_ifalter_router(primary_orig_node, recv_if); router = batadv_find_ifalter_router(primary_orig_node, recv_if);
return_router: return_router:
if (router && router->if_incoming->if_status != IF_ACTIVE) if (router && router->if_incoming->if_status != IF_ACTIVE)
...@@ -794,7 +803,7 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv, ...@@ -794,7 +803,7 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv,
return NULL; return NULL;
} }
static int check_unicast_packet(struct sk_buff *skb, int hdr_size) static int batadv_check_unicast_packet(struct sk_buff *skb, int hdr_size)
{ {
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
...@@ -819,7 +828,8 @@ static int check_unicast_packet(struct sk_buff *skb, int hdr_size) ...@@ -819,7 +828,8 @@ static int check_unicast_packet(struct sk_buff *skb, int hdr_size)
return 0; return 0;
} }
static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) static int batadv_route_unicast_packet(struct sk_buff *skb,
struct hard_iface *recv_if)
{ {
struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct orig_node *orig_node = NULL; struct orig_node *orig_node = NULL;
...@@ -839,7 +849,7 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -839,7 +849,7 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
} }
/* get routing information */ /* get routing information */
orig_node = orig_hash_find(bat_priv, unicast_packet->dest); orig_node = batadv_orig_hash_find(bat_priv, unicast_packet->dest);
if (!orig_node) if (!orig_node)
goto out; goto out;
...@@ -866,7 +876,8 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -866,7 +876,8 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
} }
if (unicast_packet->header.packet_type == BAT_UNICAST_FRAG && if (unicast_packet->header.packet_type == BAT_UNICAST_FRAG &&
frag_can_reassemble(skb, neigh_node->if_incoming->net_dev->mtu)) { batadv_frag_can_reassemble(skb,
neigh_node->if_incoming->net_dev->mtu)) {
ret = batadv_frag_reassemble_skb(skb, bat_priv, &new_skb); ret = batadv_frag_reassemble_skb(skb, bat_priv, &new_skb);
...@@ -903,7 +914,7 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -903,7 +914,7 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
return ret; return ret;
} }
static int check_unicast_ttvn(struct bat_priv *bat_priv, static int batadv_check_unicast_ttvn(struct bat_priv *bat_priv,
struct sk_buff *skb) { struct sk_buff *skb) {
uint8_t curr_ttvn; uint8_t curr_ttvn;
struct orig_node *orig_node; struct orig_node *orig_node;
...@@ -922,7 +933,8 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv, ...@@ -922,7 +933,8 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
tt_poss_change = bat_priv->tt_poss_change; tt_poss_change = bat_priv->tt_poss_change;
curr_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); curr_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn);
} else { } else {
orig_node = orig_hash_find(bat_priv, unicast_packet->dest); orig_node = batadv_orig_hash_find(bat_priv,
unicast_packet->dest);
if (!orig_node) if (!orig_node)
return 0; return 0;
...@@ -955,12 +967,12 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv, ...@@ -955,12 +967,12 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
if (!orig_node) { if (!orig_node) {
if (!batadv_is_my_client(bat_priv, ethhdr->h_dest)) if (!batadv_is_my_client(bat_priv, ethhdr->h_dest))
return 0; return 0;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
return 0; return 0;
memcpy(unicast_packet->dest, memcpy(unicast_packet->dest,
primary_if->net_dev->dev_addr, ETH_ALEN); primary_if->net_dev->dev_addr, ETH_ALEN);
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
} else { } else {
memcpy(unicast_packet->dest, orig_node->orig, memcpy(unicast_packet->dest, orig_node->orig,
ETH_ALEN); ETH_ALEN);
...@@ -969,7 +981,7 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv, ...@@ -969,7 +981,7 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
batadv_orig_node_free_ref(orig_node); batadv_orig_node_free_ref(orig_node);
} }
bat_dbg(DBG_ROUTES, bat_priv, batadv_dbg(DBG_ROUTES, bat_priv,
"TTVN mismatch (old_ttvn %u new_ttvn %u)! Rerouting unicast packet (for %pM) to %pM\n", "TTVN mismatch (old_ttvn %u new_ttvn %u)! Rerouting unicast packet (for %pM) to %pM\n",
unicast_packet->ttvn, curr_ttvn, ethhdr->h_dest, unicast_packet->ttvn, curr_ttvn, ethhdr->h_dest,
unicast_packet->dest); unicast_packet->dest);
...@@ -985,10 +997,10 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -985,10 +997,10 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
struct unicast_packet *unicast_packet; struct unicast_packet *unicast_packet;
int hdr_size = sizeof(*unicast_packet); int hdr_size = sizeof(*unicast_packet);
if (check_unicast_packet(skb, hdr_size) < 0) if (batadv_check_unicast_packet(skb, hdr_size) < 0)
return NET_RX_DROP; return NET_RX_DROP;
if (!check_unicast_ttvn(bat_priv, skb)) if (!batadv_check_unicast_ttvn(bat_priv, skb))
return NET_RX_DROP; return NET_RX_DROP;
unicast_packet = (struct unicast_packet *)skb->data; unicast_packet = (struct unicast_packet *)skb->data;
...@@ -1000,7 +1012,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -1000,7 +1012,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
return NET_RX_SUCCESS; return NET_RX_SUCCESS;
} }
return route_unicast_packet(skb, recv_if); return batadv_route_unicast_packet(skb, recv_if);
} }
int batadv_recv_ucast_frag_packet(struct sk_buff *skb, int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
...@@ -1012,10 +1024,10 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb, ...@@ -1012,10 +1024,10 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
struct sk_buff *new_skb = NULL; struct sk_buff *new_skb = NULL;
int ret; int ret;
if (check_unicast_packet(skb, hdr_size) < 0) if (batadv_check_unicast_packet(skb, hdr_size) < 0)
return NET_RX_DROP; return NET_RX_DROP;
if (!check_unicast_ttvn(bat_priv, skb)) if (!batadv_check_unicast_ttvn(bat_priv, skb))
return NET_RX_DROP; return NET_RX_DROP;
unicast_packet = (struct unicast_frag_packet *)skb->data; unicast_packet = (struct unicast_frag_packet *)skb->data;
...@@ -1037,7 +1049,7 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb, ...@@ -1037,7 +1049,7 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
return NET_RX_SUCCESS; return NET_RX_SUCCESS;
} }
return route_unicast_packet(skb, recv_if); return batadv_route_unicast_packet(skb, recv_if);
} }
...@@ -1078,7 +1090,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -1078,7 +1090,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
if (bcast_packet->header.ttl < 2) if (bcast_packet->header.ttl < 2)
goto out; goto out;
orig_node = orig_hash_find(bat_priv, bcast_packet->orig); orig_node = batadv_orig_hash_find(bat_priv, bcast_packet->orig);
if (!orig_node) if (!orig_node)
goto out; goto out;
...@@ -1086,7 +1098,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -1086,7 +1098,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
spin_lock_bh(&orig_node->bcast_seqno_lock); spin_lock_bh(&orig_node->bcast_seqno_lock);
/* check whether the packet is a duplicate */ /* check whether the packet is a duplicate */
if (bat_test_bit(orig_node->bcast_bits, orig_node->last_bcast_seqno, if (batadv_test_bit(orig_node->bcast_bits, orig_node->last_bcast_seqno,
ntohl(bcast_packet->seqno))) ntohl(bcast_packet->seqno)))
goto spin_unlock; goto spin_unlock;
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "gateway_common.h" #include "gateway_common.h"
#include "originator.h" #include "originator.h"
static void send_outstanding_bcast_packet(struct work_struct *work); static void batadv_send_outstanding_bcast_packet(struct work_struct *work);
/* send out an already prepared packet to the given address via the /* send out an already prepared packet to the given address via the
* specified batman interface * specified batman interface
...@@ -96,16 +96,16 @@ void batadv_schedule_bat_ogm(struct hard_iface *hard_iface) ...@@ -96,16 +96,16 @@ void batadv_schedule_bat_ogm(struct hard_iface *hard_iface)
bat_priv->bat_algo_ops->bat_ogm_schedule(hard_iface); bat_priv->bat_algo_ops->bat_ogm_schedule(hard_iface);
} }
static void forw_packet_free(struct forw_packet *forw_packet) static void batadv_forw_packet_free(struct forw_packet *forw_packet)
{ {
if (forw_packet->skb) if (forw_packet->skb)
kfree_skb(forw_packet->skb); kfree_skb(forw_packet->skb);
if (forw_packet->if_incoming) if (forw_packet->if_incoming)
hardif_free_ref(forw_packet->if_incoming); batadv_hardif_free_ref(forw_packet->if_incoming);
kfree(forw_packet); kfree(forw_packet);
} }
static void _add_bcast_packet_to_list(struct bat_priv *bat_priv, static void _batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
struct forw_packet *forw_packet, struct forw_packet *forw_packet,
unsigned long send_time) unsigned long send_time)
{ {
...@@ -118,7 +118,7 @@ static void _add_bcast_packet_to_list(struct bat_priv *bat_priv, ...@@ -118,7 +118,7 @@ static void _add_bcast_packet_to_list(struct bat_priv *bat_priv,
/* start timer for this packet */ /* start timer for this packet */
INIT_DELAYED_WORK(&forw_packet->delayed_work, INIT_DELAYED_WORK(&forw_packet->delayed_work,
send_outstanding_bcast_packet); batadv_send_outstanding_bcast_packet);
queue_delayed_work(batadv_event_workqueue, &forw_packet->delayed_work, queue_delayed_work(batadv_event_workqueue, &forw_packet->delayed_work,
send_time); send_time);
} }
...@@ -142,11 +142,11 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv, ...@@ -142,11 +142,11 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
struct sk_buff *newskb; struct sk_buff *newskb;
if (!atomic_dec_not_zero(&bat_priv->bcast_queue_left)) { if (!atomic_dec_not_zero(&bat_priv->bcast_queue_left)) {
bat_dbg(DBG_BATMAN, bat_priv, "bcast packet queue full\n"); batadv_dbg(DBG_BATMAN, bat_priv, "bcast packet queue full\n");
goto out; goto out;
} }
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out_and_inc; goto out_and_inc;
...@@ -171,7 +171,7 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv, ...@@ -171,7 +171,7 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
/* how often did we send the bcast packet ? */ /* how often did we send the bcast packet ? */
forw_packet->num_packets = 0; forw_packet->num_packets = 0;
_add_bcast_packet_to_list(bat_priv, forw_packet, delay); _batadv_add_bcast_packet_to_list(bat_priv, forw_packet, delay);
return NETDEV_TX_OK; return NETDEV_TX_OK;
packet_free: packet_free:
...@@ -180,11 +180,11 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv, ...@@ -180,11 +180,11 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
atomic_inc(&bat_priv->bcast_queue_left); atomic_inc(&bat_priv->bcast_queue_left);
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
return NETDEV_TX_BUSY; return NETDEV_TX_BUSY;
} }
static void send_outstanding_bcast_packet(struct work_struct *work) static void batadv_send_outstanding_bcast_packet(struct work_struct *work)
{ {
struct hard_iface *hard_iface; struct hard_iface *hard_iface;
struct delayed_work *delayed_work = struct delayed_work *delayed_work =
...@@ -220,13 +220,13 @@ static void send_outstanding_bcast_packet(struct work_struct *work) ...@@ -220,13 +220,13 @@ static void send_outstanding_bcast_packet(struct work_struct *work)
/* if we still have some more bcasts to send */ /* if we still have some more bcasts to send */
if (forw_packet->num_packets < 3) { if (forw_packet->num_packets < 3) {
_add_bcast_packet_to_list(bat_priv, forw_packet, _batadv_add_bcast_packet_to_list(bat_priv, forw_packet,
msecs_to_jiffies(5)); msecs_to_jiffies(5));
return; return;
} }
out: out:
forw_packet_free(forw_packet); batadv_forw_packet_free(forw_packet);
atomic_inc(&bat_priv->bcast_queue_left); atomic_inc(&bat_priv->bcast_queue_left);
} }
...@@ -260,7 +260,7 @@ void batadv_send_outstanding_bat_ogm_packet(struct work_struct *work) ...@@ -260,7 +260,7 @@ void batadv_send_outstanding_bat_ogm_packet(struct work_struct *work)
if (!forw_packet->own) if (!forw_packet->own)
atomic_inc(&bat_priv->batman_queue_left); atomic_inc(&bat_priv->batman_queue_left);
forw_packet_free(forw_packet); batadv_forw_packet_free(forw_packet);
} }
void batadv_purge_outstanding_packets(struct bat_priv *bat_priv, void batadv_purge_outstanding_packets(struct bat_priv *bat_priv,
...@@ -271,11 +271,11 @@ void batadv_purge_outstanding_packets(struct bat_priv *bat_priv, ...@@ -271,11 +271,11 @@ void batadv_purge_outstanding_packets(struct bat_priv *bat_priv,
bool pending; bool pending;
if (hard_iface) if (hard_iface)
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"purge_outstanding_packets(): %s\n", "purge_outstanding_packets(): %s\n",
hard_iface->net_dev->name); hard_iface->net_dev->name);
else else
bat_dbg(DBG_BATMAN, bat_priv, batadv_dbg(DBG_BATMAN, bat_priv,
"purge_outstanding_packets()\n"); "purge_outstanding_packets()\n");
/* free bcast list */ /* free bcast list */
...@@ -292,7 +292,7 @@ void batadv_purge_outstanding_packets(struct bat_priv *bat_priv, ...@@ -292,7 +292,7 @@ void batadv_purge_outstanding_packets(struct bat_priv *bat_priv,
spin_unlock_bh(&bat_priv->forw_bcast_list_lock); spin_unlock_bh(&bat_priv->forw_bcast_list_lock);
/* send_outstanding_bcast_packet() will lock the list to /* batadv_send_outstanding_bcast_packet() will lock the list to
* delete the item from the list * delete the item from the list
*/ */
pending = cancel_delayed_work_sync(&forw_packet->delayed_work); pending = cancel_delayed_work_sync(&forw_packet->delayed_work);
...@@ -300,7 +300,7 @@ void batadv_purge_outstanding_packets(struct bat_priv *bat_priv, ...@@ -300,7 +300,7 @@ void batadv_purge_outstanding_packets(struct bat_priv *bat_priv,
if (pending) { if (pending) {
hlist_del(&forw_packet->list); hlist_del(&forw_packet->list);
forw_packet_free(forw_packet); batadv_forw_packet_free(forw_packet);
} }
} }
spin_unlock_bh(&bat_priv->forw_bcast_list_lock); spin_unlock_bh(&bat_priv->forw_bcast_list_lock);
...@@ -327,7 +327,7 @@ void batadv_purge_outstanding_packets(struct bat_priv *bat_priv, ...@@ -327,7 +327,7 @@ void batadv_purge_outstanding_packets(struct bat_priv *bat_priv,
if (pending) { if (pending) {
hlist_del(&forw_packet->list); hlist_del(&forw_packet->list);
forw_packet_free(forw_packet); batadv_forw_packet_free(forw_packet);
} }
} }
spin_unlock_bh(&bat_priv->forw_bat_list_lock); spin_unlock_bh(&bat_priv->forw_bat_list_lock);
......
...@@ -37,23 +37,23 @@ ...@@ -37,23 +37,23 @@
#include "bridge_loop_avoidance.h" #include "bridge_loop_avoidance.h"
static int bat_get_settings(struct net_device *dev, struct ethtool_cmd *cmd); static int batadv_get_settings(struct net_device *dev, struct ethtool_cmd *cmd);
static void bat_get_drvinfo(struct net_device *dev, static void batadv_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info); struct ethtool_drvinfo *info);
static u32 bat_get_msglevel(struct net_device *dev); static u32 batadv_get_msglevel(struct net_device *dev);
static void bat_set_msglevel(struct net_device *dev, u32 value); static void batadv_set_msglevel(struct net_device *dev, u32 value);
static u32 bat_get_link(struct net_device *dev); static u32 batadv_get_link(struct net_device *dev);
static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data); static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data);
static void batadv_get_ethtool_stats(struct net_device *dev, static void batadv_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats, u64 *data); struct ethtool_stats *stats, u64 *data);
static int batadv_get_sset_count(struct net_device *dev, int stringset); static int batadv_get_sset_count(struct net_device *dev, int stringset);
static const struct ethtool_ops bat_ethtool_ops = { static const struct ethtool_ops batadv_ethtool_ops = {
.get_settings = bat_get_settings, .get_settings = batadv_get_settings,
.get_drvinfo = bat_get_drvinfo, .get_drvinfo = batadv_get_drvinfo,
.get_msglevel = bat_get_msglevel, .get_msglevel = batadv_get_msglevel,
.set_msglevel = bat_set_msglevel, .set_msglevel = batadv_set_msglevel,
.get_link = bat_get_link, .get_link = batadv_get_link,
.get_strings = batadv_get_strings, .get_strings = batadv_get_strings,
.get_ethtool_stats = batadv_get_ethtool_stats, .get_ethtool_stats = batadv_get_ethtool_stats,
.get_sset_count = batadv_get_sset_count, .get_sset_count = batadv_get_sset_count,
...@@ -78,25 +78,25 @@ int batadv_skb_head_push(struct sk_buff *skb, unsigned int len) ...@@ -78,25 +78,25 @@ int batadv_skb_head_push(struct sk_buff *skb, unsigned int len)
return 0; return 0;
} }
static int interface_open(struct net_device *dev) static int batadv_interface_open(struct net_device *dev)
{ {
netif_start_queue(dev); netif_start_queue(dev);
return 0; return 0;
} }
static int interface_release(struct net_device *dev) static int batadv_interface_release(struct net_device *dev)
{ {
netif_stop_queue(dev); netif_stop_queue(dev);
return 0; return 0;
} }
static struct net_device_stats *interface_stats(struct net_device *dev) static struct net_device_stats *batadv_interface_stats(struct net_device *dev)
{ {
struct bat_priv *bat_priv = netdev_priv(dev); struct bat_priv *bat_priv = netdev_priv(dev);
return &bat_priv->stats; return &bat_priv->stats;
} }
static int interface_set_mac_addr(struct net_device *dev, void *p) static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)
{ {
struct bat_priv *bat_priv = netdev_priv(dev); struct bat_priv *bat_priv = netdev_priv(dev);
struct sockaddr *addr = p; struct sockaddr *addr = p;
...@@ -116,7 +116,7 @@ static int interface_set_mac_addr(struct net_device *dev, void *p) ...@@ -116,7 +116,7 @@ static int interface_set_mac_addr(struct net_device *dev, void *p)
return 0; return 0;
} }
static int interface_change_mtu(struct net_device *dev, int new_mtu) static int batadv_interface_change_mtu(struct net_device *dev, int new_mtu)
{ {
/* check ranges */ /* check ranges */
if ((new_mtu < 68) || (new_mtu > batadv_hardif_min_mtu(dev))) if ((new_mtu < 68) || (new_mtu > batadv_hardif_min_mtu(dev)))
...@@ -127,7 +127,8 @@ static int interface_change_mtu(struct net_device *dev, int new_mtu) ...@@ -127,7 +127,8 @@ static int interface_change_mtu(struct net_device *dev, int new_mtu)
return 0; return 0;
} }
static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) static int batadv_interface_tx(struct sk_buff *skb,
struct net_device *soft_iface)
{ {
struct ethhdr *ethhdr = (struct ethhdr *)skb->data; struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
struct bat_priv *bat_priv = netdev_priv(soft_iface); struct bat_priv *bat_priv = netdev_priv(soft_iface);
...@@ -168,7 +169,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) ...@@ -168,7 +169,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
/* don't accept stp packets. STP does not help in meshes. /* don't accept stp packets. STP does not help in meshes.
* better use the bridge loop avoidance ... * better use the bridge loop avoidance ...
*/ */
if (compare_eth(ethhdr->h_dest, stp_addr)) if (batadv_compare_eth(ethhdr->h_dest, stp_addr))
goto dropped; goto dropped;
if (is_multicast_ether_addr(ethhdr->h_dest)) { if (is_multicast_ether_addr(ethhdr->h_dest)) {
...@@ -199,7 +200,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) ...@@ -199,7 +200,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
/* ethernet packet should be broadcasted */ /* ethernet packet should be broadcasted */
if (do_bcast) { if (do_bcast) {
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto dropped; goto dropped;
...@@ -253,7 +254,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) ...@@ -253,7 +254,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
bat_priv->stats.tx_dropped++; bat_priv->stats.tx_dropped++;
end: end:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
...@@ -323,23 +324,23 @@ void batadv_interface_rx(struct net_device *soft_iface, ...@@ -323,23 +324,23 @@ void batadv_interface_rx(struct net_device *soft_iface,
return; return;
} }
static const struct net_device_ops bat_netdev_ops = { static const struct net_device_ops batadv_netdev_ops = {
.ndo_open = interface_open, .ndo_open = batadv_interface_open,
.ndo_stop = interface_release, .ndo_stop = batadv_interface_release,
.ndo_get_stats = interface_stats, .ndo_get_stats = batadv_interface_stats,
.ndo_set_mac_address = interface_set_mac_addr, .ndo_set_mac_address = batadv_interface_set_mac_addr,
.ndo_change_mtu = interface_change_mtu, .ndo_change_mtu = batadv_interface_change_mtu,
.ndo_start_xmit = interface_tx, .ndo_start_xmit = batadv_interface_tx,
.ndo_validate_addr = eth_validate_addr .ndo_validate_addr = eth_validate_addr
}; };
static void interface_setup(struct net_device *dev) static void batadv_interface_setup(struct net_device *dev)
{ {
struct bat_priv *priv = netdev_priv(dev); struct bat_priv *priv = netdev_priv(dev);
ether_setup(dev); ether_setup(dev);
dev->netdev_ops = &bat_netdev_ops; dev->netdev_ops = &batadv_netdev_ops;
dev->destructor = free_netdev; dev->destructor = free_netdev;
dev->tx_queue_len = 0; dev->tx_queue_len = 0;
...@@ -353,7 +354,7 @@ static void interface_setup(struct net_device *dev) ...@@ -353,7 +354,7 @@ static void interface_setup(struct net_device *dev)
/* generate random address */ /* generate random address */
eth_hw_addr_random(dev); eth_hw_addr_random(dev);
SET_ETHTOOL_OPS(dev, &bat_ethtool_ops); SET_ETHTOOL_OPS(dev, &batadv_ethtool_ops);
memset(priv, 0, sizeof(*priv)); memset(priv, 0, sizeof(*priv));
} }
...@@ -364,7 +365,8 @@ struct net_device *batadv_softif_create(const char *name) ...@@ -364,7 +365,8 @@ struct net_device *batadv_softif_create(const char *name)
struct bat_priv *bat_priv; struct bat_priv *bat_priv;
int ret; int ret;
soft_iface = alloc_netdev(sizeof(*bat_priv), name, interface_setup); soft_iface = alloc_netdev(sizeof(*bat_priv), name,
batadv_interface_setup);
if (!soft_iface) if (!soft_iface)
goto out; goto out;
...@@ -456,14 +458,14 @@ void batadv_softif_destroy(struct net_device *soft_iface) ...@@ -456,14 +458,14 @@ void batadv_softif_destroy(struct net_device *soft_iface)
int batadv_softif_is_valid(const struct net_device *net_dev) int batadv_softif_is_valid(const struct net_device *net_dev)
{ {
if (net_dev->netdev_ops->ndo_start_xmit == interface_tx) if (net_dev->netdev_ops->ndo_start_xmit == batadv_interface_tx)
return 1; return 1;
return 0; return 0;
} }
/* ethtool */ /* ethtool */
static int bat_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) static int batadv_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{ {
cmd->supported = 0; cmd->supported = 0;
cmd->advertising = 0; cmd->advertising = 0;
...@@ -479,7 +481,7 @@ static int bat_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) ...@@ -479,7 +481,7 @@ static int bat_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
return 0; return 0;
} }
static void bat_get_drvinfo(struct net_device *dev, static void batadv_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info) struct ethtool_drvinfo *info)
{ {
strcpy(info->driver, "B.A.T.M.A.N. advanced"); strcpy(info->driver, "B.A.T.M.A.N. advanced");
...@@ -488,16 +490,16 @@ static void bat_get_drvinfo(struct net_device *dev, ...@@ -488,16 +490,16 @@ static void bat_get_drvinfo(struct net_device *dev,
strcpy(info->bus_info, "batman"); strcpy(info->bus_info, "batman");
} }
static u32 bat_get_msglevel(struct net_device *dev) static u32 batadv_get_msglevel(struct net_device *dev)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static void bat_set_msglevel(struct net_device *dev, u32 value) static void batadv_set_msglevel(struct net_device *dev, u32 value)
{ {
} }
static u32 bat_get_link(struct net_device *dev) static u32 batadv_get_link(struct net_device *dev)
{ {
return 1; return 1;
} }
...@@ -508,7 +510,7 @@ static u32 bat_get_link(struct net_device *dev) ...@@ -508,7 +510,7 @@ static u32 bat_get_link(struct net_device *dev)
*/ */
static const struct { static const struct {
const char name[ETH_GSTRING_LEN]; const char name[ETH_GSTRING_LEN];
} bat_counters_strings[] = { } batadv_counters_strings[] = {
{ "forward" }, { "forward" },
{ "forward_bytes" }, { "forward_bytes" },
{ "mgmt_tx" }, { "mgmt_tx" },
...@@ -527,8 +529,8 @@ static void batadv_get_strings(struct net_device *dev, uint32_t stringset, ...@@ -527,8 +529,8 @@ static void batadv_get_strings(struct net_device *dev, uint32_t stringset,
uint8_t *data) uint8_t *data)
{ {
if (stringset == ETH_SS_STATS) if (stringset == ETH_SS_STATS)
memcpy(data, bat_counters_strings, memcpy(data, batadv_counters_strings,
sizeof(bat_counters_strings)); sizeof(batadv_counters_strings));
} }
static void batadv_get_ethtool_stats(struct net_device *dev, static void batadv_get_ethtool_stats(struct net_device *dev,
......
...@@ -29,13 +29,14 @@ ...@@ -29,13 +29,14 @@
#include <linux/crc16.h> #include <linux/crc16.h>
static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
struct orig_node *orig_node); struct orig_node *orig_node);
static void tt_purge(struct work_struct *work); static void batadv_tt_purge(struct work_struct *work);
static void tt_global_del_orig_list(struct tt_global_entry *tt_global_entry); static void
batadv_tt_global_del_orig_list(struct tt_global_entry *tt_global_entry);
/* returns 1 if they are the same mac addr */ /* returns 1 if they are the same mac addr */
static int compare_tt(const struct hlist_node *node, const void *data2) static int batadv_compare_tt(const struct hlist_node *node, const void *data2)
{ {
const void *data1 = container_of(node, struct tt_common_entry, const void *data1 = container_of(node, struct tt_common_entry,
hash_entry); hash_entry);
...@@ -43,14 +44,14 @@ static int compare_tt(const struct hlist_node *node, const void *data2) ...@@ -43,14 +44,14 @@ static int compare_tt(const struct hlist_node *node, const void *data2)
return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
} }
static void tt_start_timer(struct bat_priv *bat_priv) static void batadv_tt_start_timer(struct bat_priv *bat_priv)
{ {
INIT_DELAYED_WORK(&bat_priv->tt_work, tt_purge); INIT_DELAYED_WORK(&bat_priv->tt_work, batadv_tt_purge);
queue_delayed_work(batadv_event_workqueue, &bat_priv->tt_work, queue_delayed_work(batadv_event_workqueue, &bat_priv->tt_work,
msecs_to_jiffies(5000)); msecs_to_jiffies(5000));
} }
static struct tt_common_entry *tt_hash_find(struct hashtable_t *hash, static struct tt_common_entry *batadv_tt_hash_find(struct hashtable_t *hash,
const void *data) const void *data)
{ {
struct hlist_head *head; struct hlist_head *head;
...@@ -61,12 +62,12 @@ static struct tt_common_entry *tt_hash_find(struct hashtable_t *hash, ...@@ -61,12 +62,12 @@ static struct tt_common_entry *tt_hash_find(struct hashtable_t *hash,
if (!hash) if (!hash)
return NULL; return NULL;
index = choose_orig(data, hash->size); index = batadv_choose_orig(data, hash->size);
head = &hash->table[index]; head = &hash->table[index];
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(tt_common_entry, node, head, hash_entry) { hlist_for_each_entry_rcu(tt_common_entry, node, head, hash_entry) {
if (!compare_eth(tt_common_entry, data)) if (!batadv_compare_eth(tt_common_entry, data))
continue; continue;
if (!atomic_inc_not_zero(&tt_common_entry->refcount)) if (!atomic_inc_not_zero(&tt_common_entry->refcount))
...@@ -80,26 +81,26 @@ static struct tt_common_entry *tt_hash_find(struct hashtable_t *hash, ...@@ -80,26 +81,26 @@ static struct tt_common_entry *tt_hash_find(struct hashtable_t *hash,
return tt_common_entry_tmp; return tt_common_entry_tmp;
} }
static struct tt_local_entry *tt_local_hash_find(struct bat_priv *bat_priv, static struct tt_local_entry *
const void *data) batadv_tt_local_hash_find(struct bat_priv *bat_priv, const void *data)
{ {
struct tt_common_entry *tt_common_entry; struct tt_common_entry *tt_common_entry;
struct tt_local_entry *tt_local_entry = NULL; struct tt_local_entry *tt_local_entry = NULL;
tt_common_entry = tt_hash_find(bat_priv->tt_local_hash, data); tt_common_entry = batadv_tt_hash_find(bat_priv->tt_local_hash, data);
if (tt_common_entry) if (tt_common_entry)
tt_local_entry = container_of(tt_common_entry, tt_local_entry = container_of(tt_common_entry,
struct tt_local_entry, common); struct tt_local_entry, common);
return tt_local_entry; return tt_local_entry;
} }
static struct tt_global_entry *tt_global_hash_find(struct bat_priv *bat_priv, static struct tt_global_entry *
const void *data) batadv_tt_global_hash_find(struct bat_priv *bat_priv, const void *data)
{ {
struct tt_common_entry *tt_common_entry; struct tt_common_entry *tt_common_entry;
struct tt_global_entry *tt_global_entry = NULL; struct tt_global_entry *tt_global_entry = NULL;
tt_common_entry = tt_hash_find(bat_priv->tt_global_hash, data); tt_common_entry = batadv_tt_hash_find(bat_priv->tt_global_hash, data);
if (tt_common_entry) if (tt_common_entry)
tt_global_entry = container_of(tt_common_entry, tt_global_entry = container_of(tt_common_entry,
struct tt_global_entry, common); struct tt_global_entry, common);
...@@ -107,13 +108,14 @@ static struct tt_global_entry *tt_global_hash_find(struct bat_priv *bat_priv, ...@@ -107,13 +108,14 @@ static struct tt_global_entry *tt_global_hash_find(struct bat_priv *bat_priv,
} }
static void tt_local_entry_free_ref(struct tt_local_entry *tt_local_entry) static void
batadv_tt_local_entry_free_ref(struct tt_local_entry *tt_local_entry)
{ {
if (atomic_dec_and_test(&tt_local_entry->common.refcount)) if (atomic_dec_and_test(&tt_local_entry->common.refcount))
kfree_rcu(tt_local_entry, common.rcu); kfree_rcu(tt_local_entry, common.rcu);
} }
static void tt_global_entry_free_rcu(struct rcu_head *rcu) static void batadv_tt_global_entry_free_rcu(struct rcu_head *rcu)
{ {
struct tt_common_entry *tt_common_entry; struct tt_common_entry *tt_common_entry;
struct tt_global_entry *tt_global_entry; struct tt_global_entry *tt_global_entry;
...@@ -125,16 +127,17 @@ static void tt_global_entry_free_rcu(struct rcu_head *rcu) ...@@ -125,16 +127,17 @@ static void tt_global_entry_free_rcu(struct rcu_head *rcu)
kfree(tt_global_entry); kfree(tt_global_entry);
} }
static void tt_global_entry_free_ref(struct tt_global_entry *tt_global_entry) static void
batadv_tt_global_entry_free_ref(struct tt_global_entry *tt_global_entry)
{ {
if (atomic_dec_and_test(&tt_global_entry->common.refcount)) { if (atomic_dec_and_test(&tt_global_entry->common.refcount)) {
tt_global_del_orig_list(tt_global_entry); batadv_tt_global_del_orig_list(tt_global_entry);
call_rcu(&tt_global_entry->common.rcu, call_rcu(&tt_global_entry->common.rcu,
tt_global_entry_free_rcu); batadv_tt_global_entry_free_rcu);
} }
} }
static void tt_orig_list_entry_free_rcu(struct rcu_head *rcu) static void batadv_tt_orig_list_entry_free_rcu(struct rcu_head *rcu)
{ {
struct tt_orig_list_entry *orig_entry; struct tt_orig_list_entry *orig_entry;
...@@ -143,15 +146,14 @@ static void tt_orig_list_entry_free_rcu(struct rcu_head *rcu) ...@@ -143,15 +146,14 @@ static void tt_orig_list_entry_free_rcu(struct rcu_head *rcu)
kfree(orig_entry); kfree(orig_entry);
} }
static void tt_orig_list_entry_free_ref(struct tt_orig_list_entry *orig_entry) static void
batadv_tt_orig_list_entry_free_ref(struct tt_orig_list_entry *orig_entry)
{ {
/* to avoid race conditions, immediately decrease the tt counter */ call_rcu(&orig_entry->rcu, batadv_tt_orig_list_entry_free_rcu);
atomic_dec(&orig_entry->orig_node->tt_size);
call_rcu(&orig_entry->rcu, tt_orig_list_entry_free_rcu);
} }
static void tt_local_event(struct bat_priv *bat_priv, const uint8_t *addr, static void batadv_tt_local_event(struct bat_priv *bat_priv,
uint8_t flags) const uint8_t *addr, uint8_t flags)
{ {
struct tt_change_node *tt_change_node; struct tt_change_node *tt_change_node;
...@@ -177,7 +179,7 @@ int batadv_tt_len(int changes_num) ...@@ -177,7 +179,7 @@ int batadv_tt_len(int changes_num)
return changes_num * sizeof(struct tt_change); return changes_num * sizeof(struct tt_change);
} }
static int tt_local_init(struct bat_priv *bat_priv) static int batadv_tt_local_init(struct bat_priv *bat_priv)
{ {
if (bat_priv->tt_local_hash) if (bat_priv->tt_local_hash)
return 0; return 0;
...@@ -201,7 +203,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, ...@@ -201,7 +203,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
struct tt_orig_list_entry *orig_entry; struct tt_orig_list_entry *orig_entry;
int hash_added; int hash_added;
tt_local_entry = tt_local_hash_find(bat_priv, addr); tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr);
if (tt_local_entry) { if (tt_local_entry) {
tt_local_entry->last_seen = jiffies; tt_local_entry->last_seen = jiffies;
...@@ -214,7 +216,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, ...@@ -214,7 +216,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
if (!tt_local_entry) if (!tt_local_entry)
goto out; goto out;
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Creating new local tt entry: %pM (ttvn: %d)\n", addr, "Creating new local tt entry: %pM (ttvn: %d)\n", addr,
(uint8_t)atomic_read(&bat_priv->ttvn)); (uint8_t)atomic_read(&bat_priv->ttvn));
...@@ -226,7 +228,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, ...@@ -226,7 +228,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
tt_local_entry->last_seen = jiffies; tt_local_entry->last_seen = jiffies;
/* the batman interface mac address should never be purged */ /* the batman interface mac address should never be purged */
if (compare_eth(addr, soft_iface->dev_addr)) if (batadv_compare_eth(addr, soft_iface->dev_addr))
tt_local_entry->common.flags |= TT_CLIENT_NOPURGE; tt_local_entry->common.flags |= TT_CLIENT_NOPURGE;
/* The local entry has to be marked as NEW to avoid to send it in /* The local entry has to be marked as NEW to avoid to send it in
...@@ -235,20 +237,21 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, ...@@ -235,20 +237,21 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
*/ */
tt_local_entry->common.flags |= TT_CLIENT_NEW; tt_local_entry->common.flags |= TT_CLIENT_NEW;
hash_added = hash_add(bat_priv->tt_local_hash, compare_tt, choose_orig, hash_added = batadv_hash_add(bat_priv->tt_local_hash, batadv_compare_tt,
batadv_choose_orig,
&tt_local_entry->common, &tt_local_entry->common,
&tt_local_entry->common.hash_entry); &tt_local_entry->common.hash_entry);
if (unlikely(hash_added != 0)) { if (unlikely(hash_added != 0)) {
/* remove the reference for the hash */ /* remove the reference for the hash */
tt_local_entry_free_ref(tt_local_entry); batadv_tt_local_entry_free_ref(tt_local_entry);
goto out; goto out;
} }
tt_local_event(bat_priv, addr, tt_local_entry->common.flags); batadv_tt_local_event(bat_priv, addr, tt_local_entry->common.flags);
/* remove address from global hash if present */ /* remove address from global hash if present */
tt_global_entry = tt_global_hash_find(bat_priv, addr); tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr);
/* Check whether it is a roaming! */ /* Check whether it is a roaming! */
if (tt_global_entry) { if (tt_global_entry) {
...@@ -258,7 +261,8 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, ...@@ -258,7 +261,8 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
hlist_for_each_entry_rcu(orig_entry, node, head, list) { hlist_for_each_entry_rcu(orig_entry, node, head, list) {
orig_entry->orig_node->tt_poss_change = true; orig_entry->orig_node->tt_poss_change = true;
send_roam_adv(bat_priv, tt_global_entry->common.addr, batadv_send_roam_adv(bat_priv,
tt_global_entry->common.addr,
orig_entry->orig_node); orig_entry->orig_node);
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -270,13 +274,14 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, ...@@ -270,13 +274,14 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
} }
out: out:
if (tt_local_entry) if (tt_local_entry)
tt_local_entry_free_ref(tt_local_entry); batadv_tt_local_entry_free_ref(tt_local_entry);
if (tt_global_entry) if (tt_global_entry)
tt_global_entry_free_ref(tt_global_entry); batadv_tt_global_entry_free_ref(tt_global_entry);
} }
static void tt_realloc_packet_buff(unsigned char **packet_buff, static void batadv_tt_realloc_packet_buff(unsigned char **packet_buff,
int *packet_buff_len, int min_packet_len, int *packet_buff_len,
int min_packet_len,
int new_packet_len) int new_packet_len)
{ {
unsigned char *new_buff; unsigned char *new_buff;
...@@ -292,14 +297,15 @@ static void tt_realloc_packet_buff(unsigned char **packet_buff, ...@@ -292,14 +297,15 @@ static void tt_realloc_packet_buff(unsigned char **packet_buff,
} }
} }
static void tt_prepare_packet_buff(struct bat_priv *bat_priv, static void batadv_tt_prepare_packet_buff(struct bat_priv *bat_priv,
unsigned char **packet_buff, unsigned char **packet_buff,
int *packet_buff_len, int min_packet_len) int *packet_buff_len,
int min_packet_len)
{ {
struct hard_iface *primary_if; struct hard_iface *primary_if;
int req_len; int req_len;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
req_len = min_packet_len; req_len = min_packet_len;
req_len += batadv_tt_len(atomic_read(&bat_priv->tt_local_changes)); req_len += batadv_tt_len(atomic_read(&bat_priv->tt_local_changes));
...@@ -310,22 +316,23 @@ static void tt_prepare_packet_buff(struct bat_priv *bat_priv, ...@@ -310,22 +316,23 @@ static void tt_prepare_packet_buff(struct bat_priv *bat_priv,
if ((!primary_if) || (req_len > primary_if->soft_iface->mtu)) if ((!primary_if) || (req_len > primary_if->soft_iface->mtu))
req_len = min_packet_len; req_len = min_packet_len;
tt_realloc_packet_buff(packet_buff, packet_buff_len, batadv_tt_realloc_packet_buff(packet_buff, packet_buff_len,
min_packet_len, req_len); min_packet_len, req_len);
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
} }
static int tt_changes_fill_buff(struct bat_priv *bat_priv, static int batadv_tt_changes_fill_buff(struct bat_priv *bat_priv,
unsigned char **packet_buff, unsigned char **packet_buff,
int *packet_buff_len, int min_packet_len) int *packet_buff_len,
int min_packet_len)
{ {
struct tt_change_node *entry, *safe; struct tt_change_node *entry, *safe;
int count = 0, tot_changes = 0, new_len; int count = 0, tot_changes = 0, new_len;
unsigned char *tt_buff; unsigned char *tt_buff;
tt_prepare_packet_buff(bat_priv, packet_buff, batadv_tt_prepare_packet_buff(bat_priv, packet_buff,
packet_buff_len, min_packet_len); packet_buff_len, min_packet_len);
new_len = *packet_buff_len - min_packet_len; new_len = *packet_buff_len - min_packet_len;
...@@ -382,7 +389,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) ...@@ -382,7 +389,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset)
uint32_t i; uint32_t i;
int ret = 0; int ret = 0;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) { if (!primary_if) {
ret = seq_printf(seq, ret = seq_printf(seq,
"BATMAN mesh %s disabled - please specify interfaces to enable it\n", "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
...@@ -424,15 +431,15 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) ...@@ -424,15 +431,15 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset)
} }
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
return ret; return ret;
} }
static void tt_local_set_pending(struct bat_priv *bat_priv, static void batadv_tt_local_set_pending(struct bat_priv *bat_priv,
struct tt_local_entry *tt_local_entry, struct tt_local_entry *tt_local_entry,
uint16_t flags, const char *message) uint16_t flags, const char *message)
{ {
tt_local_event(bat_priv, tt_local_entry->common.addr, batadv_tt_local_event(bat_priv, tt_local_entry->common.addr,
tt_local_entry->common.flags | flags); tt_local_entry->common.flags | flags);
/* The local client has to be marked as "pending to be removed" but has /* The local client has to be marked as "pending to be removed" but has
...@@ -441,7 +448,7 @@ static void tt_local_set_pending(struct bat_priv *bat_priv, ...@@ -441,7 +448,7 @@ static void tt_local_set_pending(struct bat_priv *bat_priv,
*/ */
tt_local_entry->common.flags |= TT_CLIENT_PENDING; tt_local_entry->common.flags |= TT_CLIENT_PENDING;
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Local tt entry (%pM) pending to be removed: %s\n", "Local tt entry (%pM) pending to be removed: %s\n",
tt_local_entry->common.addr, message); tt_local_entry->common.addr, message);
} }
...@@ -451,18 +458,19 @@ void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, ...@@ -451,18 +458,19 @@ void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr,
{ {
struct tt_local_entry *tt_local_entry = NULL; struct tt_local_entry *tt_local_entry = NULL;
tt_local_entry = tt_local_hash_find(bat_priv, addr); tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr);
if (!tt_local_entry) if (!tt_local_entry)
goto out; goto out;
tt_local_set_pending(bat_priv, tt_local_entry, TT_CLIENT_DEL | batadv_tt_local_set_pending(bat_priv, tt_local_entry, TT_CLIENT_DEL |
(roaming ? TT_CLIENT_ROAM : NO_FLAGS), message); (roaming ? TT_CLIENT_ROAM : NO_FLAGS),
message);
out: out:
if (tt_local_entry) if (tt_local_entry)
tt_local_entry_free_ref(tt_local_entry); batadv_tt_local_entry_free_ref(tt_local_entry);
} }
static void tt_local_purge(struct bat_priv *bat_priv) static void batadv_tt_local_purge(struct bat_priv *bat_priv)
{ {
struct hashtable_t *hash = bat_priv->tt_local_hash; struct hashtable_t *hash = bat_priv->tt_local_hash;
struct tt_local_entry *tt_local_entry; struct tt_local_entry *tt_local_entry;
...@@ -489,11 +497,11 @@ static void tt_local_purge(struct bat_priv *bat_priv) ...@@ -489,11 +497,11 @@ static void tt_local_purge(struct bat_priv *bat_priv)
if (tt_local_entry->common.flags & TT_CLIENT_PENDING) if (tt_local_entry->common.flags & TT_CLIENT_PENDING)
continue; continue;
if (!has_timed_out(tt_local_entry->last_seen, if (!batadv_has_timed_out(tt_local_entry->last_seen,
TT_LOCAL_TIMEOUT)) TT_LOCAL_TIMEOUT))
continue; continue;
tt_local_set_pending(bat_priv, tt_local_entry, batadv_tt_local_set_pending(bat_priv, tt_local_entry,
TT_CLIENT_DEL, "timed out"); TT_CLIENT_DEL, "timed out");
} }
spin_unlock_bh(list_lock); spin_unlock_bh(list_lock);
...@@ -501,7 +509,7 @@ static void tt_local_purge(struct bat_priv *bat_priv) ...@@ -501,7 +509,7 @@ static void tt_local_purge(struct bat_priv *bat_priv)
} }
static void tt_local_table_free(struct bat_priv *bat_priv) static void batadv_tt_local_table_free(struct bat_priv *bat_priv)
{ {
struct hashtable_t *hash; struct hashtable_t *hash;
spinlock_t *list_lock; /* protects write access to the hash lists */ spinlock_t *list_lock; /* protects write access to the hash lists */
...@@ -527,7 +535,7 @@ static void tt_local_table_free(struct bat_priv *bat_priv) ...@@ -527,7 +535,7 @@ static void tt_local_table_free(struct bat_priv *bat_priv)
tt_local_entry = container_of(tt_common_entry, tt_local_entry = container_of(tt_common_entry,
struct tt_local_entry, struct tt_local_entry,
common); common);
tt_local_entry_free_ref(tt_local_entry); batadv_tt_local_entry_free_ref(tt_local_entry);
} }
spin_unlock_bh(list_lock); spin_unlock_bh(list_lock);
} }
...@@ -537,7 +545,7 @@ static void tt_local_table_free(struct bat_priv *bat_priv) ...@@ -537,7 +545,7 @@ static void tt_local_table_free(struct bat_priv *bat_priv)
bat_priv->tt_local_hash = NULL; bat_priv->tt_local_hash = NULL;
} }
static int tt_global_init(struct bat_priv *bat_priv) static int batadv_tt_global_init(struct bat_priv *bat_priv)
{ {
if (bat_priv->tt_global_hash) if (bat_priv->tt_global_hash)
return 0; return 0;
...@@ -550,7 +558,7 @@ static int tt_global_init(struct bat_priv *bat_priv) ...@@ -550,7 +558,7 @@ static int tt_global_init(struct bat_priv *bat_priv)
return 0; return 0;
} }
static void tt_changes_list_free(struct bat_priv *bat_priv) static void batadv_tt_changes_list_free(struct bat_priv *bat_priv)
{ {
struct tt_change_node *entry, *safe; struct tt_change_node *entry, *safe;
...@@ -569,7 +577,7 @@ static void tt_changes_list_free(struct bat_priv *bat_priv) ...@@ -569,7 +577,7 @@ static void tt_changes_list_free(struct bat_priv *bat_priv)
/* find out if an orig_node is already in the list of a tt_global_entry. /* find out if an orig_node is already in the list of a tt_global_entry.
* returns 1 if found, 0 otherwise * returns 1 if found, 0 otherwise
*/ */
static bool tt_global_entry_has_orig(const struct tt_global_entry *entry, static bool batadv_tt_global_entry_has_orig(const struct tt_global_entry *entry,
const struct orig_node *orig_node) const struct orig_node *orig_node)
{ {
struct tt_orig_list_entry *tmp_orig_entry; struct tt_orig_list_entry *tmp_orig_entry;
...@@ -589,9 +597,9 @@ static bool tt_global_entry_has_orig(const struct tt_global_entry *entry, ...@@ -589,9 +597,9 @@ static bool tt_global_entry_has_orig(const struct tt_global_entry *entry,
return found; return found;
} }
static void tt_global_add_orig_entry(struct tt_global_entry *tt_global_entry, static void
struct orig_node *orig_node, batadv_tt_global_add_orig_entry(struct tt_global_entry *tt_global_entry,
int ttvn) struct orig_node *orig_node, int ttvn)
{ {
struct tt_orig_list_entry *orig_entry; struct tt_orig_list_entry *orig_entry;
...@@ -619,8 +627,9 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, ...@@ -619,8 +627,9 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
struct tt_global_entry *tt_global_entry = NULL; struct tt_global_entry *tt_global_entry = NULL;
int ret = 0; int ret = 0;
int hash_added; int hash_added;
struct tt_common_entry *common;
tt_global_entry = tt_global_hash_find(bat_priv, tt_addr); tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr);
if (!tt_global_entry) { if (!tt_global_entry) {
tt_global_entry = kzalloc(sizeof(*tt_global_entry), tt_global_entry = kzalloc(sizeof(*tt_global_entry),
...@@ -628,26 +637,29 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, ...@@ -628,26 +637,29 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
if (!tt_global_entry) if (!tt_global_entry)
goto out; goto out;
memcpy(tt_global_entry->common.addr, tt_addr, ETH_ALEN); common = &tt_global_entry->common;
memcpy(common->addr, tt_addr, ETH_ALEN);
tt_global_entry->common.flags = NO_FLAGS; common->flags = NO_FLAGS;
tt_global_entry->roam_at = 0; tt_global_entry->roam_at = 0;
atomic_set(&tt_global_entry->common.refcount, 2); atomic_set(&common->refcount, 2);
INIT_HLIST_HEAD(&tt_global_entry->orig_list); INIT_HLIST_HEAD(&tt_global_entry->orig_list);
spin_lock_init(&tt_global_entry->list_lock); spin_lock_init(&tt_global_entry->list_lock);
hash_added = hash_add(bat_priv->tt_global_hash, compare_tt, hash_added = batadv_hash_add(bat_priv->tt_global_hash,
choose_orig, &tt_global_entry->common, batadv_compare_tt,
&tt_global_entry->common.hash_entry); batadv_choose_orig, common,
&common->hash_entry);
if (unlikely(hash_added != 0)) { if (unlikely(hash_added != 0)) {
/* remove the reference for the hash */ /* remove the reference for the hash */
tt_global_entry_free_ref(tt_global_entry); batadv_tt_global_entry_free_ref(tt_global_entry);
goto out_remove; goto out_remove;
} }
tt_global_add_orig_entry(tt_global_entry, orig_node, ttvn); batadv_tt_global_add_orig_entry(tt_global_entry, orig_node,
ttvn);
} else { } else {
/* there is already a global entry, use this one. */ /* there is already a global entry, use this one. */
...@@ -659,20 +671,21 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, ...@@ -659,20 +671,21 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
* new one. * new one.
*/ */
if (tt_global_entry->common.flags & TT_CLIENT_ROAM) { if (tt_global_entry->common.flags & TT_CLIENT_ROAM) {
tt_global_del_orig_list(tt_global_entry); batadv_tt_global_del_orig_list(tt_global_entry);
tt_global_entry->common.flags &= ~TT_CLIENT_ROAM; tt_global_entry->common.flags &= ~TT_CLIENT_ROAM;
tt_global_entry->roam_at = 0; tt_global_entry->roam_at = 0;
} }
if (!tt_global_entry_has_orig(tt_global_entry, orig_node)) if (!batadv_tt_global_entry_has_orig(tt_global_entry,
tt_global_add_orig_entry(tt_global_entry, orig_node, orig_node))
ttvn); batadv_tt_global_add_orig_entry(tt_global_entry,
orig_node, ttvn);
} }
if (wifi) if (wifi)
tt_global_entry->common.flags |= TT_CLIENT_WIFI; tt_global_entry->common.flags |= TT_CLIENT_WIFI;
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Creating new global tt entry: %pM (via %pM)\n", "Creating new global tt entry: %pM (via %pM)\n",
tt_global_entry->common.addr, orig_node->orig); tt_global_entry->common.addr, orig_node->orig);
...@@ -683,14 +696,15 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, ...@@ -683,14 +696,15 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
ret = 1; ret = 1;
out: out:
if (tt_global_entry) if (tt_global_entry)
tt_global_entry_free_ref(tt_global_entry); batadv_tt_global_entry_free_ref(tt_global_entry);
return ret; return ret;
} }
/* print all orig nodes who announce the address for this global entry. /* print all orig nodes who announce the address for this global entry.
* it is assumed that the caller holds rcu_read_lock(); * it is assumed that the caller holds rcu_read_lock();
*/ */
static void tt_global_print_entry(struct tt_global_entry *tt_global_entry, static void
batadv_tt_global_print_entry(struct tt_global_entry *tt_global_entry,
struct seq_file *seq) struct seq_file *seq)
{ {
struct hlist_head *head; struct hlist_head *head;
...@@ -728,7 +742,7 @@ int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset) ...@@ -728,7 +742,7 @@ int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset)
uint32_t i; uint32_t i;
int ret = 0; int ret = 0;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) { if (!primary_if) {
ret = seq_printf(seq, ret = seq_printf(seq,
"BATMAN mesh %s disabled - please specify interfaces to enable it\n", "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
...@@ -758,18 +772,19 @@ int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset) ...@@ -758,18 +772,19 @@ int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset)
tt_global_entry = container_of(tt_common_entry, tt_global_entry = container_of(tt_common_entry,
struct tt_global_entry, struct tt_global_entry,
common); common);
tt_global_print_entry(tt_global_entry, seq); batadv_tt_global_print_entry(tt_global_entry, seq);
} }
rcu_read_unlock(); rcu_read_unlock();
} }
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
return ret; return ret;
} }
/* deletes the orig list of a tt_global_entry */ /* deletes the orig list of a tt_global_entry */
static void tt_global_del_orig_list(struct tt_global_entry *tt_global_entry) static void
batadv_tt_global_del_orig_list(struct tt_global_entry *tt_global_entry)
{ {
struct hlist_head *head; struct hlist_head *head;
struct hlist_node *node, *safe; struct hlist_node *node, *safe;
...@@ -779,13 +794,14 @@ static void tt_global_del_orig_list(struct tt_global_entry *tt_global_entry) ...@@ -779,13 +794,14 @@ static void tt_global_del_orig_list(struct tt_global_entry *tt_global_entry)
head = &tt_global_entry->orig_list; head = &tt_global_entry->orig_list;
hlist_for_each_entry_safe(orig_entry, node, safe, head, list) { hlist_for_each_entry_safe(orig_entry, node, safe, head, list) {
hlist_del_rcu(node); hlist_del_rcu(node);
tt_orig_list_entry_free_ref(orig_entry); batadv_tt_orig_list_entry_free_ref(orig_entry);
} }
spin_unlock_bh(&tt_global_entry->list_lock); spin_unlock_bh(&tt_global_entry->list_lock);
} }
static void tt_global_del_orig_entry(struct bat_priv *bat_priv, static void
batadv_tt_global_del_orig_entry(struct bat_priv *bat_priv,
struct tt_global_entry *tt_global_entry, struct tt_global_entry *tt_global_entry,
struct orig_node *orig_node, struct orig_node *orig_node,
const char *message) const char *message)
...@@ -798,28 +814,27 @@ static void tt_global_del_orig_entry(struct bat_priv *bat_priv, ...@@ -798,28 +814,27 @@ static void tt_global_del_orig_entry(struct bat_priv *bat_priv,
head = &tt_global_entry->orig_list; head = &tt_global_entry->orig_list;
hlist_for_each_entry_safe(orig_entry, node, safe, head, list) { hlist_for_each_entry_safe(orig_entry, node, safe, head, list) {
if (orig_entry->orig_node == orig_node) { if (orig_entry->orig_node == orig_node) {
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Deleting %pM from global tt entry %pM: %s\n", "Deleting %pM from global tt entry %pM: %s\n",
orig_node->orig, tt_global_entry->common.addr, orig_node->orig,
message); tt_global_entry->common.addr, message);
hlist_del_rcu(node); hlist_del_rcu(node);
tt_orig_list_entry_free_ref(orig_entry); batadv_tt_orig_list_entry_free_ref(orig_entry);
} }
} }
spin_unlock_bh(&tt_global_entry->list_lock); spin_unlock_bh(&tt_global_entry->list_lock);
} }
static void tt_global_del_struct(struct bat_priv *bat_priv, static void batadv_tt_global_del_struct(struct bat_priv *bat_priv,
struct tt_global_entry *tt_global_entry, struct tt_global_entry *tt_global_entry,
const char *message) const char *message)
{ {
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv, "Deleting global tt entry %pM: %s\n",
"Deleting global tt entry %pM: %s\n",
tt_global_entry->common.addr, message); tt_global_entry->common.addr, message);
hash_remove(bat_priv->tt_global_hash, compare_tt, choose_orig, batadv_hash_remove(bat_priv->tt_global_hash, batadv_compare_tt,
tt_global_entry->common.addr); batadv_choose_orig, tt_global_entry->common.addr);
tt_global_entry_free_ref(tt_global_entry); batadv_tt_global_entry_free_ref(tt_global_entry);
} }
...@@ -827,10 +842,10 @@ static void tt_global_del_struct(struct bat_priv *bat_priv, ...@@ -827,10 +842,10 @@ static void tt_global_del_struct(struct bat_priv *bat_priv,
* within tt_global entry. If yes, we set the TT_CLIENT_ROAM flag and the timer, * within tt_global entry. If yes, we set the TT_CLIENT_ROAM flag and the timer,
* otherwise we simply remove the originator scheduled for deletion. * otherwise we simply remove the originator scheduled for deletion.
*/ */
static void tt_global_del_roaming(struct bat_priv *bat_priv, static void
batadv_tt_global_del_roaming(struct bat_priv *bat_priv,
struct tt_global_entry *tt_global_entry, struct tt_global_entry *tt_global_entry,
struct orig_node *orig_node, struct orig_node *orig_node, const char *message)
const char *message)
{ {
bool last_entry = true; bool last_entry = true;
struct hlist_head *head; struct hlist_head *head;
...@@ -859,30 +874,30 @@ static void tt_global_del_roaming(struct bat_priv *bat_priv, ...@@ -859,30 +874,30 @@ static void tt_global_del_roaming(struct bat_priv *bat_priv,
/* there is another entry, we can simply delete this /* there is another entry, we can simply delete this
* one and can still use the other one. * one and can still use the other one.
*/ */
tt_global_del_orig_entry(bat_priv, tt_global_entry, batadv_tt_global_del_orig_entry(bat_priv, tt_global_entry,
orig_node, message); orig_node, message);
} }
static void tt_global_del(struct bat_priv *bat_priv, static void batadv_tt_global_del(struct bat_priv *bat_priv,
struct orig_node *orig_node, struct orig_node *orig_node,
const unsigned char *addr, const unsigned char *addr,
const char *message, bool roaming) const char *message, bool roaming)
{ {
struct tt_global_entry *tt_global_entry = NULL; struct tt_global_entry *tt_global_entry = NULL;
struct tt_local_entry *tt_local_entry = NULL; struct tt_local_entry *local_entry = NULL;
tt_global_entry = tt_global_hash_find(bat_priv, addr); tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr);
if (!tt_global_entry) if (!tt_global_entry)
goto out; goto out;
if (!roaming) { if (!roaming) {
tt_global_del_orig_entry(bat_priv, tt_global_entry, orig_node, batadv_tt_global_del_orig_entry(bat_priv, tt_global_entry,
message); orig_node, message);
if (hlist_empty(&tt_global_entry->orig_list)) if (hlist_empty(&tt_global_entry->orig_list))
tt_global_del_struct(bat_priv, tt_global_entry, batadv_tt_global_del_struct(bat_priv, tt_global_entry,
message); message);
goto out; goto out;
...@@ -901,29 +916,29 @@ static void tt_global_del(struct bat_priv *bat_priv, ...@@ -901,29 +916,29 @@ static void tt_global_del(struct bat_priv *bat_priv,
* 2) the client roamed to us => we can directly delete * 2) the client roamed to us => we can directly delete
* the global entry, since it is useless now. * the global entry, since it is useless now.
*/ */
tt_local_entry = tt_local_hash_find(bat_priv, local_entry = batadv_tt_local_hash_find(bat_priv,
tt_global_entry->common.addr); tt_global_entry->common.addr);
if (tt_local_entry) { if (local_entry) {
/* local entry exists, case 2: client roamed to us. */ /* local entry exists, case 2: client roamed to us. */
tt_global_del_orig_list(tt_global_entry); batadv_tt_global_del_orig_list(tt_global_entry);
tt_global_del_struct(bat_priv, tt_global_entry, message); batadv_tt_global_del_struct(bat_priv, tt_global_entry, message);
} else } else
/* no local entry exists, case 1: check for roaming */ /* no local entry exists, case 1: check for roaming */
tt_global_del_roaming(bat_priv, tt_global_entry, orig_node, batadv_tt_global_del_roaming(bat_priv, tt_global_entry,
message); orig_node, message);
out: out:
if (tt_global_entry) if (tt_global_entry)
tt_global_entry_free_ref(tt_global_entry); batadv_tt_global_entry_free_ref(tt_global_entry);
if (tt_local_entry) if (local_entry)
tt_local_entry_free_ref(tt_local_entry); batadv_tt_local_entry_free_ref(local_entry);
} }
void batadv_tt_global_del_orig(struct bat_priv *bat_priv, void batadv_tt_global_del_orig(struct bat_priv *bat_priv,
struct orig_node *orig_node, const char *message) struct orig_node *orig_node, const char *message)
{ {
struct tt_global_entry *tt_global_entry; struct tt_global_entry *global_entry;
struct tt_common_entry *tt_common_entry; struct tt_common_entry *tt_common_entry;
uint32_t i; uint32_t i;
struct hashtable_t *hash = bat_priv->tt_global_hash; struct hashtable_t *hash = bat_priv->tt_global_hash;
...@@ -941,20 +956,19 @@ void batadv_tt_global_del_orig(struct bat_priv *bat_priv, ...@@ -941,20 +956,19 @@ void batadv_tt_global_del_orig(struct bat_priv *bat_priv,
spin_lock_bh(list_lock); spin_lock_bh(list_lock);
hlist_for_each_entry_safe(tt_common_entry, node, safe, hlist_for_each_entry_safe(tt_common_entry, node, safe,
head, hash_entry) { head, hash_entry) {
tt_global_entry = container_of(tt_common_entry, global_entry = container_of(tt_common_entry,
struct tt_global_entry, struct tt_global_entry,
common); common);
tt_global_del_orig_entry(bat_priv, tt_global_entry, batadv_tt_global_del_orig_entry(bat_priv, global_entry,
orig_node, message); orig_node, message);
if (hlist_empty(&tt_global_entry->orig_list)) { if (hlist_empty(&global_entry->orig_list)) {
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Deleting global tt entry %pM: %s\n", "Deleting global tt entry %pM: %s\n",
tt_global_entry->common.addr, global_entry->common.addr, message);
message);
hlist_del_rcu(node); hlist_del_rcu(node);
tt_global_entry_free_ref(tt_global_entry); batadv_tt_global_entry_free_ref(global_entry);
} }
} }
spin_unlock_bh(list_lock); spin_unlock_bh(list_lock);
...@@ -962,7 +976,7 @@ void batadv_tt_global_del_orig(struct bat_priv *bat_priv, ...@@ -962,7 +976,7 @@ void batadv_tt_global_del_orig(struct bat_priv *bat_priv,
orig_node->tt_initialised = false; orig_node->tt_initialised = false;
} }
static void tt_global_roam_purge(struct bat_priv *bat_priv) static void batadv_tt_global_roam_purge(struct bat_priv *bat_priv)
{ {
struct hashtable_t *hash = bat_priv->tt_global_hash; struct hashtable_t *hash = bat_priv->tt_global_hash;
struct tt_common_entry *tt_common_entry; struct tt_common_entry *tt_common_entry;
...@@ -984,23 +998,23 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv) ...@@ -984,23 +998,23 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv)
common); common);
if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM)) if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM))
continue; continue;
if (!has_timed_out(tt_global_entry->roam_at, if (!batadv_has_timed_out(tt_global_entry->roam_at,
TT_CLIENT_ROAM_TIMEOUT)) TT_CLIENT_ROAM_TIMEOUT))
continue; continue;
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Deleting global tt entry (%pM): Roaming timeout\n", "Deleting global tt entry (%pM): Roaming timeout\n",
tt_global_entry->common.addr); tt_global_entry->common.addr);
hlist_del_rcu(node); hlist_del_rcu(node);
tt_global_entry_free_ref(tt_global_entry); batadv_tt_global_entry_free_ref(tt_global_entry);
} }
spin_unlock_bh(list_lock); spin_unlock_bh(list_lock);
} }
} }
static void tt_global_table_free(struct bat_priv *bat_priv) static void batadv_tt_global_table_free(struct bat_priv *bat_priv)
{ {
struct hashtable_t *hash; struct hashtable_t *hash;
spinlock_t *list_lock; /* protects write access to the hash lists */ spinlock_t *list_lock; /* protects write access to the hash lists */
...@@ -1026,7 +1040,7 @@ static void tt_global_table_free(struct bat_priv *bat_priv) ...@@ -1026,7 +1040,7 @@ static void tt_global_table_free(struct bat_priv *bat_priv)
tt_global_entry = container_of(tt_common_entry, tt_global_entry = container_of(tt_common_entry,
struct tt_global_entry, struct tt_global_entry,
common); common);
tt_global_entry_free_ref(tt_global_entry); batadv_tt_global_entry_free_ref(tt_global_entry);
} }
spin_unlock_bh(list_lock); spin_unlock_bh(list_lock);
} }
...@@ -1036,7 +1050,7 @@ static void tt_global_table_free(struct bat_priv *bat_priv) ...@@ -1036,7 +1050,7 @@ static void tt_global_table_free(struct bat_priv *bat_priv)
bat_priv->tt_global_hash = NULL; bat_priv->tt_global_hash = NULL;
} }
static bool _is_ap_isolated(struct tt_local_entry *tt_local_entry, static bool _batadv_is_ap_isolated(struct tt_local_entry *tt_local_entry,
struct tt_global_entry *tt_global_entry) struct tt_global_entry *tt_global_entry)
{ {
bool ret = false; bool ret = false;
...@@ -1062,19 +1076,20 @@ struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv, ...@@ -1062,19 +1076,20 @@ struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv,
int best_tq; int best_tq;
if (src && atomic_read(&bat_priv->ap_isolation)) { if (src && atomic_read(&bat_priv->ap_isolation)) {
tt_local_entry = tt_local_hash_find(bat_priv, src); tt_local_entry = batadv_tt_local_hash_find(bat_priv, src);
if (!tt_local_entry) if (!tt_local_entry)
goto out; goto out;
} }
tt_global_entry = tt_global_hash_find(bat_priv, addr); tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr);
if (!tt_global_entry) if (!tt_global_entry)
goto out; goto out;
/* check whether the clients should not communicate due to AP /* check whether the clients should not communicate due to AP
* isolation * isolation
*/ */
if (tt_local_entry && _is_ap_isolated(tt_local_entry, tt_global_entry)) if (tt_local_entry &&
_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
goto out; goto out;
best_tq = 0; best_tq = 0;
...@@ -1098,15 +1113,15 @@ struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv, ...@@ -1098,15 +1113,15 @@ struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv,
rcu_read_unlock(); rcu_read_unlock();
out: out:
if (tt_global_entry) if (tt_global_entry)
tt_global_entry_free_ref(tt_global_entry); batadv_tt_global_entry_free_ref(tt_global_entry);
if (tt_local_entry) if (tt_local_entry)
tt_local_entry_free_ref(tt_local_entry); batadv_tt_local_entry_free_ref(tt_local_entry);
return orig_node; return orig_node;
} }
/* Calculates the checksum of the local table of a given orig_node */ /* Calculates the checksum of the local table of a given orig_node */
static uint16_t tt_global_crc(struct bat_priv *bat_priv, static uint16_t batadv_tt_global_crc(struct bat_priv *bat_priv,
struct orig_node *orig_node) struct orig_node *orig_node)
{ {
uint16_t total = 0, total_one; uint16_t total = 0, total_one;
...@@ -1138,7 +1153,7 @@ static uint16_t tt_global_crc(struct bat_priv *bat_priv, ...@@ -1138,7 +1153,7 @@ static uint16_t tt_global_crc(struct bat_priv *bat_priv,
/* find out if this global entry is announced by this /* find out if this global entry is announced by this
* originator * originator
*/ */
if (!tt_global_entry_has_orig(tt_global_entry, if (!batadv_tt_global_entry_has_orig(tt_global_entry,
orig_node)) orig_node))
continue; continue;
...@@ -1188,7 +1203,7 @@ static uint16_t batadv_tt_local_crc(struct bat_priv *bat_priv) ...@@ -1188,7 +1203,7 @@ static uint16_t batadv_tt_local_crc(struct bat_priv *bat_priv)
return total; return total;
} }
static void tt_req_list_free(struct bat_priv *bat_priv) static void batadv_tt_req_list_free(struct bat_priv *bat_priv)
{ {
struct tt_req_node *node, *safe; struct tt_req_node *node, *safe;
...@@ -1202,7 +1217,7 @@ static void tt_req_list_free(struct bat_priv *bat_priv) ...@@ -1202,7 +1217,7 @@ static void tt_req_list_free(struct bat_priv *bat_priv)
spin_unlock_bh(&bat_priv->tt_req_list_lock); spin_unlock_bh(&bat_priv->tt_req_list_lock);
} }
static void tt_save_orig_buffer(struct bat_priv *bat_priv, static void batadv_tt_save_orig_buffer(struct bat_priv *bat_priv,
struct orig_node *orig_node, struct orig_node *orig_node,
const unsigned char *tt_buff, const unsigned char *tt_buff,
uint8_t tt_num_changes) uint8_t tt_num_changes)
...@@ -1225,13 +1240,13 @@ static void tt_save_orig_buffer(struct bat_priv *bat_priv, ...@@ -1225,13 +1240,13 @@ static void tt_save_orig_buffer(struct bat_priv *bat_priv,
spin_unlock_bh(&orig_node->tt_buff_lock); spin_unlock_bh(&orig_node->tt_buff_lock);
} }
static void tt_req_purge(struct bat_priv *bat_priv) static void batadv_tt_req_purge(struct bat_priv *bat_priv)
{ {
struct tt_req_node *node, *safe; struct tt_req_node *node, *safe;
spin_lock_bh(&bat_priv->tt_req_list_lock); spin_lock_bh(&bat_priv->tt_req_list_lock);
list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) {
if (has_timed_out(node->issued_at, TT_REQUEST_TIMEOUT)) { if (batadv_has_timed_out(node->issued_at, TT_REQUEST_TIMEOUT)) {
list_del(&node->list); list_del(&node->list);
kfree(node); kfree(node);
} }
...@@ -1242,15 +1257,15 @@ static void tt_req_purge(struct bat_priv *bat_priv) ...@@ -1242,15 +1257,15 @@ static void tt_req_purge(struct bat_priv *bat_priv)
/* returns the pointer to the new tt_req_node struct if no request /* returns the pointer to the new tt_req_node struct if no request
* has already been issued for this orig_node, NULL otherwise * has already been issued for this orig_node, NULL otherwise
*/ */
static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv, static struct tt_req_node *batadv_new_tt_req_node(struct bat_priv *bat_priv,
struct orig_node *orig_node) struct orig_node *orig_node)
{ {
struct tt_req_node *tt_req_node_tmp, *tt_req_node = NULL; struct tt_req_node *tt_req_node_tmp, *tt_req_node = NULL;
spin_lock_bh(&bat_priv->tt_req_list_lock); spin_lock_bh(&bat_priv->tt_req_list_lock);
list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) { list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) {
if (compare_eth(tt_req_node_tmp, orig_node) && if (batadv_compare_eth(tt_req_node_tmp, orig_node) &&
!has_timed_out(tt_req_node_tmp->issued_at, !batadv_has_timed_out(tt_req_node_tmp->issued_at,
TT_REQUEST_TIMEOUT)) TT_REQUEST_TIMEOUT))
goto unlock; goto unlock;
} }
...@@ -1269,7 +1284,8 @@ static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv, ...@@ -1269,7 +1284,8 @@ static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv,
} }
/* data_ptr is useless here, but has to be kept to respect the prototype */ /* data_ptr is useless here, but has to be kept to respect the prototype */
static int tt_local_valid_entry(const void *entry_ptr, const void *data_ptr) static int batadv_tt_local_valid_entry(const void *entry_ptr,
const void *data_ptr)
{ {
const struct tt_common_entry *tt_common_entry = entry_ptr; const struct tt_common_entry *tt_common_entry = entry_ptr;
...@@ -1278,7 +1294,8 @@ static int tt_local_valid_entry(const void *entry_ptr, const void *data_ptr) ...@@ -1278,7 +1294,8 @@ static int tt_local_valid_entry(const void *entry_ptr, const void *data_ptr)
return 1; return 1;
} }
static int tt_global_valid_entry(const void *entry_ptr, const void *data_ptr) static int batadv_tt_global_valid(const void *entry_ptr,
const void *data_ptr)
{ {
const struct tt_common_entry *tt_common_entry = entry_ptr; const struct tt_common_entry *tt_common_entry = entry_ptr;
const struct tt_global_entry *tt_global_entry; const struct tt_global_entry *tt_global_entry;
...@@ -1290,14 +1307,14 @@ static int tt_global_valid_entry(const void *entry_ptr, const void *data_ptr) ...@@ -1290,14 +1307,14 @@ static int tt_global_valid_entry(const void *entry_ptr, const void *data_ptr)
tt_global_entry = container_of(tt_common_entry, struct tt_global_entry, tt_global_entry = container_of(tt_common_entry, struct tt_global_entry,
common); common);
return tt_global_entry_has_orig(tt_global_entry, orig_node); return batadv_tt_global_entry_has_orig(tt_global_entry, orig_node);
} }
static struct sk_buff *tt_response_fill_table(uint16_t tt_len, uint8_t ttvn, static struct sk_buff *
batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn,
struct hashtable_t *hash, struct hashtable_t *hash,
struct hard_iface *primary_if, struct hard_iface *primary_if,
int (*valid_cb)(const void *, int (*valid_cb)(const void *, const void *),
const void *),
void *cb_data) void *cb_data)
{ {
struct tt_common_entry *tt_common_entry; struct tt_common_entry *tt_common_entry;
...@@ -1359,9 +1376,10 @@ static struct sk_buff *tt_response_fill_table(uint16_t tt_len, uint8_t ttvn, ...@@ -1359,9 +1376,10 @@ static struct sk_buff *tt_response_fill_table(uint16_t tt_len, uint8_t ttvn,
return skb; return skb;
} }
static int send_tt_request(struct bat_priv *bat_priv, static int batadv_send_tt_request(struct bat_priv *bat_priv,
struct orig_node *dst_orig_node, struct orig_node *dst_orig_node,
uint8_t ttvn, uint16_t tt_crc, bool full_table) uint8_t ttvn, uint16_t tt_crc,
bool full_table)
{ {
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
struct tt_query_packet *tt_request; struct tt_query_packet *tt_request;
...@@ -1370,14 +1388,14 @@ static int send_tt_request(struct bat_priv *bat_priv, ...@@ -1370,14 +1388,14 @@ static int send_tt_request(struct bat_priv *bat_priv,
struct tt_req_node *tt_req_node = NULL; struct tt_req_node *tt_req_node = NULL;
int ret = 1; int ret = 1;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
/* The new tt_req will be issued only if I'm not waiting for a /* The new tt_req will be issued only if I'm not waiting for a
* reply from the same orig_node yet * reply from the same orig_node yet
*/ */
tt_req_node = new_tt_req_node(bat_priv, dst_orig_node); tt_req_node = batadv_new_tt_req_node(bat_priv, dst_orig_node);
if (!tt_req_node) if (!tt_req_node)
goto out; goto out;
...@@ -1406,7 +1424,7 @@ static int send_tt_request(struct bat_priv *bat_priv, ...@@ -1406,7 +1424,7 @@ static int send_tt_request(struct bat_priv *bat_priv,
if (!neigh_node) if (!neigh_node)
goto out; goto out;
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Sending TT_REQUEST to %pM via %pM [%c]\n", "Sending TT_REQUEST to %pM via %pM [%c]\n",
dst_orig_node->orig, neigh_node->addr, dst_orig_node->orig, neigh_node->addr,
(full_table ? 'F' : '.')); (full_table ? 'F' : '.'));
...@@ -1420,7 +1438,7 @@ static int send_tt_request(struct bat_priv *bat_priv, ...@@ -1420,7 +1438,7 @@ static int send_tt_request(struct bat_priv *bat_priv,
if (neigh_node) if (neigh_node)
batadv_neigh_node_free_ref(neigh_node); batadv_neigh_node_free_ref(neigh_node);
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
if (ret) if (ret)
kfree_skb(skb); kfree_skb(skb);
if (ret && tt_req_node) { if (ret && tt_req_node) {
...@@ -1432,7 +1450,7 @@ static int send_tt_request(struct bat_priv *bat_priv, ...@@ -1432,7 +1450,7 @@ static int send_tt_request(struct bat_priv *bat_priv,
return ret; return ret;
} }
static bool send_other_tt_response(struct bat_priv *bat_priv, static bool batadv_send_other_tt_response(struct bat_priv *bat_priv,
struct tt_query_packet *tt_request) struct tt_query_packet *tt_request)
{ {
struct orig_node *req_dst_orig_node = NULL, *res_dst_orig_node = NULL; struct orig_node *req_dst_orig_node = NULL, *res_dst_orig_node = NULL;
...@@ -1446,17 +1464,17 @@ static bool send_other_tt_response(struct bat_priv *bat_priv, ...@@ -1446,17 +1464,17 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
struct tt_query_packet *tt_response; struct tt_query_packet *tt_response;
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Received TT_REQUEST from %pM for ttvn: %u (%pM) [%c]\n", "Received TT_REQUEST from %pM for ttvn: %u (%pM) [%c]\n",
tt_request->src, tt_request->ttvn, tt_request->dst, tt_request->src, tt_request->ttvn, tt_request->dst,
(tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); (tt_request->flags & TT_FULL_TABLE ? 'F' : '.'));
/* Let's get the orig node of the REAL destination */ /* Let's get the orig node of the REAL destination */
req_dst_orig_node = orig_hash_find(bat_priv, tt_request->dst); req_dst_orig_node = batadv_orig_hash_find(bat_priv, tt_request->dst);
if (!req_dst_orig_node) if (!req_dst_orig_node)
goto out; goto out;
res_dst_orig_node = orig_hash_find(bat_priv, tt_request->src); res_dst_orig_node = batadv_orig_hash_find(bat_priv, tt_request->src);
if (!res_dst_orig_node) if (!res_dst_orig_node)
goto out; goto out;
...@@ -1464,7 +1482,7 @@ static bool send_other_tt_response(struct bat_priv *bat_priv, ...@@ -1464,7 +1482,7 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
if (!neigh_node) if (!neigh_node)
goto out; goto out;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
...@@ -1513,9 +1531,10 @@ static bool send_other_tt_response(struct bat_priv *bat_priv, ...@@ -1513,9 +1531,10 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
sizeof(struct tt_change); sizeof(struct tt_change);
ttvn = (uint8_t)atomic_read(&req_dst_orig_node->last_ttvn); ttvn = (uint8_t)atomic_read(&req_dst_orig_node->last_ttvn);
skb = tt_response_fill_table(tt_len, ttvn, skb = batadv_tt_response_fill_table(tt_len, ttvn,
bat_priv->tt_global_hash, bat_priv->tt_global_hash,
primary_if, tt_global_valid_entry, primary_if,
batadv_tt_global_valid,
req_dst_orig_node); req_dst_orig_node);
if (!skb) if (!skb)
goto out; goto out;
...@@ -1533,7 +1552,7 @@ static bool send_other_tt_response(struct bat_priv *bat_priv, ...@@ -1533,7 +1552,7 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
if (full_table) if (full_table)
tt_response->flags |= TT_FULL_TABLE; tt_response->flags |= TT_FULL_TABLE;
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Sending TT_RESPONSE %pM via %pM for %pM (ttvn: %u)\n", "Sending TT_RESPONSE %pM via %pM for %pM (ttvn: %u)\n",
res_dst_orig_node->orig, neigh_node->addr, res_dst_orig_node->orig, neigh_node->addr,
req_dst_orig_node->orig, req_ttvn); req_dst_orig_node->orig, req_ttvn);
...@@ -1555,13 +1574,13 @@ static bool send_other_tt_response(struct bat_priv *bat_priv, ...@@ -1555,13 +1574,13 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
if (neigh_node) if (neigh_node)
batadv_neigh_node_free_ref(neigh_node); batadv_neigh_node_free_ref(neigh_node);
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
if (!ret) if (!ret)
kfree_skb(skb); kfree_skb(skb);
return ret; return ret;
} }
static bool send_my_tt_response(struct bat_priv *bat_priv, static bool batadv_send_my_tt_response(struct bat_priv *bat_priv,
struct tt_query_packet *tt_request) struct tt_query_packet *tt_request)
{ {
struct orig_node *orig_node = NULL; struct orig_node *orig_node = NULL;
...@@ -1575,7 +1594,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, ...@@ -1575,7 +1594,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
struct tt_query_packet *tt_response; struct tt_query_packet *tt_response;
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Received TT_REQUEST from %pM for ttvn: %u (me) [%c]\n", "Received TT_REQUEST from %pM for ttvn: %u (me) [%c]\n",
tt_request->src, tt_request->ttvn, tt_request->src, tt_request->ttvn,
(tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); (tt_request->flags & TT_FULL_TABLE ? 'F' : '.'));
...@@ -1584,7 +1603,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, ...@@ -1584,7 +1603,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
my_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); my_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn);
req_ttvn = tt_request->ttvn; req_ttvn = tt_request->ttvn;
orig_node = orig_hash_find(bat_priv, tt_request->src); orig_node = batadv_orig_hash_find(bat_priv, tt_request->src);
if (!orig_node) if (!orig_node)
goto out; goto out;
...@@ -1592,7 +1611,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, ...@@ -1592,7 +1611,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
if (!neigh_node) if (!neigh_node)
goto out; goto out;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
...@@ -1633,9 +1652,10 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, ...@@ -1633,9 +1652,10 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
sizeof(struct tt_change); sizeof(struct tt_change);
ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); ttvn = (uint8_t)atomic_read(&bat_priv->ttvn);
skb = tt_response_fill_table(tt_len, ttvn, skb = batadv_tt_response_fill_table(tt_len, ttvn,
bat_priv->tt_local_hash, bat_priv->tt_local_hash,
primary_if, tt_local_valid_entry, primary_if,
batadv_tt_local_valid_entry,
NULL); NULL);
if (!skb) if (!skb)
goto out; goto out;
...@@ -1653,7 +1673,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, ...@@ -1653,7 +1673,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
if (full_table) if (full_table)
tt_response->flags |= TT_FULL_TABLE; tt_response->flags |= TT_FULL_TABLE;
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Sending TT_RESPONSE to %pM via %pM [%c]\n", "Sending TT_RESPONSE to %pM via %pM [%c]\n",
orig_node->orig, neigh_node->addr, orig_node->orig, neigh_node->addr,
(tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); (tt_response->flags & TT_FULL_TABLE ? 'F' : '.'));
...@@ -1672,7 +1692,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, ...@@ -1672,7 +1692,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
if (neigh_node) if (neigh_node)
batadv_neigh_node_free_ref(neigh_node); batadv_neigh_node_free_ref(neigh_node);
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
if (!ret) if (!ret)
kfree_skb(skb); kfree_skb(skb);
/* This packet was for me, so it doesn't need to be re-routed */ /* This packet was for me, so it doesn't need to be re-routed */
...@@ -1687,26 +1707,28 @@ bool batadv_send_tt_response(struct bat_priv *bat_priv, ...@@ -1687,26 +1707,28 @@ bool batadv_send_tt_response(struct bat_priv *bat_priv,
if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_request->src)) if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_request->src))
return true; return true;
return send_my_tt_response(bat_priv, tt_request); return batadv_send_my_tt_response(bat_priv, tt_request);
} else { } else {
return send_other_tt_response(bat_priv, tt_request); return batadv_send_other_tt_response(bat_priv, tt_request);
} }
} }
static void _tt_update_changes(struct bat_priv *bat_priv, static void _batadv_tt_update_changes(struct bat_priv *bat_priv,
struct orig_node *orig_node, struct orig_node *orig_node,
struct tt_change *tt_change, struct tt_change *tt_change,
uint16_t tt_num_changes, uint8_t ttvn) uint16_t tt_num_changes, uint8_t ttvn)
{ {
int i; int i;
int is_wifi; int is_wifi;
int roams;
for (i = 0; i < tt_num_changes; i++) { for (i = 0; i < tt_num_changes; i++) {
if ((tt_change + i)->flags & TT_CLIENT_DEL) { if ((tt_change + i)->flags & TT_CLIENT_DEL) {
tt_global_del(bat_priv, orig_node, roams = (tt_change + i)->flags & TT_CLIENT_ROAM;
batadv_tt_global_del(bat_priv, orig_node,
(tt_change + i)->addr, (tt_change + i)->addr,
"tt removed by changes", "tt removed by changes",
(tt_change + i)->flags & TT_CLIENT_ROAM); roams);
} else { } else {
is_wifi = (tt_change + i)->flags & TT_CLIENT_WIFI; is_wifi = (tt_change + i)->flags & TT_CLIENT_WIFI;
if (!batadv_tt_global_add(bat_priv, orig_node, if (!batadv_tt_global_add(bat_priv, orig_node,
...@@ -1724,21 +1746,22 @@ static void _tt_update_changes(struct bat_priv *bat_priv, ...@@ -1724,21 +1746,22 @@ static void _tt_update_changes(struct bat_priv *bat_priv,
orig_node->tt_initialised = true; orig_node->tt_initialised = true;
} }
static void tt_fill_gtable(struct bat_priv *bat_priv, static void batadv_tt_fill_gtable(struct bat_priv *bat_priv,
struct tt_query_packet *tt_response) struct tt_query_packet *tt_response)
{ {
struct orig_node *orig_node = NULL; struct orig_node *orig_node = NULL;
orig_node = orig_hash_find(bat_priv, tt_response->src); orig_node = batadv_orig_hash_find(bat_priv, tt_response->src);
if (!orig_node) if (!orig_node)
goto out; goto out;
/* Purge the old table first.. */ /* Purge the old table first.. */
batadv_tt_global_del_orig(bat_priv, orig_node, "Received full table"); batadv_tt_global_del_orig(bat_priv, orig_node, "Received full table");
_tt_update_changes(bat_priv, orig_node, _batadv_tt_update_changes(bat_priv, orig_node,
(struct tt_change *)(tt_response + 1), (struct tt_change *)(tt_response + 1),
ntohs(tt_response->tt_data), tt_response->ttvn); ntohs(tt_response->tt_data),
tt_response->ttvn);
spin_lock_bh(&orig_node->tt_buff_lock); spin_lock_bh(&orig_node->tt_buff_lock);
kfree(orig_node->tt_buff); kfree(orig_node->tt_buff);
...@@ -1753,16 +1776,16 @@ static void tt_fill_gtable(struct bat_priv *bat_priv, ...@@ -1753,16 +1776,16 @@ static void tt_fill_gtable(struct bat_priv *bat_priv,
batadv_orig_node_free_ref(orig_node); batadv_orig_node_free_ref(orig_node);
} }
static void tt_update_changes(struct bat_priv *bat_priv, static void batadv_tt_update_changes(struct bat_priv *bat_priv,
struct orig_node *orig_node, struct orig_node *orig_node,
uint16_t tt_num_changes, uint8_t ttvn, uint16_t tt_num_changes, uint8_t ttvn,
struct tt_change *tt_change) struct tt_change *tt_change)
{ {
_tt_update_changes(bat_priv, orig_node, tt_change, tt_num_changes, _batadv_tt_update_changes(bat_priv, orig_node, tt_change,
ttvn); tt_num_changes, ttvn);
tt_save_orig_buffer(bat_priv, orig_node, (unsigned char *)tt_change, batadv_tt_save_orig_buffer(bat_priv, orig_node,
tt_num_changes); (unsigned char *)tt_change, tt_num_changes);
atomic_set(&orig_node->last_ttvn, ttvn); atomic_set(&orig_node->last_ttvn, ttvn);
} }
...@@ -1771,7 +1794,7 @@ bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr) ...@@ -1771,7 +1794,7 @@ bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr)
struct tt_local_entry *tt_local_entry = NULL; struct tt_local_entry *tt_local_entry = NULL;
bool ret = false; bool ret = false;
tt_local_entry = tt_local_hash_find(bat_priv, addr); tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr);
if (!tt_local_entry) if (!tt_local_entry)
goto out; goto out;
/* Check if the client has been logically deleted (but is kept for /* Check if the client has been logically deleted (but is kept for
...@@ -1782,7 +1805,7 @@ bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr) ...@@ -1782,7 +1805,7 @@ bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr)
ret = true; ret = true;
out: out:
if (tt_local_entry) if (tt_local_entry)
tt_local_entry_free_ref(tt_local_entry); batadv_tt_local_entry_free_ref(tt_local_entry);
return ret; return ret;
} }
...@@ -1792,7 +1815,7 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv, ...@@ -1792,7 +1815,7 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv,
struct tt_req_node *node, *safe; struct tt_req_node *node, *safe;
struct orig_node *orig_node = NULL; struct orig_node *orig_node = NULL;
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n", "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n",
tt_response->src, tt_response->ttvn, tt_response->src, tt_response->ttvn,
ntohs(tt_response->tt_data), ntohs(tt_response->tt_data),
...@@ -1802,14 +1825,14 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv, ...@@ -1802,14 +1825,14 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv,
if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_response->src)) if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_response->src))
goto out; goto out;
orig_node = orig_hash_find(bat_priv, tt_response->src); orig_node = batadv_orig_hash_find(bat_priv, tt_response->src);
if (!orig_node) if (!orig_node)
goto out; goto out;
if (tt_response->flags & TT_FULL_TABLE) if (tt_response->flags & TT_FULL_TABLE)
tt_fill_gtable(bat_priv, tt_response); batadv_tt_fill_gtable(bat_priv, tt_response);
else else
tt_update_changes(bat_priv, orig_node, batadv_tt_update_changes(bat_priv, orig_node,
ntohs(tt_response->tt_data), ntohs(tt_response->tt_data),
tt_response->ttvn, tt_response->ttvn,
(struct tt_change *)(tt_response + 1)); (struct tt_change *)(tt_response + 1));
...@@ -1817,7 +1840,7 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv, ...@@ -1817,7 +1840,7 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv,
/* Delete the tt_req_node from pending tt_requests list */ /* Delete the tt_req_node from pending tt_requests list */
spin_lock_bh(&bat_priv->tt_req_list_lock); spin_lock_bh(&bat_priv->tt_req_list_lock);
list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) {
if (!compare_eth(node->addr, tt_response->src)) if (!batadv_compare_eth(node->addr, tt_response->src))
continue; continue;
list_del(&node->list); list_del(&node->list);
kfree(node); kfree(node);
...@@ -1825,7 +1848,7 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv, ...@@ -1825,7 +1848,7 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv,
spin_unlock_bh(&bat_priv->tt_req_list_lock); spin_unlock_bh(&bat_priv->tt_req_list_lock);
/* Recalculate the CRC for this orig_node and store it */ /* Recalculate the CRC for this orig_node and store it */
orig_node->tt_crc = tt_global_crc(bat_priv, orig_node); orig_node->tt_crc = batadv_tt_global_crc(bat_priv, orig_node);
/* Roaming phase is over: tables are in sync again. I can /* Roaming phase is over: tables are in sync again. I can
* unset the flag * unset the flag
*/ */
...@@ -1839,20 +1862,20 @@ int batadv_tt_init(struct bat_priv *bat_priv) ...@@ -1839,20 +1862,20 @@ int batadv_tt_init(struct bat_priv *bat_priv)
{ {
int ret; int ret;
ret = tt_local_init(bat_priv); ret = batadv_tt_local_init(bat_priv);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = tt_global_init(bat_priv); ret = batadv_tt_global_init(bat_priv);
if (ret < 0) if (ret < 0)
return ret; return ret;
tt_start_timer(bat_priv); batadv_tt_start_timer(bat_priv);
return 1; return 1;
} }
static void tt_roam_list_free(struct bat_priv *bat_priv) static void batadv_tt_roam_list_free(struct bat_priv *bat_priv)
{ {
struct tt_roam_node *node, *safe; struct tt_roam_node *node, *safe;
...@@ -1866,13 +1889,13 @@ static void tt_roam_list_free(struct bat_priv *bat_priv) ...@@ -1866,13 +1889,13 @@ static void tt_roam_list_free(struct bat_priv *bat_priv)
spin_unlock_bh(&bat_priv->tt_roam_list_lock); spin_unlock_bh(&bat_priv->tt_roam_list_lock);
} }
static void tt_roam_purge(struct bat_priv *bat_priv) static void batadv_tt_roam_purge(struct bat_priv *bat_priv)
{ {
struct tt_roam_node *node, *safe; struct tt_roam_node *node, *safe;
spin_lock_bh(&bat_priv->tt_roam_list_lock); spin_lock_bh(&bat_priv->tt_roam_list_lock);
list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) { list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) {
if (!has_timed_out(node->first_time, ROAMING_MAX_TIME)) if (!batadv_has_timed_out(node->first_time, ROAMING_MAX_TIME))
continue; continue;
list_del(&node->list); list_del(&node->list);
...@@ -1887,7 +1910,7 @@ static void tt_roam_purge(struct bat_priv *bat_priv) ...@@ -1887,7 +1910,7 @@ static void tt_roam_purge(struct bat_priv *bat_priv)
* *
* returns true if the ROAMING_ADV can be sent, false otherwise * returns true if the ROAMING_ADV can be sent, false otherwise
*/ */
static bool tt_check_roam_count(struct bat_priv *bat_priv, static bool batadv_tt_check_roam_count(struct bat_priv *bat_priv,
uint8_t *client) uint8_t *client)
{ {
struct tt_roam_node *tt_roam_node; struct tt_roam_node *tt_roam_node;
...@@ -1898,10 +1921,11 @@ static bool tt_check_roam_count(struct bat_priv *bat_priv, ...@@ -1898,10 +1921,11 @@ static bool tt_check_roam_count(struct bat_priv *bat_priv,
* reply from the same orig_node yet * reply from the same orig_node yet
*/ */
list_for_each_entry(tt_roam_node, &bat_priv->tt_roam_list, list) { list_for_each_entry(tt_roam_node, &bat_priv->tt_roam_list, list) {
if (!compare_eth(tt_roam_node->addr, client)) if (!batadv_compare_eth(tt_roam_node->addr, client))
continue; continue;
if (has_timed_out(tt_roam_node->first_time, ROAMING_MAX_TIME)) if (batadv_has_timed_out(tt_roam_node->first_time,
ROAMING_MAX_TIME))
continue; continue;
if (!atomic_dec_not_zero(&tt_roam_node->counter)) if (!atomic_dec_not_zero(&tt_roam_node->counter))
...@@ -1929,7 +1953,7 @@ static bool tt_check_roam_count(struct bat_priv *bat_priv, ...@@ -1929,7 +1953,7 @@ static bool tt_check_roam_count(struct bat_priv *bat_priv,
return ret; return ret;
} }
static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
struct orig_node *orig_node) struct orig_node *orig_node)
{ {
struct neigh_node *neigh_node = NULL; struct neigh_node *neigh_node = NULL;
...@@ -1941,7 +1965,7 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, ...@@ -1941,7 +1965,7 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
/* before going on we have to check whether the client has /* before going on we have to check whether the client has
* already roamed to us too many times * already roamed to us too many times
*/ */
if (!tt_check_roam_count(bat_priv, client)) if (!batadv_tt_check_roam_count(bat_priv, client))
goto out; goto out;
skb = dev_alloc_skb(sizeof(struct roam_adv_packet) + ETH_HLEN); skb = dev_alloc_skb(sizeof(struct roam_adv_packet) + ETH_HLEN);
...@@ -1956,11 +1980,11 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, ...@@ -1956,11 +1980,11 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
roam_adv_packet->header.packet_type = BAT_ROAM_ADV; roam_adv_packet->header.packet_type = BAT_ROAM_ADV;
roam_adv_packet->header.version = COMPAT_VERSION; roam_adv_packet->header.version = COMPAT_VERSION;
roam_adv_packet->header.ttl = TTL; roam_adv_packet->header.ttl = TTL;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
memcpy(roam_adv_packet->src, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(roam_adv_packet->src, primary_if->net_dev->dev_addr, ETH_ALEN);
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
memcpy(roam_adv_packet->dst, orig_node->orig, ETH_ALEN); memcpy(roam_adv_packet->dst, orig_node->orig, ETH_ALEN);
memcpy(roam_adv_packet->client, client, ETH_ALEN); memcpy(roam_adv_packet->client, client, ETH_ALEN);
...@@ -1968,7 +1992,7 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, ...@@ -1968,7 +1992,7 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
if (!neigh_node) if (!neigh_node)
goto out; goto out;
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Sending ROAMING_ADV to %pM (client %pM) via %pM\n", "Sending ROAMING_ADV to %pM (client %pM) via %pM\n",
orig_node->orig, client, neigh_node->addr); orig_node->orig, client, neigh_node->addr);
...@@ -1985,30 +2009,30 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, ...@@ -1985,30 +2009,30 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
return; return;
} }
static void tt_purge(struct work_struct *work) static void batadv_tt_purge(struct work_struct *work)
{ {
struct delayed_work *delayed_work = struct delayed_work *delayed_work =
container_of(work, struct delayed_work, work); container_of(work, struct delayed_work, work);
struct bat_priv *bat_priv = struct bat_priv *bat_priv =
container_of(delayed_work, struct bat_priv, tt_work); container_of(delayed_work, struct bat_priv, tt_work);
tt_local_purge(bat_priv); batadv_tt_local_purge(bat_priv);
tt_global_roam_purge(bat_priv); batadv_tt_global_roam_purge(bat_priv);
tt_req_purge(bat_priv); batadv_tt_req_purge(bat_priv);
tt_roam_purge(bat_priv); batadv_tt_roam_purge(bat_priv);
tt_start_timer(bat_priv); batadv_tt_start_timer(bat_priv);
} }
void batadv_tt_free(struct bat_priv *bat_priv) void batadv_tt_free(struct bat_priv *bat_priv)
{ {
cancel_delayed_work_sync(&bat_priv->tt_work); cancel_delayed_work_sync(&bat_priv->tt_work);
tt_local_table_free(bat_priv); batadv_tt_local_table_free(bat_priv);
tt_global_table_free(bat_priv); batadv_tt_global_table_free(bat_priv);
tt_req_list_free(bat_priv); batadv_tt_req_list_free(bat_priv);
tt_changes_list_free(bat_priv); batadv_tt_changes_list_free(bat_priv);
tt_roam_list_free(bat_priv); batadv_tt_roam_list_free(bat_priv);
kfree(bat_priv->tt_buff); kfree(bat_priv->tt_buff);
} }
...@@ -2016,7 +2040,7 @@ void batadv_tt_free(struct bat_priv *bat_priv) ...@@ -2016,7 +2040,7 @@ void batadv_tt_free(struct bat_priv *bat_priv)
/* This function will enable or disable the specified flags for all the entries /* This function will enable or disable the specified flags for all the entries
* in the given hash table and returns the number of modified entries * in the given hash table and returns the number of modified entries
*/ */
static uint16_t tt_set_flags(struct hashtable_t *hash, uint16_t flags, static uint16_t batadv_tt_set_flags(struct hashtable_t *hash, uint16_t flags,
bool enable) bool enable)
{ {
uint32_t i; uint32_t i;
...@@ -2052,7 +2076,7 @@ static uint16_t tt_set_flags(struct hashtable_t *hash, uint16_t flags, ...@@ -2052,7 +2076,7 @@ static uint16_t tt_set_flags(struct hashtable_t *hash, uint16_t flags,
} }
/* Purge out all the tt local entries marked with TT_CLIENT_PENDING */ /* Purge out all the tt local entries marked with TT_CLIENT_PENDING */
static void tt_local_purge_pending_clients(struct bat_priv *bat_priv) static void batadv_tt_local_purge_pending_clients(struct bat_priv *bat_priv)
{ {
struct hashtable_t *hash = bat_priv->tt_local_hash; struct hashtable_t *hash = bat_priv->tt_local_hash;
struct tt_common_entry *tt_common_entry; struct tt_common_entry *tt_common_entry;
...@@ -2075,7 +2099,7 @@ static void tt_local_purge_pending_clients(struct bat_priv *bat_priv) ...@@ -2075,7 +2099,7 @@ static void tt_local_purge_pending_clients(struct bat_priv *bat_priv)
if (!(tt_common_entry->flags & TT_CLIENT_PENDING)) if (!(tt_common_entry->flags & TT_CLIENT_PENDING))
continue; continue;
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"Deleting local tt entry (%pM): pending\n", "Deleting local tt entry (%pM): pending\n",
tt_common_entry->addr); tt_common_entry->addr);
...@@ -2084,40 +2108,41 @@ static void tt_local_purge_pending_clients(struct bat_priv *bat_priv) ...@@ -2084,40 +2108,41 @@ static void tt_local_purge_pending_clients(struct bat_priv *bat_priv)
tt_local_entry = container_of(tt_common_entry, tt_local_entry = container_of(tt_common_entry,
struct tt_local_entry, struct tt_local_entry,
common); common);
tt_local_entry_free_ref(tt_local_entry); batadv_tt_local_entry_free_ref(tt_local_entry);
} }
spin_unlock_bh(list_lock); spin_unlock_bh(list_lock);
} }
} }
static int tt_commit_changes(struct bat_priv *bat_priv, static int batadv_tt_commit_changes(struct bat_priv *bat_priv,
unsigned char **packet_buff, int *packet_buff_len, unsigned char **packet_buff,
int packet_min_len) int *packet_buff_len, int packet_min_len)
{ {
uint16_t changed_num = 0; uint16_t changed_num = 0;
if (atomic_read(&bat_priv->tt_local_changes) < 1) if (atomic_read(&bat_priv->tt_local_changes) < 1)
return -ENOENT; return -ENOENT;
changed_num = tt_set_flags(bat_priv->tt_local_hash, changed_num = batadv_tt_set_flags(bat_priv->tt_local_hash,
TT_CLIENT_NEW, false); TT_CLIENT_NEW, false);
/* all reset entries have to be counted as local entries */ /* all reset entries have to be counted as local entries */
atomic_add(changed_num, &bat_priv->num_local_tt); atomic_add(changed_num, &bat_priv->num_local_tt);
tt_local_purge_pending_clients(bat_priv); batadv_tt_local_purge_pending_clients(bat_priv);
bat_priv->tt_crc = batadv_tt_local_crc(bat_priv); bat_priv->tt_crc = batadv_tt_local_crc(bat_priv);
/* Increment the TTVN only once per OGM interval */ /* Increment the TTVN only once per OGM interval */
atomic_inc(&bat_priv->ttvn); atomic_inc(&bat_priv->ttvn);
bat_dbg(DBG_TT, bat_priv, "Local changes committed, updating to ttvn %u\n", batadv_dbg(DBG_TT, bat_priv,
"Local changes committed, updating to ttvn %u\n",
(uint8_t)atomic_read(&bat_priv->ttvn)); (uint8_t)atomic_read(&bat_priv->ttvn));
bat_priv->tt_poss_change = false; bat_priv->tt_poss_change = false;
/* reset the sending counter */ /* reset the sending counter */
atomic_set(&bat_priv->tt_ogm_append_cnt, TT_OGM_APPEND_MAX); atomic_set(&bat_priv->tt_ogm_append_cnt, TT_OGM_APPEND_MAX);
return tt_changes_fill_buff(bat_priv, packet_buff, return batadv_tt_changes_fill_buff(bat_priv, packet_buff,
packet_buff_len, packet_min_len); packet_buff_len, packet_min_len);
} }
...@@ -2129,13 +2154,14 @@ int batadv_tt_append_diff(struct bat_priv *bat_priv, ...@@ -2129,13 +2154,14 @@ int batadv_tt_append_diff(struct bat_priv *bat_priv,
int tt_num_changes; int tt_num_changes;
/* if at least one change happened */ /* if at least one change happened */
tt_num_changes = tt_commit_changes(bat_priv, packet_buff, tt_num_changes = batadv_tt_commit_changes(bat_priv, packet_buff,
packet_buff_len, packet_min_len); packet_buff_len,
packet_min_len);
/* if the changes have been sent often enough */ /* if the changes have been sent often enough */
if ((tt_num_changes < 0) && if ((tt_num_changes < 0) &&
(!atomic_dec_not_zero(&bat_priv->tt_ogm_append_cnt))) { (!atomic_dec_not_zero(&bat_priv->tt_ogm_append_cnt))) {
tt_realloc_packet_buff(packet_buff, packet_buff_len, batadv_tt_realloc_packet_buff(packet_buff, packet_buff_len,
packet_min_len, packet_min_len); packet_min_len, packet_min_len);
tt_num_changes = 0; tt_num_changes = 0;
} }
...@@ -2153,24 +2179,24 @@ bool batadv_is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, ...@@ -2153,24 +2179,24 @@ bool batadv_is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src,
if (!atomic_read(&bat_priv->ap_isolation)) if (!atomic_read(&bat_priv->ap_isolation))
goto out; goto out;
tt_local_entry = tt_local_hash_find(bat_priv, dst); tt_local_entry = batadv_tt_local_hash_find(bat_priv, dst);
if (!tt_local_entry) if (!tt_local_entry)
goto out; goto out;
tt_global_entry = tt_global_hash_find(bat_priv, src); tt_global_entry = batadv_tt_global_hash_find(bat_priv, src);
if (!tt_global_entry) if (!tt_global_entry)
goto out; goto out;
if (!_is_ap_isolated(tt_local_entry, tt_global_entry)) if (_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
goto out; goto out;
ret = true; ret = true;
out: out:
if (tt_global_entry) if (tt_global_entry)
tt_global_entry_free_ref(tt_global_entry); batadv_tt_global_entry_free_ref(tt_global_entry);
if (tt_local_entry) if (tt_local_entry)
tt_local_entry_free_ref(tt_local_entry); batadv_tt_local_entry_free_ref(tt_local_entry);
return ret; return ret;
} }
...@@ -2200,14 +2226,14 @@ void batadv_tt_update_orig(struct bat_priv *bat_priv, ...@@ -2200,14 +2226,14 @@ void batadv_tt_update_orig(struct bat_priv *bat_priv,
goto request_table; goto request_table;
} }
tt_update_changes(bat_priv, orig_node, tt_num_changes, ttvn, batadv_tt_update_changes(bat_priv, orig_node, tt_num_changes,
(struct tt_change *)tt_buff); ttvn, (struct tt_change *)tt_buff);
/* Even if we received the precomputed crc with the OGM, we /* Even if we received the precomputed crc with the OGM, we
* prefer to recompute it to spot any possible inconsistency * prefer to recompute it to spot any possible inconsistency
* in the global table * in the global table
*/ */
orig_node->tt_crc = tt_global_crc(bat_priv, orig_node); orig_node->tt_crc = batadv_tt_global_crc(bat_priv, orig_node);
/* The ttvn alone is not enough to guarantee consistency /* The ttvn alone is not enough to guarantee consistency
* because a single value could represent different states * because a single value could represent different states
...@@ -2232,12 +2258,12 @@ void batadv_tt_update_orig(struct bat_priv *bat_priv, ...@@ -2232,12 +2258,12 @@ void batadv_tt_update_orig(struct bat_priv *bat_priv,
if (!orig_node->tt_initialised || ttvn != orig_ttvn || if (!orig_node->tt_initialised || ttvn != orig_ttvn ||
orig_node->tt_crc != tt_crc) { orig_node->tt_crc != tt_crc) {
request_table: request_table:
bat_dbg(DBG_TT, bat_priv, batadv_dbg(DBG_TT, bat_priv,
"TT inconsistency for %pM. Need to retrieve the correct information (ttvn: %u last_ttvn: %u crc: %u last_crc: %u num_changes: %u)\n", "TT inconsistency for %pM. Need to retrieve the correct information (ttvn: %u last_ttvn: %u crc: %u last_crc: %u num_changes: %u)\n",
orig_node->orig, ttvn, orig_ttvn, tt_crc, orig_node->orig, ttvn, orig_ttvn, tt_crc,
orig_node->tt_crc, tt_num_changes); orig_node->tt_crc, tt_num_changes);
send_tt_request(bat_priv, orig_node, ttvn, tt_crc, batadv_send_tt_request(bat_priv, orig_node, ttvn,
full_table); tt_crc, full_table);
return; return;
} }
} }
...@@ -2253,12 +2279,12 @@ bool batadv_tt_global_client_is_roaming(struct bat_priv *bat_priv, ...@@ -2253,12 +2279,12 @@ bool batadv_tt_global_client_is_roaming(struct bat_priv *bat_priv,
struct tt_global_entry *tt_global_entry; struct tt_global_entry *tt_global_entry;
bool ret = false; bool ret = false;
tt_global_entry = tt_global_hash_find(bat_priv, addr); tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr);
if (!tt_global_entry) if (!tt_global_entry)
goto out; goto out;
ret = tt_global_entry->common.flags & TT_CLIENT_ROAM; ret = tt_global_entry->common.flags & TT_CLIENT_ROAM;
tt_global_entry_free_ref(tt_global_entry); batadv_tt_global_entry_free_ref(tt_global_entry);
out: out:
return ret; return ret;
} }
...@@ -181,7 +181,7 @@ int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv, ...@@ -181,7 +181,7 @@ int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
*new_skb = NULL; *new_skb = NULL;
orig_node = orig_hash_find(bat_priv, unicast_packet->orig); orig_node = batadv_orig_hash_find(bat_priv, unicast_packet->orig);
if (!orig_node) if (!orig_node)
goto out; goto out;
...@@ -227,7 +227,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, ...@@ -227,7 +227,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
int large_tail = 0, ret = NET_RX_DROP; int large_tail = 0, ret = NET_RX_DROP;
uint16_t seqno; uint16_t seqno;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto dropped; goto dropped;
...@@ -277,7 +277,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, ...@@ -277,7 +277,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
kfree_skb(skb); kfree_skb(skb);
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
return ret; return ret;
} }
......
...@@ -33,7 +33,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, ...@@ -33,7 +33,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
struct hard_iface *hard_iface, struct hard_iface *hard_iface,
const uint8_t dstaddr[]); const uint8_t dstaddr[]);
static inline int frag_can_reassemble(const struct sk_buff *skb, int mtu) static inline int batadv_frag_can_reassemble(const struct sk_buff *skb, int mtu)
{ {
const struct unicast_frag_packet *unicast_packet; const struct unicast_frag_packet *unicast_packet;
int uneven_correction = 0; int uneven_correction = 0;
......
...@@ -59,7 +59,7 @@ static int vis_info_cmp(const struct hlist_node *node, const void *data2) ...@@ -59,7 +59,7 @@ static int vis_info_cmp(const struct hlist_node *node, const void *data2)
d2 = data2; d2 = data2;
p1 = (struct vis_packet *)d1->skb_packet->data; p1 = (struct vis_packet *)d1->skb_packet->data;
p2 = (struct vis_packet *)d2->skb_packet->data; p2 = (struct vis_packet *)d2->skb_packet->data;
return compare_eth(p1->vis_orig, p2->vis_orig); return batadv_compare_eth(p1->vis_orig, p2->vis_orig);
} }
/* hash function to choose an entry in a hash table of given size /* hash function to choose an entry in a hash table of given size
...@@ -127,7 +127,7 @@ static void vis_data_insert_interface(const uint8_t *interface, ...@@ -127,7 +127,7 @@ static void vis_data_insert_interface(const uint8_t *interface,
struct hlist_node *pos; struct hlist_node *pos;
hlist_for_each_entry(entry, pos, if_list, list) { hlist_for_each_entry(entry, pos, if_list, list) {
if (compare_eth(entry->addr, interface)) if (batadv_compare_eth(entry->addr, interface))
return; return;
} }
...@@ -181,7 +181,7 @@ static ssize_t vis_data_read_entry(char *buff, ...@@ -181,7 +181,7 @@ static ssize_t vis_data_read_entry(char *buff,
/* 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, "TT %pM, ", entry->dest); return sprintf(buff, "TT %pM, ", entry->dest);
else if (compare_eth(entry->src, src)) else if (batadv_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);
...@@ -208,7 +208,7 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) ...@@ -208,7 +208,7 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
size_t buff_pos, buf_size; size_t buff_pos, buf_size;
char *buff; char *buff;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
...@@ -233,7 +233,7 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) ...@@ -233,7 +233,7 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
for (j = 0; j < packet->entries; j++) { for (j = 0; j < packet->entries; j++) {
if (entries[j].quality == 0) if (entries[j].quality == 0)
continue; continue;
if (compare_eth(entries[j].src, if (batadv_compare_eth(entries[j].src,
packet->vis_orig)) packet->vis_orig))
continue; continue;
vis_data_insert_interface(entries[j].src, vis_data_insert_interface(entries[j].src,
...@@ -245,7 +245,8 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) ...@@ -245,7 +245,8 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
buf_size += 18 + 26 * packet->entries; buf_size += 18 + 26 * packet->entries;
/* add primary/secondary records */ /* add primary/secondary records */
if (compare_eth(entry->addr, packet->vis_orig)) if (batadv_compare_eth(entry->addr,
packet->vis_orig))
buf_size += buf_size +=
vis_data_count_prim_sec(&vis_if_list); vis_data_count_prim_sec(&vis_if_list);
...@@ -285,7 +286,7 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) ...@@ -285,7 +286,7 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
for (j = 0; j < packet->entries; j++) { for (j = 0; j < packet->entries; j++) {
if (entries[j].quality == 0) if (entries[j].quality == 0)
continue; continue;
if (compare_eth(entries[j].src, if (batadv_compare_eth(entries[j].src,
packet->vis_orig)) packet->vis_orig))
continue; continue;
vis_data_insert_interface(entries[j].src, vis_data_insert_interface(entries[j].src,
...@@ -305,7 +306,8 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) ...@@ -305,7 +306,8 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
entry->primary); entry->primary);
/* add primary/secondary records */ /* add primary/secondary records */
if (compare_eth(entry->addr, packet->vis_orig)) if (batadv_compare_eth(entry->addr,
packet->vis_orig))
buff_pos += buff_pos +=
vis_data_read_prim_sec(buff + buff_pos, vis_data_read_prim_sec(buff + buff_pos,
&vis_if_list); &vis_if_list);
...@@ -329,7 +331,7 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) ...@@ -329,7 +331,7 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
return ret; return ret;
} }
...@@ -379,7 +381,7 @@ static int recv_list_is_in(struct bat_priv *bat_priv, ...@@ -379,7 +381,7 @@ static int recv_list_is_in(struct bat_priv *bat_priv,
spin_lock_bh(&bat_priv->vis_list_lock); spin_lock_bh(&bat_priv->vis_list_lock);
list_for_each_entry(entry, recv_list, list) { list_for_each_entry(entry, recv_list, list) {
if (compare_eth(entry->mac, mac)) { if (batadv_compare_eth(entry->mac, mac)) {
spin_unlock_bh(&bat_priv->vis_list_lock); spin_unlock_bh(&bat_priv->vis_list_lock);
return 1; return 1;
} }
...@@ -433,8 +435,8 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv, ...@@ -433,8 +435,8 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv,
} }
} }
/* remove old entry */ /* remove old entry */
hash_remove(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, batadv_hash_remove(bat_priv->vis_hash, vis_info_cmp,
old_info); vis_info_choose, old_info);
send_list_del(old_info); send_list_del(old_info);
kref_put(&old_info->refcount, free_info); kref_put(&old_info->refcount, free_info);
} }
...@@ -474,8 +476,8 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv, ...@@ -474,8 +476,8 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv,
recv_list_add(bat_priv, &info->recv_list, packet->sender_orig); recv_list_add(bat_priv, &info->recv_list, packet->sender_orig);
/* try to add it */ /* try to add it */
hash_added = hash_add(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, hash_added = batadv_hash_add(bat_priv->vis_hash, vis_info_cmp,
info, &info->hash_entry); vis_info_choose, info, &info->hash_entry);
if (hash_added != 0) { if (hash_added != 0) {
/* did not work (for some reason) */ /* did not work (for some reason) */
kref_put(&info->refcount, free_info); kref_put(&info->refcount, free_info);
...@@ -651,7 +653,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv) ...@@ -651,7 +653,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
if (!router) if (!router)
continue; continue;
if (!compare_eth(router->addr, orig_node->orig)) if (!batadv_compare_eth(router->addr, orig_node->orig))
goto next; goto next;
if (router->if_incoming->if_status != IF_ACTIVE) if (router->if_incoming->if_status != IF_ACTIVE)
...@@ -728,7 +730,8 @@ static void purge_vis_packets(struct bat_priv *bat_priv) ...@@ -728,7 +730,8 @@ static void purge_vis_packets(struct bat_priv *bat_priv)
if (info == bat_priv->my_vis_info) if (info == bat_priv->my_vis_info)
continue; continue;
if (has_timed_out(info->first_seen, VIS_TIMEOUT)) { if (batadv_has_timed_out(info->first_seen,
VIS_TIMEOUT)) {
hlist_del(node); hlist_del(node);
send_list_del(info); send_list_del(info);
kref_put(&info->refcount, free_info); kref_put(&info->refcount, free_info);
...@@ -803,7 +806,7 @@ static void unicast_vis_packet(struct bat_priv *bat_priv, ...@@ -803,7 +806,7 @@ static void unicast_vis_packet(struct bat_priv *bat_priv,
packet = (struct vis_packet *)info->skb_packet->data; packet = (struct vis_packet *)info->skb_packet->data;
orig_node = orig_hash_find(bat_priv, packet->target_orig); orig_node = batadv_orig_hash_find(bat_priv, packet->target_orig);
if (!orig_node) if (!orig_node)
goto out; goto out;
...@@ -828,7 +831,7 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info) ...@@ -828,7 +831,7 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)
struct hard_iface *primary_if; struct hard_iface *primary_if;
struct vis_packet *packet; struct vis_packet *packet;
primary_if = primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
...@@ -849,7 +852,7 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info) ...@@ -849,7 +852,7 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)
out: out:
if (primary_if) if (primary_if)
hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
} }
/* called from timer; send (and maybe generate) vis packet. */ /* called from timer; send (and maybe generate) vis packet. */
...@@ -934,8 +937,8 @@ int batadv_vis_init(struct bat_priv *bat_priv) ...@@ -934,8 +937,8 @@ int batadv_vis_init(struct bat_priv *bat_priv)
INIT_LIST_HEAD(&bat_priv->vis_send_list); INIT_LIST_HEAD(&bat_priv->vis_send_list);
hash_added = hash_add(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, hash_added = batadv_hash_add(bat_priv->vis_hash, vis_info_cmp,
bat_priv->my_vis_info, vis_info_choose, bat_priv->my_vis_info,
&bat_priv->my_vis_info->hash_entry); &bat_priv->my_vis_info->hash_entry);
if (hash_added != 0) { if (hash_added != 0) {
pr_err("Can't add own vis packet into hash\n"); pr_err("Can't add own vis packet into hash\n");
...@@ -977,7 +980,7 @@ void batadv_vis_quit(struct bat_priv *bat_priv) ...@@ -977,7 +980,7 @@ void batadv_vis_quit(struct bat_priv *bat_priv)
spin_lock_bh(&bat_priv->vis_hash_lock); spin_lock_bh(&bat_priv->vis_hash_lock);
/* properly remove, kill timers ... */ /* properly remove, kill timers ... */
hash_delete(bat_priv->vis_hash, free_info_ref, NULL); batadv_hash_delete(bat_priv->vis_hash, free_info_ref, NULL);
bat_priv->vis_hash = NULL; bat_priv->vis_hash = NULL;
bat_priv->my_vis_info = NULL; bat_priv->my_vis_info = NULL;
spin_unlock_bh(&bat_priv->vis_hash_lock); spin_unlock_bh(&bat_priv->vis_hash_lock);
......
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