Included changes:
- yet another batch of 'namespace cleaning' patches -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iEYEABECAAYFAk/oCnEACgkQpGgxIkP9cwemxACgnCRoebBm9FXzoUfn3hI4YFTu Hg0AnA6nbPZLQ8uDqdjz45ix1G2T0FnY =+NOX -----END PGP SIGNATURE----- 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: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
1d5873e9d7
|
@ -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, ...)
|
||||||
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, ...)
|
||||||
|
|
||||||
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,14 +96,14 @@ 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;
|
||||||
struct debug_log *debug_log = bat_priv->debug_log;
|
struct debug_log *debug_log = bat_priv->debug_log;
|
||||||
|
@ -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)
|
||||||
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)
|
||||||
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 @@ err:
|
||||||
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)
|
||||||
}
|
}
|
||||||
#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);
|
||||||
|
@ -269,37 +270,37 @@ struct bat_debuginfo {
|
||||||
const struct file_operations fops;
|
const struct file_operations fops;
|
||||||
};
|
};
|
||||||
|
|
||||||
#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, \
|
||||||
.open = _open, \
|
.open = _open, \
|
||||||
.read = seq_read, \
|
.read = seq_read, \
|
||||||
.llseek = seq_lseek, \
|
.llseek = seq_lseek, \
|
||||||
.release = single_release, \
|
.release = single_release, \
|
||||||
} \
|
} \
|
||||||
};
|
};
|
||||||
|
|
||||||
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)
|
||||||
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 @@ out:
|
||||||
|
|
||||||
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)
|
||||||
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)
|
||||||
{
|
{
|
||||||
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,11 +28,11 @@
|
||||||
#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,
|
||||||
__be32 seqno)
|
__be32 seqno)
|
||||||
{
|
{
|
||||||
struct neigh_node *neigh_node;
|
struct neigh_node *neigh_node;
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ out:
|
||||||
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 @@ out:
|
||||||
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)
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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,21 +121,21 @@ 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,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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,8 +165,8 @@ 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
|
||||||
* ordinary base packet
|
* ordinary base packet
|
||||||
|
@ -179,16 +180,16 @@ 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,
|
||||||
ntohl(batman_ogm_packet->seqno),
|
ntohl(batman_ogm_packet->seqno),
|
||||||
batman_ogm_packet->tq, batman_ogm_packet->header.ttl,
|
batman_ogm_packet->tq, batman_ogm_packet->header.ttl,
|
||||||
(batman_ogm_packet->flags & DIRECTLINK ?
|
(batman_ogm_packet->flags & DIRECTLINK ?
|
||||||
"on" : "off"),
|
"on" : "off"),
|
||||||
batman_ogm_packet->ttvn, hard_iface->net_dev->name,
|
batman_ogm_packet->ttvn, hard_iface->net_dev->name,
|
||||||
hard_iface->net_dev->dev_addr);
|
hard_iface->net_dev->dev_addr);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -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)
|
||||||
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,14 +244,14 @@ 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,
|
||||||
ntohl(batman_ogm_packet->seqno),
|
ntohl(batman_ogm_packet->seqno),
|
||||||
batman_ogm_packet->header.ttl,
|
batman_ogm_packet->header.ttl,
|
||||||
forw_packet->if_incoming->net_dev->name,
|
forw_packet->if_incoming->net_dev->name,
|
||||||
forw_packet->if_incoming->net_dev->dev_addr);
|
forw_packet->if_incoming->net_dev->dev_addr);
|
||||||
|
|
||||||
/* skb is only used once and than forw_packet is free'd */
|
/* skb is only used once and than forw_packet is free'd */
|
||||||
batadv_send_skb_packet(forw_packet->skb,
|
batadv_send_skb_packet(forw_packet->skb,
|
||||||
|
@ -267,23 +268,23 @@ 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,
|
||||||
const struct hard_iface *if_incoming,
|
const struct hard_iface *if_incoming,
|
||||||
const struct forw_packet *forw_packet)
|
const struct forw_packet *forw_packet)
|
||||||
{
|
{
|
||||||
struct batman_ogm_packet *batman_ogm_packet;
|
struct batman_ogm_packet *batman_ogm_packet;
|
||||||
int aggregated_bytes = forw_packet->packet_len + packet_len;
|
int aggregated_bytes = forw_packet->packet_len + packet_len;
|
||||||
|
@ -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
|
||||||
* 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,16 +353,16 @@ 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,
|
||||||
int own_packet)
|
int own_packet)
|
||||||
{
|
{
|
||||||
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
|
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
|
||||||
struct forw_packet *forw_packet_aggr;
|
struct forw_packet *forw_packet_aggr;
|
||||||
|
@ -373,8 +374,8 @@ 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,13 +432,13 @@ 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)
|
||||||
{
|
{
|
||||||
unsigned char *skb_buff;
|
unsigned char *skb_buff;
|
||||||
|
|
||||||
|
@ -452,10 +453,11 @@ 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,
|
||||||
int own_packet, unsigned long send_time)
|
struct hard_iface *if_incoming,
|
||||||
|
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
|
||||||
* _pos -> pointer to the position in the queue
|
* _pos -> pointer to the position in the queue
|
||||||
|
@ -474,11 +476,11 @@ 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,
|
||||||
forw_packet_pos)) {
|
forw_packet_pos)) {
|
||||||
forw_packet_aggr = forw_packet_pos;
|
forw_packet_aggr = forw_packet_pos;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -500,28 +502,28 @@ 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,
|
||||||
bool is_from_best_next_hop,
|
bool is_from_best_next_hop,
|
||||||
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);
|
||||||
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,11 +546,12 @@ 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);
|
||||||
|
|
||||||
/* switch of primaries first hop flag when forwarding */
|
/* switch of primaries first hop flag when forwarding */
|
||||||
batman_ogm_packet->flags &= ~PRIMARIES_FIRST_HOP;
|
batman_ogm_packet->flags &= ~PRIMARIES_FIRST_HOP;
|
||||||
|
@ -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)
|
||||||
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,38 +606,40 @@ 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
|
||||||
struct orig_node *orig_node,
|
batadv_iv_ogm_orig_update(struct bat_priv *bat_priv,
|
||||||
const struct ethhdr *ethhdr,
|
struct orig_node *orig_node,
|
||||||
const struct batman_ogm_packet
|
const struct ethhdr *ethhdr,
|
||||||
*batman_ogm_packet,
|
const struct 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)
|
||||||
{
|
{
|
||||||
struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
|
struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
|
||||||
struct neigh_node *router = NULL;
|
struct neigh_node *router = NULL;
|
||||||
struct orig_node *orig_node_tmp;
|
struct orig_node *orig_node_tmp;
|
||||||
struct hlist_node *node;
|
struct hlist_node *node;
|
||||||
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) &&
|
||||||
atomic_inc_not_zero(&tmp_neigh_node->refcount)) {
|
tmp_neigh_node->if_incoming == if_incoming &&
|
||||||
|
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);
|
||||||
neigh_node = tmp_neigh_node;
|
neigh_node = tmp_neigh_node;
|
||||||
|
@ -659,16 +664,17 @@ 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,
|
||||||
orig_node, orig_tmp,
|
ethhdr->h_source,
|
||||||
batman_ogm_packet->seqno);
|
orig_node, orig_tmp,
|
||||||
|
batman_ogm_packet->seqno);
|
||||||
|
|
||||||
batadv_orig_node_free_ref(orig_tmp);
|
batadv_orig_node_free_ref(orig_tmp);
|
||||||
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,10 +763,10 @@ out:
|
||||||
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)
|
||||||
{
|
{
|
||||||
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
|
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
|
||||||
struct neigh_node *neigh_node = NULL, *tmp_neigh_node;
|
struct neigh_node *neigh_node = NULL, *tmp_neigh_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,11 +796,11 @@ 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,
|
||||||
batman_ogm_packet->seqno);
|
batman_ogm_packet->seqno);
|
||||||
|
|
||||||
if (!neigh_node)
|
if (!neigh_node)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -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,10 +877,10 @@ out:
|
||||||
* -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);
|
||||||
struct orig_node *orig_node;
|
struct orig_node *orig_node;
|
||||||
|
@ -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,
|
||||||
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,9 +933,9 @@ 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,10 +947,10 @@ out:
|
||||||
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)
|
||||||
{
|
{
|
||||||
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
|
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
|
||||||
struct hard_iface *hard_iface;
|
struct hard_iface *hard_iface;
|
||||||
|
@ -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,18 +986,19 @@ 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,
|
||||||
batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq,
|
ntohs(batman_ogm_packet->tt_crc),
|
||||||
batman_ogm_packet->header.ttl,
|
batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq,
|
||||||
batman_ogm_packet->header.version, has_directlink_flag);
|
batman_ogm_packet->header.ttl,
|
||||||
|
batman_ogm_packet->header.version, has_directlink_flag);
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
|
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
|
||||||
|
@ -996,16 +1008,16 @@ 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;
|
||||||
|
|
||||||
if (is_broadcast_ether_addr(ethhdr->h_source))
|
if (is_broadcast_ether_addr(ethhdr->h_source))
|
||||||
|
@ -1014,29 +1026,30 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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,37 +1061,37 @@ 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,19 +1099,19 @@ 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,18 +1120,18 @@ 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,13 +1150,13 @@ 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,
|
||||||
batman_ogm_packet);
|
batman_ogm_packet);
|
||||||
|
@ -1151,45 +1164,44 @@ 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);
|
|
||||||
|
|
||||||
/* is single hop (direct) neighbor */
|
/* is single hop (direct) neighbor */
|
||||||
if (is_single_hop_neigh) {
|
if (is_single_hop_neigh) {
|
||||||
|
|
||||||
/* mark direct link on incoming interface */
|
/* mark direct link on incoming interface */
|
||||||
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);
|
||||||
|
|
||||||
out_neigh:
|
out_neigh:
|
||||||
if ((orig_neigh_node) && (!is_single_hop_neigh))
|
if ((orig_neigh_node) && (!is_single_hop_neigh))
|
||||||
|
@ -1205,8 +1217,8 @@ out:
|
||||||
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);
|
||||||
struct batman_ogm_packet *batman_ogm_packet;
|
struct batman_ogm_packet *batman_ogm_packet;
|
||||||
|
@ -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,
|
||||||
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)
|
||||||
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 @@
|
||||||
#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)
|
||||||
#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 = { \
|
||||||
};
|
};
|
||||||
|
|
||||||
#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, \
|
||||||
#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, \
|
||||||
#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, \
|
||||||
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, \
|
||||||
\
|
\
|
||||||
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,12 +167,13 @@ 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)
|
||||||
{
|
{
|
||||||
int enabled = -1;
|
int enabled = -1;
|
||||||
|
|
||||||
|
@ -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
|
||||||
void (*post_func)(struct net_device *),
|
__batadv_store_bool_attr(char *buff, size_t count,
|
||||||
struct attribute *attr,
|
void (*post_func)(struct net_device *),
|
||||||
atomic_t *attr_store, struct net_device *net_dev)
|
struct attribute *attr,
|
||||||
|
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,26 +263,27 @@ 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
|
||||||
int min, int max,
|
__batadv_store_uint_attr(const char *buff, size_t count,
|
||||||
void (*post_func)(struct net_device *),
|
int min, int max,
|
||||||
const struct attribute *attr,
|
void (*post_func)(struct net_device *),
|
||||||
atomic_t *attr_store, struct net_device *net_dev)
|
const struct attribute *attr,
|
||||||
|
atomic_t *attr_store, struct net_device *net_dev)
|
||||||
{
|
{
|
||||||
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,
|
||||||
"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,
|
||||||
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,
|
||||||
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,
|
||||||
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,
|
||||||
(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);
|
||||||
#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)
|
||||||
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)
|
||||||
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)
|
||||||
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,
|
||||||
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,
|
||||||
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,
|
||||||
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,
|
||||||
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)
|
||||||
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)
|
||||||
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,
|
||||||
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 @@ out:
|
||||||
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],
|
||||||
(action == UEV_DEL ? "NULL" : data), ret);
|
batadv_uev_action_str[action],
|
||||||
|
(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,
|
||||||
*/
|
*/
|
||||||
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,
|
||||||
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,
|
||||||
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,8 +23,8 @@
|
||||||
/* 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,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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)
|
||||||
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 @@ unlock:
|
||||||
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)
|
||||||
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)
|
||||||
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)
|
||||||
((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)
|
||||||
*/
|
*/
|
||||||
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)
|
||||||
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)
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
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,9 +283,9 @@ 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);
|
||||||
|
|
||||||
deselect:
|
deselect:
|
||||||
batadv_gw_deselect(bat_priv);
|
batadv_gw_deselect(bat_priv);
|
||||||
|
@ -299,8 +300,9 @@ out:
|
||||||
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,13 +320,13 @@ 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),
|
||||||
(down > 2048 ? "MBit" : "KBit"),
|
(down > 2048 ? "MBit" : "KBit"),
|
||||||
(up > 2048 ? up / 1024 : up),
|
(up > 2048 ? up / 1024 : up),
|
||||||
(up > 2048 ? "MBit" : "KBit"));
|
(up > 2048 ? "MBit" : "KBit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void batadv_gw_node_update(struct bat_priv *bat_priv,
|
void batadv_gw_node_update(struct bat_priv *bat_priv,
|
||||||
|
@ -338,25 +340,25 @@ 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);
|
||||||
|
|
||||||
gw_node->deleted = 0;
|
gw_node->deleted = 0;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
if (gw_node == curr_gw)
|
if (gw_node == curr_gw)
|
||||||
goto deselect;
|
goto deselect;
|
||||||
|
@ -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 @@ unlock:
|
||||||
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)
|
||||||
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)
|
||||||
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,12 +420,13 @@ 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,
|
||||||
const struct gw_node *gw_node)
|
struct seq_file *seq,
|
||||||
|
const struct gw_node *gw_node)
|
||||||
{
|
{
|
||||||
struct gw_node *curr_gw;
|
struct gw_node *curr_gw;
|
||||||
struct neigh_node *router;
|
struct neigh_node *router;
|
||||||
|
@ -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,
|
||||||
|
|
||||||
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)
|
||||||
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)
|
||||||
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)
|
||||||
|
|
||||||
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,
|
||||||
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,
|
||||||
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 @@ out:
|
||||||
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 @@
|
||||||
#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,8 +73,8 @@ 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;
|
||||||
char *slash_ptr, *tmp_ptr;
|
char *slash_ptr, *tmp_ptr;
|
||||||
|
@ -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,
|
||||||
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 @@ out:
|
||||||
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)
|
||||||
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 @@ out:
|
||||||
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,11 +116,11 @@ 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,
|
||||||
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)
|
||||||
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,8 +164,8 @@ 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;
|
||||||
|
|
||||||
pr_warn("The newly added mac address (%pM) already exists on: %s\n",
|
pr_warn("The newly added mac address (%pM) already exists on: %s\n",
|
||||||
|
@ -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)
|
||||||
/* 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)
|
||||||
|
|
||||||
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,
|
||||||
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 @@ out:
|
||||||
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)
|
||||||
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)
|
||||||
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)
|
||||||
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)
|
||||||
/* 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 @@ out:
|
||||||
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)
|
||||||
|
|
||||||
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,13 +474,13 @@ 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;
|
||||||
struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
|
struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
|
||||||
|
@ -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,
|
||||||
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 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
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 @@
|
||||||
#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)
|
||||||
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,8 +54,8 @@ 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;
|
||||||
struct hlist_node *node, *node_tmp;
|
struct hlist_node *node, *node_tmp;
|
||||||
|
@ -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,9 +134,9 @@ out:
|
||||||
* 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)
|
||||||
{
|
{
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
struct hlist_node *node;
|
struct hlist_node *node;
|
||||||
|
|
|
@ -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)
|
||||||
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)
|
||||||
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)
|
||||||
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,8 +101,8 @@ 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;
|
||||||
struct socket_packet *socket_packet;
|
struct socket_packet *socket_packet;
|
||||||
|
@ -144,8 +144,8 @@ 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;
|
||||||
struct bat_priv *bat_priv = socket_client->bat_priv;
|
struct bat_priv *bat_priv = socket_client->bat_priv;
|
||||||
|
@ -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,15 +188,15 @@ 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,
|
||||||
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,
|
||||||
|
|
||||||
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 @@ out:
|
||||||
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)
|
||||||
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)
|
||||||
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,9 +293,9 @@ err:
|
||||||
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)
|
||||||
{
|
{
|
||||||
struct socket_packet *socket_packet;
|
struct socket_packet *socket_packet;
|
||||||
|
|
||||||
|
@ -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,
|
||||||
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)
|
||||||
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,9 +238,9 @@ 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);
|
||||||
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,9 +183,9 @@ __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, ...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -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,
|
||||||
*
|
*
|
||||||
* 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)
|
||||||
*
|
*
|
||||||
* 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 @@
|
||||||
#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)
|
||||||
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,15 +102,15 @@ 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);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
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)
|
||||||
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,
|
||||||
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,
|
||||||
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,14 +264,15 @@ free_orig_node:
|
||||||
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)
|
||||||
{
|
{
|
||||||
struct hlist_node *node, *node_tmp;
|
struct hlist_node *node, *node_tmp;
|
||||||
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,28 +282,26 @@ 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)) ||
|
last_seen = neigh_node->last_seen;
|
||||||
(neigh_node->if_incoming->if_status == IF_INACTIVE) ||
|
if_incoming = neigh_node->if_incoming;
|
||||||
(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;
|
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 ==
|
"neighbor purge: originator %pM, neighbor: %pM, iface: %s\n",
|
||||||
IF_TO_BE_REMOVED))
|
orig_node->orig, neigh_node->addr,
|
||||||
bat_dbg(DBG_BATMAN, bat_priv,
|
if_incoming->net_dev->name);
|
||||||
"neighbor purge: originator %pM, neighbor: %pM, iface: %s\n",
|
|
||||||
orig_node->orig, neigh_node->addr,
|
|
||||||
neigh_node->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));
|
||||||
|
|
||||||
neigh_purged = true;
|
neigh_purged = true;
|
||||||
|
|
||||||
|
@ -319,20 +319,20 @@ 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,
|
||||||
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)
|
||||||
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,8 +369,8 @@ 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);
|
||||||
}
|
}
|
||||||
spin_unlock_bh(list_lock);
|
spin_unlock_bh(list_lock);
|
||||||
|
@ -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)
|
||||||
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 @@ next:
|
||||||
|
|
||||||
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)
|
||||||
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,8 +544,8 @@ err:
|
||||||
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;
|
||||||
int chunk_size;
|
int chunk_size;
|
||||||
|
@ -612,8 +612,8 @@ 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);
|
||||||
|
|
||||||
if (ret == -ENOMEM)
|
if (ret == -ENOMEM)
|
||||||
|
|
|
@ -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,8 +60,8 @@ 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;
|
||||||
struct hlist_head *head;
|
struct hlist_head *head;
|
||||||
|
@ -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,8 +29,8 @@
|
||||||
#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,9 +61,9 @@ 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)
|
||||||
{
|
{
|
||||||
struct neigh_node *curr_router;
|
struct neigh_node *curr_router;
|
||||||
|
|
||||||
|
@ -71,23 +71,23 @@ 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");
|
||||||
|
|
||||||
/* 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curr_router)
|
if (curr_router)
|
||||||
|
@ -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,8 +151,8 @@ 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;
|
||||||
|
|
||||||
router = batadv_orig_node_get_router(orig_node);
|
router = batadv_orig_node_get_router(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,12 +234,12 @@ 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -275,8 +276,8 @@ 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;
|
||||||
struct orig_node *orig_node = NULL;
|
struct orig_node *orig_node = NULL;
|
||||||
|
@ -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,
|
||||||
|
|
||||||
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,8 +331,8 @@ out:
|
||||||
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;
|
||||||
struct orig_node *orig_node = NULL;
|
struct orig_node *orig_node = NULL;
|
||||||
|
@ -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,
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
/* 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,8 +473,9 @@ out:
|
||||||
* 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 *
|
||||||
const struct hard_iface *recv_if)
|
batadv_find_bond_router(struct orig_node *primary_orig,
|
||||||
|
const struct hard_iface *recv_if)
|
||||||
{
|
{
|
||||||
struct neigh_node *tmp_neigh_node;
|
struct neigh_node *tmp_neigh_node;
|
||||||
struct neigh_node *router = NULL, *first_candidate = NULL;
|
struct neigh_node *router = NULL, *first_candidate = NULL;
|
||||||
|
@ -526,8 +528,9 @@ out:
|
||||||
*
|
*
|
||||||
* 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 *
|
||||||
const struct hard_iface *recv_if)
|
batadv_find_ifalter_router(struct orig_node *primary_orig,
|
||||||
|
const struct hard_iface *recv_if)
|
||||||
{
|
{
|
||||||
struct neigh_node *tmp_neigh_node;
|
struct neigh_node *tmp_neigh_node;
|
||||||
struct neigh_node *router = NULL, *first_candidate = NULL;
|
struct neigh_node *router = NULL, *first_candidate = NULL;
|
||||||
|
@ -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)
|
||||||
* 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' : '.';
|
||||||
"Routing TT_REQUEST to %pM [%c]\n",
|
batadv_dbg(DBG_TT, bat_priv,
|
||||||
tt_query->dst,
|
"Routing TT_REQUEST to %pM [%c]\n",
|
||||||
(tt_query->flags & TT_FULL_TABLE ? 'F' : '.'));
|
tt_query->dst,
|
||||||
return route_unicast_packet(skb, recv_if);
|
tt_flag);
|
||||||
|
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)
|
||||||
|
|
||||||
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' : '.';
|
||||||
"Routing TT_RESPONSE to %pM [%c]\n",
|
batadv_dbg(DBG_TT, bat_priv,
|
||||||
tt_query->dst,
|
"Routing TT_RESPONSE to %pM [%c]\n",
|
||||||
(tt_query->flags & TT_FULL_TABLE ? 'F' : '.'));
|
tt_query->dst,
|
||||||
return route_unicast_packet(skb, recv_if);
|
tt_flag);
|
||||||
|
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)
|
||||||
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,13 +690,13 @@ 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);
|
||||||
|
|
||||||
batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client,
|
batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client,
|
||||||
atomic_read(&orig_node->last_ttvn) + 1, true,
|
atomic_read(&orig_node->last_ttvn) + 1, true,
|
||||||
|
@ -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,
|
||||||
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,
|
||||||
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 @@ err:
|
||||||
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)
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
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,8 +914,8 @@ out:
|
||||||
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;
|
||||||
struct ethhdr *ethhdr;
|
struct ethhdr *ethhdr;
|
||||||
|
@ -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,
|
||||||
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,10 +981,10 @@ 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);
|
||||||
|
|
||||||
unicast_packet->ttvn = curr_ttvn;
|
unicast_packet->ttvn = curr_ttvn;
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
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,
|
||||||
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,
|
||||||
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)
|
||||||
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,8 +1098,8 @@ 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;
|
||||||
|
|
||||||
seq_diff = ntohl(bcast_packet->seqno) - orig_node->last_bcast_seqno;
|
seq_diff = ntohl(bcast_packet->seqno) - orig_node->last_bcast_seqno;
|
||||||
|
|
|
@ -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,18 +96,18 @@ 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)
|
||||||
{
|
{
|
||||||
INIT_HLIST_NODE(&forw_packet->list);
|
INIT_HLIST_NODE(&forw_packet->list);
|
||||||
|
|
||||||
|
@ -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,
|
||||||
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,
|
||||||
/* 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 @@ out_and_inc:
|
||||||
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)
|
||||||
|
|
||||||
/* 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 @@ out:
|
||||||
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,12 +271,12 @@ 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 */
|
||||||
spin_lock_bh(&bat_priv->forw_bcast_list_lock);
|
spin_lock_bh(&bat_priv->forw_bcast_list_lock);
|
||||||
|
@ -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,
|
||||||
|
|
||||||
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,
|
||||||
|
|
||||||
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 @@
|
||||||
#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)
|
||||||
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)
|
||||||
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)
|
||||||
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)
|
||||||
/* 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)
|
||||||
|
|
||||||
/* 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 @@ dropped_freed:
|
||||||
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 @@ out:
|
||||||
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)
|
||||||
/* 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)
|
||||||
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)
|
||||||
|
|
||||||
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,8 +481,8 @@ 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");
|
||||||
strcpy(info->version, SOURCE_VERSION);
|
strcpy(info->version, SOURCE_VERSION);
|
||||||
|
@ -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)
|
||||||
*/
|
*/
|
||||||
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,
|
||||||
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,
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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,
|
||||||
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 @@ dropped:
|
||||||
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,
|
||||||
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)
|
||||||
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,
|
||||||
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,
|
||||||
/* 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)
|
||||||
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,8 +233,8 @@ 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,
|
||||||
&vis_if_list,
|
&vis_if_list,
|
||||||
|
@ -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,8 +286,8 @@ 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,
|
||||||
&vis_if_list,
|
&vis_if_list,
|
||||||
|
@ -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)
|
||||||
|
|
||||||
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,
|
||||||
|
|
||||||
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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* 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,
|
||||||
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)
|
||||||
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)
|
||||||
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,
|
||||||
|
|
||||||
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)
|
||||||
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)
|
||||||
|
|
||||||
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,9 +937,9 @@ 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");
|
||||||
/* not in hash, need to remove it manually. */
|
/* not in hash, need to remove it manually. */
|
||||||
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue