aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2012-06-03 16:19:17 -0400
committerAntonio Quartulli <ordex@autistici.org>2012-06-28 02:45:05 -0400
commit42d0b044b7c9e5821f1bf3e2b4ea7861417c11c2 (patch)
tree3dedf87facfbc4dd0392256e93088c18509e1391
parentedbf7ff72312afcc502014ccf3c72c49fa55722a (diff)
batman-adv: Prefix main defines with BATADV_
Reported-by: Martin Hundebøll <martin@hundeboll.net> Signed-off-by: Sven Eckelmann <sven@narfation.org>
-rw-r--r--net/batman-adv/bat_debugfs.c2
-rw-r--r--net/batman-adv/bat_iv_ogm.c103
-rw-r--r--net/batman-adv/bat_sysfs.c7
-rw-r--r--net/batman-adv/bitarray.c20
-rw-r--r--net/batman-adv/bitarray.h4
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c20
-rw-r--r--net/batman-adv/gateway_client.c18
-rw-r--r--net/batman-adv/hard-interface.c2
-rw-r--r--net/batman-adv/main.c13
-rw-r--r--net/batman-adv/main.h81
-rw-r--r--net/batman-adv/originator.c32
-rw-r--r--net/batman-adv/ring_buffer.c4
-rw-r--r--net/batman-adv/routing.c20
-rw-r--r--net/batman-adv/soft-interface.c10
-rw-r--r--net/batman-adv/translation-table.c87
-rw-r--r--net/batman-adv/types.h10
-rw-r--r--net/batman-adv/unicast.c2
-rw-r--r--net/batman-adv/vis.c11
18 files changed, 244 insertions, 202 deletions
diff --git a/net/batman-adv/bat_debugfs.c b/net/batman-adv/bat_debugfs.c
index f9af65ea42f..4dcda43d682 100644
--- a/net/batman-adv/bat_debugfs.c
+++ b/net/batman-adv/bat_debugfs.c
@@ -38,7 +38,7 @@ static struct dentry *batadv_debugfs;
38#define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1) 38#define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1)
39#define BATADV_LOG_BUFF(idx) (debug_log->log_buff[(idx) & BATADV_LOG_BUFF_MASK]) 39#define BATADV_LOG_BUFF(idx) (debug_log->log_buff[(idx) & BATADV_LOG_BUFF_MASK])
40 40
41static int batadv_log_buff_len = LOG_BUF_LEN; 41static int batadv_log_buff_len = BATADV_LOG_BUF_LEN;
42 42
43static void batadv_emit_log_char(struct debug_log *debug_log, char c) 43static void batadv_emit_log_char(struct debug_log *debug_log, char c)
44{ 44{
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 245bb2d7647..bbe0f123d2a 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -74,8 +74,8 @@ static int batadv_iv_ogm_iface_enable(struct hard_iface *hard_iface)
74 batman_ogm_packet->header.packet_type = BAT_IV_OGM; 74 batman_ogm_packet->header.packet_type = BAT_IV_OGM;
75 batman_ogm_packet->header.version = BATADV_COMPAT_VERSION; 75 batman_ogm_packet->header.version = BATADV_COMPAT_VERSION;
76 batman_ogm_packet->header.ttl = 2; 76 batman_ogm_packet->header.ttl = 2;
77 batman_ogm_packet->flags = NO_FLAGS; 77 batman_ogm_packet->flags = BATADV_NO_FLAGS;
78 batman_ogm_packet->tq = TQ_MAX_VALUE; 78 batman_ogm_packet->tq = BATADV_TQ_MAX_VALUE;
79 batman_ogm_packet->tt_num_changes = 0; 79 batman_ogm_packet->tt_num_changes = 0;
80 batman_ogm_packet->ttvn = 0; 80 batman_ogm_packet->ttvn = 0;
81 81
@@ -108,29 +108,37 @@ static void batadv_iv_ogm_primary_iface_set(struct hard_iface *hard_iface)
108 108
109 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; 109 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff;
110 batman_ogm_packet->flags = PRIMARIES_FIRST_HOP; 110 batman_ogm_packet->flags = PRIMARIES_FIRST_HOP;
111 batman_ogm_packet->header.ttl = TTL; 111 batman_ogm_packet->header.ttl = BATADV_TTL;
112} 112}
113 113
114/* when do we schedule our own ogm to be sent */ 114/* when do we schedule our own ogm to be sent */
115static unsigned long 115static unsigned long
116batadv_iv_ogm_emit_send_time(const struct bat_priv *bat_priv) 116batadv_iv_ogm_emit_send_time(const struct bat_priv *bat_priv)
117{ 117{
118 return jiffies + msecs_to_jiffies( 118 unsigned int msecs;
119 atomic_read(&bat_priv->orig_interval) - 119
120 JITTER + (random32() % 2*JITTER)); 120 msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER;
121 msecs += (random32() % 2 * BATADV_JITTER);
122
123 return jiffies + msecs_to_jiffies(msecs);
121} 124}
122 125
123/* when do we schedule a ogm packet to be sent */ 126/* when do we schedule a ogm packet to be sent */
124static unsigned long batadv_iv_ogm_fwd_send_time(void) 127static unsigned long batadv_iv_ogm_fwd_send_time(void)
125{ 128{
126 return jiffies + msecs_to_jiffies(random32() % (JITTER/2)); 129 return jiffies + msecs_to_jiffies(random32() % (BATADV_JITTER / 2));
127} 130}
128 131
129/* apply hop penalty for a normal link */ 132/* apply hop penalty for a normal link */
130static uint8_t batadv_hop_penalty(uint8_t tq, const struct bat_priv *bat_priv) 133static uint8_t batadv_hop_penalty(uint8_t tq, const struct bat_priv *bat_priv)
131{ 134{
132 int hop_penalty = atomic_read(&bat_priv->hop_penalty); 135 int hop_penalty = atomic_read(&bat_priv->hop_penalty);
133 return (tq * (TQ_MAX_VALUE - hop_penalty)) / (TQ_MAX_VALUE); 136 int new_tq;
137
138 new_tq = tq * (BATADV_TQ_MAX_VALUE - hop_penalty);
139 new_tq /= BATADV_TQ_MAX_VALUE;
140
141 return new_tq;
134} 142}
135 143
136/* is there another aggregated packet here? */ 144/* is there another aggregated packet here? */
@@ -143,7 +151,7 @@ static int batadv_iv_ogm_aggr_packet(int buff_pos, int packet_len,
143 next_buff_pos += batadv_tt_len(tt_num_changes); 151 next_buff_pos += batadv_tt_len(tt_num_changes);
144 152
145 return (next_buff_pos <= packet_len) && 153 return (next_buff_pos <= packet_len) &&
146 (next_buff_pos <= MAX_AGGREGATION_BYTES); 154 (next_buff_pos <= BATADV_MAX_AGGREGATION_BYTES);
147} 155}
148 156
149/* send a batman ogm to a given interface */ 157/* send a batman ogm to a given interface */
@@ -290,8 +298,11 @@ batadv_iv_ogm_can_aggregate(const struct batman_ogm_packet *new_bat_ogm_packet,
290 int aggregated_bytes = forw_packet->packet_len + packet_len; 298 int aggregated_bytes = forw_packet->packet_len + packet_len;
291 struct hard_iface *primary_if = NULL; 299 struct hard_iface *primary_if = NULL;
292 bool res = false; 300 bool res = false;
301 unsigned long aggregation_end_time;
293 302
294 batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data; 303 batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data;
304 aggregation_end_time = send_time;
305 aggregation_end_time += msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS);
295 306
296 /* we can aggregate the current packet to this aggregated packet 307 /* we can aggregate the current packet to this aggregated packet
297 * if: 308 * if:
@@ -301,9 +312,8 @@ batadv_iv_ogm_can_aggregate(const struct batman_ogm_packet *new_bat_ogm_packet,
301 * MAX_AGGREGATION_BYTES 312 * MAX_AGGREGATION_BYTES
302 */ 313 */
303 if (time_before(send_time, forw_packet->send_time) && 314 if (time_before(send_time, forw_packet->send_time) &&
304 time_after_eq(send_time + msecs_to_jiffies(MAX_AGGREGATION_MS), 315 time_after_eq(aggregation_end_time, forw_packet->send_time) &&
305 forw_packet->send_time) && 316 (aggregated_bytes <= BATADV_MAX_AGGREGATION_BYTES)) {
306 (aggregated_bytes <= MAX_AGGREGATION_BYTES)) {
307 317
308 /* check aggregation compatibility 318 /* check aggregation compatibility
309 * -> direct link packets are broadcasted on 319 * -> direct link packets are broadcasted on
@@ -367,6 +377,7 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
367 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 377 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
368 struct forw_packet *forw_packet_aggr; 378 struct forw_packet *forw_packet_aggr;
369 unsigned char *skb_buff; 379 unsigned char *skb_buff;
380 unsigned int skb_size;
370 381
371 if (!atomic_inc_not_zero(&if_incoming->refcount)) 382 if (!atomic_inc_not_zero(&if_incoming->refcount))
372 return; 383 return;
@@ -388,12 +399,12 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
388 } 399 }
389 400
390 if ((atomic_read(&bat_priv->aggregated_ogms)) && 401 if ((atomic_read(&bat_priv->aggregated_ogms)) &&
391 (packet_len < MAX_AGGREGATION_BYTES)) 402 (packet_len < BATADV_MAX_AGGREGATION_BYTES))
392 forw_packet_aggr->skb = dev_alloc_skb(MAX_AGGREGATION_BYTES + 403 skb_size = BATADV_MAX_AGGREGATION_BYTES + ETH_HLEN;
393 ETH_HLEN);
394 else 404 else
395 forw_packet_aggr->skb = dev_alloc_skb(packet_len + ETH_HLEN); 405 skb_size = packet_len + ETH_HLEN;
396 406
407 forw_packet_aggr->skb = dev_alloc_skb(skb_size);
397 if (!forw_packet_aggr->skb) { 408 if (!forw_packet_aggr->skb) {
398 if (!own_packet) 409 if (!own_packet)
399 atomic_inc(&bat_priv->batman_queue_left); 410 atomic_inc(&bat_priv->batman_queue_left);
@@ -411,7 +422,7 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
411 forw_packet_aggr->own = own_packet; 422 forw_packet_aggr->own = own_packet;
412 forw_packet_aggr->if_incoming = if_incoming; 423 forw_packet_aggr->if_incoming = if_incoming;
413 forw_packet_aggr->num_packets = 0; 424 forw_packet_aggr->num_packets = 0;
414 forw_packet_aggr->direct_link_flags = NO_FLAGS; 425 forw_packet_aggr->direct_link_flags = BATADV_NO_FLAGS;
415 forw_packet_aggr->send_time = send_time; 426 forw_packet_aggr->send_time = send_time;
416 427
417 /* save packet direct link flag status */ 428 /* save packet direct link flag status */
@@ -466,9 +477,11 @@ static void batadv_iv_ogm_queue_add(struct bat_priv *bat_priv,
466 struct hlist_node *tmp_node; 477 struct hlist_node *tmp_node;
467 struct batman_ogm_packet *batman_ogm_packet; 478 struct batman_ogm_packet *batman_ogm_packet;
468 bool direct_link; 479 bool direct_link;
480 unsigned long max_aggregation_jiffies;
469 481
470 batman_ogm_packet = (struct batman_ogm_packet *)packet_buff; 482 batman_ogm_packet = (struct batman_ogm_packet *)packet_buff;
471 direct_link = batman_ogm_packet->flags & DIRECTLINK ? 1 : 0; 483 direct_link = batman_ogm_packet->flags & DIRECTLINK ? 1 : 0;
484 max_aggregation_jiffies = msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS);
472 485
473 /* find position for the packet in the forward queue */ 486 /* find position for the packet in the forward queue */
474 spin_lock_bh(&bat_priv->forw_bat_list_lock); 487 spin_lock_bh(&bat_priv->forw_bat_list_lock);
@@ -498,9 +511,8 @@ static void batadv_iv_ogm_queue_add(struct bat_priv *bat_priv,
498 * we hold it back for a while, so that it might be aggregated 511 * we hold it back for a while, so that it might be aggregated
499 * later on 512 * later on
500 */ 513 */
501 if ((!own_packet) && 514 if (!own_packet && atomic_read(&bat_priv->aggregated_ogms))
502 (atomic_read(&bat_priv->aggregated_ogms))) 515 send_time += max_aggregation_jiffies;
503 send_time += msecs_to_jiffies(MAX_AGGREGATION_MS);
504 516
505 batadv_iv_ogm_aggregate_new(packet_buff, packet_len, 517 batadv_iv_ogm_aggregate_new(packet_buff, packet_len,
506 send_time, direct_link, 518 send_time, direct_link,
@@ -603,7 +615,7 @@ static void batadv_iv_ogm_schedule(struct hard_iface *hard_iface)
603 batman_ogm_packet->gw_flags = 615 batman_ogm_packet->gw_flags =
604 (uint8_t)atomic_read(&bat_priv->gw_bandwidth); 616 (uint8_t)atomic_read(&bat_priv->gw_bandwidth);
605 else 617 else
606 batman_ogm_packet->gw_flags = NO_FLAGS; 618 batman_ogm_packet->gw_flags = BATADV_NO_FLAGS;
607 619
608 batadv_slide_own_bcast_window(hard_iface); 620 batadv_slide_own_bcast_window(hard_iface);
609 batadv_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff, 621 batadv_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff,
@@ -772,8 +784,10 @@ static int batadv_iv_ogm_calc_tq(struct orig_node *orig_node,
772 struct neigh_node *neigh_node = NULL, *tmp_neigh_node; 784 struct neigh_node *neigh_node = NULL, *tmp_neigh_node;
773 struct hlist_node *node; 785 struct hlist_node *node;
774 uint8_t total_count; 786 uint8_t total_count;
775 uint8_t orig_eq_count, neigh_rq_count, tq_own; 787 uint8_t orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own;
776 int tq_asym_penalty, ret = 0; 788 unsigned int neigh_rq_inv_cube, neigh_rq_max_cube;
789 int tq_asym_penalty, inv_asym_penalty, ret = 0;
790 unsigned int combined_tq;
777 791
778 /* find corresponding one hop neighbor */ 792 /* find corresponding one hop neighbor */
779 rcu_read_lock(); 793 rcu_read_lock();
@@ -824,32 +838,33 @@ static int batadv_iv_ogm_calc_tq(struct orig_node *orig_node,
824 /* if we have too few packets (too less data) we set tq_own to zero 838 /* if we have too few packets (too less data) we set tq_own to zero
825 * if we receive too few packets it is not considered bidirectional 839 * if we receive too few packets it is not considered bidirectional
826 */ 840 */
827 if ((total_count < TQ_LOCAL_BIDRECT_SEND_MINIMUM) || 841 if (total_count < BATADV_TQ_LOCAL_BIDRECT_SEND_MINIMUM ||
828 (neigh_rq_count < TQ_LOCAL_BIDRECT_RECV_MINIMUM)) 842 neigh_rq_count < BATADV_TQ_LOCAL_BIDRECT_RECV_MINIMUM)
829 tq_own = 0; 843 tq_own = 0;
830 else 844 else
831 /* neigh_node->real_packet_count is never zero as we 845 /* neigh_node->real_packet_count is never zero as we
832 * only purge old information when getting new 846 * only purge old information when getting new
833 * information 847 * information
834 */ 848 */
835 tq_own = (TQ_MAX_VALUE * total_count) / neigh_rq_count; 849 tq_own = (BATADV_TQ_MAX_VALUE * total_count) / neigh_rq_count;
836 850
837 /* 1 - ((1-x) ** 3), normalized to TQ_MAX_VALUE this does 851 /* 1 - ((1-x) ** 3), normalized to TQ_MAX_VALUE this does
838 * affect the nearly-symmetric links only a little, but 852 * affect the nearly-symmetric links only a little, but
839 * punishes asymmetric links more. This will give a value 853 * punishes asymmetric links more. This will give a value
840 * between 0 and TQ_MAX_VALUE 854 * between 0 and TQ_MAX_VALUE
841 */ 855 */
842 tq_asym_penalty = TQ_MAX_VALUE - (TQ_MAX_VALUE * 856 neigh_rq_inv = BATADV_TQ_LOCAL_WINDOW_SIZE - neigh_rq_count;
843 (TQ_LOCAL_WINDOW_SIZE - neigh_rq_count) * 857 neigh_rq_inv_cube = neigh_rq_inv * neigh_rq_inv * neigh_rq_inv;
844 (TQ_LOCAL_WINDOW_SIZE - neigh_rq_count) * 858 neigh_rq_max_cube = BATADV_TQ_LOCAL_WINDOW_SIZE *
845 (TQ_LOCAL_WINDOW_SIZE - neigh_rq_count)) / 859 BATADV_TQ_LOCAL_WINDOW_SIZE *
846 (TQ_LOCAL_WINDOW_SIZE * 860 BATADV_TQ_LOCAL_WINDOW_SIZE;
847 TQ_LOCAL_WINDOW_SIZE * 861 inv_asym_penalty = BATADV_TQ_MAX_VALUE * neigh_rq_inv_cube;
848 TQ_LOCAL_WINDOW_SIZE); 862 inv_asym_penalty /= neigh_rq_max_cube;
849 863 tq_asym_penalty = BATADV_TQ_MAX_VALUE - inv_asym_penalty;
850 batman_ogm_packet->tq = ((batman_ogm_packet->tq * tq_own 864
851 * tq_asym_penalty) / 865 combined_tq = batman_ogm_packet->tq * tq_own * tq_asym_penalty;
852 (TQ_MAX_VALUE * TQ_MAX_VALUE)); 866 combined_tq /= BATADV_TQ_MAX_VALUE * BATADV_TQ_MAX_VALUE;
867 batman_ogm_packet->tq = combined_tq;
853 868
854 batadv_dbg(DBG_BATMAN, bat_priv, 869 batadv_dbg(DBG_BATMAN, bat_priv,
855 "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n", 870 "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n",
@@ -860,7 +875,7 @@ static int batadv_iv_ogm_calc_tq(struct orig_node *orig_node,
860 /* if link has the minimum required transmission quality 875 /* if link has the minimum required transmission quality
861 * consider it bidirectional 876 * consider it bidirectional
862 */ 877 */
863 if (batman_ogm_packet->tq >= TQ_TOTAL_BIDRECT_LIMIT) 878 if (batman_ogm_packet->tq >= BATADV_TQ_TOTAL_BIDRECT_LIMIT)
864 ret = 1; 879 ret = 1;
865 880
866out: 881out:
@@ -928,7 +943,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
928 943
929 tmp_neigh_node->real_packet_count = 944 tmp_neigh_node->real_packet_count =
930 bitmap_weight(tmp_neigh_node->real_bits, 945 bitmap_weight(tmp_neigh_node->real_bits,
931 TQ_LOCAL_WINDOW_SIZE); 946 BATADV_TQ_LOCAL_WINDOW_SIZE);
932 } 947 }
933 rcu_read_unlock(); 948 rcu_read_unlock();
934 949
@@ -1050,6 +1065,8 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1050 unsigned long *word; 1065 unsigned long *word;
1051 int offset; 1066 int offset;
1052 int32_t bit_pos; 1067 int32_t bit_pos;
1068 int16_t if_num;
1069 uint8_t *weight;
1053 1070
1054 orig_neigh_node = batadv_get_orig_node(bat_priv, 1071 orig_neigh_node = batadv_get_orig_node(bat_priv,
1055 ethhdr->h_source); 1072 ethhdr->h_source);
@@ -1063,15 +1080,17 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1063 if (has_directlink_flag && 1080 if (has_directlink_flag &&
1064 batadv_compare_eth(if_incoming->net_dev->dev_addr, 1081 batadv_compare_eth(if_incoming->net_dev->dev_addr,
1065 batman_ogm_packet->orig)) { 1082 batman_ogm_packet->orig)) {
1066 offset = if_incoming->if_num * NUM_WORDS; 1083 if_num = if_incoming->if_num;
1084 offset = if_num * BATADV_NUM_WORDS;
1067 1085
1068 spin_lock_bh(&orig_neigh_node->ogm_cnt_lock); 1086 spin_lock_bh(&orig_neigh_node->ogm_cnt_lock);
1069 word = &(orig_neigh_node->bcast_own[offset]); 1087 word = &(orig_neigh_node->bcast_own[offset]);
1070 bit_pos = if_incoming_seqno - 2; 1088 bit_pos = if_incoming_seqno - 2;
1071 bit_pos -= ntohl(batman_ogm_packet->seqno); 1089 bit_pos -= ntohl(batman_ogm_packet->seqno);
1072 batadv_set_bit(word, bit_pos); 1090 batadv_set_bit(word, bit_pos);
1073 orig_neigh_node->bcast_own_sum[if_incoming->if_num] = 1091 weight = &orig_neigh_node->bcast_own_sum[if_num];
1074 bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE); 1092 *weight = bitmap_weight(word,
1093 BATADV_TQ_LOCAL_WINDOW_SIZE);
1075 spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock); 1094 spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock);
1076 } 1095 }
1077 1096
diff --git a/net/batman-adv/bat_sysfs.c b/net/batman-adv/bat_sysfs.c
index a6c27f0621a..95d80d1808f 100644
--- a/net/batman-adv/bat_sysfs.c
+++ b/net/batman-adv/bat_sysfs.c
@@ -470,10 +470,11 @@ static BATADV_ATTR(vis_mode, S_IRUGO | S_IWUSR, batadv_show_vis_mode,
470static BATADV_ATTR(routing_algo, S_IRUGO, batadv_show_bat_algo, NULL); 470static BATADV_ATTR(routing_algo, S_IRUGO, batadv_show_bat_algo, NULL);
471static BATADV_ATTR(gw_mode, S_IRUGO | S_IWUSR, batadv_show_gw_mode, 471static BATADV_ATTR(gw_mode, S_IRUGO | S_IWUSR, batadv_show_gw_mode,
472 batadv_store_gw_mode); 472 batadv_store_gw_mode);
473BATADV_ATTR_SIF_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, 473BATADV_ATTR_SIF_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * BATADV_JITTER,
474 INT_MAX, NULL);
475BATADV_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, BATADV_TQ_MAX_VALUE,
474 NULL); 476 NULL);
475BATADV_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, TQ_MAX_VALUE, NULL); 477BATADV_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, BATADV_TQ_MAX_VALUE,
476BATADV_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, TQ_MAX_VALUE,
477 batadv_post_gw_deselect); 478 batadv_post_gw_deselect);
478static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth, 479static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth,
479 batadv_store_gw_bwidth); 480 batadv_store_gw_bwidth);
diff --git a/net/batman-adv/bitarray.c b/net/batman-adv/bitarray.c
index e195b9eed7e..4a009b55089 100644
--- a/net/batman-adv/bitarray.c
+++ b/net/batman-adv/bitarray.c
@@ -25,10 +25,10 @@
25/* shift the packet array by n places. */ 25/* shift the packet array by n places. */
26static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n) 26static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n)
27{ 27{
28 if (n <= 0 || n >= TQ_LOCAL_WINDOW_SIZE) 28 if (n <= 0 || n >= BATADV_TQ_LOCAL_WINDOW_SIZE)
29 return; 29 return;
30 30
31 bitmap_shift_left(seq_bits, seq_bits, n, TQ_LOCAL_WINDOW_SIZE); 31 bitmap_shift_left(seq_bits, seq_bits, n, BATADV_TQ_LOCAL_WINDOW_SIZE);
32} 32}
33 33
34 34
@@ -46,7 +46,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
46 /* sequence number is slightly older. We already got a sequence number 46 /* sequence number is slightly older. We already got a sequence number
47 * higher than this one, so we just mark it. 47 * higher than this one, so we just mark it.
48 */ 48 */
49 if ((seq_num_diff <= 0) && (seq_num_diff > -TQ_LOCAL_WINDOW_SIZE)) { 49 if (seq_num_diff <= 0 && seq_num_diff > -BATADV_TQ_LOCAL_WINDOW_SIZE) {
50 if (set_mark) 50 if (set_mark)
51 batadv_set_bit(seq_bits, -seq_num_diff); 51 batadv_set_bit(seq_bits, -seq_num_diff);
52 return 0; 52 return 0;
@@ -55,7 +55,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
55 /* sequence number is slightly newer, so we shift the window and 55 /* sequence number is slightly newer, so we shift the window and
56 * set the mark if required 56 * set the mark if required
57 */ 57 */
58 if ((seq_num_diff > 0) && (seq_num_diff < TQ_LOCAL_WINDOW_SIZE)) { 58 if (seq_num_diff > 0 && seq_num_diff < BATADV_TQ_LOCAL_WINDOW_SIZE) {
59 batadv_bitmap_shift_left(seq_bits, seq_num_diff); 59 batadv_bitmap_shift_left(seq_bits, seq_num_diff);
60 60
61 if (set_mark) 61 if (set_mark)
@@ -64,12 +64,12 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
64 } 64 }
65 65
66 /* sequence number is much newer, probably missed a lot of packets */ 66 /* sequence number is much newer, probably missed a lot of packets */
67 if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) && 67 if (seq_num_diff >= BATADV_TQ_LOCAL_WINDOW_SIZE &&
68 (seq_num_diff < EXPECTED_SEQNO_RANGE)) { 68 seq_num_diff < BATADV_EXPECTED_SEQNO_RANGE) {
69 batadv_dbg(DBG_BATMAN, bat_priv, 69 batadv_dbg(DBG_BATMAN, bat_priv,
70 "We missed a lot of packets (%i) !\n", 70 "We missed a lot of packets (%i) !\n",
71 seq_num_diff - 1); 71 seq_num_diff - 1);
72 bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE); 72 bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
73 if (set_mark) 73 if (set_mark)
74 batadv_set_bit(seq_bits, 0); 74 batadv_set_bit(seq_bits, 0);
75 return 1; 75 return 1;
@@ -80,13 +80,13 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
80 * packet should be dropped without calling this function if the 80 * packet should be dropped without calling this function if the
81 * seqno window is protected. 81 * seqno window is protected.
82 */ 82 */
83 if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || 83 if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE ||
84 (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { 84 seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) {
85 85
86 batadv_dbg(DBG_BATMAN, bat_priv, 86 batadv_dbg(DBG_BATMAN, bat_priv,
87 "Other host probably restarted!\n"); 87 "Other host probably restarted!\n");
88 88
89 bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE); 89 bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
90 if (set_mark) 90 if (set_mark)
91 batadv_set_bit(seq_bits, 0); 91 batadv_set_bit(seq_bits, 0);
92 92
diff --git a/net/batman-adv/bitarray.h b/net/batman-adv/bitarray.h
index 7954ba81cec..a081ce1c051 100644
--- a/net/batman-adv/bitarray.h
+++ b/net/batman-adv/bitarray.h
@@ -29,7 +29,7 @@ static inline int batadv_test_bit(const unsigned long *seq_bits,
29 int32_t diff; 29 int32_t diff;
30 30
31 diff = last_seqno - curr_seqno; 31 diff = last_seqno - curr_seqno;
32 if (diff < 0 || diff >= TQ_LOCAL_WINDOW_SIZE) 32 if (diff < 0 || diff >= BATADV_TQ_LOCAL_WINDOW_SIZE)
33 return 0; 33 return 0;
34 else 34 else
35 return test_bit(diff, seq_bits); 35 return test_bit(diff, seq_bits);
@@ -39,7 +39,7 @@ static inline int batadv_test_bit(const unsigned long *seq_bits,
39static inline void batadv_set_bit(unsigned long *seq_bits, int32_t n) 39static inline void batadv_set_bit(unsigned long *seq_bits, int32_t n)
40{ 40{
41 /* if too old, just drop it */ 41 /* if too old, just drop it */
42 if (n < 0 || n >= TQ_LOCAL_WINDOW_SIZE) 42 if (n < 0 || n >= BATADV_TQ_LOCAL_WINDOW_SIZE)
43 return; 43 return;
44 44
45 set_bit(n, seq_bits); /* turn the position on */ 45 set_bit(n, seq_bits); /* turn the position on */
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 42b8a207925..db20b688ee2 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -949,7 +949,7 @@ static void batadv_bla_purge_backbone_gw(struct bat_priv *bat_priv, int now)
949 if (now) 949 if (now)
950 goto purge_now; 950 goto purge_now;
951 if (!batadv_has_timed_out(backbone_gw->lasttime, 951 if (!batadv_has_timed_out(backbone_gw->lasttime,
952 BLA_BACKBONE_TIMEOUT)) 952 BATADV_BLA_BACKBONE_TIMEOUT))
953 continue; 953 continue;
954 954
955 batadv_dbg(DBG_BLA, backbone_gw->bat_priv, 955 batadv_dbg(DBG_BLA, backbone_gw->bat_priv,
@@ -1001,7 +1001,7 @@ static void batadv_bla_purge_claims(struct bat_priv *bat_priv,
1001 primary_if->net_dev->dev_addr)) 1001 primary_if->net_dev->dev_addr))
1002 continue; 1002 continue;
1003 if (!batadv_has_timed_out(claim->lasttime, 1003 if (!batadv_has_timed_out(claim->lasttime,
1004 BLA_CLAIM_TIMEOUT)) 1004 BATADV_BLA_CLAIM_TIMEOUT))
1005 continue; 1005 continue;
1006 1006
1007 batadv_dbg(DBG_BLA, bat_priv, 1007 batadv_dbg(DBG_BLA, bat_priv,
@@ -1075,7 +1075,7 @@ static void batadv_bla_start_timer(struct bat_priv *bat_priv)
1075{ 1075{
1076 INIT_DELAYED_WORK(&bat_priv->bla_work, batadv_bla_periodic_work); 1076 INIT_DELAYED_WORK(&bat_priv->bla_work, batadv_bla_periodic_work);
1077 queue_delayed_work(batadv_event_workqueue, &bat_priv->bla_work, 1077 queue_delayed_work(batadv_event_workqueue, &bat_priv->bla_work,
1078 msecs_to_jiffies(BLA_PERIOD_LENGTH)); 1078 msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
1079} 1079}
1080 1080
1081/* periodic work to do: 1081/* periodic work to do:
@@ -1162,9 +1162,9 @@ int batadv_bla_init(struct bat_priv *bat_priv)
1162 } 1162 }
1163 1163
1164 /* initialize the duplicate list */ 1164 /* initialize the duplicate list */
1165 for (i = 0; i < DUPLIST_SIZE; i++) 1165 for (i = 0; i < BATADV_DUPLIST_SIZE; i++)
1166 bat_priv->bcast_duplist[i].entrytime = 1166 bat_priv->bcast_duplist[i].entrytime =
1167 jiffies - msecs_to_jiffies(DUPLIST_TIMEOUT); 1167 jiffies - msecs_to_jiffies(BATADV_DUPLIST_TIMEOUT);
1168 bat_priv->bcast_duplist_curr = 0; 1168 bat_priv->bcast_duplist_curr = 0;
1169 1169
1170 if (bat_priv->claim_hash) 1170 if (bat_priv->claim_hash)
@@ -1216,14 +1216,15 @@ int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
1216 /* calculate the crc ... */ 1216 /* calculate the crc ... */
1217 crc = crc16(0, content, length); 1217 crc = crc16(0, content, length);
1218 1218
1219 for (i = 0 ; i < DUPLIST_SIZE; i++) { 1219 for (i = 0; i < BATADV_DUPLIST_SIZE; i++) {
1220 curr = (bat_priv->bcast_duplist_curr + i) % DUPLIST_SIZE; 1220 curr = (bat_priv->bcast_duplist_curr + i) % BATADV_DUPLIST_SIZE;
1221 entry = &bat_priv->bcast_duplist[curr]; 1221 entry = &bat_priv->bcast_duplist[curr];
1222 1222
1223 /* we can stop searching if the entry is too old ; 1223 /* we can stop searching if the entry is too old ;
1224 * later entries will be even older 1224 * later entries will be even older
1225 */ 1225 */
1226 if (batadv_has_timed_out(entry->entrytime, DUPLIST_TIMEOUT)) 1226 if (batadv_has_timed_out(entry->entrytime,
1227 BATADV_DUPLIST_TIMEOUT))
1227 break; 1228 break;
1228 1229
1229 if (entry->crc != crc) 1230 if (entry->crc != crc)
@@ -1238,7 +1239,8 @@ int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
1238 return 1; 1239 return 1;
1239 } 1240 }
1240 /* not found, add a new entry (overwrite the oldest entry) */ 1241 /* not found, add a new entry (overwrite the oldest entry) */
1241 curr = (bat_priv->bcast_duplist_curr + DUPLIST_SIZE - 1) % DUPLIST_SIZE; 1242 curr = (bat_priv->bcast_duplist_curr + BATADV_DUPLIST_SIZE - 1);
1243 curr %= BATADV_DUPLIST_SIZE;
1242 entry = &bat_priv->bcast_duplist[curr]; 1244 entry = &bat_priv->bcast_duplist[curr];
1243 entry->crc = crc; 1245 entry->crc = crc;
1244 entry->entrytime = jiffies; 1246 entry->entrytime = jiffies;
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 3916e90ff6e..5fc162c8425 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -138,8 +138,8 @@ static struct gw_node *batadv_gw_get_best_gw_node(struct bat_priv *bat_priv)
138 138
139 tmp_gw_factor = (router->tq_avg * router->tq_avg * 139 tmp_gw_factor = (router->tq_avg * router->tq_avg *
140 down * 100 * 100) / 140 down * 100 * 100) /
141 (TQ_LOCAL_WINDOW_SIZE * 141 (BATADV_TQ_LOCAL_WINDOW_SIZE *
142 TQ_LOCAL_WINDOW_SIZE * 64); 142 BATADV_TQ_LOCAL_WINDOW_SIZE * 64);
143 143
144 if ((tmp_gw_factor > max_gw_factor) || 144 if ((tmp_gw_factor > max_gw_factor) ||
145 ((tmp_gw_factor == max_gw_factor) && 145 ((tmp_gw_factor == max_gw_factor) &&
@@ -354,7 +354,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv,
354 354
355 gw_node->deleted = 0; 355 gw_node->deleted = 0;
356 356
357 if (new_gwflags == NO_FLAGS) { 357 if (new_gwflags == BATADV_NO_FLAGS) {
358 gw_node->deleted = jiffies; 358 gw_node->deleted = jiffies;
359 batadv_dbg(DBG_BATMAN, bat_priv, 359 batadv_dbg(DBG_BATMAN, bat_priv,
360 "Gateway %pM removed from gateway list\n", 360 "Gateway %pM removed from gateway list\n",
@@ -367,7 +367,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv,
367 goto unlock; 367 goto unlock;
368 } 368 }
369 369
370 if (new_gwflags == NO_FLAGS) 370 if (new_gwflags == BATADV_NO_FLAGS)
371 goto unlock; 371 goto unlock;
372 372
373 batadv_gw_node_add(bat_priv, orig_node, new_gwflags); 373 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{ 392{
393 struct gw_node *gw_node, *curr_gw; 393 struct gw_node *gw_node, *curr_gw;
394 struct hlist_node *node, *node_tmp; 394 struct hlist_node *node, *node_tmp;
395 unsigned long timeout = msecs_to_jiffies(2 * PURGE_TIMEOUT); 395 unsigned long timeout = msecs_to_jiffies(2 * BATADV_PURGE_TIMEOUT);
396 int do_deselect = 0; 396 int do_deselect = 0;
397 397
398 curr_gw = batadv_gw_get_selected_gw_node(bat_priv); 398 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 484
485 seq_printf(seq, 485 seq_printf(seq,
486 " %-12s (%s/%i) %17s [%10s]: gw_class ... [B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", 486 " %-12s (%s/%i) %17s [%10s]: gw_class ... [B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n",
487 "Gateway", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", 487 "Gateway", "#", BATADV_TQ_MAX_VALUE, "Nexthop", "outgoingIF",
488 SOURCE_VERSION, primary_if->net_dev->name, 488 BATADV_SOURCE_VERSION, primary_if->net_dev->name,
489 primary_if->net_dev->dev_addr, net_dev->name); 489 primary_if->net_dev->dev_addr, net_dev->name);
490 490
491 rcu_read_lock(); 491 rcu_read_lock();
@@ -667,7 +667,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
667 /* If we are a GW then we are our best GW. We can artificially 667 /* If we are a GW then we are our best GW. We can artificially
668 * set the tq towards ourself as the maximum value 668 * set the tq towards ourself as the maximum value
669 */ 669 */
670 curr_tq_avg = TQ_MAX_VALUE; 670 curr_tq_avg = BATADV_TQ_MAX_VALUE;
671 break; 671 break;
672 case GW_MODE_CLIENT: 672 case GW_MODE_CLIENT:
673 curr_gw = batadv_gw_get_selected_gw_node(bat_priv); 673 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 if (!neigh_old) 698 if (!neigh_old)
699 goto out; 699 goto out;
700 700
701 if (curr_tq_avg - neigh_old->tq_avg > GW_THRESHOLD) 701 if (curr_tq_avg - neigh_old->tq_avg > BATADV_GW_THRESHOLD)
702 out_of_range = true; 702 out_of_range = true;
703 703
704out: 704out:
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 9b1cb23ec1f..e7eba9c32e7 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -548,7 +548,7 @@ bool batadv_is_wifi_iface(int ifindex)
548 struct net_device *net_device = NULL; 548 struct net_device *net_device = NULL;
549 bool ret = false; 549 bool ret = false;
550 550
551 if (ifindex == NULL_IFINDEX) 551 if (ifindex == BATADV_NULL_IFINDEX)
552 goto out; 552 goto out;
553 553
554 net_device = dev_get_by_index(&init_net, ifindex); 554 net_device = dev_get_by_index(&init_net, ifindex);
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 986be72b514..df7335c4217 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -72,7 +72,7 @@ static int __init batadv_init(void)
72 register_netdevice_notifier(&batadv_hard_if_notifier); 72 register_netdevice_notifier(&batadv_hard_if_notifier);
73 73
74 pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n", 74 pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n",
75 SOURCE_VERSION, BATADV_COMPAT_VERSION); 75 BATADV_SOURCE_VERSION, BATADV_COMPAT_VERSION);
76 76
77 return 0; 77 return 0;
78} 78}
@@ -120,7 +120,8 @@ int batadv_mesh_init(struct net_device *soft_iface)
120 if (ret < 0) 120 if (ret < 0)
121 goto err; 121 goto err;
122 122
123 batadv_tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX); 123 batadv_tt_local_add(soft_iface, soft_iface->dev_addr,
124 BATADV_NULL_IFINDEX);
124 125
125 ret = batadv_vis_init(bat_priv); 126 ret = batadv_vis_init(bat_priv);
126 if (ret < 0) 127 if (ret < 0)
@@ -420,7 +421,7 @@ module_exit(batadv_exit);
420 421
421MODULE_LICENSE("GPL"); 422MODULE_LICENSE("GPL");
422 423
423MODULE_AUTHOR(DRIVER_AUTHOR); 424MODULE_AUTHOR(BATADV_DRIVER_AUTHOR);
424MODULE_DESCRIPTION(DRIVER_DESC); 425MODULE_DESCRIPTION(BATADV_DRIVER_DESC);
425MODULE_SUPPORTED_DEVICE(DRIVER_DEVICE); 426MODULE_SUPPORTED_DEVICE(BATADV_DRIVER_DEVICE);
426MODULE_VERSION(SOURCE_VERSION); 427MODULE_VERSION(BATADV_SOURCE_VERSION);
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index b7b98177dad..09660b4041f 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -20,79 +20,80 @@
20#ifndef _NET_BATMAN_ADV_MAIN_H_ 20#ifndef _NET_BATMAN_ADV_MAIN_H_
21#define _NET_BATMAN_ADV_MAIN_H_ 21#define _NET_BATMAN_ADV_MAIN_H_
22 22
23#define DRIVER_AUTHOR "Marek Lindner <lindner_marek@yahoo.de>, " \ 23#define BATADV_DRIVER_AUTHOR "Marek Lindner <lindner_marek@yahoo.de>, " \
24 "Simon Wunderlich <siwu@hrz.tu-chemnitz.de>" 24 "Simon Wunderlich <siwu@hrz.tu-chemnitz.de>"
25#define DRIVER_DESC "B.A.T.M.A.N. advanced" 25#define BATADV_DRIVER_DESC "B.A.T.M.A.N. advanced"
26#define DRIVER_DEVICE "batman-adv" 26#define BATADV_DRIVER_DEVICE "batman-adv"
27 27
28#ifndef SOURCE_VERSION 28#ifndef BATADV_SOURCE_VERSION
29#define SOURCE_VERSION "2012.3.0" 29#define BATADV_SOURCE_VERSION "2012.3.0"
30#endif 30#endif
31 31
32/* B.A.T.M.A.N. parameters */ 32/* B.A.T.M.A.N. parameters */
33 33
34#define TQ_MAX_VALUE 255 34#define BATADV_TQ_MAX_VALUE 255
35#define JITTER 20 35#define BATADV_JITTER 20
36 36
37/* Time To Live of broadcast messages */ 37/* Time To Live of broadcast messages */
38#define TTL 50 38#define BATADV_TTL 50
39 39
40/* purge originators after time in seconds if no valid packet comes in 40/* purge originators after time in seconds if no valid packet comes in
41 * -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE 41 * -> TODO: check influence on BATADV_TQ_LOCAL_WINDOW_SIZE
42 */ 42 */
43#define PURGE_TIMEOUT 200000 /* 200 seconds */ 43#define BATADV_PURGE_TIMEOUT 200000 /* 200 seconds */
44#define TT_LOCAL_TIMEOUT 3600000 /* in miliseconds */ 44#define BATADV_TT_LOCAL_TIMEOUT 3600000 /* in miliseconds */
45#define TT_CLIENT_ROAM_TIMEOUT 600000 /* in miliseconds */ 45#define BATADV_TT_CLIENT_ROAM_TIMEOUT 600000 /* in miliseconds */
46/* sliding packet range of received originator messages in sequence numbers 46/* sliding packet range of received originator messages in sequence numbers
47 * (should be a multiple of our word size) 47 * (should be a multiple of our word size)
48 */ 48 */
49#define TQ_LOCAL_WINDOW_SIZE 64 49#define BATADV_TQ_LOCAL_WINDOW_SIZE 64
50/* miliseconds we have to keep pending tt_req */ 50/* miliseconds we have to keep pending tt_req */
51#define TT_REQUEST_TIMEOUT 3000 51#define BATADV_TT_REQUEST_TIMEOUT 3000
52 52
53#define TQ_GLOBAL_WINDOW_SIZE 5 53#define BATADV_TQ_GLOBAL_WINDOW_SIZE 5
54#define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1 54#define BATADV_TQ_LOCAL_BIDRECT_SEND_MINIMUM 1
55#define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1 55#define BATADV_TQ_LOCAL_BIDRECT_RECV_MINIMUM 1
56#define TQ_TOTAL_BIDRECT_LIMIT 1 56#define BATADV_TQ_TOTAL_BIDRECT_LIMIT 1
57 57
58#define TT_OGM_APPEND_MAX 3 /* number of OGMs sent with the last tt diff */ 58/* number of OGMs sent with the last tt diff */
59#define BATADV_TT_OGM_APPEND_MAX 3
59 60
60/* Time in which a client can roam at most ROAMING_MAX_COUNT times in 61/* Time in which a client can roam at most ROAMING_MAX_COUNT times in
61 * miliseconds 62 * miliseconds
62 */ 63 */
63#define ROAMING_MAX_TIME 20000 64#define BATADV_ROAMING_MAX_TIME 20000
64#define ROAMING_MAX_COUNT 5 65#define BATADV_ROAMING_MAX_COUNT 5
65 66
66#define NO_FLAGS 0 67#define BATADV_NO_FLAGS 0
67 68
68#define NULL_IFINDEX 0 /* dummy ifindex used to avoid iface checks */ 69#define BATADV_NULL_IFINDEX 0 /* dummy ifindex used to avoid iface checks */
69 70
70#define NUM_WORDS BITS_TO_LONGS(TQ_LOCAL_WINDOW_SIZE) 71#define BATADV_NUM_WORDS BITS_TO_LONGS(BATADV_TQ_LOCAL_WINDOW_SIZE)
71 72
72#define LOG_BUF_LEN 8192 /* has to be a power of 2 */ 73#define BATADV_LOG_BUF_LEN 8192 /* has to be a power of 2 */
73 74
74#define VIS_INTERVAL 5000 /* 5 seconds */ 75#define BATADV_VIS_INTERVAL 5000 /* 5 seconds */
75 76
76/* how much worse secondary interfaces may be to be considered as bonding 77/* how much worse secondary interfaces may be to be considered as bonding
77 * candidates 78 * candidates
78 */ 79 */
79#define BONDING_TQ_THRESHOLD 50 80#define BATADV_BONDING_TQ_THRESHOLD 50
80 81
81/* should not be bigger than 512 bytes or change the size of 82/* should not be bigger than 512 bytes or change the size of
82 * forw_packet->direct_link_flags 83 * forw_packet->direct_link_flags
83 */ 84 */
84#define MAX_AGGREGATION_BYTES 512 85#define BATADV_MAX_AGGREGATION_BYTES 512
85#define MAX_AGGREGATION_MS 100 86#define BATADV_MAX_AGGREGATION_MS 100
86 87
87#define BLA_PERIOD_LENGTH 10000 /* 10 seconds */ 88#define BATADV_BLA_PERIOD_LENGTH 10000 /* 10 seconds */
88#define BLA_BACKBONE_TIMEOUT (BLA_PERIOD_LENGTH * 3) 89#define BATADV_BLA_BACKBONE_TIMEOUT (BATADV_BLA_PERIOD_LENGTH * 3)
89#define BLA_CLAIM_TIMEOUT (BLA_PERIOD_LENGTH * 10) 90#define BATADV_BLA_CLAIM_TIMEOUT (BATADV_BLA_PERIOD_LENGTH * 10)
90 91
91#define DUPLIST_SIZE 16 92#define BATADV_DUPLIST_SIZE 16
92#define DUPLIST_TIMEOUT 500 /* 500 ms */ 93#define BATADV_DUPLIST_TIMEOUT 500 /* 500 ms */
93/* don't reset again within 30 seconds */ 94/* don't reset again within 30 seconds */
94#define RESET_PROTECTION_MS 30000 95#define BATADV_RESET_PROTECTION_MS 30000
95#define EXPECTED_SEQNO_RANGE 65536 96#define BATADV_EXPECTED_SEQNO_RANGE 65536
96 97
97enum mesh_state { 98enum mesh_state {
98 MESH_INACTIVE, 99 MESH_INACTIVE,
@@ -100,8 +101,8 @@ enum mesh_state {
100 MESH_DEACTIVATING 101 MESH_DEACTIVATING
101}; 102};
102 103
103#define BCAST_QUEUE_LEN 256 104#define BATADV_BCAST_QUEUE_LEN 256
104#define BATMAN_QUEUE_LEN 256 105#define BATADV_BATMAN_QUEUE_LEN 256
105 106
106enum uev_action { 107enum uev_action {
107 UEV_ADD = 0, 108 UEV_ADD = 0,
@@ -113,7 +114,7 @@ enum uev_type {
113 UEV_GW = 0 114 UEV_GW = 0
114}; 115};
115 116
116#define GW_THRESHOLD 50 117#define BATADV_GW_THRESHOLD 50
117 118
118/* Debug Messages */ 119/* Debug Messages */
119#ifdef pr_fmt 120#ifdef pr_fmt
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 1980696a7fd..f04f591f466 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -194,6 +194,7 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
194 struct orig_node *orig_node; 194 struct orig_node *orig_node;
195 int size; 195 int size;
196 int hash_added; 196 int hash_added;
197 unsigned long reset_time;
197 198
198 orig_node = batadv_orig_hash_find(bat_priv, addr); 199 orig_node = batadv_orig_hash_find(bat_priv, addr);
199 if (orig_node) 200 if (orig_node)
@@ -226,14 +227,13 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
226 orig_node->tt_buff = NULL; 227 orig_node->tt_buff = NULL;
227 orig_node->tt_buff_len = 0; 228 orig_node->tt_buff_len = 0;
228 atomic_set(&orig_node->tt_size, 0); 229 atomic_set(&orig_node->tt_size, 0);
229 orig_node->bcast_seqno_reset = jiffies - 1 230 reset_time = jiffies - 1 - msecs_to_jiffies(BATADV_RESET_PROTECTION_MS);
230 - msecs_to_jiffies(RESET_PROTECTION_MS); 231 orig_node->bcast_seqno_reset = reset_time;
231 orig_node->batman_seqno_reset = jiffies - 1 232 orig_node->batman_seqno_reset = reset_time;
232 - msecs_to_jiffies(RESET_PROTECTION_MS);
233 233
234 atomic_set(&orig_node->bond_candidates, 0); 234 atomic_set(&orig_node->bond_candidates, 0);
235 235
236 size = bat_priv->num_ifaces * sizeof(unsigned long) * NUM_WORDS; 236 size = bat_priv->num_ifaces * sizeof(unsigned long) * BATADV_NUM_WORDS;
237 237
238 orig_node->bcast_own = kzalloc(size, GFP_ATOMIC); 238 orig_node->bcast_own = kzalloc(size, GFP_ATOMIC);
239 if (!orig_node->bcast_own) 239 if (!orig_node->bcast_own)
@@ -285,7 +285,7 @@ static bool batadv_purge_orig_neighbors(struct bat_priv *bat_priv,
285 last_seen = neigh_node->last_seen; 285 last_seen = neigh_node->last_seen;
286 if_incoming = neigh_node->if_incoming; 286 if_incoming = neigh_node->if_incoming;
287 287
288 if ((batadv_has_timed_out(last_seen, PURGE_TIMEOUT)) || 288 if ((batadv_has_timed_out(last_seen, BATADV_PURGE_TIMEOUT)) ||
289 (if_incoming->if_status == IF_INACTIVE) || 289 (if_incoming->if_status == IF_INACTIVE) ||
290 (if_incoming->if_status == IF_NOT_IN_USE) || 290 (if_incoming->if_status == IF_NOT_IN_USE) ||
291 (if_incoming->if_status == IF_TO_BE_REMOVED)) { 291 (if_incoming->if_status == IF_TO_BE_REMOVED)) {
@@ -324,7 +324,8 @@ static bool batadv_purge_orig_node(struct bat_priv *bat_priv,
324{ 324{
325 struct neigh_node *best_neigh_node; 325 struct neigh_node *best_neigh_node;
326 326
327 if (batadv_has_timed_out(orig_node->last_seen, 2 * PURGE_TIMEOUT)) { 327 if (batadv_has_timed_out(orig_node->last_seen,
328 2 * BATADV_PURGE_TIMEOUT)) {
328 batadv_dbg(DBG_BATMAN, bat_priv, 329 batadv_dbg(DBG_BATMAN, bat_priv,
329 "Originator timeout: originator %pM, last_seen %u\n", 330 "Originator timeout: originator %pM, last_seen %u\n",
330 orig_node->orig, 331 orig_node->orig,
@@ -429,11 +430,11 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
429 } 430 }
430 431
431 seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", 432 seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n",
432 SOURCE_VERSION, primary_if->net_dev->name, 433 BATADV_SOURCE_VERSION, primary_if->net_dev->name,
433 primary_if->net_dev->dev_addr, net_dev->name); 434 primary_if->net_dev->dev_addr, net_dev->name);
434 seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n", 435 seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n",
435 "Originator", "last-seen", "#", TQ_MAX_VALUE, "Nexthop", 436 "Originator", "last-seen", "#", BATADV_TQ_MAX_VALUE,
436 "outgoingIF", "Potential nexthops"); 437 "Nexthop", "outgoingIF", "Potential nexthops");
437 438
438 for (i = 0; i < hash->size; i++) { 439 for (i = 0; i < hash->size; i++) {
439 head = &hash->table[i]; 440 head = &hash->table[i];
@@ -486,14 +487,15 @@ out:
486static int batadv_orig_node_add_if(struct orig_node *orig_node, int max_if_num) 487static int batadv_orig_node_add_if(struct orig_node *orig_node, int max_if_num)
487{ 488{
488 void *data_ptr; 489 void *data_ptr;
490 size_t data_size, old_size;
489 491
490 data_ptr = kmalloc(max_if_num * sizeof(unsigned long) * NUM_WORDS, 492 data_size = max_if_num * sizeof(unsigned long) * BATADV_NUM_WORDS;
491 GFP_ATOMIC); 493 old_size = (max_if_num - 1) * sizeof(unsigned long) * BATADV_NUM_WORDS;
494 data_ptr = kmalloc(data_size, GFP_ATOMIC);
492 if (!data_ptr) 495 if (!data_ptr)
493 return -ENOMEM; 496 return -ENOMEM;
494 497
495 memcpy(data_ptr, orig_node->bcast_own, 498 memcpy(data_ptr, orig_node->bcast_own, old_size);
496 (max_if_num - 1) * sizeof(unsigned long) * NUM_WORDS);
497 kfree(orig_node->bcast_own); 499 kfree(orig_node->bcast_own);
498 orig_node->bcast_own = data_ptr; 500 orig_node->bcast_own = data_ptr;
499 501
@@ -554,7 +556,7 @@ static int batadv_orig_node_del_if(struct orig_node *orig_node,
554 if (max_if_num == 0) 556 if (max_if_num == 0)
555 goto free_bcast_own; 557 goto free_bcast_own;
556 558
557 chunk_size = sizeof(unsigned long) * NUM_WORDS; 559 chunk_size = sizeof(unsigned long) * BATADV_NUM_WORDS;
558 data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC); 560 data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC);
559 if (!data_ptr) 561 if (!data_ptr)
560 return -ENOMEM; 562 return -ENOMEM;
diff --git a/net/batman-adv/ring_buffer.c b/net/batman-adv/ring_buffer.c
index aff1ca2990f..c8f61e395b7 100644
--- a/net/batman-adv/ring_buffer.c
+++ b/net/batman-adv/ring_buffer.c
@@ -24,7 +24,7 @@ void batadv_ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index,
24 uint8_t value) 24 uint8_t value)
25{ 25{
26 lq_recv[*lq_index] = value; 26 lq_recv[*lq_index] = value;
27 *lq_index = (*lq_index + 1) % TQ_GLOBAL_WINDOW_SIZE; 27 *lq_index = (*lq_index + 1) % BATADV_TQ_GLOBAL_WINDOW_SIZE;
28} 28}
29 29
30uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[]) 30uint8_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 34
35 ptr = lq_recv; 35 ptr = lq_recv;
36 36
37 while (i < TQ_GLOBAL_WINDOW_SIZE) { 37 while (i < BATADV_TQ_GLOBAL_WINDOW_SIZE) {
38 if (*ptr != 0) { 38 if (*ptr != 0) {
39 count++; 39 count++;
40 sum += *ptr; 40 sum += *ptr;
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index c8fee749eab..b3fd61c90f3 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -42,6 +42,7 @@ void batadv_slide_own_bcast_window(struct hard_iface *hard_iface)
42 unsigned long *word; 42 unsigned long *word;
43 uint32_t i; 43 uint32_t i;
44 size_t word_index; 44 size_t word_index;
45 uint8_t *w;
45 46
46 for (i = 0; i < hash->size; i++) { 47 for (i = 0; i < hash->size; i++) {
47 head = &hash->table[i]; 48 head = &hash->table[i];
@@ -49,12 +50,12 @@ void batadv_slide_own_bcast_window(struct hard_iface *hard_iface)
49 rcu_read_lock(); 50 rcu_read_lock();
50 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { 51 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
51 spin_lock_bh(&orig_node->ogm_cnt_lock); 52 spin_lock_bh(&orig_node->ogm_cnt_lock);
52 word_index = hard_iface->if_num * NUM_WORDS; 53 word_index = hard_iface->if_num * BATADV_NUM_WORDS;
53 word = &(orig_node->bcast_own[word_index]); 54 word = &(orig_node->bcast_own[word_index]);
54 55
55 batadv_bit_get_packet(bat_priv, word, 1, 0); 56 batadv_bit_get_packet(bat_priv, word, 1, 0);
56 orig_node->bcast_own_sum[hard_iface->if_num] = 57 w = &orig_node->bcast_own_sum[hard_iface->if_num];
57 bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE); 58 *w = bitmap_weight(word, BATADV_TQ_LOCAL_WINDOW_SIZE);
58 spin_unlock_bh(&orig_node->ogm_cnt_lock); 59 spin_unlock_bh(&orig_node->ogm_cnt_lock);
59 } 60 }
60 rcu_read_unlock(); 61 rcu_read_unlock();
@@ -160,7 +161,7 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node,
160 goto candidate_del; 161 goto candidate_del;
161 162
162 /* ... and is good enough to be considered */ 163 /* ... and is good enough to be considered */
163 if (neigh_node->tq_avg < router->tq_avg - BONDING_TQ_THRESHOLD) 164 if (neigh_node->tq_avg < router->tq_avg - BATADV_BONDING_TQ_THRESHOLD)
164 goto candidate_del; 165 goto candidate_del;
165 166
166 /* check if we have another candidate with the same mac address or 167 /* 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,
232int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, 233int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
233 unsigned long *last_reset) 234 unsigned long *last_reset)
234{ 235{
235 if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || 236 if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE ||
236 (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { 237 seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) {
237 if (!batadv_has_timed_out(*last_reset, RESET_PROTECTION_MS)) 238 if (!batadv_has_timed_out(*last_reset,
239 BATADV_RESET_PROTECTION_MS))
238 return 1; 240 return 1;
239 241
240 *last_reset = jiffies; 242 *last_reset = jiffies;
@@ -316,7 +318,7 @@ static int batadv_recv_my_icmp_packet(struct bat_priv *bat_priv,
316 memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); 318 memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
317 memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); 319 memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
318 icmp_packet->msg_type = ECHO_REPLY; 320 icmp_packet->msg_type = ECHO_REPLY;
319 icmp_packet->header.ttl = TTL; 321 icmp_packet->header.ttl = BATADV_TTL;
320 322
321 batadv_send_skb_packet(skb, router->if_incoming, router->addr); 323 batadv_send_skb_packet(skb, router->if_incoming, router->addr);
322 ret = NET_RX_SUCCESS; 324 ret = NET_RX_SUCCESS;
@@ -371,7 +373,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
371 memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); 373 memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
372 memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); 374 memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
373 icmp_packet->msg_type = TTL_EXCEEDED; 375 icmp_packet->msg_type = TTL_EXCEEDED;
374 icmp_packet->header.ttl = TTL; 376 icmp_packet->header.ttl = BATADV_TTL;
375 377
376 batadv_send_skb_packet(skb, router->if_incoming, router->addr); 378 batadv_send_skb_packet(skb, router->if_incoming, router->addr);
377 ret = NET_RX_SUCCESS; 379 ret = NET_RX_SUCCESS;
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index bbbc9a93d43..c1b2ab2f37b 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -108,7 +108,7 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)
108 if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) { 108 if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) {
109 batadv_tt_local_remove(bat_priv, dev->dev_addr, 109 batadv_tt_local_remove(bat_priv, dev->dev_addr,
110 "mac address changed", false); 110 "mac address changed", false);
111 batadv_tt_local_add(dev, addr->sa_data, NULL_IFINDEX); 111 batadv_tt_local_add(dev, addr->sa_data, BATADV_NULL_IFINDEX);
112 } 112 }
113 113
114 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); 114 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
@@ -210,7 +210,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
210 210
211 bcast_packet = (struct bcast_packet *)skb->data; 211 bcast_packet = (struct bcast_packet *)skb->data;
212 bcast_packet->header.version = BATADV_COMPAT_VERSION; 212 bcast_packet->header.version = BATADV_COMPAT_VERSION;
213 bcast_packet->header.ttl = TTL; 213 bcast_packet->header.ttl = BATADV_TTL;
214 214
215 /* batman packet type: broadcast */ 215 /* batman packet type: broadcast */
216 bcast_packet->header.packet_type = BAT_BCAST; 216 bcast_packet->header.packet_type = BAT_BCAST;
@@ -394,8 +394,8 @@ struct net_device *batadv_softif_create(const char *name)
394 atomic_set(&bat_priv->hop_penalty, 30); 394 atomic_set(&bat_priv->hop_penalty, 30);
395 atomic_set(&bat_priv->log_level, 0); 395 atomic_set(&bat_priv->log_level, 0);
396 atomic_set(&bat_priv->fragmentation, 1); 396 atomic_set(&bat_priv->fragmentation, 1);
397 atomic_set(&bat_priv->bcast_queue_left, BCAST_QUEUE_LEN); 397 atomic_set(&bat_priv->bcast_queue_left, BATADV_BCAST_QUEUE_LEN);
398 atomic_set(&bat_priv->batman_queue_left, BATMAN_QUEUE_LEN); 398 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
399 399
400 atomic_set(&bat_priv->mesh_state, MESH_INACTIVE); 400 atomic_set(&bat_priv->mesh_state, MESH_INACTIVE);
401 atomic_set(&bat_priv->bcast_seqno, 1); 401 atomic_set(&bat_priv->bcast_seqno, 1);
@@ -487,7 +487,7 @@ static void batadv_get_drvinfo(struct net_device *dev,
487 struct ethtool_drvinfo *info) 487 struct ethtool_drvinfo *info)
488{ 488{
489 strcpy(info->driver, "B.A.T.M.A.N. advanced"); 489 strcpy(info->driver, "B.A.T.M.A.N. advanced");
490 strcpy(info->version, SOURCE_VERSION); 490 strcpy(info->version, BATADV_SOURCE_VERSION);
491 strcpy(info->fw_version, "N/A"); 491 strcpy(info->fw_version, "N/A");
492 strcpy(info->bus_info, "batman"); 492 strcpy(info->bus_info, "batman");
493} 493}
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 79cd3f76a86..a0487e9f18c 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -257,7 +257,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
257 (uint8_t)atomic_read(&bat_priv->ttvn)); 257 (uint8_t)atomic_read(&bat_priv->ttvn));
258 258
259 memcpy(tt_local_entry->common.addr, addr, ETH_ALEN); 259 memcpy(tt_local_entry->common.addr, addr, ETH_ALEN);
260 tt_local_entry->common.flags = NO_FLAGS; 260 tt_local_entry->common.flags = BATADV_NO_FLAGS;
261 if (batadv_is_wifi_iface(ifindex)) 261 if (batadv_is_wifi_iface(ifindex))
262 tt_local_entry->common.flags |= TT_CLIENT_WIFI; 262 tt_local_entry->common.flags |= TT_CLIENT_WIFI;
263 atomic_set(&tt_local_entry->common.refcount, 2); 263 atomic_set(&tt_local_entry->common.refcount, 2);
@@ -493,14 +493,17 @@ void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr,
493 const char *message, bool roaming) 493 const char *message, bool roaming)
494{ 494{
495 struct tt_local_entry *tt_local_entry = NULL; 495 struct tt_local_entry *tt_local_entry = NULL;
496 uint16_t flags;
496 497
497 tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr); 498 tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr);
498 if (!tt_local_entry) 499 if (!tt_local_entry)
499 goto out; 500 goto out;
500 501
501 batadv_tt_local_set_pending(bat_priv, tt_local_entry, TT_CLIENT_DEL | 502 flags = TT_CLIENT_DEL;
502 (roaming ? TT_CLIENT_ROAM : NO_FLAGS), 503 if (roaming)
503 message); 504 flags |= TT_CLIENT_ROAM;
505
506 batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags, message);
504out: 507out:
505 if (tt_local_entry) 508 if (tt_local_entry)
506 batadv_tt_local_entry_free_ref(tt_local_entry); 509 batadv_tt_local_entry_free_ref(tt_local_entry);
@@ -534,7 +537,7 @@ static void batadv_tt_local_purge(struct bat_priv *bat_priv)
534 continue; 537 continue;
535 538
536 if (!batadv_has_timed_out(tt_local_entry->last_seen, 539 if (!batadv_has_timed_out(tt_local_entry->last_seen,
537 TT_LOCAL_TIMEOUT)) 540 BATADV_TT_LOCAL_TIMEOUT))
538 continue; 541 continue;
539 542
540 batadv_tt_local_set_pending(bat_priv, tt_local_entry, 543 batadv_tt_local_set_pending(bat_priv, tt_local_entry,
@@ -1008,12 +1011,35 @@ void batadv_tt_global_del_orig(struct bat_priv *bat_priv,
1008 orig_node->tt_initialised = false; 1011 orig_node->tt_initialised = false;
1009} 1012}
1010 1013
1011static void batadv_tt_global_roam_purge(struct bat_priv *bat_priv) 1014static void batadv_tt_global_roam_purge_list(struct bat_priv *bat_priv,
1015 struct hlist_head *head)
1012{ 1016{
1013 struct hashtable_t *hash = bat_priv->tt_global_hash;
1014 struct tt_common_entry *tt_common_entry; 1017 struct tt_common_entry *tt_common_entry;
1015 struct tt_global_entry *tt_global_entry; 1018 struct tt_global_entry *tt_global_entry;
1016 struct hlist_node *node, *node_tmp; 1019 struct hlist_node *node, *node_tmp;
1020
1021 hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, head,
1022 hash_entry) {
1023 tt_global_entry = container_of(tt_common_entry,
1024 struct tt_global_entry, common);
1025 if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM))
1026 continue;
1027 if (!batadv_has_timed_out(tt_global_entry->roam_at,
1028 BATADV_TT_CLIENT_ROAM_TIMEOUT))
1029 continue;
1030
1031 batadv_dbg(DBG_TT, bat_priv,
1032 "Deleting global tt entry (%pM): Roaming timeout\n",
1033 tt_global_entry->common.addr);
1034
1035 hlist_del_rcu(node);
1036 batadv_tt_global_entry_free_ref(tt_global_entry);
1037 }
1038}
1039
1040static void batadv_tt_global_roam_purge(struct bat_priv *bat_priv)
1041{
1042 struct hashtable_t *hash = bat_priv->tt_global_hash;
1017 struct hlist_head *head; 1043 struct hlist_head *head;
1018 spinlock_t *list_lock; /* protects write access to the hash lists */ 1044 spinlock_t *list_lock; /* protects write access to the hash lists */
1019 uint32_t i; 1045 uint32_t i;
@@ -1023,24 +1049,7 @@ static void batadv_tt_global_roam_purge(struct bat_priv *bat_priv)
1023 list_lock = &hash->list_locks[i]; 1049 list_lock = &hash->list_locks[i];
1024 1050
1025 spin_lock_bh(list_lock); 1051 spin_lock_bh(list_lock);
1026 hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, 1052 batadv_tt_global_roam_purge_list(bat_priv, head);
1027 head, hash_entry) {
1028 tt_global_entry = container_of(tt_common_entry,
1029 struct tt_global_entry,
1030 common);
1031 if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM))
1032 continue;
1033 if (!batadv_has_timed_out(tt_global_entry->roam_at,
1034 TT_CLIENT_ROAM_TIMEOUT))
1035 continue;
1036
1037 batadv_dbg(DBG_TT, bat_priv,
1038 "Deleting global tt entry (%pM): Roaming timeout\n",
1039 tt_global_entry->common.addr);
1040
1041 hlist_del_rcu(node);
1042 batadv_tt_global_entry_free_ref(tt_global_entry);
1043 }
1044 spin_unlock_bh(list_lock); 1053 spin_unlock_bh(list_lock);
1045 } 1054 }
1046 1055
@@ -1278,7 +1287,8 @@ static void batadv_tt_req_purge(struct bat_priv *bat_priv)
1278 1287
1279 spin_lock_bh(&bat_priv->tt_req_list_lock); 1288 spin_lock_bh(&bat_priv->tt_req_list_lock);
1280 list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { 1289 list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) {
1281 if (batadv_has_timed_out(node->issued_at, TT_REQUEST_TIMEOUT)) { 1290 if (batadv_has_timed_out(node->issued_at,
1291 BATADV_TT_REQUEST_TIMEOUT)) {
1282 list_del(&node->list); 1292 list_del(&node->list);
1283 kfree(node); 1293 kfree(node);
1284 } 1294 }
@@ -1298,7 +1308,7 @@ static struct tt_req_node *batadv_new_tt_req_node(struct bat_priv *bat_priv,
1298 list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) { 1308 list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) {
1299 if (batadv_compare_eth(tt_req_node_tmp, orig_node) && 1309 if (batadv_compare_eth(tt_req_node_tmp, orig_node) &&
1300 !batadv_has_timed_out(tt_req_node_tmp->issued_at, 1310 !batadv_has_timed_out(tt_req_node_tmp->issued_at,
1301 TT_REQUEST_TIMEOUT)) 1311 BATADV_TT_REQUEST_TIMEOUT))
1302 goto unlock; 1312 goto unlock;
1303 } 1313 }
1304 1314
@@ -1391,7 +1401,7 @@ batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn,
1391 1401
1392 memcpy(tt_change->addr, tt_common_entry->addr, 1402 memcpy(tt_change->addr, tt_common_entry->addr,
1393 ETH_ALEN); 1403 ETH_ALEN);
1394 tt_change->flags = NO_FLAGS; 1404 tt_change->flags = BATADV_NO_FLAGS;
1395 1405
1396 tt_count++; 1406 tt_count++;
1397 tt_change++; 1407 tt_change++;
@@ -1444,7 +1454,7 @@ static int batadv_send_tt_request(struct bat_priv *bat_priv,
1444 tt_request->header.version = BATADV_COMPAT_VERSION; 1454 tt_request->header.version = BATADV_COMPAT_VERSION;
1445 memcpy(tt_request->src, primary_if->net_dev->dev_addr, ETH_ALEN); 1455 memcpy(tt_request->src, primary_if->net_dev->dev_addr, ETH_ALEN);
1446 memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN); 1456 memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN);
1447 tt_request->header.ttl = TTL; 1457 tt_request->header.ttl = BATADV_TTL;
1448 tt_request->ttvn = ttvn; 1458 tt_request->ttvn = ttvn;
1449 tt_request->tt_data = htons(tt_crc); 1459 tt_request->tt_data = htons(tt_crc);
1450 tt_request->flags = TT_REQUEST; 1460 tt_request->flags = TT_REQUEST;
@@ -1576,7 +1586,7 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv,
1576 1586
1577 tt_response->header.packet_type = BAT_TT_QUERY; 1587 tt_response->header.packet_type = BAT_TT_QUERY;
1578 tt_response->header.version = BATADV_COMPAT_VERSION; 1588 tt_response->header.version = BATADV_COMPAT_VERSION;
1579 tt_response->header.ttl = TTL; 1589 tt_response->header.ttl = BATADV_TTL;
1580 memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN); 1590 memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN);
1581 memcpy(tt_response->dst, tt_request->src, ETH_ALEN); 1591 memcpy(tt_response->dst, tt_request->src, ETH_ALEN);
1582 tt_response->flags = TT_RESPONSE; 1592 tt_response->flags = TT_RESPONSE;
@@ -1697,7 +1707,7 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv,
1697 1707
1698 tt_response->header.packet_type = BAT_TT_QUERY; 1708 tt_response->header.packet_type = BAT_TT_QUERY;
1699 tt_response->header.version = BATADV_COMPAT_VERSION; 1709 tt_response->header.version = BATADV_COMPAT_VERSION;
1700 tt_response->header.ttl = TTL; 1710 tt_response->header.ttl = BATADV_TTL;
1701 memcpy(tt_response->src, primary_if->net_dev->dev_addr, ETH_ALEN); 1711 memcpy(tt_response->src, primary_if->net_dev->dev_addr, ETH_ALEN);
1702 memcpy(tt_response->dst, tt_request->src, ETH_ALEN); 1712 memcpy(tt_response->dst, tt_request->src, ETH_ALEN);
1703 tt_response->flags = TT_RESPONSE; 1713 tt_response->flags = TT_RESPONSE;
@@ -1925,7 +1935,8 @@ static void batadv_tt_roam_purge(struct bat_priv *bat_priv)
1925 1935
1926 spin_lock_bh(&bat_priv->tt_roam_list_lock); 1936 spin_lock_bh(&bat_priv->tt_roam_list_lock);
1927 list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) { 1937 list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) {
1928 if (!batadv_has_timed_out(node->first_time, ROAMING_MAX_TIME)) 1938 if (!batadv_has_timed_out(node->first_time,
1939 BATADV_ROAMING_MAX_TIME))
1929 continue; 1940 continue;
1930 1941
1931 list_del(&node->list); 1942 list_del(&node->list);
@@ -1955,7 +1966,7 @@ static bool batadv_tt_check_roam_count(struct bat_priv *bat_priv,
1955 continue; 1966 continue;
1956 1967
1957 if (batadv_has_timed_out(tt_roam_node->first_time, 1968 if (batadv_has_timed_out(tt_roam_node->first_time,
1958 ROAMING_MAX_TIME)) 1969 BATADV_ROAMING_MAX_TIME))
1959 continue; 1970 continue;
1960 1971
1961 if (!batadv_atomic_dec_not_zero(&tt_roam_node->counter)) 1972 if (!batadv_atomic_dec_not_zero(&tt_roam_node->counter))
@@ -1971,7 +1982,8 @@ static bool batadv_tt_check_roam_count(struct bat_priv *bat_priv,
1971 goto unlock; 1982 goto unlock;
1972 1983
1973 tt_roam_node->first_time = jiffies; 1984 tt_roam_node->first_time = jiffies;
1974 atomic_set(&tt_roam_node->counter, ROAMING_MAX_COUNT - 1); 1985 atomic_set(&tt_roam_node->counter,
1986 BATADV_ROAMING_MAX_COUNT - 1);
1975 memcpy(tt_roam_node->addr, client, ETH_ALEN); 1987 memcpy(tt_roam_node->addr, client, ETH_ALEN);
1976 1988
1977 list_add(&tt_roam_node->list, &bat_priv->tt_roam_list); 1989 list_add(&tt_roam_node->list, &bat_priv->tt_roam_list);
@@ -2009,7 +2021,7 @@ static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
2009 2021
2010 roam_adv_packet->header.packet_type = BAT_ROAM_ADV; 2022 roam_adv_packet->header.packet_type = BAT_ROAM_ADV;
2011 roam_adv_packet->header.version = BATADV_COMPAT_VERSION; 2023 roam_adv_packet->header.version = BATADV_COMPAT_VERSION;
2012 roam_adv_packet->header.ttl = TTL; 2024 roam_adv_packet->header.ttl = BATADV_TTL;
2013 primary_if = batadv_primary_if_get_selected(bat_priv); 2025 primary_if = batadv_primary_if_get_selected(bat_priv);
2014 if (!primary_if) 2026 if (!primary_if)
2015 goto out; 2027 goto out;
@@ -2170,7 +2182,7 @@ static int batadv_tt_commit_changes(struct bat_priv *bat_priv,
2170 bat_priv->tt_poss_change = false; 2182 bat_priv->tt_poss_change = false;
2171 2183
2172 /* reset the sending counter */ 2184 /* reset the sending counter */
2173 atomic_set(&bat_priv->tt_ogm_append_cnt, TT_OGM_APPEND_MAX); 2185 atomic_set(&bat_priv->tt_ogm_append_cnt, BATADV_TT_OGM_APPEND_MAX);
2174 2186
2175 return batadv_tt_changes_fill_buff(bat_priv, packet_buff, 2187 return batadv_tt_changes_fill_buff(bat_priv, packet_buff,
2176 packet_buff_len, packet_min_len); 2188 packet_buff_len, packet_min_len);
@@ -2248,7 +2260,8 @@ void batadv_tt_update_orig(struct bat_priv *bat_priv,
2248 if ((!orig_node->tt_initialised && ttvn == 1) || 2260 if ((!orig_node->tt_initialised && ttvn == 1) ||
2249 ttvn - orig_ttvn == 1) { 2261 ttvn - orig_ttvn == 1) {
2250 /* the OGM could not contain the changes due to their size or 2262 /* the OGM could not contain the changes due to their size or
2251 * because they have already been sent TT_OGM_APPEND_MAX times. 2263 * because they have already been sent BATADV_TT_OGM_APPEND_MAX
2264 * times.
2252 * In this case send a tt request 2265 * In this case send a tt request
2253 */ 2266 */
2254 if (!tt_num_changes) { 2267 if (!tt_num_changes) {
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 1d5d21ed8e8..fd538ea6811 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -85,7 +85,7 @@ struct orig_node {
85 bool tt_poss_change; 85 bool tt_poss_change;
86 uint32_t last_real_seqno; 86 uint32_t last_real_seqno;
87 uint8_t last_ttl; 87 uint8_t last_ttl;
88 DECLARE_BITMAP(bcast_bits, TQ_LOCAL_WINDOW_SIZE); 88 DECLARE_BITMAP(bcast_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
89 uint32_t last_bcast_seqno; 89 uint32_t last_bcast_seqno;
90 struct hlist_head neigh_list; 90 struct hlist_head neigh_list;
91 struct list_head frag_list; 91 struct list_head frag_list;
@@ -121,13 +121,13 @@ struct neigh_node {
121 struct hlist_node list; 121 struct hlist_node list;
122 uint8_t addr[ETH_ALEN]; 122 uint8_t addr[ETH_ALEN];
123 uint8_t real_packet_count; 123 uint8_t real_packet_count;
124 uint8_t tq_recv[TQ_GLOBAL_WINDOW_SIZE]; 124 uint8_t tq_recv[BATADV_TQ_GLOBAL_WINDOW_SIZE];
125 uint8_t tq_index; 125 uint8_t tq_index;
126 uint8_t tq_avg; 126 uint8_t tq_avg;
127 uint8_t last_ttl; 127 uint8_t last_ttl;
128 struct list_head bonding_list; 128 struct list_head bonding_list;
129 unsigned long last_seen; 129 unsigned long last_seen;
130 DECLARE_BITMAP(real_bits, TQ_LOCAL_WINDOW_SIZE); 130 DECLARE_BITMAP(real_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
131 atomic_t refcount; 131 atomic_t refcount;
132 struct rcu_head rcu; 132 struct rcu_head rcu;
133 struct orig_node *orig_node; 133 struct orig_node *orig_node;
@@ -209,7 +209,7 @@ struct bat_priv {
209 struct list_head tt_roam_list; 209 struct list_head tt_roam_list;
210 struct hashtable_t *vis_hash; 210 struct hashtable_t *vis_hash;
211#ifdef CONFIG_BATMAN_ADV_BLA 211#ifdef CONFIG_BATMAN_ADV_BLA
212 struct bcast_duplist_entry bcast_duplist[DUPLIST_SIZE]; 212 struct bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE];
213 int bcast_duplist_curr; 213 int bcast_duplist_curr;
214 struct bla_claim_dst claim_dest; 214 struct bla_claim_dst claim_dest;
215#endif 215#endif
@@ -348,7 +348,7 @@ struct if_list_entry {
348}; 348};
349 349
350struct debug_log { 350struct debug_log {
351 char log_buff[LOG_BUF_LEN]; 351 char log_buff[BATADV_LOG_BUF_LEN];
352 unsigned long log_start; 352 unsigned long log_start;
353 unsigned long log_end; 353 unsigned long log_end;
354 spinlock_t lock; /* protects log_buff, log_start and log_end */ 354 spinlock_t lock; /* protects log_buff, log_start and log_end */
diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
index 80983202637..8454d916cd0 100644
--- a/net/batman-adv/unicast.c
+++ b/net/batman-adv/unicast.c
@@ -323,7 +323,7 @@ find_router:
323 /* batman packet type: unicast */ 323 /* batman packet type: unicast */
324 unicast_packet->header.packet_type = BAT_UNICAST; 324 unicast_packet->header.packet_type = BAT_UNICAST;
325 /* set unicast ttl */ 325 /* set unicast ttl */
326 unicast_packet->header.ttl = TTL; 326 unicast_packet->header.ttl = BATADV_TTL;
327 /* copy the destination for faster routing */ 327 /* copy the destination for faster routing */
328 memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN); 328 memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
329 /* set the destination tt version number */ 329 /* set the destination tt version number */
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c
index a439ed6616e..74181696eef 100644
--- a/net/batman-adv/vis.c
+++ b/net/batman-adv/vis.c
@@ -575,7 +575,7 @@ static int batadv_generate_vis_packet(struct bat_priv *bat_priv)
575 packet->vis_type = atomic_read(&bat_priv->vis_mode); 575 packet->vis_type = atomic_read(&bat_priv->vis_mode);
576 576
577 memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN); 577 memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN);
578 packet->header.ttl = TTL; 578 packet->header.ttl = BATADV_TTL;
579 packet->seqno = htonl(ntohl(packet->seqno) + 1); 579 packet->seqno = htonl(ntohl(packet->seqno) + 1);
580 packet->entries = 0; 580 packet->entries = 0;
581 skb_trim(info->skb_packet, sizeof(*packet)); 581 skb_trim(info->skb_packet, sizeof(*packet));
@@ -841,6 +841,7 @@ int batadv_vis_init(struct bat_priv *bat_priv)
841 struct vis_packet *packet; 841 struct vis_packet *packet;
842 int hash_added; 842 int hash_added;
843 unsigned int len; 843 unsigned int len;
844 unsigned long first_seen;
844 845
845 if (bat_priv->vis_hash) 846 if (bat_priv->vis_hash)
846 return 0; 847 return 0;
@@ -867,15 +868,15 @@ int batadv_vis_init(struct bat_priv *bat_priv)
867 sizeof(*packet)); 868 sizeof(*packet));
868 869
869 /* prefill the vis info */ 870 /* prefill the vis info */
870 bat_priv->my_vis_info->first_seen = jiffies - 871 first_seen = jiffies - msecs_to_jiffies(BATADV_VIS_INTERVAL);
871 msecs_to_jiffies(VIS_INTERVAL); 872 bat_priv->my_vis_info->first_seen = first_seen;
872 INIT_LIST_HEAD(&bat_priv->my_vis_info->recv_list); 873 INIT_LIST_HEAD(&bat_priv->my_vis_info->recv_list);
873 INIT_LIST_HEAD(&bat_priv->my_vis_info->send_list); 874 INIT_LIST_HEAD(&bat_priv->my_vis_info->send_list);
874 kref_init(&bat_priv->my_vis_info->refcount); 875 kref_init(&bat_priv->my_vis_info->refcount);
875 bat_priv->my_vis_info->bat_priv = bat_priv; 876 bat_priv->my_vis_info->bat_priv = bat_priv;
876 packet->header.version = BATADV_COMPAT_VERSION; 877 packet->header.version = BATADV_COMPAT_VERSION;
877 packet->header.packet_type = BAT_VIS; 878 packet->header.packet_type = BAT_VIS;
878 packet->header.ttl = TTL; 879 packet->header.ttl = BATADV_TTL;
879 packet->seqno = 0; 880 packet->seqno = 0;
880 packet->entries = 0; 881 packet->entries = 0;
881 882
@@ -936,5 +937,5 @@ static void batadv_start_vis_timer(struct bat_priv *bat_priv)
936{ 937{
937 INIT_DELAYED_WORK(&bat_priv->vis_work, batadv_send_vis_packets); 938 INIT_DELAYED_WORK(&bat_priv->vis_work, batadv_send_vis_packets);
938 queue_delayed_work(batadv_event_workqueue, &bat_priv->vis_work, 939 queue_delayed_work(batadv_event_workqueue, &bat_priv->vis_work,
939 msecs_to_jiffies(VIS_INTERVAL)); 940 msecs_to_jiffies(BATADV_VIS_INTERVAL));
940} 941}