提交 e87183c2 编写于 作者: D David S. Miller

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

Included changes:
- The last batch of patches aimed to clean the batman-adv namespace
- a couple of style fixes
- a fix for the ethtool support
- a fix to prevent sending unicast packets with an uninitialised header
  field
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
......@@ -19,11 +19,10 @@
#
obj-$(CONFIG_BATMAN_ADV) += batman-adv.o
batman-adv-y += bat_debugfs.o
batman-adv-y += bat_iv_ogm.o
batman-adv-y += bat_sysfs.o
batman-adv-y += bitarray.o
batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o
batman-adv-y += debugfs.o
batman-adv-y += gateway_client.o
batman-adv-y += gateway_common.o
batman-adv-y += hard-interface.o
......@@ -35,6 +34,7 @@ batman-adv-y += ring_buffer.o
batman-adv-y += routing.o
batman-adv-y += send.o
batman-adv-y += soft-interface.o
batman-adv-y += sysfs.o
batman-adv-y += translation-table.o
batman-adv-y += unicast.o
batman-adv-y += vis.o
此差异已折叠。
......@@ -41,7 +41,7 @@ static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n)
int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
int32_t seq_num_diff, int set_mark)
{
struct bat_priv *bat_priv = priv;
struct batadv_priv *bat_priv = priv;
/* sequence number is slightly older. We already got a sequence number
* higher than this one, so we just mark it.
......@@ -66,7 +66,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
/* sequence number is much newer, probably missed a lot of packets */
if (seq_num_diff >= BATADV_TQ_LOCAL_WINDOW_SIZE &&
seq_num_diff < BATADV_EXPECTED_SEQNO_RANGE) {
batadv_dbg(DBG_BATMAN, bat_priv,
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"We missed a lot of packets (%i) !\n",
seq_num_diff - 1);
bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
......@@ -83,7 +83,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE ||
seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) {
batadv_dbg(DBG_BATMAN, bat_priv,
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Other host probably restarted!\n");
bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
......
......@@ -21,38 +21,38 @@
#define _NET_BATMAN_ADV_BLA_H_
#ifdef CONFIG_BATMAN_ADV_BLA
int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid);
int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid);
int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid);
int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid);
int batadv_bla_is_backbone_gw(struct sk_buff *skb,
struct orig_node *orig_node, int hdr_size);
struct batadv_orig_node *orig_node, int hdr_size);
int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);
int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig);
int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
struct bcast_packet *bcast_packet,
int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig);
int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
struct batadv_bcast_packet *bcast_packet,
int hdr_size);
void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
struct hard_iface *primary_if,
struct hard_iface *oldif);
int batadv_bla_init(struct bat_priv *bat_priv);
void batadv_bla_free(struct bat_priv *bat_priv);
void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
struct batadv_hard_iface *primary_if,
struct batadv_hard_iface *oldif);
int batadv_bla_init(struct batadv_priv *bat_priv);
void batadv_bla_free(struct batadv_priv *bat_priv);
#define BATADV_BLA_CRC_INIT 0
#else /* ifdef CONFIG_BATMAN_ADV_BLA */
static inline int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb,
short vid)
static inline int batadv_bla_rx(struct batadv_priv *bat_priv,
struct sk_buff *skb, short vid)
{
return 0;
}
static inline int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb,
short vid)
static inline int batadv_bla_tx(struct batadv_priv *bat_priv,
struct sk_buff *skb, short vid)
{
return 0;
}
static inline int batadv_bla_is_backbone_gw(struct sk_buff *skb,
struct orig_node *orig_node,
struct batadv_orig_node *orig_node,
int hdr_size)
{
return 0;
......@@ -64,33 +64,33 @@ static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq,
return 0;
}
static inline int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv,
static inline int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv,
uint8_t *orig)
{
return 0;
}
static inline int
batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
struct bcast_packet *bcast_packet,
batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
struct batadv_bcast_packet *bcast_packet,
int hdr_size)
{
return 0;
}
static inline void
batadv_bla_update_orig_address(struct bat_priv *bat_priv,
struct hard_iface *primary_if,
struct hard_iface *oldif)
batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
struct batadv_hard_iface *primary_if,
struct batadv_hard_iface *oldif)
{
}
static inline int batadv_bla_init(struct bat_priv *bat_priv)
static inline int batadv_bla_init(struct batadv_priv *bat_priv)
{
return 1;
}
static inline void batadv_bla_free(struct bat_priv *bat_priv)
static inline void batadv_bla_free(struct batadv_priv *bat_priv)
{
}
......
......@@ -21,7 +21,7 @@
#include <linux/debugfs.h>
#include "bat_debugfs.h"
#include "debugfs.h"
#include "translation-table.h"
#include "originator.h"
#include "hard-interface.h"
......@@ -36,13 +36,21 @@ static struct dentry *batadv_debugfs;
#ifdef CONFIG_BATMAN_ADV_DEBUG
#define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1)
#define BATADV_LOG_BUFF(idx) (debug_log->log_buff[(idx) & BATADV_LOG_BUFF_MASK])
static int batadv_log_buff_len = BATADV_LOG_BUF_LEN;
static const int batadv_log_buff_len = BATADV_LOG_BUF_LEN;
static void batadv_emit_log_char(struct debug_log *debug_log, char c)
static char *batadv_log_char_addr(struct batadv_debug_log *debug_log,
size_t idx)
{
BATADV_LOG_BUFF(debug_log->log_end) = c;
return &debug_log->log_buff[idx & BATADV_LOG_BUFF_MASK];
}
static void batadv_emit_log_char(struct batadv_debug_log *debug_log, char c)
{
char *char_addr;
char_addr = batadv_log_char_addr(debug_log, debug_log->log_end);
*char_addr = c;
debug_log->log_end++;
if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len)
......@@ -50,7 +58,8 @@ static void batadv_emit_log_char(struct debug_log *debug_log, char c)
}
__printf(2, 3)
static int batadv_fdebug_log(struct debug_log *debug_log, const char *fmt, ...)
static int batadv_fdebug_log(struct batadv_debug_log *debug_log,
const char *fmt, ...)
{
va_list args;
static char debug_log_buf[256];
......@@ -74,7 +83,7 @@ static int batadv_fdebug_log(struct debug_log *debug_log, const char *fmt, ...)
return 0;
}
int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...)
int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
{
va_list args;
char tmp_log_buf[256];
......@@ -102,16 +111,21 @@ static int batadv_log_release(struct inode *inode, struct file *file)
return 0;
}
static int batadv_log_empty(struct batadv_debug_log *debug_log)
{
return !(debug_log->log_start - debug_log->log_end);
}
static ssize_t batadv_log_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
struct bat_priv *bat_priv = file->private_data;
struct debug_log *debug_log = bat_priv->debug_log;
struct batadv_priv *bat_priv = file->private_data;
struct batadv_debug_log *debug_log = bat_priv->debug_log;
int error, i = 0;
char *char_addr;
char c;
if ((file->f_flags & O_NONBLOCK) &&
!(debug_log->log_end - debug_log->log_start))
if ((file->f_flags & O_NONBLOCK) && batadv_log_empty(debug_log))
return -EAGAIN;
if (!buf)
......@@ -124,7 +138,7 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf,
return -EFAULT;
error = wait_event_interruptible(debug_log->queue_wait,
(debug_log->log_start - debug_log->log_end));
(!batadv_log_empty(debug_log)));
if (error)
return error;
......@@ -133,7 +147,9 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf,
while ((!error) && (i < count) &&
(debug_log->log_start != debug_log->log_end)) {
c = BATADV_LOG_BUFF(debug_log->log_start);
char_addr = batadv_log_char_addr(debug_log,
debug_log->log_start);
c = *char_addr;
debug_log->log_start++;
......@@ -158,12 +174,12 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf,
static unsigned int batadv_log_poll(struct file *file, poll_table *wait)
{
struct bat_priv *bat_priv = file->private_data;
struct debug_log *debug_log = bat_priv->debug_log;
struct batadv_priv *bat_priv = file->private_data;
struct batadv_debug_log *debug_log = bat_priv->debug_log;
poll_wait(file, &debug_log->queue_wait, wait);
if (debug_log->log_end - debug_log->log_start)
if (!batadv_log_empty(debug_log))
return POLLIN | POLLRDNORM;
return 0;
......@@ -177,7 +193,7 @@ static const struct file_operations batadv_log_fops = {
.llseek = no_llseek,
};
static int batadv_debug_log_setup(struct bat_priv *bat_priv)
static int batadv_debug_log_setup(struct batadv_priv *bat_priv)
{
struct dentry *d;
......@@ -203,19 +219,19 @@ static int batadv_debug_log_setup(struct bat_priv *bat_priv)
return -ENOMEM;
}
static void batadv_debug_log_cleanup(struct bat_priv *bat_priv)
static void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
{
kfree(bat_priv->debug_log);
bat_priv->debug_log = NULL;
}
#else /* CONFIG_BATMAN_ADV_DEBUG */
static int batadv_debug_log_setup(struct bat_priv *bat_priv)
static int batadv_debug_log_setup(struct batadv_priv *bat_priv)
{
bat_priv->debug_log = NULL;
return 0;
}
static void batadv_debug_log_cleanup(struct bat_priv *bat_priv)
static void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
{
return;
}
......@@ -265,13 +281,13 @@ static int batadv_vis_data_open(struct inode *inode, struct file *file)
return single_open(file, batadv_vis_seq_print_text, net_dev);
}
struct bat_debuginfo {
struct batadv_debuginfo {
struct attribute attr;
const struct file_operations fops;
};
#define BATADV_DEBUGINFO(_name, _mode, _open) \
struct bat_debuginfo batadv_debuginfo_##_name = { \
struct batadv_debuginfo batadv_debuginfo_##_name = { \
.attr = { .name = __stringify(_name), \
.mode = _mode, }, \
.fops = { .owner = THIS_MODULE, \
......@@ -294,7 +310,7 @@ static BATADV_DEBUGINFO(transtable_local, S_IRUGO,
batadv_transtable_local_open);
static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open);
static struct bat_debuginfo *batadv_mesh_debuginfos[] = {
static struct batadv_debuginfo *batadv_mesh_debuginfos[] = {
&batadv_debuginfo_originators,
&batadv_debuginfo_gateways,
&batadv_debuginfo_transtable_global,
......@@ -308,7 +324,7 @@ static struct bat_debuginfo *batadv_mesh_debuginfos[] = {
void batadv_debugfs_init(void)
{
struct bat_debuginfo *bat_debug;
struct batadv_debuginfo *bat_debug;
struct dentry *file;
batadv_debugfs = debugfs_create_dir(BATADV_DEBUGFS_SUBDIR, NULL);
......@@ -339,8 +355,8 @@ void batadv_debugfs_destroy(void)
int batadv_debugfs_add_meshif(struct net_device *dev)
{
struct bat_priv *bat_priv = netdev_priv(dev);
struct bat_debuginfo **bat_debug;
struct batadv_priv *bat_priv = netdev_priv(dev);
struct batadv_debuginfo **bat_debug;
struct dentry *file;
if (!batadv_debugfs)
......@@ -358,9 +374,9 @@ int batadv_debugfs_add_meshif(struct net_device *dev)
for (bat_debug = batadv_mesh_debuginfos; *bat_debug; ++bat_debug) {
file = debugfs_create_file(((*bat_debug)->attr).name,
S_IFREG | ((*bat_debug)->attr).mode,
bat_priv->debug_dir,
dev, &(*bat_debug)->fops);
S_IFREG | ((*bat_debug)->attr).mode,
bat_priv->debug_dir,
dev, &(*bat_debug)->fops);
if (!file) {
batadv_err(dev, "Can't add debugfs file: %s/%s\n",
dev->name, ((*bat_debug)->attr).name);
......@@ -382,7 +398,7 @@ int batadv_debugfs_add_meshif(struct net_device *dev)
void batadv_debugfs_del_meshif(struct net_device *dev)
{
struct bat_priv *bat_priv = netdev_priv(dev);
struct batadv_priv *bat_priv = netdev_priv(dev);
batadv_debug_log_cleanup(bat_priv);
......
......@@ -18,7 +18,7 @@
*/
#include "main.h"
#include "bat_sysfs.h"
#include "sysfs.h"
#include "gateway_client.h"
#include "gateway_common.h"
#include "hard-interface.h"
......@@ -36,15 +36,16 @@
#define BATADV_DHCP_OPTIONS_OFFSET 240
#define BATADV_DHCP_REQUEST 3
static void batadv_gw_node_free_ref(struct gw_node *gw_node)
static void batadv_gw_node_free_ref(struct batadv_gw_node *gw_node)
{
if (atomic_dec_and_test(&gw_node->refcount))
kfree_rcu(gw_node, rcu);
}
static struct gw_node *batadv_gw_get_selected_gw_node(struct bat_priv *bat_priv)
static struct batadv_gw_node *
batadv_gw_get_selected_gw_node(struct batadv_priv *bat_priv)
{
struct gw_node *gw_node;
struct batadv_gw_node *gw_node;
rcu_read_lock();
gw_node = rcu_dereference(bat_priv->curr_gw);
......@@ -59,10 +60,11 @@ static struct gw_node *batadv_gw_get_selected_gw_node(struct bat_priv *bat_priv)
return gw_node;
}
struct orig_node *batadv_gw_get_selected_orig(struct bat_priv *bat_priv)
struct batadv_orig_node *
batadv_gw_get_selected_orig(struct batadv_priv *bat_priv)
{
struct gw_node *gw_node;
struct orig_node *orig_node = NULL;
struct batadv_gw_node *gw_node;
struct batadv_orig_node *orig_node = NULL;
gw_node = batadv_gw_get_selected_gw_node(bat_priv);
if (!gw_node)
......@@ -84,10 +86,10 @@ struct orig_node *batadv_gw_get_selected_orig(struct bat_priv *bat_priv)
return orig_node;
}
static void batadv_gw_select(struct bat_priv *bat_priv,
struct gw_node *new_gw_node)
static void batadv_gw_select(struct batadv_priv *bat_priv,
struct batadv_gw_node *new_gw_node)
{
struct gw_node *curr_gw_node;
struct batadv_gw_node *curr_gw_node;
spin_lock_bh(&bat_priv->gw_list_lock);
......@@ -103,20 +105,21 @@ static void batadv_gw_select(struct bat_priv *bat_priv,
spin_unlock_bh(&bat_priv->gw_list_lock);
}
void batadv_gw_deselect(struct bat_priv *bat_priv)
void batadv_gw_deselect(struct batadv_priv *bat_priv)
{
atomic_set(&bat_priv->gw_reselect, 1);
}
static struct gw_node *batadv_gw_get_best_gw_node(struct bat_priv *bat_priv)
static struct batadv_gw_node *
batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
{
struct neigh_node *router;
struct batadv_neigh_node *router;
struct hlist_node *node;
struct gw_node *gw_node, *curr_gw = NULL;
struct batadv_gw_node *gw_node, *curr_gw = NULL;
uint32_t max_gw_factor = 0, tmp_gw_factor = 0;
uint8_t max_tq = 0;
int down, up;
struct orig_node *orig_node;
struct batadv_orig_node *orig_node;
rcu_read_lock();
hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) {
......@@ -183,10 +186,10 @@ static struct gw_node *batadv_gw_get_best_gw_node(struct bat_priv *bat_priv)
return curr_gw;
}
void batadv_gw_election(struct bat_priv *bat_priv)
void batadv_gw_election(struct batadv_priv *bat_priv)
{
struct gw_node *curr_gw = NULL, *next_gw = NULL;
struct neigh_node *router = NULL;
struct batadv_gw_node *curr_gw = NULL, *next_gw = NULL;
struct batadv_neigh_node *router = NULL;
char gw_addr[18] = { '\0' };
/* The batman daemon checks here if we already passed a full originator
......@@ -194,7 +197,7 @@ void batadv_gw_election(struct bat_priv *bat_priv)
* hear about. This check is based on the daemon's uptime which we
* don't have.
*/
if (atomic_read(&bat_priv->gw_mode) != GW_MODE_CLIENT)
if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_CLIENT)
goto out;
if (!batadv_atomic_dec_not_zero(&bat_priv->gw_reselect))
......@@ -218,21 +221,24 @@ void batadv_gw_election(struct bat_priv *bat_priv)
}
if ((curr_gw) && (!next_gw)) {
batadv_dbg(DBG_BATMAN, bat_priv,
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Removing selected gateway - no gateway in range\n");
batadv_throw_uevent(bat_priv, UEV_GW, UEV_DEL, NULL);
batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL,
NULL);
} else if ((!curr_gw) && (next_gw)) {
batadv_dbg(DBG_BATMAN, bat_priv,
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Adding route to gateway %pM (gw_flags: %i, tq: %i)\n",
next_gw->orig_node->orig,
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, BATADV_UEV_GW, BATADV_UEV_ADD,
gw_addr);
} else {
batadv_dbg(DBG_BATMAN, bat_priv,
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Changing route to gateway %pM (gw_flags: %i, tq: %i)\n",
next_gw->orig_node->orig,
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, BATADV_UEV_GW, BATADV_UEV_CHANGE,
gw_addr);
}
batadv_gw_select(bat_priv, next_gw);
......@@ -246,11 +252,11 @@ void batadv_gw_election(struct bat_priv *bat_priv)
batadv_neigh_node_free_ref(router);
}
void batadv_gw_check_election(struct bat_priv *bat_priv,
struct orig_node *orig_node)
void batadv_gw_check_election(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node)
{
struct orig_node *curr_gw_orig;
struct neigh_node *router_gw = NULL, *router_orig = NULL;
struct batadv_orig_node *curr_gw_orig;
struct batadv_neigh_node *router_gw = NULL, *router_orig = NULL;
uint8_t gw_tq_avg, orig_tq_avg;
curr_gw_orig = batadv_gw_get_selected_orig(bat_priv);
......@@ -283,7 +289,7 @@ void batadv_gw_check_election(struct bat_priv *bat_priv,
(orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_sel_class)))
goto out;
batadv_dbg(DBG_BATMAN, bat_priv,
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Restarting gateway selection: better gateway found (tq curr: %i, tq new: %i)\n",
gw_tq_avg, orig_tq_avg);
......@@ -300,11 +306,11 @@ void batadv_gw_check_election(struct bat_priv *bat_priv,
return;
}
static void batadv_gw_node_add(struct bat_priv *bat_priv,
struct orig_node *orig_node,
static void batadv_gw_node_add(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
uint8_t new_gwflags)
{
struct gw_node *gw_node;
struct batadv_gw_node *gw_node;
int down, up;
gw_node = kzalloc(sizeof(*gw_node), GFP_ATOMIC);
......@@ -320,7 +326,7 @@ static void batadv_gw_node_add(struct bat_priv *bat_priv,
spin_unlock_bh(&bat_priv->gw_list_lock);
batadv_gw_bandwidth_to_kbit(new_gwflags, &down, &up);
batadv_dbg(DBG_BATMAN, bat_priv,
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Found new gateway %pM -> gw_class: %i - %i%s/%i%s\n",
orig_node->orig, new_gwflags,
(down > 2048 ? down / 1024 : down),
......@@ -329,11 +335,12 @@ static void batadv_gw_node_add(struct bat_priv *bat_priv,
(up > 2048 ? "MBit" : "KBit"));
}
void batadv_gw_node_update(struct bat_priv *bat_priv,
struct orig_node *orig_node, uint8_t new_gwflags)
void batadv_gw_node_update(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
uint8_t new_gwflags)
{
struct hlist_node *node;
struct gw_node *gw_node, *curr_gw;
struct batadv_gw_node *gw_node, *curr_gw;
/* Note: We don't need a NULL check here, since curr_gw never gets
* dereferenced. If curr_gw is NULL we also should not exit as we may
......@@ -347,7 +354,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv,
if (gw_node->orig_node != orig_node)
continue;
batadv_dbg(DBG_BATMAN, bat_priv,
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Gateway class of originator %pM changed from %i to %i\n",
orig_node->orig, gw_node->orig_node->gw_flags,
new_gwflags);
......@@ -356,7 +363,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv,
if (new_gwflags == BATADV_NO_FLAGS) {
gw_node->deleted = jiffies;
batadv_dbg(DBG_BATMAN, bat_priv,
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Gateway %pM removed from gateway list\n",
orig_node->orig);
......@@ -382,15 +389,15 @@ void batadv_gw_node_update(struct bat_priv *bat_priv,
batadv_gw_node_free_ref(curr_gw);
}
void batadv_gw_node_delete(struct bat_priv *bat_priv,
struct orig_node *orig_node)
void batadv_gw_node_delete(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node)
{
batadv_gw_node_update(bat_priv, orig_node, 0);
}
void batadv_gw_node_purge(struct bat_priv *bat_priv)
void batadv_gw_node_purge(struct batadv_priv *bat_priv)
{
struct gw_node *gw_node, *curr_gw;
struct batadv_gw_node *gw_node, *curr_gw;
struct hlist_node *node, *node_tmp;
unsigned long timeout = msecs_to_jiffies(2 * BATADV_PURGE_TIMEOUT);
int do_deselect = 0;
......@@ -403,7 +410,7 @@ void batadv_gw_node_purge(struct bat_priv *bat_priv)
&bat_priv->gw_list, list) {
if (((!gw_node->deleted) ||
(time_before(jiffies, gw_node->deleted + timeout))) &&
atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE)
atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE)
continue;
if (curr_gw == gw_node)
......@@ -424,12 +431,12 @@ void batadv_gw_node_purge(struct bat_priv *bat_priv)
}
/* fails if orig_node has no router */
static int batadv_write_buffer_text(struct bat_priv *bat_priv,
struct seq_file *seq,
const struct gw_node *gw_node)
static int batadv_write_buffer_text(struct batadv_priv *bat_priv,
struct seq_file *seq,
const struct batadv_gw_node *gw_node)
{
struct gw_node *curr_gw;
struct neigh_node *router;
struct batadv_gw_node *curr_gw;
struct batadv_neigh_node *router;
int down, up, ret = -1;
batadv_gw_bandwidth_to_kbit(gw_node->orig_node->gw_flags, &down, &up);
......@@ -461,9 +468,9 @@ static int batadv_write_buffer_text(struct bat_priv *bat_priv,
int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
{
struct net_device *net_dev = (struct net_device *)seq->private;
struct bat_priv *bat_priv = netdev_priv(net_dev);
struct hard_iface *primary_if;
struct gw_node *gw_node;
struct batadv_priv *bat_priv = netdev_priv(net_dev);
struct batadv_hard_iface *primary_if;
struct batadv_gw_node *gw_node;
struct hlist_node *node;
int gw_count = 0, ret = 0;
......@@ -475,7 +482,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
goto out;
}
if (primary_if->if_status != IF_ACTIVE) {
if (primary_if->if_status != BATADV_IF_ACTIVE) {
ret = seq_printf(seq,
"BATMAN mesh %s disabled - primary interface not active\n",
net_dev->name);
......@@ -636,12 +643,12 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
return true;
}
bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
struct sk_buff *skb, struct ethhdr *ethhdr)
{
struct neigh_node *neigh_curr = NULL, *neigh_old = NULL;
struct orig_node *orig_dst_node = NULL;
struct gw_node *curr_gw = NULL;
struct batadv_neigh_node *neigh_curr = NULL, *neigh_old = NULL;
struct batadv_orig_node *orig_dst_node = NULL;
struct batadv_gw_node *curr_gw = NULL;
bool ret, out_of_range = false;
unsigned int header_len = 0;
uint8_t curr_tq_avg;
......@@ -663,13 +670,13 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
goto out;
switch (atomic_read(&bat_priv->gw_mode)) {
case GW_MODE_SERVER:
case BATADV_GW_MODE_SERVER:
/* If we are a GW then we are our best GW. We can artificially
* set the tq towards ourself as the maximum value
*/
curr_tq_avg = BATADV_TQ_MAX_VALUE;
break;
case GW_MODE_CLIENT:
case BATADV_GW_MODE_CLIENT:
curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
if (!curr_gw)
goto out;
......@@ -689,7 +696,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
curr_tq_avg = neigh_curr->tq_avg;
break;
case GW_MODE_OFF:
case BATADV_GW_MODE_OFF:
default:
goto out;
}
......
......@@ -20,19 +20,21 @@
#ifndef _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
#define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
void batadv_gw_deselect(struct bat_priv *bat_priv);
void batadv_gw_election(struct bat_priv *bat_priv);
struct orig_node *batadv_gw_get_selected_orig(struct bat_priv *bat_priv);
void batadv_gw_check_election(struct bat_priv *bat_priv,
struct orig_node *orig_node);
void batadv_gw_node_update(struct bat_priv *bat_priv,
struct orig_node *orig_node, uint8_t new_gwflags);
void batadv_gw_node_delete(struct bat_priv *bat_priv,
struct orig_node *orig_node);
void batadv_gw_node_purge(struct bat_priv *bat_priv);
void batadv_gw_deselect(struct batadv_priv *bat_priv);
void batadv_gw_election(struct batadv_priv *bat_priv);
struct batadv_orig_node *
batadv_gw_get_selected_orig(struct batadv_priv *bat_priv);
void batadv_gw_check_election(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node);
void batadv_gw_node_update(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
uint8_t new_gwflags);
void batadv_gw_node_delete(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node);
void batadv_gw_node_purge(struct batadv_priv *bat_priv);
int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset);
bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len);
bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
struct sk_buff *skb, struct ethhdr *ethhdr);
#endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */
......@@ -137,7 +137,7 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
size_t count)
{
struct bat_priv *bat_priv = netdev_priv(net_dev);
struct batadv_priv *bat_priv = netdev_priv(net_dev);
long gw_bandwidth_tmp = 0;
int up = 0, down = 0;
bool ret;
......
......@@ -20,10 +20,10 @@
#ifndef _NET_BATMAN_ADV_GATEWAY_COMMON_H_
#define _NET_BATMAN_ADV_GATEWAY_COMMON_H_
enum gw_modes {
GW_MODE_OFF,
GW_MODE_CLIENT,
GW_MODE_SERVER,
enum batadv_gw_modes {
BATADV_GW_MODE_OFF,
BATADV_GW_MODE_CLIENT,
BATADV_GW_MODE_SERVER,
};
#define BATADV_GW_MODE_OFF_NAME "off"
......
......@@ -23,7 +23,7 @@
#include "send.h"
#include "translation-table.h"
#include "routing.h"
#include "bat_sysfs.h"
#include "sysfs.h"
#include "originator.h"
#include "hash.h"
#include "bridge_loop_avoidance.h"
......@@ -32,16 +32,17 @@
void batadv_hardif_free_rcu(struct rcu_head *rcu)
{
struct hard_iface *hard_iface;
struct batadv_hard_iface *hard_iface;
hard_iface = container_of(rcu, struct hard_iface, rcu);
hard_iface = container_of(rcu, struct batadv_hard_iface, rcu);
dev_put(hard_iface->net_dev);
kfree(hard_iface);
}
struct hard_iface *batadv_hardif_get_by_netdev(const struct net_device *net_dev)
struct batadv_hard_iface *
batadv_hardif_get_by_netdev(const struct net_device *net_dev)
{
struct hard_iface *hard_iface;
struct batadv_hard_iface *hard_iface;
rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
......@@ -75,17 +76,17 @@ static int batadv_is_valid_iface(const struct net_device *net_dev)
return 1;
}
static struct hard_iface *
static struct batadv_hard_iface *
batadv_hardif_get_active(const struct net_device *soft_iface)
{
struct hard_iface *hard_iface;
struct batadv_hard_iface *hard_iface;
rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
if (hard_iface->soft_iface != soft_iface)
continue;
if (hard_iface->if_status == IF_ACTIVE &&
if (hard_iface->if_status == BATADV_IF_ACTIVE &&
atomic_inc_not_zero(&hard_iface->refcount))
goto out;
}
......@@ -97,17 +98,17 @@ batadv_hardif_get_active(const struct net_device *soft_iface)
return hard_iface;
}
static void batadv_primary_if_update_addr(struct bat_priv *bat_priv,
struct hard_iface *oldif)
static void batadv_primary_if_update_addr(struct batadv_priv *bat_priv,
struct batadv_hard_iface *oldif)
{
struct vis_packet *vis_packet;
struct hard_iface *primary_if;
struct batadv_vis_packet *vis_packet;
struct batadv_hard_iface *primary_if;
primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if)
goto out;
vis_packet = (struct vis_packet *)
vis_packet = (struct batadv_vis_packet *)
bat_priv->my_vis_info->skb_packet->data;
memcpy(vis_packet->vis_orig, primary_if->net_dev->dev_addr, ETH_ALEN);
memcpy(vis_packet->sender_orig,
......@@ -119,10 +120,10 @@ static void batadv_primary_if_update_addr(struct bat_priv *bat_priv,
batadv_hardif_free_ref(primary_if);
}
static void batadv_primary_if_select(struct bat_priv *bat_priv,
struct hard_iface *new_hard_iface)
static void batadv_primary_if_select(struct batadv_priv *bat_priv,
struct batadv_hard_iface *new_hard_iface)
{
struct hard_iface *curr_hard_iface;
struct batadv_hard_iface *curr_hard_iface;
ASSERT_RTNL();
......@@ -143,7 +144,8 @@ static void batadv_primary_if_select(struct bat_priv *bat_priv,
batadv_hardif_free_ref(curr_hard_iface);
}
static bool batadv_hardif_is_iface_up(const struct hard_iface *hard_iface)
static bool
batadv_hardif_is_iface_up(const struct batadv_hard_iface *hard_iface)
{
if (hard_iface->net_dev->flags & IFF_UP)
return true;
......@@ -153,12 +155,12 @@ static bool batadv_hardif_is_iface_up(const struct hard_iface *hard_iface)
static void batadv_check_known_mac_addr(const struct net_device *net_dev)
{
const struct hard_iface *hard_iface;
const struct batadv_hard_iface *hard_iface;
rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
if ((hard_iface->if_status != IF_ACTIVE) &&
(hard_iface->if_status != IF_TO_BE_ACTIVATED))
if ((hard_iface->if_status != BATADV_IF_ACTIVE) &&
(hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED))
continue;
if (hard_iface->net_dev == net_dev)
......@@ -177,8 +179,8 @@ static void batadv_check_known_mac_addr(const struct net_device *net_dev)
int batadv_hardif_min_mtu(struct net_device *soft_iface)
{
const struct bat_priv *bat_priv = netdev_priv(soft_iface);
const struct hard_iface *hard_iface;
const struct batadv_priv *bat_priv = netdev_priv(soft_iface);
const struct batadv_hard_iface *hard_iface;
/* allow big frames if all devices are capable to do so
* (have MTU > 1500 + BAT_HEADER_LEN)
*/
......@@ -189,8 +191,8 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
if ((hard_iface->if_status != IF_ACTIVE) &&
(hard_iface->if_status != IF_TO_BE_ACTIVATED))
if ((hard_iface->if_status != BATADV_IF_ACTIVE) &&
(hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED))
continue;
if (hard_iface->soft_iface != soft_iface)
......@@ -215,18 +217,19 @@ void batadv_update_min_mtu(struct net_device *soft_iface)
soft_iface->mtu = min_mtu;
}
static void batadv_hardif_activate_interface(struct hard_iface *hard_iface)
static void
batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)
{
struct bat_priv *bat_priv;
struct hard_iface *primary_if = NULL;
struct batadv_priv *bat_priv;
struct batadv_hard_iface *primary_if = NULL;
if (hard_iface->if_status != IF_INACTIVE)
if (hard_iface->if_status != BATADV_IF_INACTIVE)
goto out;
bat_priv = netdev_priv(hard_iface->soft_iface);
bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface);
hard_iface->if_status = IF_TO_BE_ACTIVATED;
hard_iface->if_status = BATADV_IF_TO_BE_ACTIVATED;
/* the first active interface becomes our primary interface or
* the next active interface after the old primary interface was removed
......@@ -245,13 +248,14 @@ static void batadv_hardif_activate_interface(struct hard_iface *hard_iface)
batadv_hardif_free_ref(primary_if);
}
static void batadv_hardif_deactivate_interface(struct hard_iface *hard_iface)
static void
batadv_hardif_deactivate_interface(struct batadv_hard_iface *hard_iface)
{
if ((hard_iface->if_status != IF_ACTIVE) &&
(hard_iface->if_status != IF_TO_BE_ACTIVATED))
if ((hard_iface->if_status != BATADV_IF_ACTIVE) &&
(hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED))
return;
hard_iface->if_status = IF_INACTIVE;
hard_iface->if_status = BATADV_IF_INACTIVE;
batadv_info(hard_iface->soft_iface, "Interface deactivated: %s\n",
hard_iface->net_dev->name);
......@@ -259,15 +263,15 @@ static void batadv_hardif_deactivate_interface(struct hard_iface *hard_iface)
batadv_update_min_mtu(hard_iface->soft_iface);
}
int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
const char *iface_name)
{
struct bat_priv *bat_priv;
struct batadv_priv *bat_priv;
struct net_device *soft_iface;
__be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN);
int ret;
if (hard_iface->if_status != IF_NOT_IN_USE)
if (hard_iface->if_status != BATADV_IF_NOT_IN_USE)
goto out;
if (!atomic_inc_not_zero(&hard_iface->refcount))
......@@ -308,7 +312,7 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
hard_iface->if_num = bat_priv->num_ifaces;
bat_priv->num_ifaces++;
hard_iface->if_status = IF_INACTIVE;
hard_iface->if_status = BATADV_IF_INACTIVE;
batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces);
hard_iface->batman_adv_ptype.type = ethertype;
......@@ -320,15 +324,15 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
hard_iface->net_dev->name);
if (atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu <
ETH_DATA_LEN + BATADV_HEADER_LEN)
if (atomic_read(&bat_priv->fragmentation) &&
hard_iface->net_dev->mtu < ETH_DATA_LEN + BATADV_HEADER_LEN)
batadv_info(hard_iface->soft_iface,
"The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to %zi would solve the problem.\n",
hard_iface->net_dev->name, hard_iface->net_dev->mtu,
ETH_DATA_LEN + BATADV_HEADER_LEN);
if (!atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu <
ETH_DATA_LEN + BATADV_HEADER_LEN)
if (!atomic_read(&bat_priv->fragmentation) &&
hard_iface->net_dev->mtu < ETH_DATA_LEN + BATADV_HEADER_LEN)
batadv_info(hard_iface->soft_iface,
"The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. If you experience problems getting traffic through try increasing the MTU to %zi.\n",
hard_iface->net_dev->name, hard_iface->net_dev->mtu,
......@@ -354,15 +358,15 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
return ret;
}
void batadv_hardif_disable_interface(struct hard_iface *hard_iface)
void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface)
{
struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
struct hard_iface *primary_if = NULL;
struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
struct batadv_hard_iface *primary_if = NULL;
if (hard_iface->if_status == IF_ACTIVE)
if (hard_iface->if_status == BATADV_IF_ACTIVE)
batadv_hardif_deactivate_interface(hard_iface);
if (hard_iface->if_status != IF_INACTIVE)
if (hard_iface->if_status != BATADV_IF_INACTIVE)
goto out;
batadv_info(hard_iface->soft_iface, "Removing interface: %s\n",
......@@ -374,7 +378,7 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface)
primary_if = batadv_primary_if_get_selected(bat_priv);
if (hard_iface == primary_if) {
struct hard_iface *new_if;
struct batadv_hard_iface *new_if;
new_if = batadv_hardif_get_active(hard_iface->soft_iface);
batadv_primary_if_select(bat_priv, new_if);
......@@ -384,7 +388,7 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface)
}
bat_priv->bat_algo_ops->bat_iface_disable(hard_iface);
hard_iface->if_status = IF_NOT_IN_USE;
hard_iface->if_status = BATADV_IF_NOT_IN_USE;
/* delete all references to this hard_iface */
batadv_purge_orig_ref(bat_priv);
......@@ -403,10 +407,10 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface)
batadv_hardif_free_ref(primary_if);
}
static struct hard_iface *
static struct batadv_hard_iface *
batadv_hardif_add_interface(struct net_device *net_dev)
{
struct hard_iface *hard_iface;
struct batadv_hard_iface *hard_iface;
int ret;
ASSERT_RTNL();
......@@ -428,7 +432,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
hard_iface->if_num = -1;
hard_iface->net_dev = net_dev;
hard_iface->soft_iface = NULL;
hard_iface->if_status = IF_NOT_IN_USE;
hard_iface->if_status = BATADV_IF_NOT_IN_USE;
INIT_LIST_HEAD(&hard_iface->list);
/* extra reference for return */
atomic_set(&hard_iface->refcount, 2);
......@@ -452,25 +456,25 @@ batadv_hardif_add_interface(struct net_device *net_dev)
return NULL;
}
static void batadv_hardif_remove_interface(struct hard_iface *hard_iface)
static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface)
{
ASSERT_RTNL();
/* first deactivate interface */
if (hard_iface->if_status != IF_NOT_IN_USE)
if (hard_iface->if_status != BATADV_IF_NOT_IN_USE)
batadv_hardif_disable_interface(hard_iface);
if (hard_iface->if_status != IF_NOT_IN_USE)
if (hard_iface->if_status != BATADV_IF_NOT_IN_USE)
return;
hard_iface->if_status = IF_TO_BE_REMOVED;
hard_iface->if_status = BATADV_IF_TO_BE_REMOVED;
batadv_sysfs_del_hardif(&hard_iface->hardif_obj);
batadv_hardif_free_ref(hard_iface);
}
void batadv_hardif_remove_interfaces(void)
{
struct hard_iface *hard_iface, *hard_iface_tmp;
struct batadv_hard_iface *hard_iface, *hard_iface_tmp;
rtnl_lock();
list_for_each_entry_safe(hard_iface, hard_iface_tmp,
......@@ -485,10 +489,11 @@ static int batadv_hard_if_event(struct notifier_block *this,
unsigned long event, void *ptr)
{
struct net_device *net_dev = ptr;
struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
struct hard_iface *primary_if = NULL;
struct bat_priv *bat_priv;
struct batadv_hard_iface *hard_iface;
struct batadv_hard_iface *primary_if = NULL;
struct batadv_priv *bat_priv;
hard_iface = batadv_hardif_get_by_netdev(net_dev);
if (!hard_iface && event == NETDEV_REGISTER)
hard_iface = batadv_hardif_add_interface(net_dev);
......@@ -513,7 +518,7 @@ static int batadv_hard_if_event(struct notifier_block *this,
batadv_update_min_mtu(hard_iface->soft_iface);
break;
case NETDEV_CHANGEADDR:
if (hard_iface->if_status == IF_NOT_IN_USE)
if (hard_iface->if_status == BATADV_IF_NOT_IN_USE)
goto hardif_put;
batadv_check_known_mac_addr(hard_iface->net_dev);
......
......@@ -20,22 +20,22 @@
#ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_
#define _NET_BATMAN_ADV_HARD_INTERFACE_H_
enum hard_if_state {
IF_NOT_IN_USE,
IF_TO_BE_REMOVED,
IF_INACTIVE,
IF_ACTIVE,
IF_TO_BE_ACTIVATED,
IF_I_WANT_YOU
enum batadv_hard_if_state {
BATADV_IF_NOT_IN_USE,
BATADV_IF_TO_BE_REMOVED,
BATADV_IF_INACTIVE,
BATADV_IF_ACTIVE,
BATADV_IF_TO_BE_ACTIVATED,
BATADV_IF_I_WANT_YOU,
};
extern struct notifier_block batadv_hard_if_notifier;
struct hard_iface*
struct batadv_hard_iface*
batadv_hardif_get_by_netdev(const struct net_device *net_dev);
int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
const char *iface_name);
void batadv_hardif_disable_interface(struct hard_iface *hard_iface);
void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface);
void batadv_hardif_remove_interfaces(void);
int batadv_hardif_min_mtu(struct net_device *soft_iface);
void batadv_update_min_mtu(struct net_device *soft_iface);
......@@ -43,16 +43,16 @@ void batadv_hardif_free_rcu(struct rcu_head *rcu);
bool batadv_is_wifi_iface(int ifindex);
static inline void
batadv_hardif_free_ref(struct hard_iface *hard_iface)
batadv_hardif_free_ref(struct batadv_hard_iface *hard_iface)
{
if (atomic_dec_and_test(&hard_iface->refcount))
call_rcu(&hard_iface->rcu, batadv_hardif_free_rcu);
}
static inline struct hard_iface *
batadv_primary_if_get_selected(struct bat_priv *bat_priv)
static inline struct batadv_hard_iface *
batadv_primary_if_get_selected(struct batadv_priv *bat_priv)
{
struct hard_iface *hard_iface;
struct batadv_hard_iface *hard_iface;
rcu_read_lock();
hard_iface = rcu_dereference(bat_priv->primary_if);
......
......@@ -21,18 +21,18 @@
#include "hash.h"
/* clears the hash */
static void batadv_hash_init(struct hashtable_t *hash)
static void batadv_hash_init(struct batadv_hashtable *hash)
{
uint32_t i;
for (i = 0 ; i < hash->size; i++) {
for (i = 0; i < hash->size; i++) {
INIT_HLIST_HEAD(&hash->table[i]);
spin_lock_init(&hash->list_locks[i]);
}
}
/* free only the hashtable and the hash itself. */
void batadv_hash_destroy(struct hashtable_t *hash)
void batadv_hash_destroy(struct batadv_hashtable *hash)
{
kfree(hash->list_locks);
kfree(hash->table);
......@@ -40,9 +40,9 @@ void batadv_hash_destroy(struct hashtable_t *hash)
}
/* allocates and clears the hash */
struct hashtable_t *batadv_hash_new(uint32_t size)
struct batadv_hashtable *batadv_hash_new(uint32_t size)
{
struct hashtable_t *hash;
struct batadv_hashtable *hash;
hash = kmalloc(sizeof(*hash), GFP_ATOMIC);
if (!hash)
......@@ -68,7 +68,7 @@ struct hashtable_t *batadv_hash_new(uint32_t size)
return NULL;
}
void batadv_hash_set_lock_class(struct hashtable_t *hash,
void batadv_hash_set_lock_class(struct batadv_hashtable *hash,
struct lock_class_key *key)
{
uint32_t i;
......
......@@ -25,37 +25,39 @@
/* callback to a compare function. should compare 2 element datas for their
* keys, return 0 if same and not 0 if not same
*/
typedef int (*hashdata_compare_cb)(const struct hlist_node *, const void *);
typedef int (*batadv_hashdata_compare_cb)(const struct hlist_node *,
const void *);
/* the hashfunction, should return an index
* based on the key in the data of the first
* argument and the size the second
*/
typedef uint32_t (*hashdata_choose_cb)(const void *, uint32_t);
typedef void (*hashdata_free_cb)(struct hlist_node *, void *);
typedef uint32_t (*batadv_hashdata_choose_cb)(const void *, uint32_t);
typedef void (*batadv_hashdata_free_cb)(struct hlist_node *, void *);
struct hashtable_t {
struct batadv_hashtable {
struct hlist_head *table; /* the hashtable itself with the buckets */
spinlock_t *list_locks; /* spinlock for each hash list entry */
uint32_t size; /* size of hashtable */
};
/* allocates and clears the hash */
struct hashtable_t *batadv_hash_new(uint32_t size);
struct batadv_hashtable *batadv_hash_new(uint32_t size);
/* set class key for all locks */
void batadv_hash_set_lock_class(struct hashtable_t *hash,
void batadv_hash_set_lock_class(struct batadv_hashtable *hash,
struct lock_class_key *key);
/* free only the hashtable and the hash itself. */
void batadv_hash_destroy(struct hashtable_t *hash);
void batadv_hash_destroy(struct batadv_hashtable *hash);
/* remove the hash structure. if hashdata_free_cb != NULL, this function will be
* called to remove the elements inside of the hash. if you don't remove the
* elements, memory might be leaked.
*/
static inline void batadv_hash_delete(struct hashtable_t *hash,
hashdata_free_cb free_cb, void *arg)
static inline void batadv_hash_delete(struct batadv_hashtable *hash,
batadv_hashdata_free_cb free_cb,
void *arg)
{
struct hlist_head *head;
struct hlist_node *node, *node_tmp;
......@@ -89,9 +91,9 @@ static inline void batadv_hash_delete(struct hashtable_t *hash,
* Returns 0 on success, 1 if the element already is in the hash
* and -1 on error.
*/
static inline int batadv_hash_add(struct hashtable_t *hash,
hashdata_compare_cb compare,
hashdata_choose_cb choose,
static inline int batadv_hash_add(struct batadv_hashtable *hash,
batadv_hashdata_compare_cb compare,
batadv_hashdata_choose_cb choose,
const void *data,
struct hlist_node *data_node)
{
......@@ -134,9 +136,10 @@ static inline int batadv_hash_add(struct hashtable_t *hash,
* structure you use with just the key filled, we just need the key for
* comparing.
*/
static inline void *batadv_hash_remove(struct hashtable_t *hash,
hashdata_compare_cb compare,
hashdata_choose_cb choose, void *data)
static inline void *batadv_hash_remove(struct batadv_hashtable *hash,
batadv_hashdata_compare_cb compare,
batadv_hashdata_choose_cb choose,
void *data)
{
uint32_t index;
struct hlist_node *node;
......
......@@ -26,10 +26,10 @@
#include "originator.h"
#include "hard-interface.h"
static struct socket_client *batadv_socket_client_hash[256];
static struct batadv_socket_client *batadv_socket_client_hash[256];
static void batadv_socket_add_packet(struct socket_client *socket_client,
struct icmp_packet_rr *icmp_packet,
static void batadv_socket_add_packet(struct batadv_socket_client *socket_client,
struct batadv_icmp_packet_rr *icmp_packet,
size_t icmp_len);
void batadv_socket_init(void)
......@@ -40,7 +40,7 @@ void batadv_socket_init(void)
static int batadv_socket_open(struct inode *inode, struct file *file)
{
unsigned int i;
struct socket_client *socket_client;
struct batadv_socket_client *socket_client;
nonseekable_open(inode, file);
......@@ -77,8 +77,8 @@ static int batadv_socket_open(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_packet *socket_packet;
struct batadv_socket_client *socket_client = file->private_data;
struct batadv_socket_packet *socket_packet;
struct list_head *list_pos, *list_pos_tmp;
spin_lock_bh(&socket_client->lock);
......@@ -86,7 +86,7 @@ static int batadv_socket_release(struct inode *inode, struct file *file)
/* for all packets in the queue ... */
list_for_each_safe(list_pos, list_pos_tmp, &socket_client->queue_list) {
socket_packet = list_entry(list_pos,
struct socket_packet, list);
struct batadv_socket_packet, list);
list_del(list_pos);
kfree(socket_packet);
......@@ -104,15 +104,15 @@ static int batadv_socket_release(struct inode *inode, struct file *file)
static ssize_t batadv_socket_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
struct socket_client *socket_client = file->private_data;
struct socket_packet *socket_packet;
struct batadv_socket_client *socket_client = file->private_data;
struct batadv_socket_packet *socket_packet;
size_t packet_len;
int error;
if ((file->f_flags & O_NONBLOCK) && (socket_client->queue_len == 0))
return -EAGAIN;
if ((!buf) || (count < sizeof(struct icmp_packet)))
if ((!buf) || (count < sizeof(struct batadv_icmp_packet)))
return -EINVAL;
if (!access_ok(VERIFY_WRITE, buf, count))
......@@ -127,7 +127,7 @@ static ssize_t batadv_socket_read(struct file *file, char __user *buf,
spin_lock_bh(&socket_client->lock);
socket_packet = list_first_entry(&socket_client->queue_list,
struct socket_packet, list);
struct batadv_socket_packet, list);
list_del(&socket_packet->list);
socket_client->queue_len--;
......@@ -147,18 +147,18 @@ static ssize_t batadv_socket_read(struct file *file, char __user *buf,
static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
size_t len, loff_t *off)
{
struct socket_client *socket_client = file->private_data;
struct bat_priv *bat_priv = socket_client->bat_priv;
struct hard_iface *primary_if = NULL;
struct batadv_socket_client *socket_client = file->private_data;
struct batadv_priv *bat_priv = socket_client->bat_priv;
struct batadv_hard_iface *primary_if = NULL;
struct sk_buff *skb;
struct icmp_packet_rr *icmp_packet;
struct batadv_icmp_packet_rr *icmp_packet;
struct orig_node *orig_node = NULL;
struct neigh_node *neigh_node = NULL;
size_t packet_len = sizeof(struct icmp_packet);
struct batadv_orig_node *orig_node = NULL;
struct batadv_neigh_node *neigh_node = NULL;
size_t packet_len = sizeof(struct batadv_icmp_packet);
if (len < sizeof(struct icmp_packet)) {
batadv_dbg(DBG_BATMAN, bat_priv,
if (len < sizeof(struct batadv_icmp_packet)) {
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Error - can't send packet from char device: invalid packet size\n");
return -EINVAL;
}
......@@ -170,8 +170,8 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
goto out;
}
if (len >= sizeof(struct icmp_packet_rr))
packet_len = sizeof(struct icmp_packet_rr);
if (len >= sizeof(struct batadv_icmp_packet_rr))
packet_len = sizeof(struct batadv_icmp_packet_rr);
skb = dev_alloc_skb(packet_len + ETH_HLEN);
if (!skb) {
......@@ -180,22 +180,22 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
}
skb_reserve(skb, ETH_HLEN);
icmp_packet = (struct icmp_packet_rr *)skb_put(skb, packet_len);
icmp_packet = (struct batadv_icmp_packet_rr *)skb_put(skb, packet_len);
if (copy_from_user(icmp_packet, buff, packet_len)) {
len = -EFAULT;
goto free_skb;
}
if (icmp_packet->header.packet_type != BAT_ICMP) {
batadv_dbg(DBG_BATMAN, bat_priv,
if (icmp_packet->header.packet_type != BATADV_ICMP) {
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n");
len = -EINVAL;
goto free_skb;
}
if (icmp_packet->msg_type != ECHO_REQUEST) {
batadv_dbg(DBG_BATMAN, bat_priv,
if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) {
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n");
len = -EINVAL;
goto free_skb;
......@@ -204,14 +204,14 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
icmp_packet->uid = socket_client->index;
if (icmp_packet->header.version != BATADV_COMPAT_VERSION) {
icmp_packet->msg_type = PARAMETER_PROBLEM;
icmp_packet->msg_type = BATADV_PARAMETER_PROBLEM;
icmp_packet->header.version = BATADV_COMPAT_VERSION;
batadv_socket_add_packet(socket_client, icmp_packet,
packet_len);
goto free_skb;
}
if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE)
if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
goto dst_unreach;
orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->dst);
......@@ -225,13 +225,13 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
if (!neigh_node->if_incoming)
goto dst_unreach;
if (neigh_node->if_incoming->if_status != IF_ACTIVE)
if (neigh_node->if_incoming->if_status != BATADV_IF_ACTIVE)
goto dst_unreach;
memcpy(icmp_packet->orig,
primary_if->net_dev->dev_addr, ETH_ALEN);
if (packet_len == sizeof(struct icmp_packet_rr))
if (packet_len == sizeof(struct batadv_icmp_packet_rr))
memcpy(icmp_packet->rr,
neigh_node->if_incoming->net_dev->dev_addr, ETH_ALEN);
......@@ -239,7 +239,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
goto out;
dst_unreach:
icmp_packet->msg_type = DESTINATION_UNREACHABLE;
icmp_packet->msg_type = BATADV_DESTINATION_UNREACHABLE;
batadv_socket_add_packet(socket_client, icmp_packet, packet_len);
free_skb:
kfree_skb(skb);
......@@ -255,7 +255,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
static unsigned int batadv_socket_poll(struct file *file, poll_table *wait)
{
struct socket_client *socket_client = file->private_data;
struct batadv_socket_client *socket_client = file->private_data;
poll_wait(file, &socket_client->queue_wait, wait);
......@@ -275,7 +275,7 @@ static const struct file_operations batadv_fops = {
.llseek = no_llseek,
};
int batadv_socket_setup(struct bat_priv *bat_priv)
int batadv_socket_setup(struct batadv_priv *bat_priv)
{
struct dentry *d;
......@@ -293,11 +293,11 @@ int batadv_socket_setup(struct bat_priv *bat_priv)
return -ENOMEM;
}
static void batadv_socket_add_packet(struct socket_client *socket_client,
struct icmp_packet_rr *icmp_packet,
static void batadv_socket_add_packet(struct batadv_socket_client *socket_client,
struct batadv_icmp_packet_rr *icmp_packet,
size_t icmp_len)
{
struct socket_packet *socket_packet;
struct batadv_socket_packet *socket_packet;
socket_packet = kmalloc(sizeof(*socket_packet), GFP_ATOMIC);
......@@ -324,7 +324,8 @@ static void batadv_socket_add_packet(struct socket_client *socket_client,
if (socket_client->queue_len > 100) {
socket_packet = list_first_entry(&socket_client->queue_list,
struct socket_packet, list);
struct batadv_socket_packet,
list);
list_del(&socket_packet->list);
kfree(socket_packet);
......@@ -336,10 +337,10 @@ static void batadv_socket_add_packet(struct socket_client *socket_client,
wake_up(&socket_client->queue_wait);
}
void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet,
void batadv_socket_receive_packet(struct batadv_icmp_packet_rr *icmp_packet,
size_t icmp_len)
{
struct socket_client *hash;
struct batadv_socket_client *hash;
hash = batadv_socket_client_hash[icmp_packet->uid];
if (hash)
......
......@@ -23,8 +23,8 @@
#define BATADV_ICMP_SOCKET "socket"
void batadv_socket_init(void);
int batadv_socket_setup(struct bat_priv *bat_priv);
void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet,
int batadv_socket_setup(struct batadv_priv *bat_priv);
void batadv_socket_receive_packet(struct batadv_icmp_packet_rr *icmp_packet,
size_t icmp_len);
#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */
......@@ -18,8 +18,8 @@
*/
#include "main.h"
#include "bat_sysfs.h"
#include "bat_debugfs.h"
#include "sysfs.h"
#include "debugfs.h"
#include "routing.h"
#include "send.h"
#include "originator.h"
......@@ -39,7 +39,7 @@
*/
struct list_head batadv_hardif_list;
static int (*batadv_rx_handler[256])(struct sk_buff *,
struct hard_iface *);
struct batadv_hard_iface *);
char batadv_routing_algo[20] = "BATMAN_IV";
static struct hlist_head batadv_algo_list;
......@@ -92,7 +92,7 @@ static void __exit batadv_exit(void)
int batadv_mesh_init(struct net_device *soft_iface)
{
struct bat_priv *bat_priv = netdev_priv(soft_iface);
struct batadv_priv *bat_priv = netdev_priv(soft_iface);
int ret;
spin_lock_init(&bat_priv->forw_bat_list_lock);
......@@ -132,7 +132,7 @@ int batadv_mesh_init(struct net_device *soft_iface)
goto err;
atomic_set(&bat_priv->gw_reselect, 0);
atomic_set(&bat_priv->mesh_state, MESH_ACTIVE);
atomic_set(&bat_priv->mesh_state, BATADV_MESH_ACTIVE);
return 0;
......@@ -143,9 +143,9 @@ int batadv_mesh_init(struct net_device *soft_iface)
void batadv_mesh_free(struct net_device *soft_iface)
{
struct bat_priv *bat_priv = netdev_priv(soft_iface);
struct batadv_priv *bat_priv = netdev_priv(soft_iface);
atomic_set(&bat_priv->mesh_state, MESH_DEACTIVATING);
atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
batadv_purge_outstanding_packets(bat_priv, NULL);
......@@ -160,7 +160,7 @@ void batadv_mesh_free(struct net_device *soft_iface)
free_percpu(bat_priv->bat_counters);
atomic_set(&bat_priv->mesh_state, MESH_INACTIVE);
atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
}
void batadv_inc_module_count(void)
......@@ -175,11 +175,11 @@ void batadv_dec_module_count(void)
int batadv_is_my_mac(const uint8_t *addr)
{
const struct hard_iface *hard_iface;
const struct batadv_hard_iface *hard_iface;
rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
if (hard_iface->if_status != IF_ACTIVE)
if (hard_iface->if_status != BATADV_IF_ACTIVE)
continue;
if (batadv_compare_eth(hard_iface->net_dev->dev_addr, addr)) {
......@@ -192,7 +192,7 @@ int batadv_is_my_mac(const uint8_t *addr)
}
static int batadv_recv_unhandled_packet(struct sk_buff *skb,
struct hard_iface *recv_if)
struct batadv_hard_iface *recv_if)
{
return NET_RX_DROP;
}
......@@ -204,13 +204,14 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype,
struct net_device *orig_dev)
{
struct bat_priv *bat_priv;
struct batman_ogm_packet *batman_ogm_packet;
struct hard_iface *hard_iface;
struct batadv_priv *bat_priv;
struct batadv_ogm_packet *batadv_ogm_packet;
struct batadv_hard_iface *hard_iface;
uint8_t idx;
int ret;
hard_iface = container_of(ptype, struct hard_iface, batman_adv_ptype);
hard_iface = container_of(ptype, struct batadv_hard_iface,
batman_adv_ptype);
skb = skb_share_check(skb, GFP_ATOMIC);
/* skb was released by skb_share_check() */
......@@ -230,26 +231,26 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
bat_priv = netdev_priv(hard_iface->soft_iface);
if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE)
if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
goto err_free;
/* discard frames on not active interfaces */
if (hard_iface->if_status != IF_ACTIVE)
if (hard_iface->if_status != BATADV_IF_ACTIVE)
goto err_free;
batman_ogm_packet = (struct batman_ogm_packet *)skb->data;
batadv_ogm_packet = (struct batadv_ogm_packet *)skb->data;
if (batman_ogm_packet->header.version != BATADV_COMPAT_VERSION) {
batadv_dbg(DBG_BATMAN, bat_priv,
if (batadv_ogm_packet->header.version != BATADV_COMPAT_VERSION) {
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Drop packet: incompatible batman version (%i)\n",
batman_ogm_packet->header.version);
batadv_ogm_packet->header.version);
goto err_free;
}
/* all receive handlers return whether they received or reused
* the supplied skb. if not, we have to free the skb.
*/
idx = batman_ogm_packet->header.packet_type;
idx = batadv_ogm_packet->header.packet_type;
ret = (*batadv_rx_handler[idx])(skb, hard_iface);
if (ret == NET_RX_DROP)
......@@ -275,24 +276,25 @@ static void batadv_recv_handler_init(void)
batadv_rx_handler[i] = batadv_recv_unhandled_packet;
/* batman icmp packet */
batadv_rx_handler[BAT_ICMP] = batadv_recv_icmp_packet;
batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet;
/* unicast packet */
batadv_rx_handler[BAT_UNICAST] = batadv_recv_unicast_packet;
batadv_rx_handler[BATADV_UNICAST] = batadv_recv_unicast_packet;
/* fragmented unicast packet */
batadv_rx_handler[BAT_UNICAST_FRAG] = batadv_recv_ucast_frag_packet;
batadv_rx_handler[BATADV_UNICAST_FRAG] = batadv_recv_ucast_frag_packet;
/* broadcast packet */
batadv_rx_handler[BAT_BCAST] = batadv_recv_bcast_packet;
batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;
/* vis packet */
batadv_rx_handler[BAT_VIS] = batadv_recv_vis_packet;
batadv_rx_handler[BATADV_VIS] = batadv_recv_vis_packet;
/* Translation table query (request or response) */
batadv_rx_handler[BAT_TT_QUERY] = batadv_recv_tt_query;
batadv_rx_handler[BATADV_TT_QUERY] = batadv_recv_tt_query;
/* Roaming advertisement */
batadv_rx_handler[BAT_ROAM_ADV] = batadv_recv_roam_adv;
batadv_rx_handler[BATADV_ROAM_ADV] = batadv_recv_roam_adv;
}
int batadv_recv_handler_register(uint8_t packet_type,
int (*recv_handler)(struct sk_buff *,
struct hard_iface *))
int
batadv_recv_handler_register(uint8_t packet_type,
int (*recv_handler)(struct sk_buff *,
struct batadv_hard_iface *))
{
if (batadv_rx_handler[packet_type] != &batadv_recv_unhandled_packet)
return -EBUSY;
......@@ -306,9 +308,9 @@ void batadv_recv_handler_unregister(uint8_t packet_type)
batadv_rx_handler[packet_type] = batadv_recv_unhandled_packet;
}
static struct bat_algo_ops *batadv_algo_get(char *name)
static struct batadv_algo_ops *batadv_algo_get(char *name)
{
struct bat_algo_ops *bat_algo_ops = NULL, *bat_algo_ops_tmp;
struct batadv_algo_ops *bat_algo_ops = NULL, *bat_algo_ops_tmp;
struct hlist_node *node;
hlist_for_each_entry(bat_algo_ops_tmp, node, &batadv_algo_list, list) {
......@@ -322,9 +324,9 @@ static struct bat_algo_ops *batadv_algo_get(char *name)
return bat_algo_ops;
}
int batadv_algo_register(struct bat_algo_ops *bat_algo_ops)
int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops)
{
struct bat_algo_ops *bat_algo_ops_tmp;
struct batadv_algo_ops *bat_algo_ops_tmp;
int ret;
bat_algo_ops_tmp = batadv_algo_get(bat_algo_ops->name);
......@@ -356,9 +358,9 @@ int batadv_algo_register(struct bat_algo_ops *bat_algo_ops)
return ret;
}
int batadv_algo_select(struct bat_priv *bat_priv, char *name)
int batadv_algo_select(struct batadv_priv *bat_priv, char *name)
{
struct bat_algo_ops *bat_algo_ops;
struct batadv_algo_ops *bat_algo_ops;
int ret = -EINVAL;
bat_algo_ops = batadv_algo_get(name);
......@@ -374,7 +376,7 @@ int batadv_algo_select(struct bat_priv *bat_priv, char *name)
int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
{
struct bat_algo_ops *bat_algo_ops;
struct batadv_algo_ops *bat_algo_ops;
struct hlist_node *node;
seq_printf(seq, "Available routing algorithms:\n");
......@@ -388,7 +390,7 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
static int batadv_param_set_ra(const char *val, const struct kernel_param *kp)
{
struct bat_algo_ops *bat_algo_ops;
struct batadv_algo_ops *bat_algo_ops;
char *algo_name = (char *)val;
size_t name_len = strlen(algo_name);
......
......@@ -95,23 +95,23 @@
#define BATADV_RESET_PROTECTION_MS 30000
#define BATADV_EXPECTED_SEQNO_RANGE 65536
enum mesh_state {
MESH_INACTIVE,
MESH_ACTIVE,
MESH_DEACTIVATING
enum batadv_mesh_state {
BATADV_MESH_INACTIVE,
BATADV_MESH_ACTIVE,
BATADV_MESH_DEACTIVATING,
};
#define BATADV_BCAST_QUEUE_LEN 256
#define BATADV_BATMAN_QUEUE_LEN 256
enum uev_action {
UEV_ADD = 0,
UEV_DEL,
UEV_CHANGE
enum batadv_uev_action {
BATADV_UEV_ADD = 0,
BATADV_UEV_DEL,
BATADV_UEV_CHANGE,
};
enum uev_type {
UEV_GW = 0
enum batadv_uev_type {
BATADV_UEV_GW = 0,
};
#define BATADV_GW_THRESHOLD 50
......@@ -124,12 +124,12 @@ enum uev_type {
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
/* all messages related to routing / flooding / broadcasting / etc */
enum dbg_level {
DBG_BATMAN = 1 << 0,
DBG_ROUTES = 1 << 1, /* route added / changed / deleted */
DBG_TT = 1 << 2, /* translation table operations */
DBG_BLA = 1 << 3, /* bridge loop avoidance */
DBG_ALL = 15
enum batadv_dbg_level {
BATADV_DBG_BATMAN = 1 << 0,
BATADV_DBG_ROUTES = 1 << 1, /* route added / changed / deleted */
BATADV_DBG_TT = 1 << 2, /* translation table operations */
BATADV_DBG_BLA = 1 << 3, /* bridge loop avoidance */
BATADV_DBG_ALL = 15,
};
/* Kernel headers */
......@@ -164,16 +164,17 @@ int batadv_is_my_mac(const uint8_t *addr);
int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype,
struct net_device *orig_dev);
int batadv_recv_handler_register(uint8_t packet_type,
int (*recv_handler)(struct sk_buff *,
struct hard_iface *));
int
batadv_recv_handler_register(uint8_t packet_type,
int (*recv_handler)(struct sk_buff *,
struct batadv_hard_iface *));
void batadv_recv_handler_unregister(uint8_t packet_type);
int batadv_algo_register(struct bat_algo_ops *bat_algo_ops);
int batadv_algo_select(struct bat_priv *bat_priv, char *name);
int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops);
int batadv_algo_select(struct batadv_priv *bat_priv, char *name);
int batadv_algo_seq_print_text(struct seq_file *seq, void *offset);
#ifdef CONFIG_BATMAN_ADV_DEBUG
int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...)
int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
__printf(2, 3);
#define batadv_dbg(type, bat_priv, fmt, arg...) \
......@@ -185,7 +186,7 @@ __printf(2, 3);
#else /* !CONFIG_BATMAN_ADV_DEBUG */
__printf(3, 4)
static inline void batadv_dbg(int type __always_unused,
struct bat_priv *bat_priv __always_unused,
struct batadv_priv *bat_priv __always_unused,
const char *fmt __always_unused, ...)
{
}
......@@ -194,15 +195,15 @@ static inline void batadv_dbg(int type __always_unused,
#define batadv_info(net_dev, fmt, arg...) \
do { \
struct net_device *_netdev = (net_dev); \
struct bat_priv *_batpriv = netdev_priv(_netdev); \
batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
struct batadv_priv *_batpriv = netdev_priv(_netdev); \
batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg); \
pr_info("%s: " fmt, _netdev->name, ## arg); \
} while (0)
#define batadv_err(net_dev, fmt, arg...) \
do { \
struct net_device *_netdev = (net_dev); \
struct bat_priv *_batpriv = netdev_priv(_netdev); \
batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
struct batadv_priv *_batpriv = netdev_priv(_netdev); \
batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg); \
pr_err("%s: " fmt, _netdev->name, ## arg); \
} while (0)
......@@ -250,7 +251,7 @@ static inline bool batadv_has_timed_out(unsigned long timestamp,
#define batadv_seq_after(x, y) batadv_seq_before(y, x)
/* Stop preemption on local cpu while incrementing the counter */
static inline void batadv_add_counter(struct bat_priv *bat_priv, size_t idx,
static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx,
size_t count)
{
int cpu = get_cpu();
......@@ -261,11 +262,11 @@ static inline void batadv_add_counter(struct bat_priv *bat_priv, size_t idx,
#define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1)
/* Sum and return the cpu-local counters for index 'idx' */
static inline uint64_t batadv_sum_counter(struct bat_priv *bat_priv, size_t idx)
static inline uint64_t batadv_sum_counter(struct batadv_priv *bat_priv,
size_t idx)
{
uint64_t *counters;
uint64_t *counters, sum = 0;
int cpu;
int sum = 0;
for_each_possible_cpu(cpu) {
counters = per_cpu_ptr(bat_priv->bat_counters, cpu);
......
......@@ -30,7 +30,7 @@
static void batadv_purge_orig(struct work_struct *work);
static void batadv_start_purge_timer(struct bat_priv *bat_priv)
static void batadv_start_purge_timer(struct batadv_priv *bat_priv)
{
INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig);
queue_delayed_work(batadv_event_workqueue,
......@@ -40,12 +40,13 @@ static void batadv_start_purge_timer(struct bat_priv *bat_priv)
/* returns 1 if they are the same originator */
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 batadv_orig_node,
hash_entry);
return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
}
int batadv_originator_init(struct bat_priv *bat_priv)
int batadv_originator_init(struct batadv_priv *bat_priv)
{
if (bat_priv->orig_hash)
return 0;
......@@ -62,16 +63,17 @@ int batadv_originator_init(struct bat_priv *bat_priv)
return -ENOMEM;
}
void batadv_neigh_node_free_ref(struct neigh_node *neigh_node)
void batadv_neigh_node_free_ref(struct batadv_neigh_node *neigh_node)
{
if (atomic_dec_and_test(&neigh_node->refcount))
kfree_rcu(neigh_node, rcu);
}
/* increases the refcounter of a found router */
struct neigh_node *batadv_orig_node_get_router(struct orig_node *orig_node)
struct batadv_neigh_node *
batadv_orig_node_get_router(struct batadv_orig_node *orig_node)
{
struct neigh_node *router;
struct batadv_neigh_node *router;
rcu_read_lock();
router = rcu_dereference(orig_node->router);
......@@ -83,12 +85,12 @@ struct neigh_node *batadv_orig_node_get_router(struct orig_node *orig_node)
return router;
}
struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface,
const uint8_t *neigh_addr,
uint32_t seqno)
struct batadv_neigh_node *
batadv_neigh_node_new(struct batadv_hard_iface *hard_iface,
const uint8_t *neigh_addr, uint32_t seqno)
{
struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
struct neigh_node *neigh_node;
struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
struct batadv_neigh_node *neigh_node;
neigh_node = kzalloc(sizeof(*neigh_node), GFP_ATOMIC);
if (!neigh_node)
......@@ -102,7 +104,7 @@ struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface,
/* extra reference for return */
atomic_set(&neigh_node->refcount, 2);
batadv_dbg(DBG_BATMAN, bat_priv,
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Creating new neighbor %pM, initial seqno %d\n",
neigh_addr, seqno);
......@@ -113,10 +115,10 @@ struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface,
static void batadv_orig_node_free_rcu(struct rcu_head *rcu)
{
struct hlist_node *node, *node_tmp;
struct neigh_node *neigh_node, *tmp_neigh_node;
struct orig_node *orig_node;
struct batadv_neigh_node *neigh_node, *tmp_neigh_node;
struct batadv_orig_node *orig_node;
orig_node = container_of(rcu, struct orig_node, rcu);
orig_node = container_of(rcu, struct batadv_orig_node, rcu);
spin_lock_bh(&orig_node->neigh_list_lock);
......@@ -146,19 +148,19 @@ static void batadv_orig_node_free_rcu(struct rcu_head *rcu)
kfree(orig_node);
}
void batadv_orig_node_free_ref(struct orig_node *orig_node)
void batadv_orig_node_free_ref(struct batadv_orig_node *orig_node)
{
if (atomic_dec_and_test(&orig_node->refcount))
call_rcu(&orig_node->rcu, batadv_orig_node_free_rcu);
}
void batadv_originator_free(struct bat_priv *bat_priv)
void batadv_originator_free(struct batadv_priv *bat_priv)
{
struct hashtable_t *hash = bat_priv->orig_hash;
struct batadv_hashtable *hash = bat_priv->orig_hash;
struct hlist_node *node, *node_tmp;
struct hlist_head *head;
spinlock_t *list_lock; /* spinlock to protect write access */
struct orig_node *orig_node;
struct batadv_orig_node *orig_node;
uint32_t i;
if (!hash)
......@@ -188,10 +190,10 @@ void batadv_originator_free(struct bat_priv *bat_priv)
/* this function finds or creates an originator entry for the given
* address if it does not exits
*/
struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
const uint8_t *addr)
struct batadv_orig_node *batadv_get_orig_node(struct batadv_priv *bat_priv,
const uint8_t *addr)
{
struct orig_node *orig_node;
struct batadv_orig_node *orig_node;
int size;
int hash_added;
unsigned long reset_time;
......@@ -200,8 +202,8 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
if (orig_node)
return orig_node;
batadv_dbg(DBG_BATMAN, bat_priv, "Creating new originator: %pM\n",
addr);
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Creating new originator: %pM\n", addr);
orig_node = kzalloc(sizeof(*orig_node), GFP_ATOMIC);
if (!orig_node)
......@@ -264,15 +266,16 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
return NULL;
}
static bool batadv_purge_orig_neighbors(struct bat_priv *bat_priv,
struct orig_node *orig_node,
struct neigh_node **best_neigh_node)
static bool
batadv_purge_orig_neighbors(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
struct batadv_neigh_node **best_neigh_node)
{
struct hlist_node *node, *node_tmp;
struct neigh_node *neigh_node;
struct batadv_neigh_node *neigh_node;
bool neigh_purged = false;
unsigned long last_seen;
struct hard_iface *if_incoming;
struct batadv_hard_iface *if_incoming;
*best_neigh_node = NULL;
......@@ -286,19 +289,19 @@ static bool batadv_purge_orig_neighbors(struct bat_priv *bat_priv,
if_incoming = neigh_node->if_incoming;
if ((batadv_has_timed_out(last_seen, BATADV_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 ((if_incoming->if_status == IF_INACTIVE) ||
(if_incoming->if_status == IF_NOT_IN_USE) ||
(if_incoming->if_status == IF_TO_BE_REMOVED))
batadv_dbg(DBG_BATMAN, bat_priv,
(if_incoming->if_status == BATADV_IF_INACTIVE) ||
(if_incoming->if_status == BATADV_IF_NOT_IN_USE) ||
(if_incoming->if_status == BATADV_IF_TO_BE_REMOVED)) {
if ((if_incoming->if_status == BATADV_IF_INACTIVE) ||
(if_incoming->if_status == BATADV_IF_NOT_IN_USE) ||
(if_incoming->if_status == BATADV_IF_TO_BE_REMOVED))
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"neighbor purge: originator %pM, neighbor: %pM, iface: %s\n",
orig_node->orig, neigh_node->addr,
if_incoming->net_dev->name);
else
batadv_dbg(DBG_BATMAN, bat_priv,
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"neighbor timeout: originator %pM, neighbor: %pM, last_seen: %u\n",
orig_node->orig, neigh_node->addr,
jiffies_to_msecs(last_seen));
......@@ -319,14 +322,14 @@ static bool batadv_purge_orig_neighbors(struct bat_priv *bat_priv,
return neigh_purged;
}
static bool batadv_purge_orig_node(struct bat_priv *bat_priv,
struct orig_node *orig_node)
static bool batadv_purge_orig_node(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node)
{
struct neigh_node *best_neigh_node;
struct batadv_neigh_node *best_neigh_node;
if (batadv_has_timed_out(orig_node->last_seen,
2 * BATADV_PURGE_TIMEOUT)) {
batadv_dbg(DBG_BATMAN, bat_priv,
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Originator timeout: originator %pM, last_seen %u\n",
orig_node->orig,
jiffies_to_msecs(orig_node->last_seen));
......@@ -341,13 +344,13 @@ static bool batadv_purge_orig_node(struct bat_priv *bat_priv,
return false;
}
static void _batadv_purge_orig(struct bat_priv *bat_priv)
static void _batadv_purge_orig(struct batadv_priv *bat_priv)
{
struct hashtable_t *hash = bat_priv->orig_hash;
struct batadv_hashtable *hash = bat_priv->orig_hash;
struct hlist_node *node, *node_tmp;
struct hlist_head *head;
spinlock_t *list_lock; /* spinlock to protect write access */
struct orig_node *orig_node;
struct batadv_orig_node *orig_node;
uint32_t i;
if (!hash)
......@@ -383,16 +386,16 @@ static void _batadv_purge_orig(struct bat_priv *bat_priv)
static void batadv_purge_orig(struct work_struct *work)
{
struct delayed_work *delayed_work =
container_of(work, struct delayed_work, work);
struct bat_priv *bat_priv =
container_of(delayed_work, struct bat_priv, orig_work);
struct delayed_work *delayed_work;
struct batadv_priv *bat_priv;
delayed_work = container_of(work, struct delayed_work, work);
bat_priv = container_of(delayed_work, struct batadv_priv, orig_work);
_batadv_purge_orig(bat_priv);
batadv_start_purge_timer(bat_priv);
}
void batadv_purge_orig_ref(struct bat_priv *bat_priv)
void batadv_purge_orig_ref(struct batadv_priv *bat_priv)
{
_batadv_purge_orig(bat_priv);
}
......@@ -400,16 +403,17 @@ void batadv_purge_orig_ref(struct bat_priv *bat_priv)
int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
{
struct net_device *net_dev = (struct net_device *)seq->private;
struct bat_priv *bat_priv = netdev_priv(net_dev);
struct hashtable_t *hash = bat_priv->orig_hash;
struct batadv_priv *bat_priv = netdev_priv(net_dev);
struct batadv_hashtable *hash = bat_priv->orig_hash;
struct hlist_node *node, *node_tmp;
struct hlist_head *head;
struct hard_iface *primary_if;
struct orig_node *orig_node;
struct neigh_node *neigh_node, *neigh_node_tmp;
struct batadv_hard_iface *primary_if;
struct batadv_orig_node *orig_node;
struct batadv_neigh_node *neigh_node, *neigh_node_tmp;
int batman_count = 0;
int last_seen_secs;
int last_seen_msecs;
unsigned long last_seen_jiffies;
uint32_t i;
int ret = 0;
......@@ -422,7 +426,7 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
goto out;
}
if (primary_if->if_status != IF_ACTIVE) {
if (primary_if->if_status != BATADV_IF_ACTIVE) {
ret = seq_printf(seq,
"BATMAN mesh %s disabled - primary interface not active\n",
net_dev->name);
......@@ -448,10 +452,10 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
if (neigh_node->tq_avg == 0)
goto next;
last_seen_secs = jiffies_to_msecs(jiffies -
orig_node->last_seen) / 1000;
last_seen_msecs = jiffies_to_msecs(jiffies -
orig_node->last_seen) % 1000;
last_seen_jiffies = jiffies - orig_node->last_seen;
last_seen_msecs = jiffies_to_msecs(last_seen_jiffies);
last_seen_secs = last_seen_msecs / 1000;
last_seen_msecs = last_seen_msecs % 1000;
seq_printf(seq, "%pM %4i.%03is (%3i) %pM [%10s]:",
orig_node->orig, last_seen_secs,
......@@ -484,7 +488,8 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
return ret;
}
static int batadv_orig_node_add_if(struct orig_node *orig_node, int max_if_num)
static int batadv_orig_node_add_if(struct batadv_orig_node *orig_node,
int max_if_num)
{
void *data_ptr;
size_t data_size, old_size;
......@@ -511,13 +516,14 @@ static int batadv_orig_node_add_if(struct orig_node *orig_node, int max_if_num)
return 0;
}
int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num)
int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
int max_if_num)
{
struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
struct hashtable_t *hash = bat_priv->orig_hash;
struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
struct batadv_hashtable *hash = bat_priv->orig_hash;
struct hlist_node *node;
struct hlist_head *head;
struct orig_node *orig_node;
struct batadv_orig_node *orig_node;
uint32_t i;
int ret;
......@@ -546,7 +552,7 @@ int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num)
return -ENOMEM;
}
static int batadv_orig_node_del_if(struct orig_node *orig_node,
static int batadv_orig_node_del_if(struct batadv_orig_node *orig_node,
int max_if_num, int del_if_num)
{
void *data_ptr = NULL;
......@@ -594,14 +600,15 @@ static int batadv_orig_node_del_if(struct orig_node *orig_node,
return 0;
}
int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num)
int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface,
int max_if_num)
{
struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
struct hashtable_t *hash = bat_priv->orig_hash;
struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
struct batadv_hashtable *hash = bat_priv->orig_hash;
struct hlist_node *node;
struct hlist_head *head;
struct hard_iface *hard_iface_tmp;
struct orig_node *orig_node;
struct batadv_hard_iface *hard_iface_tmp;
struct batadv_orig_node *orig_node;
uint32_t i;
int ret;
......@@ -627,7 +634,7 @@ int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num)
/* renumber remaining batman interfaces _inside_ of orig_hash_lock */
rcu_read_lock();
list_for_each_entry_rcu(hard_iface_tmp, &batadv_hardif_list, list) {
if (hard_iface_tmp->if_status == IF_NOT_IN_USE)
if (hard_iface_tmp->if_status == BATADV_IF_NOT_IN_USE)
continue;
if (hard_iface == hard_iface_tmp)
......
......@@ -22,20 +22,23 @@
#include "hash.h"
int batadv_originator_init(struct bat_priv *bat_priv);
void batadv_originator_free(struct bat_priv *bat_priv);
void batadv_purge_orig_ref(struct bat_priv *bat_priv);
void batadv_orig_node_free_ref(struct orig_node *orig_node);
struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
const uint8_t *addr);
struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface,
const uint8_t *neigh_addr,
uint32_t seqno);
void batadv_neigh_node_free_ref(struct neigh_node *neigh_node);
struct neigh_node *batadv_orig_node_get_router(struct orig_node *orig_node);
int batadv_originator_init(struct batadv_priv *bat_priv);
void batadv_originator_free(struct batadv_priv *bat_priv);
void batadv_purge_orig_ref(struct batadv_priv *bat_priv);
void batadv_orig_node_free_ref(struct batadv_orig_node *orig_node);
struct batadv_orig_node *batadv_get_orig_node(struct batadv_priv *bat_priv,
const uint8_t *addr);
struct batadv_neigh_node *
batadv_neigh_node_new(struct batadv_hard_iface *hard_iface,
const uint8_t *neigh_addr, uint32_t seqno);
void batadv_neigh_node_free_ref(struct batadv_neigh_node *neigh_node);
struct batadv_neigh_node *
batadv_orig_node_get_router(struct batadv_orig_node *orig_node);
int batadv_orig_seq_print_text(struct seq_file *seq, void *offset);
int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num);
int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num);
int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
int max_if_num);
int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface,
int max_if_num);
/* hashfunction to choose an entry in a hash table of given size
......@@ -60,13 +63,13 @@ static inline uint32_t batadv_choose_orig(const void *data, uint32_t size)
return hash % size;
}
static inline struct orig_node *batadv_orig_hash_find(struct bat_priv *bat_priv,
const void *data)
static inline struct batadv_orig_node *
batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data)
{
struct hashtable_t *hash = bat_priv->orig_hash;
struct batadv_hashtable *hash = bat_priv->orig_hash;
struct hlist_head *head;
struct hlist_node *node;
struct orig_node *orig_node, *orig_node_tmp = NULL;
struct batadv_orig_node *orig_node, *orig_node_tmp = NULL;
int index;
if (!hash)
......
......@@ -22,99 +22,99 @@
#define BATADV_ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
enum bat_packettype {
BAT_IV_OGM = 0x01,
BAT_ICMP = 0x02,
BAT_UNICAST = 0x03,
BAT_BCAST = 0x04,
BAT_VIS = 0x05,
BAT_UNICAST_FRAG = 0x06,
BAT_TT_QUERY = 0x07,
BAT_ROAM_ADV = 0x08
enum batadv_packettype {
BATADV_IV_OGM = 0x01,
BATADV_ICMP = 0x02,
BATADV_UNICAST = 0x03,
BATADV_BCAST = 0x04,
BATADV_VIS = 0x05,
BATADV_UNICAST_FRAG = 0x06,
BATADV_TT_QUERY = 0x07,
BATADV_ROAM_ADV = 0x08,
};
/* this file is included by batctl which needs these defines */
#define BATADV_COMPAT_VERSION 14
enum batman_iv_flags {
NOT_BEST_NEXT_HOP = 1 << 3,
PRIMARIES_FIRST_HOP = 1 << 4,
VIS_SERVER = 1 << 5,
DIRECTLINK = 1 << 6
enum batadv_iv_flags {
BATADV_NOT_BEST_NEXT_HOP = 1 << 3,
BATADV_PRIMARIES_FIRST_HOP = 1 << 4,
BATADV_VIS_SERVER = 1 << 5,
BATADV_DIRECTLINK = 1 << 6,
};
/* ICMP message types */
enum icmp_packettype {
ECHO_REPLY = 0,
DESTINATION_UNREACHABLE = 3,
ECHO_REQUEST = 8,
TTL_EXCEEDED = 11,
PARAMETER_PROBLEM = 12
enum batadv_icmp_packettype {
BATADV_ECHO_REPLY = 0,
BATADV_DESTINATION_UNREACHABLE = 3,
BATADV_ECHO_REQUEST = 8,
BATADV_TTL_EXCEEDED = 11,
BATADV_PARAMETER_PROBLEM = 12,
};
/* vis defines */
enum vis_packettype {
VIS_TYPE_SERVER_SYNC = 0,
VIS_TYPE_CLIENT_UPDATE = 1
enum batadv_vis_packettype {
BATADV_VIS_TYPE_SERVER_SYNC = 0,
BATADV_VIS_TYPE_CLIENT_UPDATE = 1,
};
/* fragmentation defines */
enum unicast_frag_flags {
UNI_FRAG_HEAD = 1 << 0,
UNI_FRAG_LARGETAIL = 1 << 1
enum batadv_unicast_frag_flags {
BATADV_UNI_FRAG_HEAD = 1 << 0,
BATADV_UNI_FRAG_LARGETAIL = 1 << 1,
};
/* TT_QUERY subtypes */
#define BATADV_TT_QUERY_TYPE_MASK 0x3
enum tt_query_packettype {
TT_REQUEST = 0,
TT_RESPONSE = 1
enum batadv_tt_query_packettype {
BATADV_TT_REQUEST = 0,
BATADV_TT_RESPONSE = 1,
};
/* TT_QUERY flags */
enum tt_query_flags {
TT_FULL_TABLE = 1 << 2
enum batadv_tt_query_flags {
BATADV_TT_FULL_TABLE = 1 << 2,
};
/* TT_CLIENT flags.
/* BATADV_TT_CLIENT flags.
* Flags from 1 to 1 << 7 are sent on the wire, while flags from 1 << 8 to
* 1 << 15 are used for local computation only
*/
enum tt_client_flags {
TT_CLIENT_DEL = 1 << 0,
TT_CLIENT_ROAM = 1 << 1,
TT_CLIENT_WIFI = 1 << 2,
TT_CLIENT_NOPURGE = 1 << 8,
TT_CLIENT_NEW = 1 << 9,
TT_CLIENT_PENDING = 1 << 10
enum batadv_tt_client_flags {
BATADV_TT_CLIENT_DEL = 1 << 0,
BATADV_TT_CLIENT_ROAM = 1 << 1,
BATADV_TT_CLIENT_WIFI = 1 << 2,
BATADV_TT_CLIENT_NOPURGE = 1 << 8,
BATADV_TT_CLIENT_NEW = 1 << 9,
BATADV_TT_CLIENT_PENDING = 1 << 10,
};
/* claim frame types for the bridge loop avoidance */
enum bla_claimframe {
CLAIM_TYPE_ADD = 0x00,
CLAIM_TYPE_DEL = 0x01,
CLAIM_TYPE_ANNOUNCE = 0x02,
CLAIM_TYPE_REQUEST = 0x03
enum batadv_bla_claimframe {
BATADV_CLAIM_TYPE_ADD = 0x00,
BATADV_CLAIM_TYPE_DEL = 0x01,
BATADV_CLAIM_TYPE_ANNOUNCE = 0x02,
BATADV_CLAIM_TYPE_REQUEST = 0x03,
};
/* the destination hardware field in the ARP frame is used to
* transport the claim type and the group id
*/
struct bla_claim_dst {
struct batadv_bla_claim_dst {
uint8_t magic[3]; /* FF:43:05 */
uint8_t type; /* bla_claimframe */
__be16 group; /* group id */
} __packed;
struct batman_header {
struct batadv_header {
uint8_t packet_type;
uint8_t version; /* batman version field */
uint8_t ttl;
} __packed;
struct batman_ogm_packet {
struct batman_header header;
struct batadv_ogm_packet {
struct batadv_header header;
uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
__be32 seqno;
uint8_t orig[ETH_ALEN];
......@@ -126,10 +126,10 @@ struct batman_ogm_packet {
__be16 tt_crc;
} __packed;
#define BATADV_OGM_HLEN sizeof(struct batman_ogm_packet)
#define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
struct icmp_packet {
struct batman_header header;
struct batadv_icmp_packet {
struct batadv_header header;
uint8_t msg_type; /* see ICMP message types above */
uint8_t dst[ETH_ALEN];
uint8_t orig[ETH_ALEN];
......@@ -143,8 +143,8 @@ struct icmp_packet {
/* icmp_packet_rr must start with all fields from imcp_packet
* as this is assumed by code that handles ICMP packets
*/
struct icmp_packet_rr {
struct batman_header header;
struct batadv_icmp_packet_rr {
struct batadv_header header;
uint8_t msg_type; /* see ICMP message types above */
uint8_t dst[ETH_ALEN];
uint8_t orig[ETH_ALEN];
......@@ -154,14 +154,14 @@ struct icmp_packet_rr {
uint8_t rr[BATADV_RR_LEN][ETH_ALEN];
} __packed;
struct unicast_packet {
struct batman_header header;
struct batadv_unicast_packet {
struct batadv_header header;
uint8_t ttvn; /* destination translation table version number */
uint8_t dest[ETH_ALEN];
} __packed;
struct unicast_frag_packet {
struct batman_header header;
struct batadv_unicast_frag_packet {
struct batadv_header header;
uint8_t ttvn; /* destination translation table version number */
uint8_t dest[ETH_ALEN];
uint8_t flags;
......@@ -170,15 +170,15 @@ struct unicast_frag_packet {
__be16 seqno;
} __packed;
struct bcast_packet {
struct batman_header header;
struct batadv_bcast_packet {
struct batadv_header header;
uint8_t reserved;
__be32 seqno;
uint8_t orig[ETH_ALEN];
} __packed;
struct vis_packet {
struct batman_header header;
struct batadv_vis_packet {
struct batadv_header header;
uint8_t vis_type; /* which type of vis-participant sent this? */
__be32 seqno; /* sequence number */
uint8_t entries; /* number of entries behind this struct */
......@@ -188,8 +188,8 @@ struct vis_packet {
uint8_t sender_orig[ETH_ALEN]; /* who sent or forwarded this packet */
} __packed;
struct tt_query_packet {
struct batman_header header;
struct batadv_tt_query_packet {
struct batadv_header header;
/* the flag field is a combination of:
* - TT_REQUEST or TT_RESPONSE
* - TT_FULL_TABLE
......@@ -212,15 +212,15 @@ struct tt_query_packet {
__be16 tt_data;
} __packed;
struct roam_adv_packet {
struct batman_header header;
struct batadv_roam_adv_packet {
struct batadv_header header;
uint8_t reserved;
uint8_t dst[ETH_ALEN];
uint8_t src[ETH_ALEN];
uint8_t client[ETH_ALEN];
} __packed;
struct tt_change {
struct batadv_tt_change {
uint8_t flags;
uint8_t addr[ETH_ALEN];
} __packed;
......
此差异已折叠。
......@@ -20,32 +20,40 @@
#ifndef _NET_BATMAN_ADV_ROUTING_H_
#define _NET_BATMAN_ADV_ROUTING_H_
void batadv_slide_own_bcast_window(struct hard_iface *hard_iface);
void batadv_slide_own_bcast_window(struct batadv_hard_iface *hard_iface);
bool batadv_check_management_packet(struct sk_buff *skb,
struct hard_iface *hard_iface,
struct batadv_hard_iface *hard_iface,
int header_len);
void batadv_update_route(struct bat_priv *bat_priv, struct orig_node *orig_node,
struct neigh_node *neigh_node);
int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if);
int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if);
void batadv_update_route(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
struct batadv_neigh_node *neigh_node);
int batadv_recv_icmp_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if);
int batadv_recv_unicast_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if);
int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
struct hard_iface *recv_if);
int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if);
int batadv_recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if);
int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if);
int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if);
struct neigh_node *batadv_find_router(struct bat_priv *bat_priv,
struct orig_node *orig_node,
const struct hard_iface *recv_if);
void batadv_bonding_candidate_del(struct orig_node *orig_node,
struct neigh_node *neigh_node);
void batadv_bonding_candidate_add(struct orig_node *orig_node,
struct neigh_node *neigh_node);
void batadv_bonding_save_primary(const struct orig_node *orig_node,
struct orig_node *orig_neigh_node,
const struct batman_ogm_packet
struct batadv_hard_iface *recv_if);
int batadv_recv_bcast_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if);
int batadv_recv_vis_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if);
int batadv_recv_tt_query(struct sk_buff *skb,
struct batadv_hard_iface *recv_if);
int batadv_recv_roam_adv(struct sk_buff *skb,
struct batadv_hard_iface *recv_if);
struct batadv_neigh_node *
batadv_find_router(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
const struct batadv_hard_iface *recv_if);
void batadv_bonding_candidate_del(struct batadv_orig_node *orig_node,
struct batadv_neigh_node *neigh_node);
void batadv_bonding_candidate_add(struct batadv_orig_node *orig_node,
struct batadv_neigh_node *neigh_node);
void batadv_bonding_save_primary(const struct batadv_orig_node *orig_node,
struct batadv_orig_node *orig_neigh_node,
const struct batadv_ogm_packet
*batman_ogm_packet);
int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
int batadv_window_protected(struct batadv_priv *bat_priv, int32_t seq_num_diff,
unsigned long *last_reset);
#endif /* _NET_BATMAN_ADV_ROUTING_H_ */
此差异已折叠。
......@@ -20,14 +20,16 @@
#ifndef _NET_BATMAN_ADV_SEND_H_
#define _NET_BATMAN_ADV_SEND_H_
int batadv_send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
int batadv_send_skb_packet(struct sk_buff *skb,
struct batadv_hard_iface *hard_iface,
const uint8_t *dst_addr);
void batadv_schedule_bat_ogm(struct hard_iface *hard_iface);
int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface);
int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
const struct sk_buff *skb,
unsigned long delay);
void batadv_send_outstanding_bat_ogm_packet(struct work_struct *work);
void batadv_purge_outstanding_packets(struct bat_priv *bat_priv,
const struct hard_iface *hard_iface);
void
batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
const struct batadv_hard_iface *hard_iface);
#endif /* _NET_BATMAN_ADV_SEND_H_ */
此差异已折叠。
......@@ -22,7 +22,7 @@
int batadv_skb_head_push(struct sk_buff *skb, unsigned int len);
void batadv_interface_rx(struct net_device *soft_iface, struct sk_buff *skb,
struct hard_iface *recv_if, int hdr_size);
struct batadv_hard_iface *recv_if, int hdr_size);
struct net_device *batadv_softif_create(const char *name);
void batadv_softif_destroy(struct net_device *soft_iface);
int batadv_softif_is_valid(const struct net_device *net_dev);
......
......@@ -23,7 +23,7 @@
#define BATADV_SYSFS_IF_MESH_SUBDIR "mesh"
#define BATADV_SYSFS_IF_BAT_SUBDIR "batman_adv"
struct bat_attribute {
struct batadv_attribute {
struct attribute attr;
ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
char *buf);
......@@ -36,7 +36,7 @@ void batadv_sysfs_del_meshif(struct net_device *dev);
int batadv_sysfs_add_hardif(struct kobject **hardif_obj,
struct net_device *dev);
void batadv_sysfs_del_hardif(struct kobject **hardif_obj);
int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
enum uev_action action, const char *data);
int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type,
enum batadv_uev_action action, const char *data);
#endif /* _NET_BATMAN_ADV_SYSFS_H_ */
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -25,31 +25,32 @@
#define BATADV_FRAG_TIMEOUT 10000 /* purge frag list entries after time in ms */
#define BATADV_FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */
int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
int batadv_frag_reassemble_skb(struct sk_buff *skb,
struct batadv_priv *bat_priv,
struct sk_buff **new_skb);
void batadv_frag_list_free(struct list_head *head);
int batadv_unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv);
int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
struct hard_iface *hard_iface,
int batadv_unicast_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv);
int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
struct batadv_hard_iface *hard_iface,
const uint8_t dstaddr[]);
static inline int batadv_frag_can_reassemble(const struct sk_buff *skb, int mtu)
{
const struct unicast_frag_packet *unicast_packet;
const struct batadv_unicast_frag_packet *unicast_packet;
int uneven_correction = 0;
unsigned int merged_size;
unicast_packet = (struct unicast_frag_packet *)skb->data;
unicast_packet = (struct batadv_unicast_frag_packet *)skb->data;
if (unicast_packet->flags & UNI_FRAG_LARGETAIL) {
if (unicast_packet->flags & UNI_FRAG_HEAD)
if (unicast_packet->flags & BATADV_UNI_FRAG_LARGETAIL) {
if (unicast_packet->flags & BATADV_UNI_FRAG_HEAD)
uneven_correction = 1;
else
uneven_correction = -1;
}
merged_size = (skb->len - sizeof(*unicast_packet)) * 2;
merged_size += sizeof(struct unicast_packet) + uneven_correction;
merged_size += sizeof(struct batadv_unicast_packet) + uneven_correction;
return merged_size <= mtu;
}
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册