Commit 82aee5d7 authored by David S. Miller's avatar David S. Miller

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

Included changes:
- another batch of patches meant to clean batman-adv namespace
- deletion of an obsolete intermediate buffer used in the visualization code to
  print the output
- TT code cleanups
parents 41347dcd 42d0b044
...@@ -35,14 +35,14 @@ ...@@ -35,14 +35,14 @@
static struct dentry *batadv_debugfs; static struct dentry *batadv_debugfs;
#ifdef CONFIG_BATMAN_ADV_DEBUG #ifdef CONFIG_BATMAN_ADV_DEBUG
#define LOG_BUFF_MASK (batadv_log_buff_len - 1) #define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1)
#define LOG_BUFF(idx) (debug_log->log_buff[(idx) & LOG_BUFF_MASK]) #define BATADV_LOG_BUFF(idx) (debug_log->log_buff[(idx) & BATADV_LOG_BUFF_MASK])
static int batadv_log_buff_len = LOG_BUF_LEN; static int batadv_log_buff_len = BATADV_LOG_BUF_LEN;
static void batadv_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; BATADV_LOG_BUFF(debug_log->log_end) = c;
debug_log->log_end++; debug_log->log_end++;
if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len) if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len)
...@@ -133,7 +133,7 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf, ...@@ -133,7 +133,7 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf,
while ((!error) && (i < count) && while ((!error) && (i < count) &&
(debug_log->log_start != debug_log->log_end)) { (debug_log->log_start != debug_log->log_end)) {
c = LOG_BUFF(debug_log->log_start); c = BATADV_LOG_BUFF(debug_log->log_start);
debug_log->log_start++; debug_log->log_start++;
...@@ -270,7 +270,7 @@ struct bat_debuginfo { ...@@ -270,7 +270,7 @@ struct bat_debuginfo {
const struct file_operations fops; const struct file_operations fops;
}; };
#define BAT_DEBUGINFO(_name, _mode, _open) \ #define BATADV_DEBUGINFO(_name, _mode, _open) \
struct bat_debuginfo batadv_debuginfo_##_name = { \ struct bat_debuginfo batadv_debuginfo_##_name = { \
.attr = { .name = __stringify(_name), \ .attr = { .name = __stringify(_name), \
.mode = _mode, }, \ .mode = _mode, }, \
...@@ -282,15 +282,17 @@ struct bat_debuginfo batadv_debuginfo_##_name = { \ ...@@ -282,15 +282,17 @@ struct bat_debuginfo batadv_debuginfo_##_name = { \
} \ } \
}; };
static BAT_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open); static BATADV_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open);
static BAT_DEBUGINFO(originators, S_IRUGO, batadv_originators_open); static BATADV_DEBUGINFO(originators, S_IRUGO, batadv_originators_open);
static BAT_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open); static BATADV_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open);
static BAT_DEBUGINFO(transtable_global, S_IRUGO, batadv_transtable_global_open); static BATADV_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, batadv_bla_claim_table_open); static BATADV_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open);
#endif #endif
static BAT_DEBUGINFO(transtable_local, S_IRUGO, batadv_transtable_local_open); static BATADV_DEBUGINFO(transtable_local, S_IRUGO,
static BAT_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open); batadv_transtable_local_open);
static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open);
static struct bat_debuginfo *batadv_mesh_debuginfos[] = { static struct bat_debuginfo *batadv_mesh_debuginfos[] = {
&batadv_debuginfo_originators, &batadv_debuginfo_originators,
...@@ -309,7 +311,7 @@ void batadv_debugfs_init(void) ...@@ -309,7 +311,7 @@ void batadv_debugfs_init(void)
struct bat_debuginfo *bat_debug; struct bat_debuginfo *bat_debug;
struct dentry *file; struct dentry *file;
batadv_debugfs = debugfs_create_dir(DEBUGFS_BAT_SUBDIR, NULL); batadv_debugfs = debugfs_create_dir(BATADV_DEBUGFS_SUBDIR, NULL);
if (batadv_debugfs == ERR_PTR(-ENODEV)) if (batadv_debugfs == ERR_PTR(-ENODEV))
batadv_debugfs = NULL; batadv_debugfs = NULL;
...@@ -360,7 +362,7 @@ int batadv_debugfs_add_meshif(struct net_device *dev) ...@@ -360,7 +362,7 @@ int batadv_debugfs_add_meshif(struct net_device *dev)
bat_priv->debug_dir, bat_priv->debug_dir,
dev, &(*bat_debug)->fops); dev, &(*bat_debug)->fops);
if (!file) { if (!file) {
bat_err(dev, "Can't add debugfs file: %s/%s\n", batadv_err(dev, "Can't add debugfs file: %s/%s\n",
dev->name, ((*bat_debug)->attr).name); dev->name, ((*bat_debug)->attr).name);
goto rem_attr; goto rem_attr;
} }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#ifndef _NET_BATMAN_ADV_DEBUGFS_H_ #ifndef _NET_BATMAN_ADV_DEBUGFS_H_
#define _NET_BATMAN_ADV_DEBUGFS_H_ #define _NET_BATMAN_ADV_DEBUGFS_H_
#define DEBUGFS_BAT_SUBDIR "batman_adv" #define BATADV_DEBUGFS_SUBDIR "batman_adv"
void batadv_debugfs_init(void); void batadv_debugfs_init(void);
void batadv_debugfs_destroy(void); void batadv_debugfs_destroy(void);
......
This diff is collapsed.
This diff is collapsed.
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
#ifndef _NET_BATMAN_ADV_SYSFS_H_ #ifndef _NET_BATMAN_ADV_SYSFS_H_
#define _NET_BATMAN_ADV_SYSFS_H_ #define _NET_BATMAN_ADV_SYSFS_H_
#define SYSFS_IF_MESH_SUBDIR "mesh" #define BATADV_SYSFS_IF_MESH_SUBDIR "mesh"
#define SYSFS_IF_BAT_SUBDIR "batman_adv" #define BATADV_SYSFS_IF_BAT_SUBDIR "batman_adv"
struct bat_attribute { struct bat_attribute {
struct attribute attr; struct attribute attr;
......
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
/* shift the packet array by n places. */ /* shift the packet array by n places. */
static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n) static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n)
{ {
if (n <= 0 || n >= TQ_LOCAL_WINDOW_SIZE) if (n <= 0 || n >= BATADV_TQ_LOCAL_WINDOW_SIZE)
return; return;
bitmap_shift_left(seq_bits, seq_bits, n, TQ_LOCAL_WINDOW_SIZE); bitmap_shift_left(seq_bits, seq_bits, n, BATADV_TQ_LOCAL_WINDOW_SIZE);
} }
...@@ -46,7 +46,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, ...@@ -46,7 +46,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
/* sequence number is slightly older. We already got a sequence number /* sequence number is slightly older. We already got a sequence number
* higher than this one, so we just mark it. * higher than this one, so we just mark it.
*/ */
if ((seq_num_diff <= 0) && (seq_num_diff > -TQ_LOCAL_WINDOW_SIZE)) { if (seq_num_diff <= 0 && seq_num_diff > -BATADV_TQ_LOCAL_WINDOW_SIZE) {
if (set_mark) if (set_mark)
batadv_set_bit(seq_bits, -seq_num_diff); batadv_set_bit(seq_bits, -seq_num_diff);
return 0; return 0;
...@@ -55,7 +55,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, ...@@ -55,7 +55,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
/* sequence number is slightly newer, so we shift the window and /* sequence number is slightly newer, so we shift the window and
* set the mark if required * set the mark if required
*/ */
if ((seq_num_diff > 0) && (seq_num_diff < TQ_LOCAL_WINDOW_SIZE)) { if (seq_num_diff > 0 && seq_num_diff < BATADV_TQ_LOCAL_WINDOW_SIZE) {
batadv_bitmap_shift_left(seq_bits, seq_num_diff); batadv_bitmap_shift_left(seq_bits, seq_num_diff);
if (set_mark) if (set_mark)
...@@ -64,12 +64,12 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, ...@@ -64,12 +64,12 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
} }
/* 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 >= BATADV_TQ_LOCAL_WINDOW_SIZE &&
(seq_num_diff < EXPECTED_SEQNO_RANGE)) { seq_num_diff < BATADV_EXPECTED_SEQNO_RANGE) {
batadv_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, BATADV_TQ_LOCAL_WINDOW_SIZE);
if (set_mark) if (set_mark)
batadv_set_bit(seq_bits, 0); batadv_set_bit(seq_bits, 0);
return 1; return 1;
...@@ -80,13 +80,13 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, ...@@ -80,13 +80,13 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
* packet should be dropped without calling this function if the * packet should be dropped without calling this function if the
* seqno window is protected. * seqno window is protected.
*/ */
if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE ||
(seq_num_diff >= EXPECTED_SEQNO_RANGE)) { seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) {
batadv_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, BATADV_TQ_LOCAL_WINDOW_SIZE);
if (set_mark) if (set_mark)
batadv_set_bit(seq_bits, 0); batadv_set_bit(seq_bits, 0);
......
...@@ -29,7 +29,7 @@ static inline int batadv_test_bit(const unsigned long *seq_bits, ...@@ -29,7 +29,7 @@ static inline int batadv_test_bit(const unsigned long *seq_bits,
int32_t diff; int32_t diff;
diff = last_seqno - curr_seqno; diff = last_seqno - curr_seqno;
if (diff < 0 || diff >= TQ_LOCAL_WINDOW_SIZE) if (diff < 0 || diff >= BATADV_TQ_LOCAL_WINDOW_SIZE)
return 0; return 0;
else else
return test_bit(diff, seq_bits); return test_bit(diff, seq_bits);
...@@ -39,7 +39,7 @@ static inline int batadv_test_bit(const unsigned long *seq_bits, ...@@ -39,7 +39,7 @@ static inline int batadv_test_bit(const unsigned long *seq_bits,
static inline void batadv_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 >= BATADV_TQ_LOCAL_WINDOW_SIZE)
return; return;
set_bit(n, seq_bits); /* turn the position on */ set_bit(n, seq_bits); /* turn the position on */
......
...@@ -237,7 +237,7 @@ static void batadv_bla_del_backbone_claims(struct backbone_gw *backbone_gw) ...@@ -237,7 +237,7 @@ static void batadv_bla_del_backbone_claims(struct backbone_gw *backbone_gw)
} }
/* all claims gone, intialize CRC */ /* all claims gone, intialize CRC */
backbone_gw->crc = BLA_CRC_INIT; backbone_gw->crc = BATADV_BLA_CRC_INIT;
} }
/* @bat_priv: the bat priv with all the soft interface information /* @bat_priv: the bat priv with all the soft interface information
...@@ -375,7 +375,7 @@ static struct backbone_gw *batadv_bla_get_backbone_gw(struct bat_priv *bat_priv, ...@@ -375,7 +375,7 @@ static struct backbone_gw *batadv_bla_get_backbone_gw(struct bat_priv *bat_priv,
entry->vid = vid; entry->vid = vid;
entry->lasttime = jiffies; entry->lasttime = jiffies;
entry->crc = BLA_CRC_INIT; entry->crc = BATADV_BLA_CRC_INIT;
entry->bat_priv = bat_priv; entry->bat_priv = bat_priv;
atomic_set(&entry->request_sent, 0); atomic_set(&entry->request_sent, 0);
memcpy(entry->orig, orig, ETH_ALEN); memcpy(entry->orig, orig, ETH_ALEN);
...@@ -949,7 +949,7 @@ static void batadv_bla_purge_backbone_gw(struct bat_priv *bat_priv, int now) ...@@ -949,7 +949,7 @@ static void batadv_bla_purge_backbone_gw(struct bat_priv *bat_priv, int now)
if (now) if (now)
goto purge_now; goto purge_now;
if (!batadv_has_timed_out(backbone_gw->lasttime, if (!batadv_has_timed_out(backbone_gw->lasttime,
BLA_BACKBONE_TIMEOUT)) BATADV_BLA_BACKBONE_TIMEOUT))
continue; continue;
batadv_dbg(DBG_BLA, backbone_gw->bat_priv, batadv_dbg(DBG_BLA, backbone_gw->bat_priv,
...@@ -1001,7 +1001,7 @@ static void batadv_bla_purge_claims(struct bat_priv *bat_priv, ...@@ -1001,7 +1001,7 @@ static void batadv_bla_purge_claims(struct bat_priv *bat_priv,
primary_if->net_dev->dev_addr)) primary_if->net_dev->dev_addr))
continue; continue;
if (!batadv_has_timed_out(claim->lasttime, if (!batadv_has_timed_out(claim->lasttime,
BLA_CLAIM_TIMEOUT)) BATADV_BLA_CLAIM_TIMEOUT))
continue; continue;
batadv_dbg(DBG_BLA, bat_priv, batadv_dbg(DBG_BLA, bat_priv,
...@@ -1075,7 +1075,7 @@ static void batadv_bla_start_timer(struct bat_priv *bat_priv) ...@@ -1075,7 +1075,7 @@ static void batadv_bla_start_timer(struct bat_priv *bat_priv)
{ {
INIT_DELAYED_WORK(&bat_priv->bla_work, batadv_bla_periodic_work); INIT_DELAYED_WORK(&bat_priv->bla_work, batadv_bla_periodic_work);
queue_delayed_work(batadv_event_workqueue, &bat_priv->bla_work, queue_delayed_work(batadv_event_workqueue, &bat_priv->bla_work,
msecs_to_jiffies(BLA_PERIOD_LENGTH)); msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
} }
/* periodic work to do: /* periodic work to do:
...@@ -1162,9 +1162,9 @@ int batadv_bla_init(struct bat_priv *bat_priv) ...@@ -1162,9 +1162,9 @@ int batadv_bla_init(struct bat_priv *bat_priv)
} }
/* initialize the duplicate list */ /* initialize the duplicate list */
for (i = 0; i < DUPLIST_SIZE; i++) for (i = 0; i < BATADV_DUPLIST_SIZE; i++)
bat_priv->bcast_duplist[i].entrytime = bat_priv->bcast_duplist[i].entrytime =
jiffies - msecs_to_jiffies(DUPLIST_TIMEOUT); jiffies - msecs_to_jiffies(BATADV_DUPLIST_TIMEOUT);
bat_priv->bcast_duplist_curr = 0; bat_priv->bcast_duplist_curr = 0;
if (bat_priv->claim_hash) if (bat_priv->claim_hash)
...@@ -1216,14 +1216,15 @@ int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, ...@@ -1216,14 +1216,15 @@ int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
/* calculate the crc ... */ /* calculate the crc ... */
crc = crc16(0, content, length); crc = crc16(0, content, length);
for (i = 0 ; i < DUPLIST_SIZE; i++) { for (i = 0; i < BATADV_DUPLIST_SIZE; i++) {
curr = (bat_priv->bcast_duplist_curr + i) % DUPLIST_SIZE; curr = (bat_priv->bcast_duplist_curr + i) % BATADV_DUPLIST_SIZE;
entry = &bat_priv->bcast_duplist[curr]; entry = &bat_priv->bcast_duplist[curr];
/* we can stop searching if the entry is too old ; /* we can stop searching if the entry is too old ;
* later entries will be even older * later entries will be even older
*/ */
if (batadv_has_timed_out(entry->entrytime, DUPLIST_TIMEOUT)) if (batadv_has_timed_out(entry->entrytime,
BATADV_DUPLIST_TIMEOUT))
break; break;
if (entry->crc != crc) if (entry->crc != crc)
...@@ -1238,7 +1239,8 @@ int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, ...@@ -1238,7 +1239,8 @@ int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
return 1; return 1;
} }
/* not found, add a new entry (overwrite the oldest entry) */ /* not found, add a new entry (overwrite the oldest entry) */
curr = (bat_priv->bcast_duplist_curr + DUPLIST_SIZE - 1) % DUPLIST_SIZE; curr = (bat_priv->bcast_duplist_curr + BATADV_DUPLIST_SIZE - 1);
curr %= BATADV_DUPLIST_SIZE;
entry = &bat_priv->bcast_duplist[curr]; entry = &bat_priv->bcast_duplist[curr];
entry->crc = crc; entry->crc = crc;
entry->entrytime = jiffies; entry->entrytime = jiffies;
......
...@@ -36,7 +36,7 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv, ...@@ -36,7 +36,7 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
int batadv_bla_init(struct bat_priv *bat_priv); int batadv_bla_init(struct bat_priv *bat_priv);
void batadv_bla_free(struct bat_priv *bat_priv); void batadv_bla_free(struct bat_priv *bat_priv);
#define BLA_CRC_INIT 0 #define BATADV_BLA_CRC_INIT 0
#else /* ifdef CONFIG_BATMAN_ADV_BLA */ #else /* ifdef CONFIG_BATMAN_ADV_BLA */
static inline int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, static inline int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb,
......
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
/* This is the offset of the options field in a dhcp packet starting at /* This is the offset of the options field in a dhcp packet starting at
* the beginning of the dhcp header * the beginning of the dhcp header
*/ */
#define DHCP_OPTIONS_OFFSET 240 #define BATADV_DHCP_OPTIONS_OFFSET 240
#define DHCP_REQUEST 3 #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 gw_node *gw_node)
{ {
...@@ -138,8 +138,8 @@ static struct gw_node *batadv_gw_get_best_gw_node(struct bat_priv *bat_priv) ...@@ -138,8 +138,8 @@ static struct gw_node *batadv_gw_get_best_gw_node(struct bat_priv *bat_priv)
tmp_gw_factor = (router->tq_avg * router->tq_avg * tmp_gw_factor = (router->tq_avg * router->tq_avg *
down * 100 * 100) / down * 100 * 100) /
(TQ_LOCAL_WINDOW_SIZE * (BATADV_TQ_LOCAL_WINDOW_SIZE *
TQ_LOCAL_WINDOW_SIZE * 64); BATADV_TQ_LOCAL_WINDOW_SIZE * 64);
if ((tmp_gw_factor > max_gw_factor) || if ((tmp_gw_factor > max_gw_factor) ||
((tmp_gw_factor == max_gw_factor) && ((tmp_gw_factor == max_gw_factor) &&
...@@ -197,7 +197,7 @@ void batadv_gw_election(struct bat_priv *bat_priv) ...@@ -197,7 +197,7 @@ void batadv_gw_election(struct bat_priv *bat_priv)
if (atomic_read(&bat_priv->gw_mode) != GW_MODE_CLIENT) if (atomic_read(&bat_priv->gw_mode) != GW_MODE_CLIENT)
goto out; goto out;
if (!atomic_dec_not_zero(&bat_priv->gw_reselect)) if (!batadv_atomic_dec_not_zero(&bat_priv->gw_reselect))
goto out; goto out;
curr_gw = batadv_gw_get_selected_gw_node(bat_priv); curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
...@@ -354,7 +354,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv, ...@@ -354,7 +354,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv,
gw_node->deleted = 0; gw_node->deleted = 0;
if (new_gwflags == NO_FLAGS) { if (new_gwflags == BATADV_NO_FLAGS) {
gw_node->deleted = jiffies; gw_node->deleted = jiffies;
batadv_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",
...@@ -367,7 +367,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv, ...@@ -367,7 +367,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv,
goto unlock; goto unlock;
} }
if (new_gwflags == NO_FLAGS) if (new_gwflags == BATADV_NO_FLAGS)
goto unlock; goto unlock;
batadv_gw_node_add(bat_priv, orig_node, new_gwflags); batadv_gw_node_add(bat_priv, orig_node, new_gwflags);
...@@ -392,7 +392,7 @@ void batadv_gw_node_purge(struct bat_priv *bat_priv) ...@@ -392,7 +392,7 @@ void batadv_gw_node_purge(struct bat_priv *bat_priv)
{ {
struct gw_node *gw_node, *curr_gw; struct gw_node *gw_node, *curr_gw;
struct hlist_node *node, *node_tmp; struct hlist_node *node, *node_tmp;
unsigned long timeout = msecs_to_jiffies(2 * PURGE_TIMEOUT); unsigned long timeout = msecs_to_jiffies(2 * BATADV_PURGE_TIMEOUT);
int do_deselect = 0; int do_deselect = 0;
curr_gw = batadv_gw_get_selected_gw_node(bat_priv); curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
...@@ -484,8 +484,8 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) ...@@ -484,8 +484,8 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
seq_printf(seq, seq_printf(seq,
" %-12s (%s/%i) %17s [%10s]: gw_class ... [B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", " %-12s (%s/%i) %17s [%10s]: gw_class ... [B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n",
"Gateway", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", "Gateway", "#", BATADV_TQ_MAX_VALUE, "Nexthop", "outgoingIF",
SOURCE_VERSION, primary_if->net_dev->name, BATADV_SOURCE_VERSION, primary_if->net_dev->name,
primary_if->net_dev->dev_addr, net_dev->name); primary_if->net_dev->dev_addr, net_dev->name);
rcu_read_lock(); rcu_read_lock();
...@@ -521,11 +521,11 @@ static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len) ...@@ -521,11 +521,11 @@ static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len)
pkt_len = skb_headlen(skb); pkt_len = skb_headlen(skb);
if (pkt_len < header_len + DHCP_OPTIONS_OFFSET + 1) if (pkt_len < header_len + BATADV_DHCP_OPTIONS_OFFSET + 1)
goto out; goto out;
p = skb->data + header_len + DHCP_OPTIONS_OFFSET; p = skb->data + header_len + BATADV_DHCP_OPTIONS_OFFSET;
pkt_len -= header_len + DHCP_OPTIONS_OFFSET + 1; pkt_len -= header_len + BATADV_DHCP_OPTIONS_OFFSET + 1;
/* Access the dhcp option lists. Each entry is made up by: /* Access the dhcp option lists. Each entry is made up by:
* - octet 1: option type * - octet 1: option type
...@@ -543,7 +543,7 @@ static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len) ...@@ -543,7 +543,7 @@ static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len)
p += 2; p += 2;
/* check if the message type is what we need */ /* check if the message type is what we need */
if (*p == DHCP_REQUEST) if (*p == BATADV_DHCP_REQUEST)
ret = true; ret = true;
break; break;
} else if (*p == 0) { } else if (*p == 0) {
...@@ -667,7 +667,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv, ...@@ -667,7 +667,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
/* If we are a GW then we are our best GW. We can artificially /* If we are a GW then we are our best GW. We can artificially
* set the tq towards ourself as the maximum value * set the tq towards ourself as the maximum value
*/ */
curr_tq_avg = TQ_MAX_VALUE; curr_tq_avg = BATADV_TQ_MAX_VALUE;
break; break;
case GW_MODE_CLIENT: case GW_MODE_CLIENT:
curr_gw = batadv_gw_get_selected_gw_node(bat_priv); curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
...@@ -698,7 +698,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv, ...@@ -698,7 +698,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
if (!neigh_old) if (!neigh_old)
goto out; goto out;
if (curr_tq_avg - neigh_old->tq_avg > GW_THRESHOLD) if (curr_tq_avg - neigh_old->tq_avg > BATADV_GW_THRESHOLD)
out_of_range = true; out_of_range = true;
out: out:
......
...@@ -97,7 +97,7 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff, ...@@ -97,7 +97,7 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
ret = kstrtol(buff, 10, &ldown); ret = kstrtol(buff, 10, &ldown);
if (ret) { if (ret) {
bat_err(net_dev, batadv_err(net_dev,
"Download speed of gateway mode invalid: %s\n", "Download speed of gateway mode invalid: %s\n",
buff); buff);
return false; return false;
...@@ -122,7 +122,7 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff, ...@@ -122,7 +122,7 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
ret = kstrtol(slash_ptr + 1, 10, &lup); ret = kstrtol(slash_ptr + 1, 10, &lup);
if (ret) { if (ret) {
bat_err(net_dev, batadv_err(net_dev,
"Upload speed of gateway mode invalid: %s\n", "Upload speed of gateway mode invalid: %s\n",
slash_ptr + 1); slash_ptr + 1);
return false; return false;
...@@ -164,7 +164,7 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, ...@@ -164,7 +164,7 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
return count; return count;
batadv_gw_deselect(bat_priv); batadv_gw_deselect(bat_priv);
bat_info(net_dev, batadv_info(net_dev,
"Changing gateway bandwidth from: '%i' to: '%ld' (propagating: %d%s/%d%s)\n", "Changing gateway bandwidth from: '%i' to: '%ld' (propagating: %d%s/%d%s)\n",
atomic_read(&bat_priv->gw_bandwidth), gw_bandwidth_tmp, atomic_read(&bat_priv->gw_bandwidth), gw_bandwidth_tmp,
(down > 2048 ? down / 1024 : down), (down > 2048 ? down / 1024 : down),
......
...@@ -26,9 +26,9 @@ enum gw_modes { ...@@ -26,9 +26,9 @@ enum gw_modes {
GW_MODE_SERVER, GW_MODE_SERVER,
}; };
#define GW_MODE_OFF_NAME "off" #define BATADV_GW_MODE_OFF_NAME "off"
#define GW_MODE_CLIENT_NAME "client" #define BATADV_GW_MODE_CLIENT_NAME "client"
#define GW_MODE_SERVER_NAME "server" #define BATADV_GW_MODE_SERVER_NAME "server"
void batadv_gw_bandwidth_to_kbit(uint8_t gw_class, int *down, int *up); void batadv_gw_bandwidth_to_kbit(uint8_t gw_class, int *down, int *up);
ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
......
...@@ -196,7 +196,8 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface) ...@@ -196,7 +196,8 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
if (hard_iface->soft_iface != soft_iface) if (hard_iface->soft_iface != soft_iface)
continue; continue;
min_mtu = min_t(int, hard_iface->net_dev->mtu - BAT_HEADER_LEN, min_mtu = min_t(int,
hard_iface->net_dev->mtu - BATADV_HEADER_LEN,
min_mtu); min_mtu);
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -234,7 +235,7 @@ static void batadv_hardif_activate_interface(struct hard_iface *hard_iface) ...@@ -234,7 +235,7 @@ static void batadv_hardif_activate_interface(struct hard_iface *hard_iface)
if (!primary_if) if (!primary_if)
batadv_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", batadv_info(hard_iface->soft_iface, "Interface activated: %s\n",
hard_iface->net_dev->name); hard_iface->net_dev->name);
batadv_update_min_mtu(hard_iface->soft_iface); batadv_update_min_mtu(hard_iface->soft_iface);
...@@ -252,7 +253,7 @@ static void batadv_hardif_deactivate_interface(struct hard_iface *hard_iface) ...@@ -252,7 +253,7 @@ static void batadv_hardif_deactivate_interface(struct hard_iface *hard_iface)
hard_iface->if_status = IF_INACTIVE; hard_iface->if_status = IF_INACTIVE;
bat_info(hard_iface->soft_iface, "Interface deactivated: %s\n", batadv_info(hard_iface->soft_iface, "Interface deactivated: %s\n",
hard_iface->net_dev->name); hard_iface->net_dev->name);
batadv_update_min_mtu(hard_iface->soft_iface); batadv_update_min_mtu(hard_iface->soft_iface);
...@@ -263,6 +264,7 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface, ...@@ -263,6 +264,7 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
{ {
struct bat_priv *bat_priv; struct bat_priv *bat_priv;
struct net_device *soft_iface; struct net_device *soft_iface;
__be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN);
int ret; int ret;
if (hard_iface->if_status != IF_NOT_IN_USE) if (hard_iface->if_status != IF_NOT_IN_USE)
...@@ -309,33 +311,33 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface, ...@@ -309,33 +311,33 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
hard_iface->if_status = IF_INACTIVE; hard_iface->if_status = IF_INACTIVE;
batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces); batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces);
hard_iface->batman_adv_ptype.type = __constant_htons(ETH_P_BATMAN); hard_iface->batman_adv_ptype.type = ethertype;
hard_iface->batman_adv_ptype.func = batadv_batman_skb_recv; hard_iface->batman_adv_ptype.func = batadv_batman_skb_recv;
hard_iface->batman_adv_ptype.dev = hard_iface->net_dev; hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
dev_add_pack(&hard_iface->batman_adv_ptype); dev_add_pack(&hard_iface->batman_adv_ptype);
atomic_set(&hard_iface->frag_seqno, 1); atomic_set(&hard_iface->frag_seqno, 1);
bat_info(hard_iface->soft_iface, "Adding interface: %s\n", batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
hard_iface->net_dev->name); hard_iface->net_dev->name);
if (atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < if (atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu <
ETH_DATA_LEN + BAT_HEADER_LEN) ETH_DATA_LEN + BATADV_HEADER_LEN)
bat_info(hard_iface->soft_iface, 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", "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, hard_iface->net_dev->name, hard_iface->net_dev->mtu,
ETH_DATA_LEN + BAT_HEADER_LEN); ETH_DATA_LEN + BATADV_HEADER_LEN);
if (!atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < if (!atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu <
ETH_DATA_LEN + BAT_HEADER_LEN) ETH_DATA_LEN + BATADV_HEADER_LEN)
bat_info(hard_iface->soft_iface, 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", "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, hard_iface->net_dev->name, hard_iface->net_dev->mtu,
ETH_DATA_LEN + BAT_HEADER_LEN); ETH_DATA_LEN + BATADV_HEADER_LEN);
if (batadv_hardif_is_iface_up(hard_iface)) if (batadv_hardif_is_iface_up(hard_iface))
batadv_hardif_activate_interface(hard_iface); batadv_hardif_activate_interface(hard_iface);
else else
bat_err(hard_iface->soft_iface, batadv_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",
hard_iface->net_dev->name); hard_iface->net_dev->name);
...@@ -363,7 +365,7 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface) ...@@ -363,7 +365,7 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface)
if (hard_iface->if_status != IF_INACTIVE) if (hard_iface->if_status != IF_INACTIVE)
goto out; goto out;
bat_info(hard_iface->soft_iface, "Removing interface: %s\n", batadv_info(hard_iface->soft_iface, "Removing interface: %s\n",
hard_iface->net_dev->name); hard_iface->net_dev->name);
dev_remove_pack(&hard_iface->batman_adv_ptype); dev_remove_pack(&hard_iface->batman_adv_ptype);
...@@ -546,7 +548,7 @@ bool batadv_is_wifi_iface(int ifindex) ...@@ -546,7 +548,7 @@ bool batadv_is_wifi_iface(int ifindex)
struct net_device *net_device = NULL; struct net_device *net_device = NULL;
bool ret = false; bool ret = false;
if (ifindex == NULL_IFINDEX) if (ifindex == BATADV_NULL_IFINDEX)
goto out; goto out;
net_device = dev_get_by_index(&init_net, ifindex); net_device = dev_get_by_index(&init_net, ifindex);
......
...@@ -203,9 +203,9 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, ...@@ -203,9 +203,9 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
icmp_packet->uid = socket_client->index; icmp_packet->uid = socket_client->index;
if (icmp_packet->header.version != COMPAT_VERSION) { if (icmp_packet->header.version != BATADV_COMPAT_VERSION) {
icmp_packet->msg_type = PARAMETER_PROBLEM; icmp_packet->msg_type = PARAMETER_PROBLEM;
icmp_packet->header.version = COMPAT_VERSION; icmp_packet->header.version = BATADV_COMPAT_VERSION;
batadv_socket_add_packet(socket_client, icmp_packet, batadv_socket_add_packet(socket_client, icmp_packet,
packet_len); packet_len);
goto free_skb; goto free_skb;
...@@ -282,7 +282,7 @@ int batadv_socket_setup(struct bat_priv *bat_priv) ...@@ -282,7 +282,7 @@ int batadv_socket_setup(struct bat_priv *bat_priv)
if (!bat_priv->debug_dir) if (!bat_priv->debug_dir)
goto err; goto err;
d = debugfs_create_file(ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR, d = debugfs_create_file(BATADV_ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR,
bat_priv->debug_dir, bat_priv, &batadv_fops); bat_priv->debug_dir, bat_priv, &batadv_fops);
if (!d) if (!d)
goto err; goto err;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ #ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_
#define _NET_BATMAN_ADV_ICMP_SOCKET_H_ #define _NET_BATMAN_ADV_ICMP_SOCKET_H_
#define ICMP_SOCKET "socket" #define BATADV_ICMP_SOCKET "socket"
void batadv_socket_init(void); void batadv_socket_init(void);
int batadv_socket_setup(struct bat_priv *bat_priv); int batadv_socket_setup(struct bat_priv *bat_priv);
......
...@@ -38,22 +38,23 @@ ...@@ -38,22 +38,23 @@
* list traversals just rcu-locked * list traversals just rcu-locked
*/ */
struct list_head batadv_hardif_list; struct list_head batadv_hardif_list;
static int (*recv_packet_handler[256])(struct sk_buff *, struct hard_iface *); static int (*batadv_rx_handler[256])(struct sk_buff *,
struct hard_iface *);
char batadv_routing_algo[20] = "BATMAN_IV"; char batadv_routing_algo[20] = "BATMAN_IV";
static struct hlist_head bat_algo_list; static struct hlist_head batadv_algo_list;
unsigned char batadv_broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; unsigned char batadv_broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
struct workqueue_struct *batadv_event_workqueue; struct workqueue_struct *batadv_event_workqueue;
static void recv_handler_init(void); static void batadv_recv_handler_init(void);
static int __init batman_init(void) static int __init batadv_init(void)
{ {
INIT_LIST_HEAD(&batadv_hardif_list); INIT_LIST_HEAD(&batadv_hardif_list);
INIT_HLIST_HEAD(&bat_algo_list); INIT_HLIST_HEAD(&batadv_algo_list);
recv_handler_init(); batadv_recv_handler_init();
batadv_iv_init(); batadv_iv_init();
...@@ -71,12 +72,12 @@ static int __init batman_init(void) ...@@ -71,12 +72,12 @@ static int __init batman_init(void)
register_netdevice_notifier(&batadv_hard_if_notifier); register_netdevice_notifier(&batadv_hard_if_notifier);
pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n", pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n",
SOURCE_VERSION, COMPAT_VERSION); BATADV_SOURCE_VERSION, BATADV_COMPAT_VERSION);
return 0; return 0;
} }
static void __exit batman_exit(void) static void __exit batadv_exit(void)
{ {
batadv_debugfs_destroy(); batadv_debugfs_destroy();
unregister_netdevice_notifier(&batadv_hard_if_notifier); unregister_netdevice_notifier(&batadv_hard_if_notifier);
...@@ -119,7 +120,8 @@ int batadv_mesh_init(struct net_device *soft_iface) ...@@ -119,7 +120,8 @@ int batadv_mesh_init(struct net_device *soft_iface)
if (ret < 0) if (ret < 0)
goto err; goto err;
batadv_tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX); batadv_tt_local_add(soft_iface, soft_iface->dev_addr,
BATADV_NULL_IFINDEX);
ret = batadv_vis_init(bat_priv); ret = batadv_vis_init(bat_priv);
if (ret < 0) if (ret < 0)
...@@ -189,7 +191,7 @@ int batadv_is_my_mac(const uint8_t *addr) ...@@ -189,7 +191,7 @@ int batadv_is_my_mac(const uint8_t *addr)
return 0; return 0;
} }
static int recv_unhandled_packet(struct sk_buff *skb, static int batadv_recv_unhandled_packet(struct sk_buff *skb,
struct hard_iface *recv_if) struct hard_iface *recv_if)
{ {
return NET_RX_DROP; return NET_RX_DROP;
...@@ -237,7 +239,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -237,7 +239,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
batman_ogm_packet = (struct batman_ogm_packet *)skb->data; batman_ogm_packet = (struct batman_ogm_packet *)skb->data;
if (batman_ogm_packet->header.version != COMPAT_VERSION) { if (batman_ogm_packet->header.version != BATADV_COMPAT_VERSION) {
batadv_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);
...@@ -248,7 +250,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -248,7 +250,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
* the supplied skb. if not, we have to free the skb. * the supplied skb. if not, we have to free the skb.
*/ */
idx = batman_ogm_packet->header.packet_type; idx = batman_ogm_packet->header.packet_type;
ret = (*recv_packet_handler[idx])(skb, hard_iface); ret = (*batadv_rx_handler[idx])(skb, hard_iface);
if (ret == NET_RX_DROP) if (ret == NET_RX_DROP)
kfree_skb(skb); kfree_skb(skb);
...@@ -265,51 +267,51 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -265,51 +267,51 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
return NET_RX_DROP; return NET_RX_DROP;
} }
static void recv_handler_init(void) static void batadv_recv_handler_init(void)
{ {
int i; int i;
for (i = 0; i < ARRAY_SIZE(recv_packet_handler); i++) for (i = 0; i < ARRAY_SIZE(batadv_rx_handler); i++)
recv_packet_handler[i] = recv_unhandled_packet; batadv_rx_handler[i] = batadv_recv_unhandled_packet;
/* batman icmp packet */ /* batman icmp packet */
recv_packet_handler[BAT_ICMP] = batadv_recv_icmp_packet; batadv_rx_handler[BAT_ICMP] = batadv_recv_icmp_packet;
/* unicast packet */ /* unicast packet */
recv_packet_handler[BAT_UNICAST] = batadv_recv_unicast_packet; batadv_rx_handler[BAT_UNICAST] = batadv_recv_unicast_packet;
/* fragmented unicast packet */ /* fragmented unicast packet */
recv_packet_handler[BAT_UNICAST_FRAG] = batadv_recv_ucast_frag_packet; batadv_rx_handler[BAT_UNICAST_FRAG] = batadv_recv_ucast_frag_packet;
/* broadcast packet */ /* broadcast packet */
recv_packet_handler[BAT_BCAST] = batadv_recv_bcast_packet; batadv_rx_handler[BAT_BCAST] = batadv_recv_bcast_packet;
/* vis packet */ /* vis packet */
recv_packet_handler[BAT_VIS] = batadv_recv_vis_packet; batadv_rx_handler[BAT_VIS] = batadv_recv_vis_packet;
/* Translation table query (request or response) */ /* Translation table query (request or response) */
recv_packet_handler[BAT_TT_QUERY] = batadv_recv_tt_query; batadv_rx_handler[BAT_TT_QUERY] = batadv_recv_tt_query;
/* Roaming advertisement */ /* Roaming advertisement */
recv_packet_handler[BAT_ROAM_ADV] = batadv_recv_roam_adv; batadv_rx_handler[BAT_ROAM_ADV] = batadv_recv_roam_adv;
} }
int batadv_recv_handler_register(uint8_t packet_type, int batadv_recv_handler_register(uint8_t packet_type,
int (*recv_handler)(struct sk_buff *, int (*recv_handler)(struct sk_buff *,
struct hard_iface *)) struct hard_iface *))
{ {
if (recv_packet_handler[packet_type] != &recv_unhandled_packet) if (batadv_rx_handler[packet_type] != &batadv_recv_unhandled_packet)
return -EBUSY; return -EBUSY;
recv_packet_handler[packet_type] = recv_handler; batadv_rx_handler[packet_type] = recv_handler;
return 0; return 0;
} }
void batadv_recv_handler_unregister(uint8_t packet_type) void batadv_recv_handler_unregister(uint8_t packet_type)
{ {
recv_packet_handler[packet_type] = recv_unhandled_packet; batadv_rx_handler[packet_type] = batadv_recv_unhandled_packet;
} }
static struct bat_algo_ops *bat_algo_get(char *name) static struct bat_algo_ops *batadv_algo_get(char *name)
{ {
struct bat_algo_ops *bat_algo_ops = NULL, *bat_algo_ops_tmp; struct bat_algo_ops *bat_algo_ops = NULL, *bat_algo_ops_tmp;
struct hlist_node *node; struct hlist_node *node;
hlist_for_each_entry(bat_algo_ops_tmp, node, &bat_algo_list, list) { hlist_for_each_entry(bat_algo_ops_tmp, node, &batadv_algo_list, list) {
if (strcmp(bat_algo_ops_tmp->name, name) != 0) if (strcmp(bat_algo_ops_tmp->name, name) != 0)
continue; continue;
...@@ -325,7 +327,7 @@ int batadv_algo_register(struct bat_algo_ops *bat_algo_ops) ...@@ -325,7 +327,7 @@ int batadv_algo_register(struct bat_algo_ops *bat_algo_ops)
struct bat_algo_ops *bat_algo_ops_tmp; struct bat_algo_ops *bat_algo_ops_tmp;
int ret; int ret;
bat_algo_ops_tmp = bat_algo_get(bat_algo_ops->name); bat_algo_ops_tmp = batadv_algo_get(bat_algo_ops->name);
if (bat_algo_ops_tmp) { if (bat_algo_ops_tmp) {
pr_info("Trying to register already registered routing algorithm: %s\n", pr_info("Trying to register already registered routing algorithm: %s\n",
bat_algo_ops->name); bat_algo_ops->name);
...@@ -347,7 +349,7 @@ int batadv_algo_register(struct bat_algo_ops *bat_algo_ops) ...@@ -347,7 +349,7 @@ int batadv_algo_register(struct bat_algo_ops *bat_algo_ops)
} }
INIT_HLIST_NODE(&bat_algo_ops->list); INIT_HLIST_NODE(&bat_algo_ops->list);
hlist_add_head(&bat_algo_ops->list, &bat_algo_list); hlist_add_head(&bat_algo_ops->list, &batadv_algo_list);
ret = 0; ret = 0;
out: out:
...@@ -359,7 +361,7 @@ int batadv_algo_select(struct bat_priv *bat_priv, char *name) ...@@ -359,7 +361,7 @@ int batadv_algo_select(struct bat_priv *bat_priv, char *name)
struct bat_algo_ops *bat_algo_ops; struct bat_algo_ops *bat_algo_ops;
int ret = -EINVAL; int ret = -EINVAL;
bat_algo_ops = bat_algo_get(name); bat_algo_ops = batadv_algo_get(name);
if (!bat_algo_ops) if (!bat_algo_ops)
goto out; goto out;
...@@ -377,14 +379,14 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset) ...@@ -377,14 +379,14 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
seq_printf(seq, "Available routing algorithms:\n"); seq_printf(seq, "Available routing algorithms:\n");
hlist_for_each_entry(bat_algo_ops, node, &bat_algo_list, list) { hlist_for_each_entry(bat_algo_ops, node, &batadv_algo_list, list) {
seq_printf(seq, "%s\n", bat_algo_ops->name); seq_printf(seq, "%s\n", bat_algo_ops->name);
} }
return 0; return 0;
} }
static int param_set_ra(const char *val, const struct kernel_param *kp) static int batadv_param_set_ra(const char *val, const struct kernel_param *kp)
{ {
struct bat_algo_ops *bat_algo_ops; struct bat_algo_ops *bat_algo_ops;
char *algo_name = (char *)val; char *algo_name = (char *)val;
...@@ -393,7 +395,7 @@ static int param_set_ra(const char *val, const struct kernel_param *kp) ...@@ -393,7 +395,7 @@ static int param_set_ra(const char *val, const struct kernel_param *kp)
if (algo_name[name_len - 1] == '\n') if (algo_name[name_len - 1] == '\n')
algo_name[name_len - 1] = '\0'; algo_name[name_len - 1] = '\0';
bat_algo_ops = bat_algo_get(algo_name); bat_algo_ops = batadv_algo_get(algo_name);
if (!bat_algo_ops) { if (!bat_algo_ops) {
pr_err("Routing algorithm '%s' is not supported\n", algo_name); pr_err("Routing algorithm '%s' is not supported\n", algo_name);
return -EINVAL; return -EINVAL;
...@@ -402,23 +404,24 @@ static int param_set_ra(const char *val, const struct kernel_param *kp) ...@@ -402,23 +404,24 @@ static int param_set_ra(const char *val, const struct kernel_param *kp)
return param_set_copystring(algo_name, kp); return param_set_copystring(algo_name, kp);
} }
static const struct kernel_param_ops param_ops_ra = { static const struct kernel_param_ops batadv_param_ops_ra = {
.set = param_set_ra, .set = batadv_param_set_ra,
.get = param_get_string, .get = param_get_string,
}; };
static struct kparam_string __param_string_ra = { static struct kparam_string batadv_param_string_ra = {
.maxlen = sizeof(batadv_routing_algo), .maxlen = sizeof(batadv_routing_algo),
.string = batadv_routing_algo, .string = batadv_routing_algo,
}; };
module_param_cb(routing_algo, &param_ops_ra, &__param_string_ra, 0644); module_param_cb(routing_algo, &batadv_param_ops_ra, &batadv_param_string_ra,
module_init(batman_init); 0644);
module_exit(batman_exit); module_init(batadv_init);
module_exit(batadv_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_AUTHOR(BATADV_DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC); MODULE_DESCRIPTION(BATADV_DRIVER_DESC);
MODULE_SUPPORTED_DEVICE(DRIVER_DEVICE); MODULE_SUPPORTED_DEVICE(BATADV_DRIVER_DEVICE);
MODULE_VERSION(SOURCE_VERSION); MODULE_VERSION(BATADV_SOURCE_VERSION);
...@@ -20,79 +20,80 @@ ...@@ -20,79 +20,80 @@
#ifndef _NET_BATMAN_ADV_MAIN_H_ #ifndef _NET_BATMAN_ADV_MAIN_H_
#define _NET_BATMAN_ADV_MAIN_H_ #define _NET_BATMAN_ADV_MAIN_H_
#define DRIVER_AUTHOR "Marek Lindner <lindner_marek@yahoo.de>, " \ #define BATADV_DRIVER_AUTHOR "Marek Lindner <lindner_marek@yahoo.de>, " \
"Simon Wunderlich <siwu@hrz.tu-chemnitz.de>" "Simon Wunderlich <siwu@hrz.tu-chemnitz.de>"
#define DRIVER_DESC "B.A.T.M.A.N. advanced" #define BATADV_DRIVER_DESC "B.A.T.M.A.N. advanced"
#define DRIVER_DEVICE "batman-adv" #define BATADV_DRIVER_DEVICE "batman-adv"
#ifndef SOURCE_VERSION #ifndef BATADV_SOURCE_VERSION
#define SOURCE_VERSION "2012.3.0" #define BATADV_SOURCE_VERSION "2012.3.0"
#endif #endif
/* B.A.T.M.A.N. parameters */ /* B.A.T.M.A.N. parameters */
#define TQ_MAX_VALUE 255 #define BATADV_TQ_MAX_VALUE 255
#define JITTER 20 #define BATADV_JITTER 20
/* Time To Live of broadcast messages */ /* Time To Live of broadcast messages */
#define TTL 50 #define BATADV_TTL 50
/* purge originators after time in seconds if no valid packet comes in /* purge originators after time in seconds if no valid packet comes in
* -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE * -> TODO: check influence on BATADV_TQ_LOCAL_WINDOW_SIZE
*/ */
#define PURGE_TIMEOUT 200000 /* 200 seconds */ #define BATADV_PURGE_TIMEOUT 200000 /* 200 seconds */
#define TT_LOCAL_TIMEOUT 3600000 /* in miliseconds */ #define BATADV_TT_LOCAL_TIMEOUT 3600000 /* in miliseconds */
#define TT_CLIENT_ROAM_TIMEOUT 600000 /* in miliseconds */ #define BATADV_TT_CLIENT_ROAM_TIMEOUT 600000 /* in miliseconds */
/* sliding packet range of received originator messages in sequence numbers /* sliding packet range of received originator messages in sequence numbers
* (should be a multiple of our word size) * (should be a multiple of our word size)
*/ */
#define TQ_LOCAL_WINDOW_SIZE 64 #define BATADV_TQ_LOCAL_WINDOW_SIZE 64
/* miliseconds we have to keep pending tt_req */ /* miliseconds we have to keep pending tt_req */
#define TT_REQUEST_TIMEOUT 3000 #define BATADV_TT_REQUEST_TIMEOUT 3000
#define TQ_GLOBAL_WINDOW_SIZE 5 #define BATADV_TQ_GLOBAL_WINDOW_SIZE 5
#define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1 #define BATADV_TQ_LOCAL_BIDRECT_SEND_MINIMUM 1
#define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1 #define BATADV_TQ_LOCAL_BIDRECT_RECV_MINIMUM 1
#define TQ_TOTAL_BIDRECT_LIMIT 1 #define BATADV_TQ_TOTAL_BIDRECT_LIMIT 1
#define TT_OGM_APPEND_MAX 3 /* number of OGMs sent with the last tt diff */ /* number of OGMs sent with the last tt diff */
#define BATADV_TT_OGM_APPEND_MAX 3
/* Time in which a client can roam at most ROAMING_MAX_COUNT times in /* Time in which a client can roam at most ROAMING_MAX_COUNT times in
* miliseconds * miliseconds
*/ */
#define ROAMING_MAX_TIME 20000 #define BATADV_ROAMING_MAX_TIME 20000
#define ROAMING_MAX_COUNT 5 #define BATADV_ROAMING_MAX_COUNT 5
#define NO_FLAGS 0 #define BATADV_NO_FLAGS 0
#define NULL_IFINDEX 0 /* dummy ifindex used to avoid iface checks */ #define BATADV_NULL_IFINDEX 0 /* dummy ifindex used to avoid iface checks */
#define NUM_WORDS BITS_TO_LONGS(TQ_LOCAL_WINDOW_SIZE) #define BATADV_NUM_WORDS BITS_TO_LONGS(BATADV_TQ_LOCAL_WINDOW_SIZE)
#define LOG_BUF_LEN 8192 /* has to be a power of 2 */ #define BATADV_LOG_BUF_LEN 8192 /* has to be a power of 2 */
#define VIS_INTERVAL 5000 /* 5 seconds */ #define BATADV_VIS_INTERVAL 5000 /* 5 seconds */
/* how much worse secondary interfaces may be to be considered as bonding /* how much worse secondary interfaces may be to be considered as bonding
* candidates * candidates
*/ */
#define BONDING_TQ_THRESHOLD 50 #define BATADV_BONDING_TQ_THRESHOLD 50
/* should not be bigger than 512 bytes or change the size of /* should not be bigger than 512 bytes or change the size of
* forw_packet->direct_link_flags * forw_packet->direct_link_flags
*/ */
#define MAX_AGGREGATION_BYTES 512 #define BATADV_MAX_AGGREGATION_BYTES 512
#define MAX_AGGREGATION_MS 100 #define BATADV_MAX_AGGREGATION_MS 100
#define BLA_PERIOD_LENGTH 10000 /* 10 seconds */ #define BATADV_BLA_PERIOD_LENGTH 10000 /* 10 seconds */
#define BLA_BACKBONE_TIMEOUT (BLA_PERIOD_LENGTH * 3) #define BATADV_BLA_BACKBONE_TIMEOUT (BATADV_BLA_PERIOD_LENGTH * 3)
#define BLA_CLAIM_TIMEOUT (BLA_PERIOD_LENGTH * 10) #define BATADV_BLA_CLAIM_TIMEOUT (BATADV_BLA_PERIOD_LENGTH * 10)
#define DUPLIST_SIZE 16 #define BATADV_DUPLIST_SIZE 16
#define DUPLIST_TIMEOUT 500 /* 500 ms */ #define BATADV_DUPLIST_TIMEOUT 500 /* 500 ms */
/* don't reset again within 30 seconds */ /* don't reset again within 30 seconds */
#define RESET_PROTECTION_MS 30000 #define BATADV_RESET_PROTECTION_MS 30000
#define EXPECTED_SEQNO_RANGE 65536 #define BATADV_EXPECTED_SEQNO_RANGE 65536
enum mesh_state { enum mesh_state {
MESH_INACTIVE, MESH_INACTIVE,
...@@ -100,8 +101,8 @@ enum mesh_state { ...@@ -100,8 +101,8 @@ enum mesh_state {
MESH_DEACTIVATING MESH_DEACTIVATING
}; };
#define BCAST_QUEUE_LEN 256 #define BATADV_BCAST_QUEUE_LEN 256
#define BATMAN_QUEUE_LEN 256 #define BATADV_BATMAN_QUEUE_LEN 256
enum uev_action { enum uev_action {
UEV_ADD = 0, UEV_ADD = 0,
...@@ -113,7 +114,7 @@ enum uev_type { ...@@ -113,7 +114,7 @@ enum uev_type {
UEV_GW = 0 UEV_GW = 0
}; };
#define GW_THRESHOLD 50 #define BATADV_GW_THRESHOLD 50
/* Debug Messages */ /* Debug Messages */
#ifdef pr_fmt #ifdef pr_fmt
...@@ -190,14 +191,14 @@ static inline void batadv_dbg(int type __always_unused, ...@@ -190,14 +191,14 @@ static inline void batadv_dbg(int type __always_unused,
} }
#endif #endif
#define bat_info(net_dev, fmt, arg...) \ #define batadv_info(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); \
batadv_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 batadv_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); \
...@@ -226,10 +227,10 @@ static inline bool batadv_has_timed_out(unsigned long timestamp, ...@@ -226,10 +227,10 @@ static inline bool batadv_has_timed_out(unsigned long timestamp,
return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout)); return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout));
} }
#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0) #define batadv_atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
/* Returns the smallest signed integer in two's complement with the sizeof x */ /* Returns the smallest signed integer in two's complement with the sizeof x */
#define smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u))) #define batadv_smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u)))
/* Checks if a sequence number x is a predecessor/successor of y. /* Checks if a sequence number x is a predecessor/successor of y.
* they handle overflows/underflows and can correctly check for a * they handle overflows/underflows and can correctly check for a
...@@ -241,12 +242,12 @@ static inline bool batadv_has_timed_out(unsigned long timestamp, ...@@ -241,12 +242,12 @@ static inline bool batadv_has_timed_out(unsigned long timestamp,
* - when adding 128 - it is neither a predecessor nor a successor, * - when adding 128 - it is neither a predecessor nor a successor,
* - after adding more than 127 to the starting value - it is a successor * - after adding more than 127 to the starting value - it is a successor
*/ */
#define seq_before(x, y) ({typeof(x) _d1 = (x); \ #define batadv_seq_before(x, y) ({typeof(x) _d1 = (x); \
typeof(y) _d2 = (y); \ typeof(y) _d2 = (y); \
typeof(x) _dummy = (_d1 - _d2); \ typeof(x) _dummy = (_d1 - _d2); \
(void) (&_d1 == &_d2); \ (void) (&_d1 == &_d2); \
_dummy > smallest_signed_int(_dummy); }) _dummy > batadv_smallest_signed_int(_dummy); })
#define seq_after(x, y) seq_before(y, x) #define batadv_seq_after(x, y) batadv_seq_before(y, x)
/* Stop preemption on local cpu while incrementing the counter */ /* 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 bat_priv *bat_priv, size_t idx,
......
...@@ -194,6 +194,7 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, ...@@ -194,6 +194,7 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
struct orig_node *orig_node; struct orig_node *orig_node;
int size; int size;
int hash_added; int hash_added;
unsigned long reset_time;
orig_node = batadv_orig_hash_find(bat_priv, addr); orig_node = batadv_orig_hash_find(bat_priv, addr);
if (orig_node) if (orig_node)
...@@ -226,14 +227,13 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, ...@@ -226,14 +227,13 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
orig_node->tt_buff = NULL; orig_node->tt_buff = NULL;
orig_node->tt_buff_len = 0; orig_node->tt_buff_len = 0;
atomic_set(&orig_node->tt_size, 0); atomic_set(&orig_node->tt_size, 0);
orig_node->bcast_seqno_reset = jiffies - 1 reset_time = jiffies - 1 - msecs_to_jiffies(BATADV_RESET_PROTECTION_MS);
- msecs_to_jiffies(RESET_PROTECTION_MS); orig_node->bcast_seqno_reset = reset_time;
orig_node->batman_seqno_reset = jiffies - 1 orig_node->batman_seqno_reset = reset_time;
- msecs_to_jiffies(RESET_PROTECTION_MS);
atomic_set(&orig_node->bond_candidates, 0); atomic_set(&orig_node->bond_candidates, 0);
size = bat_priv->num_ifaces * sizeof(unsigned long) * NUM_WORDS; size = bat_priv->num_ifaces * sizeof(unsigned long) * BATADV_NUM_WORDS;
orig_node->bcast_own = kzalloc(size, GFP_ATOMIC); orig_node->bcast_own = kzalloc(size, GFP_ATOMIC);
if (!orig_node->bcast_own) if (!orig_node->bcast_own)
...@@ -285,7 +285,7 @@ static bool batadv_purge_orig_neighbors(struct bat_priv *bat_priv, ...@@ -285,7 +285,7 @@ static bool batadv_purge_orig_neighbors(struct bat_priv *bat_priv,
last_seen = neigh_node->last_seen; last_seen = neigh_node->last_seen;
if_incoming = neigh_node->if_incoming; if_incoming = neigh_node->if_incoming;
if ((batadv_has_timed_out(last_seen, PURGE_TIMEOUT)) || if ((batadv_has_timed_out(last_seen, BATADV_PURGE_TIMEOUT)) ||
(if_incoming->if_status == IF_INACTIVE) || (if_incoming->if_status == IF_INACTIVE) ||
(if_incoming->if_status == IF_NOT_IN_USE) || (if_incoming->if_status == IF_NOT_IN_USE) ||
(if_incoming->if_status == IF_TO_BE_REMOVED)) { (if_incoming->if_status == IF_TO_BE_REMOVED)) {
...@@ -324,7 +324,8 @@ static bool batadv_purge_orig_node(struct bat_priv *bat_priv, ...@@ -324,7 +324,8 @@ static bool batadv_purge_orig_node(struct bat_priv *bat_priv,
{ {
struct neigh_node *best_neigh_node; struct neigh_node *best_neigh_node;
if (batadv_has_timed_out(orig_node->last_seen, 2 * PURGE_TIMEOUT)) { if (batadv_has_timed_out(orig_node->last_seen,
2 * BATADV_PURGE_TIMEOUT)) {
batadv_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,
...@@ -370,7 +371,7 @@ static void _batadv_purge_orig(struct bat_priv *bat_priv) ...@@ -370,7 +371,7 @@ static void _batadv_purge_orig(struct bat_priv *bat_priv)
} }
if (batadv_has_timed_out(orig_node->last_frag_packet, if (batadv_has_timed_out(orig_node->last_frag_packet,
FRAG_TIMEOUT)) BATADV_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);
...@@ -429,11 +430,11 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) ...@@ -429,11 +430,11 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
} }
seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n",
SOURCE_VERSION, primary_if->net_dev->name, BATADV_SOURCE_VERSION, primary_if->net_dev->name,
primary_if->net_dev->dev_addr, net_dev->name); primary_if->net_dev->dev_addr, net_dev->name);
seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n", seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n",
"Originator", "last-seen", "#", TQ_MAX_VALUE, "Nexthop", "Originator", "last-seen", "#", BATADV_TQ_MAX_VALUE,
"outgoingIF", "Potential nexthops"); "Nexthop", "outgoingIF", "Potential nexthops");
for (i = 0; i < hash->size; i++) { for (i = 0; i < hash->size; i++) {
head = &hash->table[i]; head = &hash->table[i];
...@@ -486,14 +487,15 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) ...@@ -486,14 +487,15 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
static int batadv_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;
size_t data_size, old_size;
data_ptr = kmalloc(max_if_num * sizeof(unsigned long) * NUM_WORDS, data_size = max_if_num * sizeof(unsigned long) * BATADV_NUM_WORDS;
GFP_ATOMIC); old_size = (max_if_num - 1) * sizeof(unsigned long) * BATADV_NUM_WORDS;
data_ptr = kmalloc(data_size, GFP_ATOMIC);
if (!data_ptr) if (!data_ptr)
return -ENOMEM; return -ENOMEM;
memcpy(data_ptr, orig_node->bcast_own, memcpy(data_ptr, orig_node->bcast_own, old_size);
(max_if_num - 1) * sizeof(unsigned long) * NUM_WORDS);
kfree(orig_node->bcast_own); kfree(orig_node->bcast_own);
orig_node->bcast_own = data_ptr; orig_node->bcast_own = data_ptr;
...@@ -554,7 +556,7 @@ static int batadv_orig_node_del_if(struct orig_node *orig_node, ...@@ -554,7 +556,7 @@ static int batadv_orig_node_del_if(struct orig_node *orig_node,
if (max_if_num == 0) if (max_if_num == 0)
goto free_bcast_own; goto free_bcast_own;
chunk_size = sizeof(unsigned long) * NUM_WORDS; chunk_size = sizeof(unsigned long) * BATADV_NUM_WORDS;
data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC); data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC);
if (!data_ptr) if (!data_ptr)
return -ENOMEM; return -ENOMEM;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#ifndef _NET_BATMAN_ADV_PACKET_H_ #ifndef _NET_BATMAN_ADV_PACKET_H_
#define _NET_BATMAN_ADV_PACKET_H_ #define _NET_BATMAN_ADV_PACKET_H_
#define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */ #define BATADV_ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
enum bat_packettype { enum bat_packettype {
BAT_IV_OGM = 0x01, BAT_IV_OGM = 0x01,
...@@ -34,7 +34,7 @@ enum bat_packettype { ...@@ -34,7 +34,7 @@ enum bat_packettype {
}; };
/* this file is included by batctl which needs these defines */ /* this file is included by batctl which needs these defines */
#define COMPAT_VERSION 14 #define BATADV_COMPAT_VERSION 14
enum batman_iv_flags { enum batman_iv_flags {
NOT_BEST_NEXT_HOP = 1 << 3, NOT_BEST_NEXT_HOP = 1 << 3,
...@@ -65,7 +65,7 @@ enum unicast_frag_flags { ...@@ -65,7 +65,7 @@ enum unicast_frag_flags {
}; };
/* TT_QUERY subtypes */ /* TT_QUERY subtypes */
#define TT_QUERY_TYPE_MASK 0x3 #define BATADV_TT_QUERY_TYPE_MASK 0x3
enum tt_query_packettype { enum tt_query_packettype {
TT_REQUEST = 0, TT_REQUEST = 0,
...@@ -126,7 +126,7 @@ struct batman_ogm_packet { ...@@ -126,7 +126,7 @@ struct batman_ogm_packet {
__be16 tt_crc; __be16 tt_crc;
} __packed; } __packed;
#define BATMAN_OGM_HLEN sizeof(struct batman_ogm_packet) #define BATADV_OGM_HLEN sizeof(struct batman_ogm_packet)
struct icmp_packet { struct icmp_packet {
struct batman_header header; struct batman_header header;
...@@ -138,7 +138,7 @@ struct icmp_packet { ...@@ -138,7 +138,7 @@ struct icmp_packet {
uint8_t reserved; uint8_t reserved;
} __packed; } __packed;
#define BAT_RR_LEN 16 #define BATADV_RR_LEN 16
/* icmp_packet_rr must start with all fields from imcp_packet /* icmp_packet_rr must start with all fields from imcp_packet
* as this is assumed by code that handles ICMP packets * as this is assumed by code that handles ICMP packets
...@@ -151,7 +151,7 @@ struct icmp_packet_rr { ...@@ -151,7 +151,7 @@ struct icmp_packet_rr {
__be16 seqno; __be16 seqno;
uint8_t uid; uint8_t uid;
uint8_t rr_cur; uint8_t rr_cur;
uint8_t rr[BAT_RR_LEN][ETH_ALEN]; uint8_t rr[BATADV_RR_LEN][ETH_ALEN];
} __packed; } __packed;
struct unicast_packet { struct unicast_packet {
......
...@@ -24,7 +24,7 @@ void batadv_ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index, ...@@ -24,7 +24,7 @@ void batadv_ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index,
uint8_t value) uint8_t value)
{ {
lq_recv[*lq_index] = value; lq_recv[*lq_index] = value;
*lq_index = (*lq_index + 1) % TQ_GLOBAL_WINDOW_SIZE; *lq_index = (*lq_index + 1) % BATADV_TQ_GLOBAL_WINDOW_SIZE;
} }
uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[]) uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[])
...@@ -34,7 +34,7 @@ uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[]) ...@@ -34,7 +34,7 @@ uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[])
ptr = lq_recv; ptr = lq_recv;
while (i < TQ_GLOBAL_WINDOW_SIZE) { while (i < BATADV_TQ_GLOBAL_WINDOW_SIZE) {
if (*ptr != 0) { if (*ptr != 0) {
count++; count++;
sum += *ptr; sum += *ptr;
......
...@@ -42,6 +42,7 @@ void batadv_slide_own_bcast_window(struct hard_iface *hard_iface) ...@@ -42,6 +42,7 @@ void batadv_slide_own_bcast_window(struct hard_iface *hard_iface)
unsigned long *word; unsigned long *word;
uint32_t i; uint32_t i;
size_t word_index; size_t word_index;
uint8_t *w;
for (i = 0; i < hash->size; i++) { for (i = 0; i < hash->size; i++) {
head = &hash->table[i]; head = &hash->table[i];
...@@ -49,12 +50,12 @@ void batadv_slide_own_bcast_window(struct hard_iface *hard_iface) ...@@ -49,12 +50,12 @@ void batadv_slide_own_bcast_window(struct hard_iface *hard_iface)
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);
word_index = hard_iface->if_num * NUM_WORDS; word_index = hard_iface->if_num * BATADV_NUM_WORDS;
word = &(orig_node->bcast_own[word_index]); word = &(orig_node->bcast_own[word_index]);
batadv_bit_get_packet(bat_priv, word, 1, 0); batadv_bit_get_packet(bat_priv, word, 1, 0);
orig_node->bcast_own_sum[hard_iface->if_num] = w = &orig_node->bcast_own_sum[hard_iface->if_num];
bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE); *w = bitmap_weight(word, BATADV_TQ_LOCAL_WINDOW_SIZE);
spin_unlock_bh(&orig_node->ogm_cnt_lock); spin_unlock_bh(&orig_node->ogm_cnt_lock);
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -160,7 +161,7 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node, ...@@ -160,7 +161,7 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node,
goto candidate_del; goto candidate_del;
/* ... and is good enough to be considered */ /* ... and is good enough to be considered */
if (neigh_node->tq_avg < router->tq_avg - BONDING_TQ_THRESHOLD) if (neigh_node->tq_avg < router->tq_avg - BATADV_BONDING_TQ_THRESHOLD)
goto candidate_del; goto candidate_del;
/* check if we have another candidate with the same mac address or /* check if we have another candidate with the same mac address or
...@@ -232,9 +233,10 @@ batadv_bonding_save_primary(const struct orig_node *orig_node, ...@@ -232,9 +233,10 @@ batadv_bonding_save_primary(const struct orig_node *orig_node,
int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
unsigned long *last_reset) unsigned long *last_reset)
{ {
if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE ||
(seq_num_diff >= EXPECTED_SEQNO_RANGE)) { seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) {
if (!batadv_has_timed_out(*last_reset, RESET_PROTECTION_MS)) if (!batadv_has_timed_out(*last_reset,
BATADV_RESET_PROTECTION_MS))
return 1; return 1;
*last_reset = jiffies; *last_reset = jiffies;
...@@ -316,7 +318,7 @@ static int batadv_recv_my_icmp_packet(struct bat_priv *bat_priv, ...@@ -316,7 +318,7 @@ static int batadv_recv_my_icmp_packet(struct bat_priv *bat_priv,
memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
icmp_packet->msg_type = ECHO_REPLY; icmp_packet->msg_type = ECHO_REPLY;
icmp_packet->header.ttl = TTL; icmp_packet->header.ttl = BATADV_TTL;
batadv_send_skb_packet(skb, router->if_incoming, router->addr); batadv_send_skb_packet(skb, router->if_incoming, router->addr);
ret = NET_RX_SUCCESS; ret = NET_RX_SUCCESS;
...@@ -371,7 +373,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, ...@@ -371,7 +373,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
icmp_packet->msg_type = TTL_EXCEEDED; icmp_packet->msg_type = TTL_EXCEEDED;
icmp_packet->header.ttl = TTL; icmp_packet->header.ttl = BATADV_TTL;
batadv_send_skb_packet(skb, router->if_incoming, router->addr); batadv_send_skb_packet(skb, router->if_incoming, router->addr);
ret = NET_RX_SUCCESS; ret = NET_RX_SUCCESS;
...@@ -423,7 +425,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -423,7 +425,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
/* add record route information if not full */ /* add record route information if not full */
if ((hdr_size == sizeof(struct icmp_packet_rr)) && if ((hdr_size == sizeof(struct icmp_packet_rr)) &&
(icmp_packet->rr_cur < BAT_RR_LEN)) { (icmp_packet->rr_cur < BATADV_RR_LEN)) {
memcpy(&(icmp_packet->rr[icmp_packet->rr_cur]), memcpy(&(icmp_packet->rr[icmp_packet->rr_cur]),
ethhdr->h_dest, ETH_ALEN); ethhdr->h_dest, ETH_ALEN);
icmp_packet->rr_cur++; icmp_packet->rr_cur++;
...@@ -603,7 +605,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -603,7 +605,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
tt_query = (struct tt_query_packet *)skb->data; tt_query = (struct tt_query_packet *)skb->data;
switch (tt_query->flags & TT_QUERY_TYPE_MASK) { switch (tt_query->flags & BATADV_TT_QUERY_TYPE_MASK) {
case TT_REQUEST: case TT_REQUEST:
batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_RX); batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_RX);
...@@ -699,8 +701,8 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) ...@@ -699,8 +701,8 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
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, TT_CLIENT_ROAM,
false); atomic_read(&orig_node->last_ttvn) + 1);
/* Roaming phase starts: I have new information but the ttvn has not /* Roaming phase starts: I have new information but the ttvn has not
* been incremented yet. This flag will make me check all the incoming * been incremented yet. This flag will make me check all the incoming
...@@ -922,6 +924,7 @@ static int batadv_check_unicast_ttvn(struct bat_priv *bat_priv, ...@@ -922,6 +924,7 @@ static int batadv_check_unicast_ttvn(struct bat_priv *bat_priv,
struct hard_iface *primary_if; struct hard_iface *primary_if;
struct unicast_packet *unicast_packet; struct unicast_packet *unicast_packet;
bool tt_poss_change; bool tt_poss_change;
int is_old_ttvn;
/* I could need to modify it */ /* I could need to modify it */
if (skb_cow(skb, sizeof(struct unicast_packet)) < 0) if (skb_cow(skb, sizeof(struct unicast_packet)) < 0)
...@@ -945,7 +948,8 @@ static int batadv_check_unicast_ttvn(struct bat_priv *bat_priv, ...@@ -945,7 +948,8 @@ static int batadv_check_unicast_ttvn(struct bat_priv *bat_priv,
} }
/* Check whether I have to reroute the packet */ /* Check whether I have to reroute the packet */
if (seq_before(unicast_packet->ttvn, curr_ttvn) || tt_poss_change) { is_old_ttvn = batadv_seq_before(unicast_packet->ttvn, curr_ttvn);
if (is_old_ttvn || tt_poss_change) {
/* check if there is enough data before accessing it */ /* check if there is enough data before accessing it */
if (pskb_may_pull(skb, sizeof(struct unicast_packet) + if (pskb_may_pull(skb, sizeof(struct unicast_packet) +
ETH_HLEN) < 0) ETH_HLEN) < 0)
......
...@@ -58,11 +58,11 @@ int batadv_send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface, ...@@ -58,11 +58,11 @@ int batadv_send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
ethhdr = (struct ethhdr *)skb_mac_header(skb); ethhdr = (struct ethhdr *)skb_mac_header(skb);
memcpy(ethhdr->h_source, hard_iface->net_dev->dev_addr, ETH_ALEN); memcpy(ethhdr->h_source, hard_iface->net_dev->dev_addr, ETH_ALEN);
memcpy(ethhdr->h_dest, dst_addr, ETH_ALEN); memcpy(ethhdr->h_dest, dst_addr, ETH_ALEN);
ethhdr->h_proto = __constant_htons(ETH_P_BATMAN); ethhdr->h_proto = __constant_htons(BATADV_ETH_P_BATMAN);
skb_set_network_header(skb, ETH_HLEN); skb_set_network_header(skb, ETH_HLEN);
skb->priority = TC_PRIO_CONTROL; skb->priority = TC_PRIO_CONTROL;
skb->protocol = __constant_htons(ETH_P_BATMAN); skb->protocol = __constant_htons(BATADV_ETH_P_BATMAN);
skb->dev = hard_iface->net_dev; skb->dev = hard_iface->net_dev;
...@@ -141,7 +141,7 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv, ...@@ -141,7 +141,7 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
struct bcast_packet *bcast_packet; struct bcast_packet *bcast_packet;
struct sk_buff *newskb; struct sk_buff *newskb;
if (!atomic_dec_not_zero(&bat_priv->bcast_queue_left)) { if (!batadv_atomic_dec_not_zero(&bat_priv->bcast_queue_left)) {
batadv_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;
} }
......
...@@ -108,7 +108,7 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) ...@@ -108,7 +108,7 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)
if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) { if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) {
batadv_tt_local_remove(bat_priv, dev->dev_addr, batadv_tt_local_remove(bat_priv, dev->dev_addr,
"mac address changed", false); "mac address changed", false);
batadv_tt_local_add(dev, addr->sa_data, NULL_IFINDEX); batadv_tt_local_add(dev, addr->sa_data, BATADV_NULL_IFINDEX);
} }
memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
...@@ -135,6 +135,7 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -135,6 +135,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
struct hard_iface *primary_if = NULL; struct hard_iface *primary_if = NULL;
struct bcast_packet *bcast_packet; struct bcast_packet *bcast_packet;
struct vlan_ethhdr *vhdr; struct vlan_ethhdr *vhdr;
__be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN);
static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 0x00, static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 0x00,
0x00}; 0x00};
unsigned int header_len = 0; unsigned int header_len = 0;
...@@ -152,11 +153,11 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -152,11 +153,11 @@ static int batadv_interface_tx(struct sk_buff *skb,
vhdr = (struct vlan_ethhdr *)skb->data; vhdr = (struct vlan_ethhdr *)skb->data;
vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK; vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
if (ntohs(vhdr->h_vlan_encapsulated_proto) != ETH_P_BATMAN) if (vhdr->h_vlan_encapsulated_proto != ethertype)
break; break;
/* fall through */ /* fall through */
case ETH_P_BATMAN: case BATADV_ETH_P_BATMAN:
goto dropped; goto dropped;
} }
...@@ -208,8 +209,8 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -208,8 +209,8 @@ static int batadv_interface_tx(struct sk_buff *skb,
goto dropped; goto dropped;
bcast_packet = (struct bcast_packet *)skb->data; bcast_packet = (struct bcast_packet *)skb->data;
bcast_packet->header.version = COMPAT_VERSION; bcast_packet->header.version = BATADV_COMPAT_VERSION;
bcast_packet->header.ttl = TTL; bcast_packet->header.ttl = BATADV_TTL;
/* batman packet type: broadcast */ /* batman packet type: broadcast */
bcast_packet->header.packet_type = BAT_BCAST; bcast_packet->header.packet_type = BAT_BCAST;
...@@ -266,6 +267,7 @@ void batadv_interface_rx(struct net_device *soft_iface, ...@@ -266,6 +267,7 @@ void batadv_interface_rx(struct net_device *soft_iface,
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
struct vlan_ethhdr *vhdr; struct vlan_ethhdr *vhdr;
short vid __maybe_unused = -1; short vid __maybe_unused = -1;
__be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN);
/* check if enough space is available for pulling, and pull */ /* check if enough space is available for pulling, and pull */
if (!pskb_may_pull(skb, hdr_size)) if (!pskb_may_pull(skb, hdr_size))
...@@ -281,11 +283,11 @@ void batadv_interface_rx(struct net_device *soft_iface, ...@@ -281,11 +283,11 @@ void batadv_interface_rx(struct net_device *soft_iface,
vhdr = (struct vlan_ethhdr *)skb->data; vhdr = (struct vlan_ethhdr *)skb->data;
vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK; vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
if (ntohs(vhdr->h_vlan_encapsulated_proto) != ETH_P_BATMAN) if (vhdr->h_vlan_encapsulated_proto != ethertype)
break; break;
/* fall through */ /* fall through */
case ETH_P_BATMAN: case BATADV_ETH_P_BATMAN:
goto dropped; goto dropped;
} }
...@@ -349,7 +351,7 @@ static void batadv_interface_setup(struct net_device *dev) ...@@ -349,7 +351,7 @@ static void batadv_interface_setup(struct net_device *dev)
*/ */
dev->mtu = ETH_DATA_LEN; dev->mtu = ETH_DATA_LEN;
/* reserve more space in the skbuff for our header */ /* reserve more space in the skbuff for our header */
dev->hard_header_len = BAT_HEADER_LEN; dev->hard_header_len = BATADV_HEADER_LEN;
/* generate random address */ /* generate random address */
eth_hw_addr_random(dev); eth_hw_addr_random(dev);
...@@ -392,8 +394,8 @@ struct net_device *batadv_softif_create(const char *name) ...@@ -392,8 +394,8 @@ struct net_device *batadv_softif_create(const char *name)
atomic_set(&bat_priv->hop_penalty, 30); atomic_set(&bat_priv->hop_penalty, 30);
atomic_set(&bat_priv->log_level, 0); atomic_set(&bat_priv->log_level, 0);
atomic_set(&bat_priv->fragmentation, 1); atomic_set(&bat_priv->fragmentation, 1);
atomic_set(&bat_priv->bcast_queue_left, BCAST_QUEUE_LEN); atomic_set(&bat_priv->bcast_queue_left, BATADV_BCAST_QUEUE_LEN);
atomic_set(&bat_priv->batman_queue_left, BATMAN_QUEUE_LEN); atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
atomic_set(&bat_priv->mesh_state, MESH_INACTIVE); atomic_set(&bat_priv->mesh_state, MESH_INACTIVE);
atomic_set(&bat_priv->bcast_seqno, 1); atomic_set(&bat_priv->bcast_seqno, 1);
...@@ -485,7 +487,7 @@ static void batadv_get_drvinfo(struct net_device *dev, ...@@ -485,7 +487,7 @@ 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, BATADV_SOURCE_VERSION);
strcpy(info->fw_version, "N/A"); strcpy(info->fw_version, "N/A");
strcpy(info->bus_info, "batman"); strcpy(info->bus_info, "batman");
} }
......
This diff is collapsed.
...@@ -32,8 +32,8 @@ void batadv_tt_global_add_orig(struct bat_priv *bat_priv, ...@@ -32,8 +32,8 @@ void batadv_tt_global_add_orig(struct bat_priv *bat_priv,
struct orig_node *orig_node, struct orig_node *orig_node,
const unsigned char *tt_buff, int tt_buff_len); const unsigned char *tt_buff, int tt_buff_len);
int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
const unsigned char *addr, uint8_t ttvn, bool roaming, const unsigned char *addr, uint8_t flags,
bool wifi); uint8_t ttvn);
int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset); int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset);
void batadv_tt_global_del_orig(struct bat_priv *bat_priv, void batadv_tt_global_del_orig(struct bat_priv *bat_priv,
struct orig_node *orig_node, struct orig_node *orig_node,
......
...@@ -22,12 +22,11 @@ ...@@ -22,12 +22,11 @@
#include "packet.h" #include "packet.h"
#include "bitarray.h" #include "bitarray.h"
#include <linux/kernel.h>
#define BAT_HEADER_LEN (ETH_HLEN + \ #define BATADV_HEADER_LEN \
((sizeof(struct unicast_packet) > sizeof(struct bcast_packet) ? \ (ETH_HLEN + max(sizeof(struct unicast_packet), \
sizeof(struct unicast_packet) : \ sizeof(struct bcast_packet)))
sizeof(struct bcast_packet))))
struct hard_iface { struct hard_iface {
struct list_head list; struct list_head list;
...@@ -86,7 +85,7 @@ struct orig_node { ...@@ -86,7 +85,7 @@ struct orig_node {
bool tt_poss_change; bool tt_poss_change;
uint32_t last_real_seqno; uint32_t last_real_seqno;
uint8_t last_ttl; uint8_t last_ttl;
DECLARE_BITMAP(bcast_bits, TQ_LOCAL_WINDOW_SIZE); DECLARE_BITMAP(bcast_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
uint32_t last_bcast_seqno; uint32_t last_bcast_seqno;
struct hlist_head neigh_list; struct hlist_head neigh_list;
struct list_head frag_list; struct list_head frag_list;
...@@ -122,13 +121,13 @@ struct neigh_node { ...@@ -122,13 +121,13 @@ struct neigh_node {
struct hlist_node list; struct hlist_node list;
uint8_t addr[ETH_ALEN]; uint8_t addr[ETH_ALEN];
uint8_t real_packet_count; uint8_t real_packet_count;
uint8_t tq_recv[TQ_GLOBAL_WINDOW_SIZE]; uint8_t tq_recv[BATADV_TQ_GLOBAL_WINDOW_SIZE];
uint8_t tq_index; uint8_t tq_index;
uint8_t tq_avg; uint8_t tq_avg;
uint8_t last_ttl; uint8_t last_ttl;
struct list_head bonding_list; struct list_head bonding_list;
unsigned long last_seen; unsigned long last_seen;
DECLARE_BITMAP(real_bits, TQ_LOCAL_WINDOW_SIZE); DECLARE_BITMAP(real_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
atomic_t refcount; atomic_t refcount;
struct rcu_head rcu; struct rcu_head rcu;
struct orig_node *orig_node; struct orig_node *orig_node;
...@@ -210,7 +209,7 @@ struct bat_priv { ...@@ -210,7 +209,7 @@ struct bat_priv {
struct list_head tt_roam_list; struct list_head tt_roam_list;
struct hashtable_t *vis_hash; struct hashtable_t *vis_hash;
#ifdef CONFIG_BATMAN_ADV_BLA #ifdef CONFIG_BATMAN_ADV_BLA
struct bcast_duplist_entry bcast_duplist[DUPLIST_SIZE]; struct bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE];
int bcast_duplist_curr; int bcast_duplist_curr;
struct bla_claim_dst claim_dest; struct bla_claim_dst claim_dest;
#endif #endif
...@@ -349,7 +348,7 @@ struct if_list_entry { ...@@ -349,7 +348,7 @@ struct if_list_entry {
}; };
struct debug_log { struct debug_log {
char log_buff[LOG_BUF_LEN]; char log_buff[BATADV_LOG_BUF_LEN];
unsigned long log_start; unsigned long log_start;
unsigned long log_end; unsigned long log_end;
spinlock_t lock; /* protects log_buff, log_start and log_end */ spinlock_t lock; /* protects log_buff, log_start and log_end */
......
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
#include "hard-interface.h" #include "hard-interface.h"
static struct sk_buff *frag_merge_packet(struct list_head *head, static struct sk_buff *
batadv_frag_merge_packet(struct list_head *head,
struct frag_packet_list_entry *tfp, struct frag_packet_list_entry *tfp,
struct sk_buff *skb) struct sk_buff *skb)
{ {
...@@ -75,7 +76,8 @@ static struct sk_buff *frag_merge_packet(struct list_head *head, ...@@ -75,7 +76,8 @@ static struct sk_buff *frag_merge_packet(struct list_head *head,
return NULL; return NULL;
} }
static void frag_create_entry(struct list_head *head, struct sk_buff *skb) static void batadv_frag_create_entry(struct list_head *head,
struct sk_buff *skb)
{ {
struct frag_packet_list_entry *tfp; struct frag_packet_list_entry *tfp;
struct unicast_frag_packet *up = struct unicast_frag_packet *up =
...@@ -91,12 +93,12 @@ static void frag_create_entry(struct list_head *head, struct sk_buff *skb) ...@@ -91,12 +93,12 @@ static void frag_create_entry(struct list_head *head, struct sk_buff *skb)
return; return;
} }
static int frag_create_buffer(struct list_head *head) static int batadv_frag_create_buffer(struct list_head *head)
{ {
int i; int i;
struct frag_packet_list_entry *tfp; struct frag_packet_list_entry *tfp;
for (i = 0; i < FRAG_BUFFER_SIZE; i++) { for (i = 0; i < BATADV_FRAG_BUFFER_SIZE; i++) {
tfp = kmalloc(sizeof(*tfp), GFP_ATOMIC); tfp = kmalloc(sizeof(*tfp), GFP_ATOMIC);
if (!tfp) { if (!tfp) {
batadv_frag_list_free(head); batadv_frag_list_free(head);
...@@ -111,7 +113,8 @@ static int frag_create_buffer(struct list_head *head) ...@@ -111,7 +113,8 @@ static int frag_create_buffer(struct list_head *head)
return 0; return 0;
} }
static struct frag_packet_list_entry *frag_search_packet(struct list_head *head, static struct frag_packet_list_entry *
batadv_frag_search_packet(struct list_head *head,
const struct unicast_frag_packet *up) const struct unicast_frag_packet *up)
{ {
struct frag_packet_list_entry *tfp; struct frag_packet_list_entry *tfp;
...@@ -188,22 +191,22 @@ int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv, ...@@ -188,22 +191,22 @@ int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
orig_node->last_frag_packet = jiffies; orig_node->last_frag_packet = jiffies;
if (list_empty(&orig_node->frag_list) && if (list_empty(&orig_node->frag_list) &&
frag_create_buffer(&orig_node->frag_list)) { batadv_frag_create_buffer(&orig_node->frag_list)) {
pr_debug("couldn't create frag buffer\n"); pr_debug("couldn't create frag buffer\n");
goto out; goto out;
} }
tmp_frag_entry = frag_search_packet(&orig_node->frag_list, tmp_frag_entry = batadv_frag_search_packet(&orig_node->frag_list,
unicast_packet); unicast_packet);
if (!tmp_frag_entry) { if (!tmp_frag_entry) {
frag_create_entry(&orig_node->frag_list, skb); batadv_frag_create_entry(&orig_node->frag_list, skb);
ret = NET_RX_SUCCESS; ret = NET_RX_SUCCESS;
goto out; goto out;
} }
*new_skb = frag_merge_packet(&orig_node->frag_list, tmp_frag_entry, *new_skb = batadv_frag_merge_packet(&orig_node->frag_list,
skb); tmp_frag_entry, skb);
/* if not, merge failed */ /* if not, merge failed */
if (*new_skb) if (*new_skb)
ret = NET_RX_SUCCESS; ret = NET_RX_SUCCESS;
...@@ -250,7 +253,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, ...@@ -250,7 +253,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
memcpy(frag1, &tmp_uc, sizeof(tmp_uc)); memcpy(frag1, &tmp_uc, sizeof(tmp_uc));
frag1->header.ttl--; frag1->header.ttl--;
frag1->header.version = COMPAT_VERSION; frag1->header.version = BATADV_COMPAT_VERSION;
frag1->header.packet_type = BAT_UNICAST_FRAG; frag1->header.packet_type = BAT_UNICAST_FRAG;
memcpy(frag1->orig, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(frag1->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
...@@ -316,11 +319,11 @@ int batadv_unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv) ...@@ -316,11 +319,11 @@ int batadv_unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
unicast_packet = (struct unicast_packet *)skb->data; unicast_packet = (struct unicast_packet *)skb->data;
unicast_packet->header.version = COMPAT_VERSION; unicast_packet->header.version = BATADV_COMPAT_VERSION;
/* batman packet type: unicast */ /* batman packet type: unicast */
unicast_packet->header.packet_type = BAT_UNICAST; unicast_packet->header.packet_type = BAT_UNICAST;
/* set unicast ttl */ /* set unicast ttl */
unicast_packet->header.ttl = TTL; unicast_packet->header.ttl = BATADV_TTL;
/* copy the destination for faster routing */ /* copy the destination for faster routing */
memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN); memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
/* set the destination tt version number */ /* set the destination tt version number */
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
#include "packet.h" #include "packet.h"
#define FRAG_TIMEOUT 10000 /* purge frag list entries after time in ms */ #define BATADV_FRAG_TIMEOUT 10000 /* purge frag list entries after time in ms */
#define FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */ #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 bat_priv *bat_priv,
struct sk_buff **new_skb); struct sk_buff **new_skb);
......
This diff is collapsed.
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#define _NET_BATMAN_ADV_VIS_H_ #define _NET_BATMAN_ADV_VIS_H_
/* timeout of vis packets in miliseconds */ /* timeout of vis packets in miliseconds */
#define VIS_TIMEOUT 200000 #define BATADV_VIS_TIMEOUT 200000
int batadv_vis_seq_print_text(struct seq_file *seq, void *offset); int batadv_vis_seq_print_text(struct seq_file *seq, void *offset);
void batadv_receive_server_sync_packet(struct bat_priv *bat_priv, void batadv_receive_server_sync_packet(struct bat_priv *bat_priv,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment