aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/batman-adv/bat_debugfs.c34
-rw-r--r--net/batman-adv/bat_debugfs.h2
-rw-r--r--net/batman-adv/bat_iv_ogm.c125
-rw-r--r--net/batman-adv/bat_sysfs.c228
-rw-r--r--net/batman-adv/bat_sysfs.h4
-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.c24
-rw-r--r--net/batman-adv/bridge_loop_avoidance.h2
-rw-r--r--net/batman-adv/gateway_client.c32
-rw-r--r--net/batman-adv/gateway_common.c26
-rw-r--r--net/batman-adv/gateway_common.h6
-rw-r--r--net/batman-adv/hard-interface.c50
-rw-r--r--net/batman-adv/icmp_socket.c6
-rw-r--r--net/batman-adv/icmp_socket.h2
-rw-r--r--net/batman-adv/main.c91
-rw-r--r--net/batman-adv/main.h101
-rw-r--r--net/batman-adv/originator.c34
-rw-r--r--net/batman-adv/packet.h12
-rw-r--r--net/batman-adv/ring_buffer.c4
-rw-r--r--net/batman-adv/routing.c32
-rw-r--r--net/batman-adv/send.c6
-rw-r--r--net/batman-adv/soft-interface.c24
-rw-r--r--net/batman-adv/translation-table.c163
-rw-r--r--net/batman-adv/translation-table.h4
-rw-r--r--net/batman-adv/types.h19
-rw-r--r--net/batman-adv/unicast.c37
-rw-r--r--net/batman-adv/unicast.h4
-rw-r--r--net/batman-adv/vis.c422
-rw-r--r--net/batman-adv/vis.h2
30 files changed, 780 insertions, 740 deletions
diff --git a/net/batman-adv/bat_debugfs.c b/net/batman-adv/bat_debugfs.c
index 03f09f0f6d98..4dcda43d6822 100644
--- a/net/batman-adv/bat_debugfs.c
+++ b/net/batman-adv/bat_debugfs.c
@@ -35,14 +35,14 @@
35static struct dentry *batadv_debugfs; 35static struct dentry *batadv_debugfs;
36 36
37#ifdef CONFIG_BATMAN_ADV_DEBUG 37#ifdef CONFIG_BATMAN_ADV_DEBUG
38#define LOG_BUFF_MASK (batadv_log_buff_len - 1) 38#define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1)
39#define LOG_BUFF(idx) (debug_log->log_buff[(idx) & 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{
45 LOG_BUFF(debug_log->log_end) = c; 45 BATADV_LOG_BUFF(debug_log->log_end) = c;
46 debug_log->log_end++; 46 debug_log->log_end++;
47 47
48 if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len) 48 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 133
134 while ((!error) && (i < count) && 134 while ((!error) && (i < count) &&
135 (debug_log->log_start != debug_log->log_end)) { 135 (debug_log->log_start != debug_log->log_end)) {
136 c = LOG_BUFF(debug_log->log_start); 136 c = BATADV_LOG_BUFF(debug_log->log_start);
137 137
138 debug_log->log_start++; 138 debug_log->log_start++;
139 139
@@ -270,7 +270,7 @@ struct bat_debuginfo {
270 const struct file_operations fops; 270 const struct file_operations fops;
271}; 271};
272 272
273#define BAT_DEBUGINFO(_name, _mode, _open) \ 273#define BATADV_DEBUGINFO(_name, _mode, _open) \
274struct bat_debuginfo batadv_debuginfo_##_name = { \ 274struct bat_debuginfo batadv_debuginfo_##_name = { \
275 .attr = { .name = __stringify(_name), \ 275 .attr = { .name = __stringify(_name), \
276 .mode = _mode, }, \ 276 .mode = _mode, }, \
@@ -282,15 +282,17 @@ struct bat_debuginfo batadv_debuginfo_##_name = { \
282 } \ 282 } \
283}; 283};
284 284
285static BAT_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open); 285static BATADV_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open);
286static BAT_DEBUGINFO(originators, S_IRUGO, batadv_originators_open); 286static BATADV_DEBUGINFO(originators, S_IRUGO, batadv_originators_open);
287static BAT_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open); 287static BATADV_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open);
288static BAT_DEBUGINFO(transtable_global, S_IRUGO, batadv_transtable_global_open); 288static BATADV_DEBUGINFO(transtable_global, S_IRUGO,
289 batadv_transtable_global_open);
289#ifdef CONFIG_BATMAN_ADV_BLA 290#ifdef CONFIG_BATMAN_ADV_BLA
290static BAT_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open); 291static BATADV_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open);
291#endif 292#endif
292static BAT_DEBUGINFO(transtable_local, S_IRUGO, batadv_transtable_local_open); 293static BATADV_DEBUGINFO(transtable_local, S_IRUGO,
293static BAT_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open); 294 batadv_transtable_local_open);
295static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open);
294 296
295static struct bat_debuginfo *batadv_mesh_debuginfos[] = { 297static struct bat_debuginfo *batadv_mesh_debuginfos[] = {
296 &batadv_debuginfo_originators, 298 &batadv_debuginfo_originators,
@@ -309,7 +311,7 @@ void batadv_debugfs_init(void)
309 struct bat_debuginfo *bat_debug; 311 struct bat_debuginfo *bat_debug;
310 struct dentry *file; 312 struct dentry *file;
311 313
312 batadv_debugfs = debugfs_create_dir(DEBUGFS_BAT_SUBDIR, NULL); 314 batadv_debugfs = debugfs_create_dir(BATADV_DEBUGFS_SUBDIR, NULL);
313 if (batadv_debugfs == ERR_PTR(-ENODEV)) 315 if (batadv_debugfs == ERR_PTR(-ENODEV))
314 batadv_debugfs = NULL; 316 batadv_debugfs = NULL;
315 317
@@ -360,8 +362,8 @@ int batadv_debugfs_add_meshif(struct net_device *dev)
360 bat_priv->debug_dir, 362 bat_priv->debug_dir,
361 dev, &(*bat_debug)->fops); 363 dev, &(*bat_debug)->fops);
362 if (!file) { 364 if (!file) {
363 bat_err(dev, "Can't add debugfs file: %s/%s\n", 365 batadv_err(dev, "Can't add debugfs file: %s/%s\n",
364 dev->name, ((*bat_debug)->attr).name); 366 dev->name, ((*bat_debug)->attr).name);
365 goto rem_attr; 367 goto rem_attr;
366 } 368 }
367 } 369 }
diff --git a/net/batman-adv/bat_debugfs.h b/net/batman-adv/bat_debugfs.h
index eb0d576b4f9d..3319e1f21f55 100644
--- a/net/batman-adv/bat_debugfs.h
+++ b/net/batman-adv/bat_debugfs.h
@@ -20,7 +20,7 @@
20#ifndef _NET_BATMAN_ADV_DEBUGFS_H_ 20#ifndef _NET_BATMAN_ADV_DEBUGFS_H_
21#define _NET_BATMAN_ADV_DEBUGFS_H_ 21#define _NET_BATMAN_ADV_DEBUGFS_H_
22 22
23#define DEBUGFS_BAT_SUBDIR "batman_adv" 23#define BATADV_DEBUGFS_SUBDIR "batman_adv"
24 24
25void batadv_debugfs_init(void); 25void batadv_debugfs_init(void);
26void batadv_debugfs_destroy(void); 26void batadv_debugfs_destroy(void);
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index ca6466574c46..bbe0f123d2a5 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -64,7 +64,7 @@ static int batadv_iv_ogm_iface_enable(struct hard_iface *hard_iface)
64 get_random_bytes(&random_seqno, sizeof(random_seqno)); 64 get_random_bytes(&random_seqno, sizeof(random_seqno));
65 atomic_set(&hard_iface->seqno, random_seqno); 65 atomic_set(&hard_iface->seqno, random_seqno);
66 66
67 hard_iface->packet_len = BATMAN_OGM_HLEN; 67 hard_iface->packet_len = BATADV_OGM_HLEN;
68 hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC); 68 hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC);
69 69
70 if (!hard_iface->packet_buff) 70 if (!hard_iface->packet_buff)
@@ -72,10 +72,10 @@ static int batadv_iv_ogm_iface_enable(struct hard_iface *hard_iface)
72 72
73 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; 73 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff;
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 = 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? */
@@ -139,11 +147,11 @@ static int batadv_iv_ogm_aggr_packet(int buff_pos, int packet_len,
139{ 147{
140 int next_buff_pos = 0; 148 int next_buff_pos = 0;
141 149
142 next_buff_pos += buff_pos + BATMAN_OGM_HLEN; 150 next_buff_pos += buff_pos + BATADV_OGM_HLEN;
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 */
@@ -191,7 +199,7 @@ static void batadv_iv_ogm_send_to_if(struct forw_packet *forw_packet,
191 batman_ogm_packet->ttvn, hard_iface->net_dev->name, 199 batman_ogm_packet->ttvn, hard_iface->net_dev->name,
192 hard_iface->net_dev->dev_addr); 200 hard_iface->net_dev->dev_addr);
193 201
194 buff_pos += BATMAN_OGM_HLEN; 202 buff_pos += BATADV_OGM_HLEN;
195 buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes); 203 buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes);
196 packet_num++; 204 packet_num++;
197 batman_ogm_packet = (struct batman_ogm_packet *) 205 batman_ogm_packet = (struct batman_ogm_packet *)
@@ -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,13 +377,14 @@ 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;
373 384
374 /* own packet should always be scheduled */ 385 /* own packet should always be scheduled */
375 if (!own_packet) { 386 if (!own_packet) {
376 if (!atomic_dec_not_zero(&bat_priv->batman_queue_left)) { 387 if (!batadv_atomic_dec_not_zero(&bat_priv->batman_queue_left)) {
377 batadv_dbg(DBG_BATMAN, bat_priv, 388 batadv_dbg(DBG_BATMAN, bat_priv,
378 "batman packet queue full\n"); 389 "batman packet queue full\n");
379 goto out; 390 goto out;
@@ -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,
@@ -561,7 +573,7 @@ static void batadv_iv_ogm_forward(struct orig_node *orig_node,
561 batman_ogm_packet->flags &= ~DIRECTLINK; 573 batman_ogm_packet->flags &= ~DIRECTLINK;
562 574
563 batadv_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet, 575 batadv_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet,
564 BATMAN_OGM_HLEN + batadv_tt_len(tt_num_changes), 576 BATADV_OGM_HLEN + batadv_tt_len(tt_num_changes),
565 if_incoming, 0, batadv_iv_ogm_fwd_send_time()); 577 if_incoming, 0, batadv_iv_ogm_fwd_send_time());
566} 578}
567 579
@@ -579,7 +591,7 @@ static void batadv_iv_ogm_schedule(struct hard_iface *hard_iface)
579 tt_num_changes = batadv_tt_append_diff(bat_priv, 591 tt_num_changes = batadv_tt_append_diff(bat_priv,
580 &hard_iface->packet_buff, 592 &hard_iface->packet_buff,
581 &hard_iface->packet_len, 593 &hard_iface->packet_len,
582 BATMAN_OGM_HLEN); 594 BATADV_OGM_HLEN);
583 595
584 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; 596 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff;
585 597
@@ -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
@@ -1025,7 +1040,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1025 } 1040 }
1026 rcu_read_unlock(); 1041 rcu_read_unlock();
1027 1042
1028 if (batman_ogm_packet->header.version != COMPAT_VERSION) { 1043 if (batman_ogm_packet->header.version != BATADV_COMPAT_VERSION) {
1029 batadv_dbg(DBG_BATMAN, bat_priv, 1044 batadv_dbg(DBG_BATMAN, bat_priv,
1030 "Drop packet: incompatible batman version (%i)\n", 1045 "Drop packet: incompatible batman version (%i)\n",
1031 batman_ogm_packet->header.version); 1046 batman_ogm_packet->header.version);
@@ -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
@@ -1227,7 +1246,7 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
1227 unsigned char *tt_buff, *packet_buff; 1246 unsigned char *tt_buff, *packet_buff;
1228 bool ret; 1247 bool ret;
1229 1248
1230 ret = batadv_check_management_packet(skb, if_incoming, BATMAN_OGM_HLEN); 1249 ret = batadv_check_management_packet(skb, if_incoming, BATADV_OGM_HLEN);
1231 if (!ret) 1250 if (!ret)
1232 return NET_RX_DROP; 1251 return NET_RX_DROP;
1233 1252
@@ -1248,12 +1267,12 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
1248 1267
1249 /* unpack the aggregated packets and process them one by one */ 1268 /* unpack the aggregated packets and process them one by one */
1250 do { 1269 do {
1251 tt_buff = packet_buff + buff_pos + BATMAN_OGM_HLEN; 1270 tt_buff = packet_buff + buff_pos + BATADV_OGM_HLEN;
1252 1271
1253 batadv_iv_ogm_process(ethhdr, batman_ogm_packet, tt_buff, 1272 batadv_iv_ogm_process(ethhdr, batman_ogm_packet, tt_buff,
1254 if_incoming); 1273 if_incoming);
1255 1274
1256 buff_pos += BATMAN_OGM_HLEN; 1275 buff_pos += BATADV_OGM_HLEN;
1257 buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes); 1276 buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes);
1258 1277
1259 batman_ogm_packet = (struct batman_ogm_packet *) 1278 batman_ogm_packet = (struct batman_ogm_packet *)
diff --git a/net/batman-adv/bat_sysfs.c b/net/batman-adv/bat_sysfs.c
index 03b76a41ac4e..95d80d1808f2 100644
--- a/net/batman-adv/bat_sysfs.c
+++ b/net/batman-adv/bat_sysfs.c
@@ -38,9 +38,9 @@ static struct bat_priv *batadv_kobj_to_batpriv(struct kobject *obj)
38 return netdev_priv(net_dev); 38 return netdev_priv(net_dev);
39} 39}
40 40
41#define UEV_TYPE_VAR "BATTYPE=" 41#define BATADV_UEV_TYPE_VAR "BATTYPE="
42#define UEV_ACTION_VAR "BATACTION=" 42#define BATADV_UEV_ACTION_VAR "BATACTION="
43#define UEV_DATA_VAR "BATDATA=" 43#define BATADV_UEV_DATA_VAR "BATDATA="
44 44
45static char *batadv_uev_action_str[] = { 45static char *batadv_uev_action_str[] = {
46 "add", 46 "add",
@@ -53,15 +53,15 @@ static char *batadv_uev_type_str[] = {
53}; 53};
54 54
55/* Use this, if you have customized show and store functions */ 55/* Use this, if you have customized show and store functions */
56#define BAT_ATTR(_name, _mode, _show, _store) \ 56#define BATADV_ATTR(_name, _mode, _show, _store) \
57struct bat_attribute batadv_attr_##_name = { \ 57struct bat_attribute batadv_attr_##_name = { \
58 .attr = {.name = __stringify(_name), \ 58 .attr = {.name = __stringify(_name), \
59 .mode = _mode }, \ 59 .mode = _mode }, \
60 .show = _show, \ 60 .show = _show, \
61 .store = _store, \ 61 .store = _store, \
62}; 62};
63 63
64#define BAT_ATTR_SIF_STORE_BOOL(_name, _post_func) \ 64#define BATADV_ATTR_SIF_STORE_BOOL(_name, _post_func) \
65ssize_t batadv_store_##_name(struct kobject *kobj, \ 65ssize_t batadv_store_##_name(struct kobject *kobj, \
66 struct attribute *attr, char *buff, \ 66 struct attribute *attr, char *buff, \
67 size_t count) \ 67 size_t count) \
@@ -72,7 +72,7 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \
72 &bat_priv->_name, net_dev); \ 72 &bat_priv->_name, net_dev); \
73} 73}
74 74
75#define BAT_ATTR_SIF_SHOW_BOOL(_name) \ 75#define BATADV_ATTR_SIF_SHOW_BOOL(_name) \
76ssize_t batadv_show_##_name(struct kobject *kobj, \ 76ssize_t batadv_show_##_name(struct kobject *kobj, \
77 struct attribute *attr, char *buff) \ 77 struct attribute *attr, char *buff) \
78{ \ 78{ \
@@ -85,14 +85,14 @@ ssize_t batadv_show_##_name(struct kobject *kobj, \
85/* Use this, if you are going to turn a [name] in the soft-interface 85/* Use this, if you are going to turn a [name] in the soft-interface
86 * (bat_priv) on or off 86 * (bat_priv) on or off
87 */ 87 */
88#define BAT_ATTR_SIF_BOOL(_name, _mode, _post_func) \ 88#define BATADV_ATTR_SIF_BOOL(_name, _mode, _post_func) \
89 static BAT_ATTR_SIF_STORE_BOOL(_name, _post_func) \ 89 static BATADV_ATTR_SIF_STORE_BOOL(_name, _post_func) \
90 static BAT_ATTR_SIF_SHOW_BOOL(_name) \ 90 static BATADV_ATTR_SIF_SHOW_BOOL(_name) \
91 static BAT_ATTR(_name, _mode, batadv_show_##_name, \ 91 static BATADV_ATTR(_name, _mode, batadv_show_##_name, \
92 batadv_store_##_name) 92 batadv_store_##_name)
93 93
94 94
95#define BAT_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \ 95#define BATADV_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \
96ssize_t batadv_store_##_name(struct kobject *kobj, \ 96ssize_t batadv_store_##_name(struct kobject *kobj, \
97 struct attribute *attr, char *buff, \ 97 struct attribute *attr, char *buff, \
98 size_t count) \ 98 size_t count) \
@@ -104,7 +104,7 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \
104 &bat_priv->_name, net_dev); \ 104 &bat_priv->_name, net_dev); \
105} 105}
106 106
107#define BAT_ATTR_SIF_SHOW_UINT(_name) \ 107#define BATADV_ATTR_SIF_SHOW_UINT(_name) \
108ssize_t batadv_show_##_name(struct kobject *kobj, \ 108ssize_t batadv_show_##_name(struct kobject *kobj, \
109 struct attribute *attr, char *buff) \ 109 struct attribute *attr, char *buff) \
110{ \ 110{ \
@@ -115,14 +115,14 @@ ssize_t batadv_show_##_name(struct kobject *kobj, \
115/* Use this, if you are going to set [name] in the soft-interface 115/* Use this, if you are going to set [name] in the soft-interface
116 * (bat_priv) to an unsigned integer value 116 * (bat_priv) to an unsigned integer value
117 */ 117 */
118#define BAT_ATTR_SIF_UINT(_name, _mode, _min, _max, _post_func) \ 118#define BATADV_ATTR_SIF_UINT(_name, _mode, _min, _max, _post_func) \
119 static BAT_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \ 119 static BATADV_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func)\
120 static BAT_ATTR_SIF_SHOW_UINT(_name) \ 120 static BATADV_ATTR_SIF_SHOW_UINT(_name) \
121 static BAT_ATTR(_name, _mode, batadv_show_##_name, \ 121 static BATADV_ATTR(_name, _mode, batadv_show_##_name, \
122 batadv_store_##_name) 122 batadv_store_##_name)
123 123
124 124
125#define BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \ 125#define BATADV_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \
126ssize_t batadv_store_##_name(struct kobject *kobj, \ 126ssize_t batadv_store_##_name(struct kobject *kobj, \
127 struct attribute *attr, char *buff, \ 127 struct attribute *attr, char *buff, \
128 size_t count) \ 128 size_t count) \
@@ -143,7 +143,7 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \
143 return length; \ 143 return length; \
144} 144}
145 145
146#define BAT_ATTR_HIF_SHOW_UINT(_name) \ 146#define BATADV_ATTR_HIF_SHOW_UINT(_name) \
147ssize_t batadv_show_##_name(struct kobject *kobj, \ 147ssize_t batadv_show_##_name(struct kobject *kobj, \
148 struct attribute *attr, char *buff) \ 148 struct attribute *attr, char *buff) \
149{ \ 149{ \
@@ -164,11 +164,11 @@ ssize_t batadv_show_##_name(struct kobject *kobj, \
164/* Use this, if you are going to set [name] in hard_iface to an 164/* Use this, if you are going to set [name] in hard_iface to an
165 * unsigned integer value 165 * unsigned integer value
166 */ 166 */
167#define BAT_ATTR_HIF_UINT(_name, _mode, _min, _max, _post_func) \ 167#define BATADV_ATTR_HIF_UINT(_name, _mode, _min, _max, _post_func) \
168 static BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \ 168 static BATADV_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func)\
169 static BAT_ATTR_HIF_SHOW_UINT(_name) \ 169 static BATADV_ATTR_HIF_SHOW_UINT(_name) \
170 static BAT_ATTR(_name, _mode, batadv_show_##_name, \ 170 static BATADV_ATTR(_name, _mode, batadv_show_##_name, \
171 batadv_store_##_name) 171 batadv_store_##_name)
172 172
173 173
174static int batadv_store_bool_attr(char *buff, size_t count, 174static int batadv_store_bool_attr(char *buff, size_t count,
@@ -191,18 +191,17 @@ static int batadv_store_bool_attr(char *buff, size_t count,
191 enabled = 0; 191 enabled = 0;
192 192
193 if (enabled < 0) { 193 if (enabled < 0) {
194 bat_info(net_dev, 194 batadv_info(net_dev, "%s: Invalid parameter received: %s\n",
195 "%s: Invalid parameter received: %s\n", 195 attr_name, buff);
196 attr_name, buff);
197 return -EINVAL; 196 return -EINVAL;
198 } 197 }
199 198
200 if (atomic_read(attr) == enabled) 199 if (atomic_read(attr) == enabled)
201 return count; 200 return count;
202 201
203 bat_info(net_dev, "%s: Changing from: %s to: %s\n", attr_name, 202 batadv_info(net_dev, "%s: Changing from: %s to: %s\n", attr_name,
204 atomic_read(attr) == 1 ? "enabled" : "disabled", 203 atomic_read(attr) == 1 ? "enabled" : "disabled",
205 enabled == 1 ? "enabled" : "disabled"); 204 enabled == 1 ? "enabled" : "disabled");
206 205
207 atomic_set(attr, (unsigned int)enabled); 206 atomic_set(attr, (unsigned int)enabled);
208 return count; 207 return count;
@@ -235,29 +234,28 @@ static int batadv_store_uint_attr(const char *buff, size_t count,
235 234
236 ret = kstrtoul(buff, 10, &uint_val); 235 ret = kstrtoul(buff, 10, &uint_val);
237 if (ret) { 236 if (ret) {
238 bat_info(net_dev, 237 batadv_info(net_dev, "%s: Invalid parameter received: %s\n",
239 "%s: Invalid parameter received: %s\n", 238 attr_name, buff);
240 attr_name, buff);
241 return -EINVAL; 239 return -EINVAL;
242 } 240 }
243 241
244 if (uint_val < min) { 242 if (uint_val < min) {
245 bat_info(net_dev, "%s: Value is too small: %lu min: %u\n", 243 batadv_info(net_dev, "%s: Value is too small: %lu min: %u\n",
246 attr_name, uint_val, min); 244 attr_name, uint_val, min);
247 return -EINVAL; 245 return -EINVAL;
248 } 246 }
249 247
250 if (uint_val > max) { 248 if (uint_val > max) {
251 bat_info(net_dev, "%s: Value is too big: %lu max: %u\n", 249 batadv_info(net_dev, "%s: Value is too big: %lu max: %u\n",
252 attr_name, uint_val, max); 250 attr_name, uint_val, max);
253 return -EINVAL; 251 return -EINVAL;
254 } 252 }
255 253
256 if (atomic_read(attr) == uint_val) 254 if (atomic_read(attr) == uint_val)
257 return count; 255 return count;
258 256
259 bat_info(net_dev, "%s: Changing from: %i to: %lu\n", 257 batadv_info(net_dev, "%s: Changing from: %i to: %lu\n",
260 attr_name, atomic_read(attr), uint_val); 258 attr_name, atomic_read(attr), uint_val);
261 259
262 atomic_set(attr, uint_val); 260 atomic_set(attr, uint_val);
263 return count; 261 return count;
@@ -299,6 +297,7 @@ static ssize_t batadv_store_vis_mode(struct kobject *kobj,
299 struct bat_priv *bat_priv = netdev_priv(net_dev); 297 struct bat_priv *bat_priv = netdev_priv(net_dev);
300 unsigned long val; 298 unsigned long val;
301 int ret, vis_mode_tmp = -1; 299 int ret, vis_mode_tmp = -1;
300 const char *old_mode, *new_mode;
302 301
303 ret = kstrtoul(buff, 10, &val); 302 ret = kstrtoul(buff, 10, &val);
304 303
@@ -315,19 +314,27 @@ static ssize_t batadv_store_vis_mode(struct kobject *kobj,
315 if (buff[count - 1] == '\n') 314 if (buff[count - 1] == '\n')
316 buff[count - 1] = '\0'; 315 buff[count - 1] = '\0';
317 316
318 bat_info(net_dev, 317 batadv_info(net_dev,
319 "Invalid parameter for 'vis mode' setting received: %s\n", 318 "Invalid parameter for 'vis mode' setting received: %s\n",
320 buff); 319 buff);
321 return -EINVAL; 320 return -EINVAL;
322 } 321 }
323 322
324 if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp) 323 if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp)
325 return count; 324 return count;
326 325
327 bat_info(net_dev, "Changing vis mode from: %s to: %s\n", 326 if (atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE)
328 atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ? 327 old_mode = "client";
329 "client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ? 328 else
330 "client" : "server"); 329 old_mode = "server";
330
331 if (vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE)
332 new_mode = "client";
333 else
334 new_mode = "server";
335
336 batadv_info(net_dev, "Changing vis mode from: %s to: %s\n", old_mode,
337 new_mode);
331 338
332 atomic_set(&bat_priv->vis_mode, (unsigned int)vis_mode_tmp); 339 atomic_set(&bat_priv->vis_mode, (unsigned int)vis_mode_tmp);
333 return count; 340 return count;
@@ -354,13 +361,16 @@ static ssize_t batadv_show_gw_mode(struct kobject *kobj, struct attribute *attr,
354 361
355 switch (atomic_read(&bat_priv->gw_mode)) { 362 switch (atomic_read(&bat_priv->gw_mode)) {
356 case GW_MODE_CLIENT: 363 case GW_MODE_CLIENT:
357 bytes_written = sprintf(buff, "%s\n", GW_MODE_CLIENT_NAME); 364 bytes_written = sprintf(buff, "%s\n",
365 BATADV_GW_MODE_CLIENT_NAME);
358 break; 366 break;
359 case GW_MODE_SERVER: 367 case GW_MODE_SERVER:
360 bytes_written = sprintf(buff, "%s\n", GW_MODE_SERVER_NAME); 368 bytes_written = sprintf(buff, "%s\n",
369 BATADV_GW_MODE_SERVER_NAME);
361 break; 370 break;
362 default: 371 default:
363 bytes_written = sprintf(buff, "%s\n", GW_MODE_OFF_NAME); 372 bytes_written = sprintf(buff, "%s\n",
373 BATADV_GW_MODE_OFF_NAME);
364 break; 374 break;
365 } 375 }
366 376
@@ -379,21 +389,22 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj,
379 if (buff[count - 1] == '\n') 389 if (buff[count - 1] == '\n')
380 buff[count - 1] = '\0'; 390 buff[count - 1] = '\0';
381 391
382 if (strncmp(buff, GW_MODE_OFF_NAME, strlen(GW_MODE_OFF_NAME)) == 0) 392 if (strncmp(buff, BATADV_GW_MODE_OFF_NAME,
393 strlen(BATADV_GW_MODE_OFF_NAME)) == 0)
383 gw_mode_tmp = GW_MODE_OFF; 394 gw_mode_tmp = GW_MODE_OFF;
384 395
385 if (strncmp(buff, GW_MODE_CLIENT_NAME, 396 if (strncmp(buff, BATADV_GW_MODE_CLIENT_NAME,
386 strlen(GW_MODE_CLIENT_NAME)) == 0) 397 strlen(BATADV_GW_MODE_CLIENT_NAME)) == 0)
387 gw_mode_tmp = GW_MODE_CLIENT; 398 gw_mode_tmp = GW_MODE_CLIENT;
388 399
389 if (strncmp(buff, GW_MODE_SERVER_NAME, 400 if (strncmp(buff, BATADV_GW_MODE_SERVER_NAME,
390 strlen(GW_MODE_SERVER_NAME)) == 0) 401 strlen(BATADV_GW_MODE_SERVER_NAME)) == 0)
391 gw_mode_tmp = GW_MODE_SERVER; 402 gw_mode_tmp = GW_MODE_SERVER;
392 403
393 if (gw_mode_tmp < 0) { 404 if (gw_mode_tmp < 0) {
394 bat_info(net_dev, 405 batadv_info(net_dev,
395 "Invalid parameter for 'gw mode' setting received: %s\n", 406 "Invalid parameter for 'gw mode' setting received: %s\n",
396 buff); 407 buff);
397 return -EINVAL; 408 return -EINVAL;
398 } 409 }
399 410
@@ -402,18 +413,18 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj,
402 413
403 switch (atomic_read(&bat_priv->gw_mode)) { 414 switch (atomic_read(&bat_priv->gw_mode)) {
404 case GW_MODE_CLIENT: 415 case GW_MODE_CLIENT:
405 curr_gw_mode_str = GW_MODE_CLIENT_NAME; 416 curr_gw_mode_str = BATADV_GW_MODE_CLIENT_NAME;
406 break; 417 break;
407 case GW_MODE_SERVER: 418 case GW_MODE_SERVER:
408 curr_gw_mode_str = GW_MODE_SERVER_NAME; 419 curr_gw_mode_str = BATADV_GW_MODE_SERVER_NAME;
409 break; 420 break;
410 default: 421 default:
411 curr_gw_mode_str = GW_MODE_OFF_NAME; 422 curr_gw_mode_str = BATADV_GW_MODE_OFF_NAME;
412 break; 423 break;
413 } 424 }
414 425
415 bat_info(net_dev, "Changing gw mode from: %s to: %s\n", 426 batadv_info(net_dev, "Changing gw mode from: %s to: %s\n",
416 curr_gw_mode_str, buff); 427 curr_gw_mode_str, buff);
417 428
418 batadv_gw_deselect(bat_priv); 429 batadv_gw_deselect(bat_priv);
419 atomic_set(&bat_priv->gw_mode, (unsigned int)gw_mode_tmp); 430 atomic_set(&bat_priv->gw_mode, (unsigned int)gw_mode_tmp);
@@ -447,26 +458,28 @@ static ssize_t batadv_store_gw_bwidth(struct kobject *kobj,
447 return batadv_gw_bandwidth_set(net_dev, buff, count); 458 return batadv_gw_bandwidth_set(net_dev, buff, count);
448} 459}
449 460
450BAT_ATTR_SIF_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL); 461BATADV_ATTR_SIF_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL);
451BAT_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL); 462BATADV_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
452#ifdef CONFIG_BATMAN_ADV_BLA 463#ifdef CONFIG_BATMAN_ADV_BLA
453BAT_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL); 464BATADV_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL);
454#endif 465#endif
455BAT_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu); 466BATADV_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu);
456BAT_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL); 467BATADV_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL);
457static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, batadv_show_vis_mode, 468static BATADV_ATTR(vis_mode, S_IRUGO | S_IWUSR, batadv_show_vis_mode,
458 batadv_store_vis_mode); 469 batadv_store_vis_mode);
459static BAT_ATTR(routing_algo, S_IRUGO, batadv_show_bat_algo, NULL); 470static BATADV_ATTR(routing_algo, S_IRUGO, batadv_show_bat_algo, NULL);
460static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, batadv_show_gw_mode, 471static BATADV_ATTR(gw_mode, S_IRUGO | S_IWUSR, batadv_show_gw_mode,
461 batadv_store_gw_mode); 472 batadv_store_gw_mode);
462BAT_ATTR_SIF_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, NULL); 473BATADV_ATTR_SIF_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * BATADV_JITTER,
463BAT_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, TQ_MAX_VALUE, NULL); 474 INT_MAX, NULL);
464BAT_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, TQ_MAX_VALUE, 475BATADV_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, BATADV_TQ_MAX_VALUE,
465 batadv_post_gw_deselect); 476 NULL);
466static BAT_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth, 477BATADV_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, BATADV_TQ_MAX_VALUE,
467 batadv_store_gw_bwidth); 478 batadv_post_gw_deselect);
479static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth,
480 batadv_store_gw_bwidth);
468#ifdef CONFIG_BATMAN_ADV_DEBUG 481#ifdef CONFIG_BATMAN_ADV_DEBUG
469BAT_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, DBG_ALL, NULL); 482BATADV_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, DBG_ALL, NULL);
470#endif 483#endif
471 484
472static struct bat_attribute *batadv_mesh_attrs[] = { 485static struct bat_attribute *batadv_mesh_attrs[] = {
@@ -497,11 +510,11 @@ int batadv_sysfs_add_meshif(struct net_device *dev)
497 struct bat_attribute **bat_attr; 510 struct bat_attribute **bat_attr;
498 int err; 511 int err;
499 512
500 bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR, 513 bat_priv->mesh_obj = kobject_create_and_add(BATADV_SYSFS_IF_MESH_SUBDIR,
501 batif_kobject); 514 batif_kobject);
502 if (!bat_priv->mesh_obj) { 515 if (!bat_priv->mesh_obj) {
503 bat_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name, 516 batadv_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name,
504 SYSFS_IF_MESH_SUBDIR); 517 BATADV_SYSFS_IF_MESH_SUBDIR);
505 goto out; 518 goto out;
506 } 519 }
507 520
@@ -509,9 +522,9 @@ int batadv_sysfs_add_meshif(struct net_device *dev)
509 err = sysfs_create_file(bat_priv->mesh_obj, 522 err = sysfs_create_file(bat_priv->mesh_obj,
510 &((*bat_attr)->attr)); 523 &((*bat_attr)->attr));
511 if (err) { 524 if (err) {
512 bat_err(dev, "Can't add sysfs file: %s/%s/%s\n", 525 batadv_err(dev, "Can't add sysfs file: %s/%s/%s\n",
513 dev->name, SYSFS_IF_MESH_SUBDIR, 526 dev->name, BATADV_SYSFS_IF_MESH_SUBDIR,
514 ((*bat_attr)->attr).name); 527 ((*bat_attr)->attr).name);
515 goto rem_attr; 528 goto rem_attr;
516 } 529 }
517 } 530 }
@@ -649,9 +662,9 @@ static ssize_t batadv_show_iface_status(struct kobject *kobj,
649 return length; 662 return length;
650} 663}
651 664
652static BAT_ATTR(mesh_iface, S_IRUGO | S_IWUSR, 665static BATADV_ATTR(mesh_iface, S_IRUGO | S_IWUSR, batadv_show_mesh_iface,
653 batadv_show_mesh_iface, batadv_store_mesh_iface); 666 batadv_store_mesh_iface);
654static BAT_ATTR(iface_status, S_IRUGO, batadv_show_iface_status, NULL); 667static BATADV_ATTR(iface_status, S_IRUGO, batadv_show_iface_status, NULL);
655 668
656static struct bat_attribute *batadv_batman_attrs[] = { 669static struct bat_attribute *batadv_batman_attrs[] = {
657 &batadv_attr_mesh_iface, 670 &batadv_attr_mesh_iface,
@@ -665,21 +678,21 @@ int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
665 struct bat_attribute **bat_attr; 678 struct bat_attribute **bat_attr;
666 int err; 679 int err;
667 680
668 *hardif_obj = kobject_create_and_add(SYSFS_IF_BAT_SUBDIR, 681 *hardif_obj = kobject_create_and_add(BATADV_SYSFS_IF_BAT_SUBDIR,
669 hardif_kobject); 682 hardif_kobject);
670 683
671 if (!*hardif_obj) { 684 if (!*hardif_obj) {
672 bat_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name, 685 batadv_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name,
673 SYSFS_IF_BAT_SUBDIR); 686 BATADV_SYSFS_IF_BAT_SUBDIR);
674 goto out; 687 goto out;
675 } 688 }
676 689
677 for (bat_attr = batadv_batman_attrs; *bat_attr; ++bat_attr) { 690 for (bat_attr = batadv_batman_attrs; *bat_attr; ++bat_attr) {
678 err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr)); 691 err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr));
679 if (err) { 692 if (err) {
680 bat_err(dev, "Can't add sysfs file: %s/%s/%s\n", 693 batadv_err(dev, "Can't add sysfs file: %s/%s/%s\n",
681 dev->name, SYSFS_IF_BAT_SUBDIR, 694 dev->name, BATADV_SYSFS_IF_BAT_SUBDIR,
682 ((*bat_attr)->attr).name); 695 ((*bat_attr)->attr).name);
683 goto rem_attr; 696 goto rem_attr;
684 } 697 }
685 } 698 }
@@ -713,31 +726,32 @@ int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
713 726
714 bat_kobj = &primary_if->soft_iface->dev.kobj; 727 bat_kobj = &primary_if->soft_iface->dev.kobj;
715 728
716 uevent_env[0] = kmalloc(strlen(UEV_TYPE_VAR) + 729 uevent_env[0] = kmalloc(strlen(BATADV_UEV_TYPE_VAR) +
717 strlen(batadv_uev_type_str[type]) + 1, 730 strlen(batadv_uev_type_str[type]) + 1,
718 GFP_ATOMIC); 731 GFP_ATOMIC);
719 if (!uevent_env[0]) 732 if (!uevent_env[0])
720 goto out; 733 goto out;
721 734
722 sprintf(uevent_env[0], "%s%s", UEV_TYPE_VAR, batadv_uev_type_str[type]); 735 sprintf(uevent_env[0], "%s%s", BATADV_UEV_TYPE_VAR,
736 batadv_uev_type_str[type]);
723 737
724 uevent_env[1] = kmalloc(strlen(UEV_ACTION_VAR) + 738 uevent_env[1] = kmalloc(strlen(BATADV_UEV_ACTION_VAR) +
725 strlen(batadv_uev_action_str[action]) + 1, 739 strlen(batadv_uev_action_str[action]) + 1,
726 GFP_ATOMIC); 740 GFP_ATOMIC);
727 if (!uevent_env[1]) 741 if (!uevent_env[1])
728 goto out; 742 goto out;
729 743
730 sprintf(uevent_env[1], "%s%s", UEV_ACTION_VAR, 744 sprintf(uevent_env[1], "%s%s", BATADV_UEV_ACTION_VAR,
731 batadv_uev_action_str[action]); 745 batadv_uev_action_str[action]);
732 746
733 /* If the event is DEL, ignore the data field */ 747 /* If the event is DEL, ignore the data field */
734 if (action != UEV_DEL) { 748 if (action != UEV_DEL) {
735 uevent_env[2] = kmalloc(strlen(UEV_DATA_VAR) + 749 uevent_env[2] = kmalloc(strlen(BATADV_UEV_DATA_VAR) +
736 strlen(data) + 1, GFP_ATOMIC); 750 strlen(data) + 1, GFP_ATOMIC);
737 if (!uevent_env[2]) 751 if (!uevent_env[2])
738 goto out; 752 goto out;
739 753
740 sprintf(uevent_env[2], "%s%s", UEV_DATA_VAR, data); 754 sprintf(uevent_env[2], "%s%s", BATADV_UEV_DATA_VAR, data);
741 } 755 }
742 756
743 ret = kobject_uevent_env(bat_kobj, KOBJ_CHANGE, uevent_env); 757 ret = kobject_uevent_env(bat_kobj, KOBJ_CHANGE, uevent_env);
diff --git a/net/batman-adv/bat_sysfs.h b/net/batman-adv/bat_sysfs.h
index 367227707d52..23a8390851a6 100644
--- a/net/batman-adv/bat_sysfs.h
+++ b/net/batman-adv/bat_sysfs.h
@@ -20,8 +20,8 @@
20#ifndef _NET_BATMAN_ADV_SYSFS_H_ 20#ifndef _NET_BATMAN_ADV_SYSFS_H_
21#define _NET_BATMAN_ADV_SYSFS_H_ 21#define _NET_BATMAN_ADV_SYSFS_H_
22 22
23#define SYSFS_IF_MESH_SUBDIR "mesh" 23#define BATADV_SYSFS_IF_MESH_SUBDIR "mesh"
24#define SYSFS_IF_BAT_SUBDIR "batman_adv" 24#define BATADV_SYSFS_IF_BAT_SUBDIR "batman_adv"
25 25
26struct bat_attribute { 26struct bat_attribute {
27 struct attribute attr; 27 struct attribute attr;
diff --git a/net/batman-adv/bitarray.c b/net/batman-adv/bitarray.c
index e195b9eed7ee..4a009b550895 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 7954ba81cece..a081ce1c0514 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 0592d2bcb9b5..db20b688ee25 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -237,7 +237,7 @@ static void batadv_bla_del_backbone_claims(struct backbone_gw *backbone_gw)
237 } 237 }
238 238
239 /* all claims gone, intialize CRC */ 239 /* all claims gone, intialize CRC */
240 backbone_gw->crc = BLA_CRC_INIT; 240 backbone_gw->crc = BATADV_BLA_CRC_INIT;
241} 241}
242 242
243/* @bat_priv: the bat priv with all the soft interface information 243/* @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 375
376 entry->vid = vid; 376 entry->vid = vid;
377 entry->lasttime = jiffies; 377 entry->lasttime = jiffies;
378 entry->crc = BLA_CRC_INIT; 378 entry->crc = BATADV_BLA_CRC_INIT;
379 entry->bat_priv = bat_priv; 379 entry->bat_priv = bat_priv;
380 atomic_set(&entry->request_sent, 0); 380 atomic_set(&entry->request_sent, 0);
381 memcpy(entry->orig, orig, ETH_ALEN); 381 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 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/bridge_loop_avoidance.h b/net/batman-adv/bridge_loop_avoidance.h
index 9818b1e4c59e..58563f0cf61d 100644
--- a/net/batman-adv/bridge_loop_avoidance.h
+++ b/net/batman-adv/bridge_loop_avoidance.h
@@ -36,7 +36,7 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
36int batadv_bla_init(struct bat_priv *bat_priv); 36int batadv_bla_init(struct bat_priv *bat_priv);
37void batadv_bla_free(struct bat_priv *bat_priv); 37void batadv_bla_free(struct bat_priv *bat_priv);
38 38
39#define BLA_CRC_INIT 0 39#define BATADV_BLA_CRC_INIT 0
40#else /* ifdef CONFIG_BATMAN_ADV_BLA */ 40#else /* ifdef CONFIG_BATMAN_ADV_BLA */
41 41
42static inline int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, 42static inline int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb,
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index efe7519f1491..5fc162c8425a 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -33,8 +33,8 @@
33/* This is the offset of the options field in a dhcp packet starting at 33/* This is the offset of the options field in a dhcp packet starting at
34 * the beginning of the dhcp header 34 * the beginning of the dhcp header
35 */ 35 */
36#define DHCP_OPTIONS_OFFSET 240 36#define BATADV_DHCP_OPTIONS_OFFSET 240
37#define DHCP_REQUEST 3 37#define BATADV_DHCP_REQUEST 3
38 38
39static void batadv_gw_node_free_ref(struct gw_node *gw_node) 39static void batadv_gw_node_free_ref(struct gw_node *gw_node)
40{ 40{
@@ -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) &&
@@ -197,7 +197,7 @@ void batadv_gw_election(struct bat_priv *bat_priv)
197 if (atomic_read(&bat_priv->gw_mode) != GW_MODE_CLIENT) 197 if (atomic_read(&bat_priv->gw_mode) != GW_MODE_CLIENT)
198 goto out; 198 goto out;
199 199
200 if (!atomic_dec_not_zero(&bat_priv->gw_reselect)) 200 if (!batadv_atomic_dec_not_zero(&bat_priv->gw_reselect))
201 goto out; 201 goto out;
202 202
203 curr_gw = batadv_gw_get_selected_gw_node(bat_priv); 203 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 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();
@@ -521,11 +521,11 @@ static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len)
521 521
522 pkt_len = skb_headlen(skb); 522 pkt_len = skb_headlen(skb);
523 523
524 if (pkt_len < header_len + DHCP_OPTIONS_OFFSET + 1) 524 if (pkt_len < header_len + BATADV_DHCP_OPTIONS_OFFSET + 1)
525 goto out; 525 goto out;
526 526
527 p = skb->data + header_len + DHCP_OPTIONS_OFFSET; 527 p = skb->data + header_len + BATADV_DHCP_OPTIONS_OFFSET;
528 pkt_len -= header_len + DHCP_OPTIONS_OFFSET + 1; 528 pkt_len -= header_len + BATADV_DHCP_OPTIONS_OFFSET + 1;
529 529
530 /* Access the dhcp option lists. Each entry is made up by: 530 /* Access the dhcp option lists. Each entry is made up by:
531 * - octet 1: option type 531 * - octet 1: option type
@@ -543,7 +543,7 @@ static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len)
543 p += 2; 543 p += 2;
544 544
545 /* check if the message type is what we need */ 545 /* check if the message type is what we need */
546 if (*p == DHCP_REQUEST) 546 if (*p == BATADV_DHCP_REQUEST)
547 ret = true; 547 ret = true;
548 break; 548 break;
549 } else if (*p == 0) { 549 } else if (*p == 0) {
@@ -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/gateway_common.c b/net/batman-adv/gateway_common.c
index 6edf37f9a15c..f5c3980aaea6 100644
--- a/net/batman-adv/gateway_common.c
+++ b/net/batman-adv/gateway_common.c
@@ -97,9 +97,9 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
97 97
98 ret = kstrtol(buff, 10, &ldown); 98 ret = kstrtol(buff, 10, &ldown);
99 if (ret) { 99 if (ret) {
100 bat_err(net_dev, 100 batadv_err(net_dev,
101 "Download speed of gateway mode invalid: %s\n", 101 "Download speed of gateway mode invalid: %s\n",
102 buff); 102 buff);
103 return false; 103 return false;
104 } 104 }
105 105
@@ -122,9 +122,9 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
122 122
123 ret = kstrtol(slash_ptr + 1, 10, &lup); 123 ret = kstrtol(slash_ptr + 1, 10, &lup);
124 if (ret) { 124 if (ret) {
125 bat_err(net_dev, 125 batadv_err(net_dev,
126 "Upload speed of gateway mode invalid: %s\n", 126 "Upload speed of gateway mode invalid: %s\n",
127 slash_ptr + 1); 127 slash_ptr + 1);
128 return false; 128 return false;
129 } 129 }
130 130
@@ -164,13 +164,13 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
164 return count; 164 return count;
165 165
166 batadv_gw_deselect(bat_priv); 166 batadv_gw_deselect(bat_priv);
167 bat_info(net_dev, 167 batadv_info(net_dev,
168 "Changing gateway bandwidth from: '%i' to: '%ld' (propagating: %d%s/%d%s)\n", 168 "Changing gateway bandwidth from: '%i' to: '%ld' (propagating: %d%s/%d%s)\n",
169 atomic_read(&bat_priv->gw_bandwidth), gw_bandwidth_tmp, 169 atomic_read(&bat_priv->gw_bandwidth), gw_bandwidth_tmp,
170 (down > 2048 ? down / 1024 : down), 170 (down > 2048 ? down / 1024 : down),
171 (down > 2048 ? "MBit" : "KBit"), 171 (down > 2048 ? "MBit" : "KBit"),
172 (up > 2048 ? up / 1024 : up), 172 (up > 2048 ? up / 1024 : up),
173 (up > 2048 ? "MBit" : "KBit")); 173 (up > 2048 ? "MBit" : "KBit"));
174 174
175 atomic_set(&bat_priv->gw_bandwidth, gw_bandwidth_tmp); 175 atomic_set(&bat_priv->gw_bandwidth, gw_bandwidth_tmp);
176 176
diff --git a/net/batman-adv/gateway_common.h b/net/batman-adv/gateway_common.h
index 6f8a4d0cbbb6..31bbc3c070a6 100644
--- a/net/batman-adv/gateway_common.h
+++ b/net/batman-adv/gateway_common.h
@@ -26,9 +26,9 @@ enum gw_modes {
26 GW_MODE_SERVER, 26 GW_MODE_SERVER,
27}; 27};
28 28
29#define GW_MODE_OFF_NAME "off" 29#define BATADV_GW_MODE_OFF_NAME "off"
30#define GW_MODE_CLIENT_NAME "client" 30#define BATADV_GW_MODE_CLIENT_NAME "client"
31#define GW_MODE_SERVER_NAME "server" 31#define BATADV_GW_MODE_SERVER_NAME "server"
32 32
33void batadv_gw_bandwidth_to_kbit(uint8_t gw_class, int *down, int *up); 33void batadv_gw_bandwidth_to_kbit(uint8_t gw_class, int *down, int *up);
34ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, 34ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index c22c145d8224..e7eba9c32e70 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -196,7 +196,8 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
196 if (hard_iface->soft_iface != soft_iface) 196 if (hard_iface->soft_iface != soft_iface)
197 continue; 197 continue;
198 198
199 min_mtu = min_t(int, hard_iface->net_dev->mtu - BAT_HEADER_LEN, 199 min_mtu = min_t(int,
200 hard_iface->net_dev->mtu - BATADV_HEADER_LEN,
200 min_mtu); 201 min_mtu);
201 } 202 }
202 rcu_read_unlock(); 203 rcu_read_unlock();
@@ -234,8 +235,8 @@ static void batadv_hardif_activate_interface(struct hard_iface *hard_iface)
234 if (!primary_if) 235 if (!primary_if)
235 batadv_primary_if_select(bat_priv, hard_iface); 236 batadv_primary_if_select(bat_priv, hard_iface);
236 237
237 bat_info(hard_iface->soft_iface, "Interface activated: %s\n", 238 batadv_info(hard_iface->soft_iface, "Interface activated: %s\n",
238 hard_iface->net_dev->name); 239 hard_iface->net_dev->name);
239 240
240 batadv_update_min_mtu(hard_iface->soft_iface); 241 batadv_update_min_mtu(hard_iface->soft_iface);
241 242
@@ -252,8 +253,8 @@ static void batadv_hardif_deactivate_interface(struct hard_iface *hard_iface)
252 253
253 hard_iface->if_status = IF_INACTIVE; 254 hard_iface->if_status = IF_INACTIVE;
254 255
255 bat_info(hard_iface->soft_iface, "Interface deactivated: %s\n", 256 batadv_info(hard_iface->soft_iface, "Interface deactivated: %s\n",
256 hard_iface->net_dev->name); 257 hard_iface->net_dev->name);
257 258
258 batadv_update_min_mtu(hard_iface->soft_iface); 259 batadv_update_min_mtu(hard_iface->soft_iface);
259} 260}
@@ -263,6 +264,7 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
263{ 264{
264 struct bat_priv *bat_priv; 265 struct bat_priv *bat_priv;
265 struct net_device *soft_iface; 266 struct net_device *soft_iface;
267 __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN);
266 int ret; 268 int ret;
267 269
268 if (hard_iface->if_status != IF_NOT_IN_USE) 270 if (hard_iface->if_status != IF_NOT_IN_USE)
@@ -309,35 +311,35 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
309 hard_iface->if_status = IF_INACTIVE; 311 hard_iface->if_status = IF_INACTIVE;
310 batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces); 312 batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces);
311 313
312 hard_iface->batman_adv_ptype.type = __constant_htons(ETH_P_BATMAN); 314 hard_iface->batman_adv_ptype.type = ethertype;
313 hard_iface->batman_adv_ptype.func = batadv_batman_skb_recv; 315 hard_iface->batman_adv_ptype.func = batadv_batman_skb_recv;
314 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev; 316 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
315 dev_add_pack(&hard_iface->batman_adv_ptype); 317 dev_add_pack(&hard_iface->batman_adv_ptype);
316 318
317 atomic_set(&hard_iface->frag_seqno, 1); 319 atomic_set(&hard_iface->frag_seqno, 1);
318 bat_info(hard_iface->soft_iface, "Adding interface: %s\n", 320 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
319 hard_iface->net_dev->name); 321 hard_iface->net_dev->name);
320 322
321 if (atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < 323 if (atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu <
322 ETH_DATA_LEN + BAT_HEADER_LEN) 324 ETH_DATA_LEN + BATADV_HEADER_LEN)
323 bat_info(hard_iface->soft_iface, 325 batadv_info(hard_iface->soft_iface,
324 "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", 326 "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",
325 hard_iface->net_dev->name, hard_iface->net_dev->mtu, 327 hard_iface->net_dev->name, hard_iface->net_dev->mtu,
326 ETH_DATA_LEN + BAT_HEADER_LEN); 328 ETH_DATA_LEN + BATADV_HEADER_LEN);
327 329
328 if (!atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < 330 if (!atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu <
329 ETH_DATA_LEN + BAT_HEADER_LEN) 331 ETH_DATA_LEN + BATADV_HEADER_LEN)
330 bat_info(hard_iface->soft_iface, 332 batadv_info(hard_iface->soft_iface,
331 "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", 333 "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",
332 hard_iface->net_dev->name, hard_iface->net_dev->mtu, 334 hard_iface->net_dev->name, hard_iface->net_dev->mtu,
333 ETH_DATA_LEN + BAT_HEADER_LEN); 335 ETH_DATA_LEN + BATADV_HEADER_LEN);
334 336
335 if (batadv_hardif_is_iface_up(hard_iface)) 337 if (batadv_hardif_is_iface_up(hard_iface))
336 batadv_hardif_activate_interface(hard_iface); 338 batadv_hardif_activate_interface(hard_iface);
337 else 339 else
338 bat_err(hard_iface->soft_iface, 340 batadv_err(hard_iface->soft_iface,
339 "Not using interface %s (retrying later): interface not active\n", 341 "Not using interface %s (retrying later): interface not active\n",
340 hard_iface->net_dev->name); 342 hard_iface->net_dev->name);
341 343
342 /* begin scheduling originator messages on that interface */ 344 /* begin scheduling originator messages on that interface */
343 batadv_schedule_bat_ogm(hard_iface); 345 batadv_schedule_bat_ogm(hard_iface);
@@ -363,8 +365,8 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface)
363 if (hard_iface->if_status != IF_INACTIVE) 365 if (hard_iface->if_status != IF_INACTIVE)
364 goto out; 366 goto out;
365 367
366 bat_info(hard_iface->soft_iface, "Removing interface: %s\n", 368 batadv_info(hard_iface->soft_iface, "Removing interface: %s\n",
367 hard_iface->net_dev->name); 369 hard_iface->net_dev->name);
368 dev_remove_pack(&hard_iface->batman_adv_ptype); 370 dev_remove_pack(&hard_iface->batman_adv_ptype);
369 371
370 bat_priv->num_ifaces--; 372 bat_priv->num_ifaces--;
@@ -546,7 +548,7 @@ bool batadv_is_wifi_iface(int ifindex)
546 struct net_device *net_device = NULL; 548 struct net_device *net_device = NULL;
547 bool ret = false; 549 bool ret = false;
548 550
549 if (ifindex == NULL_IFINDEX) 551 if (ifindex == BATADV_NULL_IFINDEX)
550 goto out; 552 goto out;
551 553
552 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/icmp_socket.c b/net/batman-adv/icmp_socket.c
index b285c31bfa9e..f2f578b1d9f0 100644
--- a/net/batman-adv/icmp_socket.c
+++ b/net/batman-adv/icmp_socket.c
@@ -203,9 +203,9 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
203 203
204 icmp_packet->uid = socket_client->index; 204 icmp_packet->uid = socket_client->index;
205 205
206 if (icmp_packet->header.version != COMPAT_VERSION) { 206 if (icmp_packet->header.version != BATADV_COMPAT_VERSION) {
207 icmp_packet->msg_type = PARAMETER_PROBLEM; 207 icmp_packet->msg_type = PARAMETER_PROBLEM;
208 icmp_packet->header.version = COMPAT_VERSION; 208 icmp_packet->header.version = BATADV_COMPAT_VERSION;
209 batadv_socket_add_packet(socket_client, icmp_packet, 209 batadv_socket_add_packet(socket_client, icmp_packet,
210 packet_len); 210 packet_len);
211 goto free_skb; 211 goto free_skb;
@@ -282,7 +282,7 @@ int batadv_socket_setup(struct bat_priv *bat_priv)
282 if (!bat_priv->debug_dir) 282 if (!bat_priv->debug_dir)
283 goto err; 283 goto err;
284 284
285 d = debugfs_create_file(ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR, 285 d = debugfs_create_file(BATADV_ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR,
286 bat_priv->debug_dir, bat_priv, &batadv_fops); 286 bat_priv->debug_dir, bat_priv, &batadv_fops);
287 if (!d) 287 if (!d)
288 goto err; 288 goto err;
diff --git a/net/batman-adv/icmp_socket.h b/net/batman-adv/icmp_socket.h
index a62ab80df9bd..f88f9f0fe7a7 100644
--- a/net/batman-adv/icmp_socket.h
+++ b/net/batman-adv/icmp_socket.h
@@ -20,7 +20,7 @@
20#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ 20#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_
21#define _NET_BATMAN_ADV_ICMP_SOCKET_H_ 21#define _NET_BATMAN_ADV_ICMP_SOCKET_H_
22 22
23#define ICMP_SOCKET "socket" 23#define BATADV_ICMP_SOCKET "socket"
24 24
25void batadv_socket_init(void); 25void batadv_socket_init(void);
26int batadv_socket_setup(struct bat_priv *bat_priv); 26int batadv_socket_setup(struct bat_priv *bat_priv);
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index e4564306453c..df7335c4217a 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -38,22 +38,23 @@
38 * list traversals just rcu-locked 38 * list traversals just rcu-locked
39 */ 39 */
40struct list_head batadv_hardif_list; 40struct list_head batadv_hardif_list;
41static int (*recv_packet_handler[256])(struct sk_buff *, struct hard_iface *); 41static int (*batadv_rx_handler[256])(struct sk_buff *,
42 struct hard_iface *);
42char batadv_routing_algo[20] = "BATMAN_IV"; 43char batadv_routing_algo[20] = "BATMAN_IV";
43static struct hlist_head bat_algo_list; 44static struct hlist_head batadv_algo_list;
44 45
45unsigned char batadv_broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 46unsigned char batadv_broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
46 47
47struct workqueue_struct *batadv_event_workqueue; 48struct workqueue_struct *batadv_event_workqueue;
48 49
49static void recv_handler_init(void); 50static void batadv_recv_handler_init(void);
50 51
51static int __init batman_init(void) 52static int __init batadv_init(void)
52{ 53{
53 INIT_LIST_HEAD(&batadv_hardif_list); 54 INIT_LIST_HEAD(&batadv_hardif_list);
54 INIT_HLIST_HEAD(&bat_algo_list); 55 INIT_HLIST_HEAD(&batadv_algo_list);
55 56
56 recv_handler_init(); 57 batadv_recv_handler_init();
57 58
58 batadv_iv_init(); 59 batadv_iv_init();
59 60
@@ -71,12 +72,12 @@ static int __init batman_init(void)
71 register_netdevice_notifier(&batadv_hard_if_notifier); 72 register_netdevice_notifier(&batadv_hard_if_notifier);
72 73
73 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",
74 SOURCE_VERSION, COMPAT_VERSION); 75 BATADV_SOURCE_VERSION, BATADV_COMPAT_VERSION);
75 76
76 return 0; 77 return 0;
77} 78}
78 79
79static void __exit batman_exit(void) 80static void __exit batadv_exit(void)
80{ 81{
81 batadv_debugfs_destroy(); 82 batadv_debugfs_destroy();
82 unregister_netdevice_notifier(&batadv_hard_if_notifier); 83 unregister_netdevice_notifier(&batadv_hard_if_notifier);
@@ -119,7 +120,8 @@ int batadv_mesh_init(struct net_device *soft_iface)
119 if (ret < 0) 120 if (ret < 0)
120 goto err; 121 goto err;
121 122
122 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);
123 125
124 ret = batadv_vis_init(bat_priv); 126 ret = batadv_vis_init(bat_priv);
125 if (ret < 0) 127 if (ret < 0)
@@ -189,8 +191,8 @@ int batadv_is_my_mac(const uint8_t *addr)
189 return 0; 191 return 0;
190} 192}
191 193
192static int recv_unhandled_packet(struct sk_buff *skb, 194static int batadv_recv_unhandled_packet(struct sk_buff *skb,
193 struct hard_iface *recv_if) 195 struct hard_iface *recv_if)
194{ 196{
195 return NET_RX_DROP; 197 return NET_RX_DROP;
196} 198}
@@ -237,7 +239,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
237 239
238 batman_ogm_packet = (struct batman_ogm_packet *)skb->data; 240 batman_ogm_packet = (struct batman_ogm_packet *)skb->data;
239 241
240 if (batman_ogm_packet->header.version != COMPAT_VERSION) { 242 if (batman_ogm_packet->header.version != BATADV_COMPAT_VERSION) {
241 batadv_dbg(DBG_BATMAN, bat_priv, 243 batadv_dbg(DBG_BATMAN, bat_priv,
242 "Drop packet: incompatible batman version (%i)\n", 244 "Drop packet: incompatible batman version (%i)\n",
243 batman_ogm_packet->header.version); 245 batman_ogm_packet->header.version);
@@ -248,7 +250,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
248 * the supplied skb. if not, we have to free the skb. 250 * the supplied skb. if not, we have to free the skb.
249 */ 251 */
250 idx = batman_ogm_packet->header.packet_type; 252 idx = batman_ogm_packet->header.packet_type;
251 ret = (*recv_packet_handler[idx])(skb, hard_iface); 253 ret = (*batadv_rx_handler[idx])(skb, hard_iface);
252 254
253 if (ret == NET_RX_DROP) 255 if (ret == NET_RX_DROP)
254 kfree_skb(skb); 256 kfree_skb(skb);
@@ -265,51 +267,51 @@ err_out:
265 return NET_RX_DROP; 267 return NET_RX_DROP;
266} 268}
267 269
268static void recv_handler_init(void) 270static void batadv_recv_handler_init(void)
269{ 271{
270 int i; 272 int i;
271 273
272 for (i = 0; i < ARRAY_SIZE(recv_packet_handler); i++) 274 for (i = 0; i < ARRAY_SIZE(batadv_rx_handler); i++)
273 recv_packet_handler[i] = recv_unhandled_packet; 275 batadv_rx_handler[i] = batadv_recv_unhandled_packet;
274 276
275 /* batman icmp packet */ 277 /* batman icmp packet */
276 recv_packet_handler[BAT_ICMP] = batadv_recv_icmp_packet; 278 batadv_rx_handler[BAT_ICMP] = batadv_recv_icmp_packet;
277 /* unicast packet */ 279 /* unicast packet */
278 recv_packet_handler[BAT_UNICAST] = batadv_recv_unicast_packet; 280 batadv_rx_handler[BAT_UNICAST] = batadv_recv_unicast_packet;
279 /* fragmented unicast packet */ 281 /* fragmented unicast packet */
280 recv_packet_handler[BAT_UNICAST_FRAG] = batadv_recv_ucast_frag_packet; 282 batadv_rx_handler[BAT_UNICAST_FRAG] = batadv_recv_ucast_frag_packet;
281 /* broadcast packet */ 283 /* broadcast packet */
282 recv_packet_handler[BAT_BCAST] = batadv_recv_bcast_packet; 284 batadv_rx_handler[BAT_BCAST] = batadv_recv_bcast_packet;
283 /* vis packet */ 285 /* vis packet */
284 recv_packet_handler[BAT_VIS] = batadv_recv_vis_packet; 286 batadv_rx_handler[BAT_VIS] = batadv_recv_vis_packet;
285 /* Translation table query (request or response) */ 287 /* Translation table query (request or response) */
286 recv_packet_handler[BAT_TT_QUERY] = batadv_recv_tt_query; 288 batadv_rx_handler[BAT_TT_QUERY] = batadv_recv_tt_query;
287 /* Roaming advertisement */ 289 /* Roaming advertisement */
288 recv_packet_handler[BAT_ROAM_ADV] = batadv_recv_roam_adv; 290 batadv_rx_handler[BAT_ROAM_ADV] = batadv_recv_roam_adv;
289} 291}
290 292
291int batadv_recv_handler_register(uint8_t packet_type, 293int batadv_recv_handler_register(uint8_t packet_type,
292 int (*recv_handler)(struct sk_buff *, 294 int (*recv_handler)(struct sk_buff *,
293 struct hard_iface *)) 295 struct hard_iface *))
294{ 296{
295 if (recv_packet_handler[packet_type] != &recv_unhandled_packet) 297 if (batadv_rx_handler[packet_type] != &batadv_recv_unhandled_packet)
296 return -EBUSY; 298 return -EBUSY;
297 299
298 recv_packet_handler[packet_type] = recv_handler; 300 batadv_rx_handler[packet_type] = recv_handler;
299 return 0; 301 return 0;
300} 302}
301 303
302void batadv_recv_handler_unregister(uint8_t packet_type) 304void batadv_recv_handler_unregister(uint8_t packet_type)
303{ 305{
304 recv_packet_handler[packet_type] = recv_unhandled_packet; 306 batadv_rx_handler[packet_type] = batadv_recv_unhandled_packet;
305} 307}
306 308
307static struct bat_algo_ops *bat_algo_get(char *name) 309static struct bat_algo_ops *batadv_algo_get(char *name)
308{ 310{
309 struct bat_algo_ops *bat_algo_ops = NULL, *bat_algo_ops_tmp; 311 struct bat_algo_ops *bat_algo_ops = NULL, *bat_algo_ops_tmp;
310 struct hlist_node *node; 312 struct hlist_node *node;
311 313
312 hlist_for_each_entry(bat_algo_ops_tmp, node, &bat_algo_list, list) { 314 hlist_for_each_entry(bat_algo_ops_tmp, node, &batadv_algo_list, list) {
313 if (strcmp(bat_algo_ops_tmp->name, name) != 0) 315 if (strcmp(bat_algo_ops_tmp->name, name) != 0)
314 continue; 316 continue;
315 317
@@ -325,7 +327,7 @@ int batadv_algo_register(struct bat_algo_ops *bat_algo_ops)
325 struct bat_algo_ops *bat_algo_ops_tmp; 327 struct bat_algo_ops *bat_algo_ops_tmp;
326 int ret; 328 int ret;
327 329
328 bat_algo_ops_tmp = bat_algo_get(bat_algo_ops->name); 330 bat_algo_ops_tmp = batadv_algo_get(bat_algo_ops->name);
329 if (bat_algo_ops_tmp) { 331 if (bat_algo_ops_tmp) {
330 pr_info("Trying to register already registered routing algorithm: %s\n", 332 pr_info("Trying to register already registered routing algorithm: %s\n",
331 bat_algo_ops->name); 333 bat_algo_ops->name);
@@ -347,7 +349,7 @@ int batadv_algo_register(struct bat_algo_ops *bat_algo_ops)
347 } 349 }
348 350
349 INIT_HLIST_NODE(&bat_algo_ops->list); 351 INIT_HLIST_NODE(&bat_algo_ops->list);
350 hlist_add_head(&bat_algo_ops->list, &bat_algo_list); 352 hlist_add_head(&bat_algo_ops->list, &batadv_algo_list);
351 ret = 0; 353 ret = 0;
352 354
353out: 355out:
@@ -359,7 +361,7 @@ int batadv_algo_select(struct bat_priv *bat_priv, char *name)
359 struct bat_algo_ops *bat_algo_ops; 361 struct bat_algo_ops *bat_algo_ops;
360 int ret = -EINVAL; 362 int ret = -EINVAL;
361 363
362 bat_algo_ops = bat_algo_get(name); 364 bat_algo_ops = batadv_algo_get(name);
363 if (!bat_algo_ops) 365 if (!bat_algo_ops)
364 goto out; 366 goto out;
365 367
@@ -377,14 +379,14 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
377 379
378 seq_printf(seq, "Available routing algorithms:\n"); 380 seq_printf(seq, "Available routing algorithms:\n");
379 381
380 hlist_for_each_entry(bat_algo_ops, node, &bat_algo_list, list) { 382 hlist_for_each_entry(bat_algo_ops, node, &batadv_algo_list, list) {
381 seq_printf(seq, "%s\n", bat_algo_ops->name); 383 seq_printf(seq, "%s\n", bat_algo_ops->name);
382 } 384 }
383 385
384 return 0; 386 return 0;
385} 387}
386 388
387static int param_set_ra(const char *val, const struct kernel_param *kp) 389static int batadv_param_set_ra(const char *val, const struct kernel_param *kp)
388{ 390{
389 struct bat_algo_ops *bat_algo_ops; 391 struct bat_algo_ops *bat_algo_ops;
390 char *algo_name = (char *)val; 392 char *algo_name = (char *)val;
@@ -393,7 +395,7 @@ static int param_set_ra(const char *val, const struct kernel_param *kp)
393 if (algo_name[name_len - 1] == '\n') 395 if (algo_name[name_len - 1] == '\n')
394 algo_name[name_len - 1] = '\0'; 396 algo_name[name_len - 1] = '\0';
395 397
396 bat_algo_ops = bat_algo_get(algo_name); 398 bat_algo_ops = batadv_algo_get(algo_name);
397 if (!bat_algo_ops) { 399 if (!bat_algo_ops) {
398 pr_err("Routing algorithm '%s' is not supported\n", algo_name); 400 pr_err("Routing algorithm '%s' is not supported\n", algo_name);
399 return -EINVAL; 401 return -EINVAL;
@@ -402,23 +404,24 @@ static int param_set_ra(const char *val, const struct kernel_param *kp)
402 return param_set_copystring(algo_name, kp); 404 return param_set_copystring(algo_name, kp);
403} 405}
404 406
405static const struct kernel_param_ops param_ops_ra = { 407static const struct kernel_param_ops batadv_param_ops_ra = {
406 .set = param_set_ra, 408 .set = batadv_param_set_ra,
407 .get = param_get_string, 409 .get = param_get_string,
408}; 410};
409 411
410static struct kparam_string __param_string_ra = { 412static struct kparam_string batadv_param_string_ra = {
411 .maxlen = sizeof(batadv_routing_algo), 413 .maxlen = sizeof(batadv_routing_algo),
412 .string = batadv_routing_algo, 414 .string = batadv_routing_algo,
413}; 415};
414 416
415module_param_cb(routing_algo, &param_ops_ra, &__param_string_ra, 0644); 417module_param_cb(routing_algo, &batadv_param_ops_ra, &batadv_param_string_ra,
416module_init(batman_init); 418 0644);
417module_exit(batman_exit); 419module_init(batadv_init);
420module_exit(batadv_exit);
418 421
419MODULE_LICENSE("GPL"); 422MODULE_LICENSE("GPL");
420 423
421MODULE_AUTHOR(DRIVER_AUTHOR); 424MODULE_AUTHOR(BATADV_DRIVER_AUTHOR);
422MODULE_DESCRIPTION(DRIVER_DESC); 425MODULE_DESCRIPTION(BATADV_DRIVER_DESC);
423MODULE_SUPPORTED_DEVICE(DRIVER_DEVICE); 426MODULE_SUPPORTED_DEVICE(BATADV_DRIVER_DEVICE);
424MODULE_VERSION(SOURCE_VERSION); 427MODULE_VERSION(BATADV_SOURCE_VERSION);
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 28242642c3f1..09660b4041f9 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
@@ -190,14 +191,14 @@ static inline void batadv_dbg(int type __always_unused,
190} 191}
191#endif 192#endif
192 193
193#define bat_info(net_dev, fmt, arg...) \ 194#define batadv_info(net_dev, fmt, arg...) \
194 do { \ 195 do { \
195 struct net_device *_netdev = (net_dev); \ 196 struct net_device *_netdev = (net_dev); \
196 struct bat_priv *_batpriv = netdev_priv(_netdev); \ 197 struct bat_priv *_batpriv = netdev_priv(_netdev); \
197 batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ 198 batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
198 pr_info("%s: " fmt, _netdev->name, ## arg); \ 199 pr_info("%s: " fmt, _netdev->name, ## arg); \
199 } while (0) 200 } while (0)
200#define bat_err(net_dev, fmt, arg...) \ 201#define batadv_err(net_dev, fmt, arg...) \
201 do { \ 202 do { \
202 struct net_device *_netdev = (net_dev); \ 203 struct net_device *_netdev = (net_dev); \
203 struct bat_priv *_batpriv = netdev_priv(_netdev); \ 204 struct bat_priv *_batpriv = netdev_priv(_netdev); \
@@ -226,10 +227,10 @@ static inline bool batadv_has_timed_out(unsigned long timestamp,
226 return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout)); 227 return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout));
227} 228}
228 229
229#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0) 230#define batadv_atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
230 231
231/* Returns the smallest signed integer in two's complement with the sizeof x */ 232/* Returns the smallest signed integer in two's complement with the sizeof x */
232#define smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u))) 233#define batadv_smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u)))
233 234
234/* Checks if a sequence number x is a predecessor/successor of y. 235/* Checks if a sequence number x is a predecessor/successor of y.
235 * they handle overflows/underflows and can correctly check for a 236 * 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 * - when adding 128 - it is neither a predecessor nor a successor, 242 * - when adding 128 - it is neither a predecessor nor a successor,
242 * - after adding more than 127 to the starting value - it is a successor 243 * - after adding more than 127 to the starting value - it is a successor
243 */ 244 */
244#define seq_before(x, y) ({typeof(x) _d1 = (x); \ 245#define batadv_seq_before(x, y) ({typeof(x) _d1 = (x); \
245 typeof(y) _d2 = (y); \ 246 typeof(y) _d2 = (y); \
246 typeof(x) _dummy = (_d1 - _d2); \ 247 typeof(x) _dummy = (_d1 - _d2); \
247 (void) (&_d1 == &_d2); \ 248 (void) (&_d1 == &_d2); \
248 _dummy > smallest_signed_int(_dummy); }) 249 _dummy > batadv_smallest_signed_int(_dummy); })
249#define seq_after(x, y) seq_before(y, x) 250#define batadv_seq_after(x, y) batadv_seq_before(y, x)
250 251
251/* Stop preemption on local cpu while incrementing the counter */ 252/* Stop preemption on local cpu while incrementing the counter */
252static inline void batadv_add_counter(struct bat_priv *bat_priv, size_t idx, 253static inline void batadv_add_counter(struct bat_priv *bat_priv, size_t idx,
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index bf9ec39a8349..f04f591f4668 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,
@@ -370,7 +371,7 @@ static void _batadv_purge_orig(struct bat_priv *bat_priv)
370 } 371 }
371 372
372 if (batadv_has_timed_out(orig_node->last_frag_packet, 373 if (batadv_has_timed_out(orig_node->last_frag_packet,
373 FRAG_TIMEOUT)) 374 BATADV_FRAG_TIMEOUT))
374 batadv_frag_list_free(&orig_node->frag_list); 375 batadv_frag_list_free(&orig_node->frag_list);
375 } 376 }
376 spin_unlock_bh(list_lock); 377 spin_unlock_bh(list_lock);
@@ -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/packet.h b/net/batman-adv/packet.h
index c90219cd648e..e562414c2940 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -20,7 +20,7 @@
20#ifndef _NET_BATMAN_ADV_PACKET_H_ 20#ifndef _NET_BATMAN_ADV_PACKET_H_
21#define _NET_BATMAN_ADV_PACKET_H_ 21#define _NET_BATMAN_ADV_PACKET_H_
22 22
23#define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */ 23#define BATADV_ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
24 24
25enum bat_packettype { 25enum bat_packettype {
26 BAT_IV_OGM = 0x01, 26 BAT_IV_OGM = 0x01,
@@ -34,7 +34,7 @@ enum bat_packettype {
34}; 34};
35 35
36/* this file is included by batctl which needs these defines */ 36/* this file is included by batctl which needs these defines */
37#define COMPAT_VERSION 14 37#define BATADV_COMPAT_VERSION 14
38 38
39enum batman_iv_flags { 39enum batman_iv_flags {
40 NOT_BEST_NEXT_HOP = 1 << 3, 40 NOT_BEST_NEXT_HOP = 1 << 3,
@@ -65,7 +65,7 @@ enum unicast_frag_flags {
65}; 65};
66 66
67/* TT_QUERY subtypes */ 67/* TT_QUERY subtypes */
68#define TT_QUERY_TYPE_MASK 0x3 68#define BATADV_TT_QUERY_TYPE_MASK 0x3
69 69
70enum tt_query_packettype { 70enum tt_query_packettype {
71 TT_REQUEST = 0, 71 TT_REQUEST = 0,
@@ -126,7 +126,7 @@ struct batman_ogm_packet {
126 __be16 tt_crc; 126 __be16 tt_crc;
127} __packed; 127} __packed;
128 128
129#define BATMAN_OGM_HLEN sizeof(struct batman_ogm_packet) 129#define BATADV_OGM_HLEN sizeof(struct batman_ogm_packet)
130 130
131struct icmp_packet { 131struct icmp_packet {
132 struct batman_header header; 132 struct batman_header header;
@@ -138,7 +138,7 @@ struct icmp_packet {
138 uint8_t reserved; 138 uint8_t reserved;
139} __packed; 139} __packed;
140 140
141#define BAT_RR_LEN 16 141#define BATADV_RR_LEN 16
142 142
143/* icmp_packet_rr must start with all fields from imcp_packet 143/* icmp_packet_rr must start with all fields from imcp_packet
144 * as this is assumed by code that handles ICMP packets 144 * as this is assumed by code that handles ICMP packets
@@ -151,7 +151,7 @@ struct icmp_packet_rr {
151 __be16 seqno; 151 __be16 seqno;
152 uint8_t uid; 152 uint8_t uid;
153 uint8_t rr_cur; 153 uint8_t rr_cur;
154 uint8_t rr[BAT_RR_LEN][ETH_ALEN]; 154 uint8_t rr[BATADV_RR_LEN][ETH_ALEN];
155} __packed; 155} __packed;
156 156
157struct unicast_packet { 157struct unicast_packet {
diff --git a/net/batman-adv/ring_buffer.c b/net/batman-adv/ring_buffer.c
index aff1ca2990f1..c8f61e395b74 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 e7ee40d6d609..b3fd61c90f32 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;
@@ -423,7 +425,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
423 425
424 /* add record route information if not full */ 426 /* add record route information if not full */
425 if ((hdr_size == sizeof(struct icmp_packet_rr)) && 427 if ((hdr_size == sizeof(struct icmp_packet_rr)) &&
426 (icmp_packet->rr_cur < BAT_RR_LEN)) { 428 (icmp_packet->rr_cur < BATADV_RR_LEN)) {
427 memcpy(&(icmp_packet->rr[icmp_packet->rr_cur]), 429 memcpy(&(icmp_packet->rr[icmp_packet->rr_cur]),
428 ethhdr->h_dest, ETH_ALEN); 430 ethhdr->h_dest, ETH_ALEN);
429 icmp_packet->rr_cur++; 431 icmp_packet->rr_cur++;
@@ -603,7 +605,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
603 605
604 tt_query = (struct tt_query_packet *)skb->data; 606 tt_query = (struct tt_query_packet *)skb->data;
605 607
606 switch (tt_query->flags & TT_QUERY_TYPE_MASK) { 608 switch (tt_query->flags & BATADV_TT_QUERY_TYPE_MASK) {
607 case TT_REQUEST: 609 case TT_REQUEST:
608 batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_RX); 610 batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_RX);
609 611
@@ -699,8 +701,8 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
699 roam_adv_packet->src, roam_adv_packet->client); 701 roam_adv_packet->src, roam_adv_packet->client);
700 702
701 batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client, 703 batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client,
702 atomic_read(&orig_node->last_ttvn) + 1, true, 704 TT_CLIENT_ROAM,
703 false); 705 atomic_read(&orig_node->last_ttvn) + 1);
704 706
705 /* Roaming phase starts: I have new information but the ttvn has not 707 /* Roaming phase starts: I have new information but the ttvn has not
706 * been incremented yet. This flag will make me check all the incoming 708 * 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 struct hard_iface *primary_if; 924 struct hard_iface *primary_if;
923 struct unicast_packet *unicast_packet; 925 struct unicast_packet *unicast_packet;
924 bool tt_poss_change; 926 bool tt_poss_change;
927 int is_old_ttvn;
925 928
926 /* I could need to modify it */ 929 /* I could need to modify it */
927 if (skb_cow(skb, sizeof(struct unicast_packet)) < 0) 930 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 } 948 }
946 949
947 /* Check whether I have to reroute the packet */ 950 /* Check whether I have to reroute the packet */
948 if (seq_before(unicast_packet->ttvn, curr_ttvn) || tt_poss_change) { 951 is_old_ttvn = batadv_seq_before(unicast_packet->ttvn, curr_ttvn);
952 if (is_old_ttvn || tt_poss_change) {
949 /* check if there is enough data before accessing it */ 953 /* check if there is enough data before accessing it */
950 if (pskb_may_pull(skb, sizeof(struct unicast_packet) + 954 if (pskb_may_pull(skb, sizeof(struct unicast_packet) +
951 ETH_HLEN) < 0) 955 ETH_HLEN) < 0)
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 1842cbc280c7..72542cb01662 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -58,11 +58,11 @@ int batadv_send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
58 ethhdr = (struct ethhdr *)skb_mac_header(skb); 58 ethhdr = (struct ethhdr *)skb_mac_header(skb);
59 memcpy(ethhdr->h_source, hard_iface->net_dev->dev_addr, ETH_ALEN); 59 memcpy(ethhdr->h_source, hard_iface->net_dev->dev_addr, ETH_ALEN);
60 memcpy(ethhdr->h_dest, dst_addr, ETH_ALEN); 60 memcpy(ethhdr->h_dest, dst_addr, ETH_ALEN);
61 ethhdr->h_proto = __constant_htons(ETH_P_BATMAN); 61 ethhdr->h_proto = __constant_htons(BATADV_ETH_P_BATMAN);
62 62
63 skb_set_network_header(skb, ETH_HLEN); 63 skb_set_network_header(skb, ETH_HLEN);
64 skb->priority = TC_PRIO_CONTROL; 64 skb->priority = TC_PRIO_CONTROL;
65 skb->protocol = __constant_htons(ETH_P_BATMAN); 65 skb->protocol = __constant_htons(BATADV_ETH_P_BATMAN);
66 66
67 skb->dev = hard_iface->net_dev; 67 skb->dev = hard_iface->net_dev;
68 68
@@ -141,7 +141,7 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
141 struct bcast_packet *bcast_packet; 141 struct bcast_packet *bcast_packet;
142 struct sk_buff *newskb; 142 struct sk_buff *newskb;
143 143
144 if (!atomic_dec_not_zero(&bat_priv->bcast_queue_left)) { 144 if (!batadv_atomic_dec_not_zero(&bat_priv->bcast_queue_left)) {
145 batadv_dbg(DBG_BATMAN, bat_priv, "bcast packet queue full\n"); 145 batadv_dbg(DBG_BATMAN, bat_priv, "bcast packet queue full\n");
146 goto out; 146 goto out;
147 } 147 }
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 2de1d742119f..c1b2ab2f37bb 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);
@@ -135,6 +135,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
135 struct hard_iface *primary_if = NULL; 135 struct hard_iface *primary_if = NULL;
136 struct bcast_packet *bcast_packet; 136 struct bcast_packet *bcast_packet;
137 struct vlan_ethhdr *vhdr; 137 struct vlan_ethhdr *vhdr;
138 __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN);
138 static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 0x00, 139 static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 0x00,
139 0x00}; 140 0x00};
140 unsigned int header_len = 0; 141 unsigned int header_len = 0;
@@ -152,11 +153,11 @@ static int batadv_interface_tx(struct sk_buff *skb,
152 vhdr = (struct vlan_ethhdr *)skb->data; 153 vhdr = (struct vlan_ethhdr *)skb->data;
153 vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK; 154 vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
154 155
155 if (ntohs(vhdr->h_vlan_encapsulated_proto) != ETH_P_BATMAN) 156 if (vhdr->h_vlan_encapsulated_proto != ethertype)
156 break; 157 break;
157 158
158 /* fall through */ 159 /* fall through */
159 case ETH_P_BATMAN: 160 case BATADV_ETH_P_BATMAN:
160 goto dropped; 161 goto dropped;
161 } 162 }
162 163
@@ -208,8 +209,8 @@ static int batadv_interface_tx(struct sk_buff *skb,
208 goto dropped; 209 goto dropped;
209 210
210 bcast_packet = (struct bcast_packet *)skb->data; 211 bcast_packet = (struct bcast_packet *)skb->data;
211 bcast_packet->header.version = COMPAT_VERSION; 212 bcast_packet->header.version = BATADV_COMPAT_VERSION;
212 bcast_packet->header.ttl = TTL; 213 bcast_packet->header.ttl = BATADV_TTL;
213 214
214 /* batman packet type: broadcast */ 215 /* batman packet type: broadcast */
215 bcast_packet->header.packet_type = BAT_BCAST; 216 bcast_packet->header.packet_type = BAT_BCAST;
@@ -266,6 +267,7 @@ void batadv_interface_rx(struct net_device *soft_iface,
266 struct ethhdr *ethhdr; 267 struct ethhdr *ethhdr;
267 struct vlan_ethhdr *vhdr; 268 struct vlan_ethhdr *vhdr;
268 short vid __maybe_unused = -1; 269 short vid __maybe_unused = -1;
270 __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN);
269 271
270 /* check if enough space is available for pulling, and pull */ 272 /* check if enough space is available for pulling, and pull */
271 if (!pskb_may_pull(skb, hdr_size)) 273 if (!pskb_may_pull(skb, hdr_size))
@@ -281,11 +283,11 @@ void batadv_interface_rx(struct net_device *soft_iface,
281 vhdr = (struct vlan_ethhdr *)skb->data; 283 vhdr = (struct vlan_ethhdr *)skb->data;
282 vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK; 284 vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
283 285
284 if (ntohs(vhdr->h_vlan_encapsulated_proto) != ETH_P_BATMAN) 286 if (vhdr->h_vlan_encapsulated_proto != ethertype)
285 break; 287 break;
286 288
287 /* fall through */ 289 /* fall through */
288 case ETH_P_BATMAN: 290 case BATADV_ETH_P_BATMAN:
289 goto dropped; 291 goto dropped;
290 } 292 }
291 293
@@ -349,7 +351,7 @@ static void batadv_interface_setup(struct net_device *dev)
349 */ 351 */
350 dev->mtu = ETH_DATA_LEN; 352 dev->mtu = ETH_DATA_LEN;
351 /* reserve more space in the skbuff for our header */ 353 /* reserve more space in the skbuff for our header */
352 dev->hard_header_len = BAT_HEADER_LEN; 354 dev->hard_header_len = BATADV_HEADER_LEN;
353 355
354 /* generate random address */ 356 /* generate random address */
355 eth_hw_addr_random(dev); 357 eth_hw_addr_random(dev);
@@ -392,8 +394,8 @@ struct net_device *batadv_softif_create(const char *name)
392 atomic_set(&bat_priv->hop_penalty, 30); 394 atomic_set(&bat_priv->hop_penalty, 30);
393 atomic_set(&bat_priv->log_level, 0); 395 atomic_set(&bat_priv->log_level, 0);
394 atomic_set(&bat_priv->fragmentation, 1); 396 atomic_set(&bat_priv->fragmentation, 1);
395 atomic_set(&bat_priv->bcast_queue_left, BCAST_QUEUE_LEN); 397 atomic_set(&bat_priv->bcast_queue_left, BATADV_BCAST_QUEUE_LEN);
396 atomic_set(&bat_priv->batman_queue_left, BATMAN_QUEUE_LEN); 398 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
397 399
398 atomic_set(&bat_priv->mesh_state, MESH_INACTIVE); 400 atomic_set(&bat_priv->mesh_state, MESH_INACTIVE);
399 atomic_set(&bat_priv->bcast_seqno, 1); 401 atomic_set(&bat_priv->bcast_seqno, 1);
@@ -485,7 +487,7 @@ static void batadv_get_drvinfo(struct net_device *dev,
485 struct ethtool_drvinfo *info) 487 struct ethtool_drvinfo *info)
486{ 488{
487 strcpy(info->driver, "B.A.T.M.A.N. advanced"); 489 strcpy(info->driver, "B.A.T.M.A.N. advanced");
488 strcpy(info->version, SOURCE_VERSION); 490 strcpy(info->version, BATADV_SOURCE_VERSION);
489 strcpy(info->fw_version, "N/A"); 491 strcpy(info->fw_version, "N/A");
490 strcpy(info->bus_info, "batman"); 492 strcpy(info->bus_info, "batman");
491} 493}
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index c673b58f3ee1..a0487e9f18c7 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -157,7 +157,9 @@ batadv_tt_orig_list_entry_free_ref(struct tt_orig_list_entry *orig_entry)
157static void batadv_tt_local_event(struct bat_priv *bat_priv, 157static void batadv_tt_local_event(struct bat_priv *bat_priv,
158 const uint8_t *addr, uint8_t flags) 158 const uint8_t *addr, uint8_t flags)
159{ 159{
160 struct tt_change_node *tt_change_node; 160 struct tt_change_node *tt_change_node, *entry, *safe;
161 bool event_removed = false;
162 bool del_op_requested, del_op_entry;
161 163
162 tt_change_node = kmalloc(sizeof(*tt_change_node), GFP_ATOMIC); 164 tt_change_node = kmalloc(sizeof(*tt_change_node), GFP_ATOMIC);
163 165
@@ -167,13 +169,45 @@ static void batadv_tt_local_event(struct bat_priv *bat_priv,
167 tt_change_node->change.flags = flags; 169 tt_change_node->change.flags = flags;
168 memcpy(tt_change_node->change.addr, addr, ETH_ALEN); 170 memcpy(tt_change_node->change.addr, addr, ETH_ALEN);
169 171
172 del_op_requested = flags & TT_CLIENT_DEL;
173
174 /* check for ADD+DEL or DEL+ADD events */
170 spin_lock_bh(&bat_priv->tt_changes_list_lock); 175 spin_lock_bh(&bat_priv->tt_changes_list_lock);
176 list_for_each_entry_safe(entry, safe, &bat_priv->tt_changes_list,
177 list) {
178 if (!batadv_compare_eth(entry->change.addr, addr))
179 continue;
180
181 /* DEL+ADD in the same orig interval have no effect and can be
182 * removed to avoid silly behaviour on the receiver side. The
183 * other way around (ADD+DEL) can happen in case of roaming of
184 * a client still in the NEW state. Roaming of NEW clients is
185 * now possible due to automatically recognition of "temporary"
186 * clients
187 */
188 del_op_entry = entry->change.flags & TT_CLIENT_DEL;
189 if (!del_op_requested && del_op_entry)
190 goto del;
191 if (del_op_requested && !del_op_entry)
192 goto del;
193 continue;
194del:
195 list_del(&entry->list);
196 kfree(entry);
197 event_removed = true;
198 goto unlock;
199 }
200
171 /* track the change in the OGMinterval list */ 201 /* track the change in the OGMinterval list */
172 list_add_tail(&tt_change_node->list, &bat_priv->tt_changes_list); 202 list_add_tail(&tt_change_node->list, &bat_priv->tt_changes_list);
173 atomic_inc(&bat_priv->tt_local_changes); 203
204unlock:
174 spin_unlock_bh(&bat_priv->tt_changes_list_lock); 205 spin_unlock_bh(&bat_priv->tt_changes_list_lock);
175 206
176 atomic_set(&bat_priv->tt_ogm_append_cnt, 0); 207 if (event_removed)
208 atomic_dec(&bat_priv->tt_local_changes);
209 else
210 atomic_inc(&bat_priv->tt_local_changes);
177} 211}
178 212
179int batadv_tt_len(int changes_num) 213int batadv_tt_len(int changes_num)
@@ -223,7 +257,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
223 (uint8_t)atomic_read(&bat_priv->ttvn)); 257 (uint8_t)atomic_read(&bat_priv->ttvn));
224 258
225 memcpy(tt_local_entry->common.addr, addr, ETH_ALEN); 259 memcpy(tt_local_entry->common.addr, addr, ETH_ALEN);
226 tt_local_entry->common.flags = NO_FLAGS; 260 tt_local_entry->common.flags = BATADV_NO_FLAGS;
227 if (batadv_is_wifi_iface(ifindex)) 261 if (batadv_is_wifi_iface(ifindex))
228 tt_local_entry->common.flags |= TT_CLIENT_WIFI; 262 tt_local_entry->common.flags |= TT_CLIENT_WIFI;
229 atomic_set(&tt_local_entry->common.refcount, 2); 263 atomic_set(&tt_local_entry->common.refcount, 2);
@@ -459,14 +493,17 @@ void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr,
459 const char *message, bool roaming) 493 const char *message, bool roaming)
460{ 494{
461 struct tt_local_entry *tt_local_entry = NULL; 495 struct tt_local_entry *tt_local_entry = NULL;
496 uint16_t flags;
462 497
463 tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr); 498 tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr);
464 if (!tt_local_entry) 499 if (!tt_local_entry)
465 goto out; 500 goto out;
466 501
467 batadv_tt_local_set_pending(bat_priv, tt_local_entry, TT_CLIENT_DEL | 502 flags = TT_CLIENT_DEL;
468 (roaming ? TT_CLIENT_ROAM : NO_FLAGS), 503 if (roaming)
469 message); 504 flags |= TT_CLIENT_ROAM;
505
506 batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags, message);
470out: 507out:
471 if (tt_local_entry) 508 if (tt_local_entry)
472 batadv_tt_local_entry_free_ref(tt_local_entry); 509 batadv_tt_local_entry_free_ref(tt_local_entry);
@@ -500,7 +537,7 @@ static void batadv_tt_local_purge(struct bat_priv *bat_priv)
500 continue; 537 continue;
501 538
502 if (!batadv_has_timed_out(tt_local_entry->last_seen, 539 if (!batadv_has_timed_out(tt_local_entry->last_seen,
503 TT_LOCAL_TIMEOUT)) 540 BATADV_TT_LOCAL_TIMEOUT))
504 continue; 541 continue;
505 542
506 batadv_tt_local_set_pending(bat_priv, tt_local_entry, 543 batadv_tt_local_set_pending(bat_priv, tt_local_entry,
@@ -623,8 +660,8 @@ batadv_tt_global_add_orig_entry(struct tt_global_entry *tt_global_entry,
623 660
624/* caller must hold orig_node refcount */ 661/* caller must hold orig_node refcount */
625int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, 662int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
626 const unsigned char *tt_addr, uint8_t ttvn, 663 const unsigned char *tt_addr, uint8_t flags,
627 bool roaming, bool wifi) 664 uint8_t ttvn)
628{ 665{
629 struct tt_global_entry *tt_global_entry = NULL; 666 struct tt_global_entry *tt_global_entry = NULL;
630 int ret = 0; 667 int ret = 0;
@@ -634,15 +671,14 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
634 tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr); 671 tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr);
635 672
636 if (!tt_global_entry) { 673 if (!tt_global_entry) {
637 tt_global_entry = kzalloc(sizeof(*tt_global_entry), 674 tt_global_entry = kzalloc(sizeof(*tt_global_entry), GFP_ATOMIC);
638 GFP_ATOMIC);
639 if (!tt_global_entry) 675 if (!tt_global_entry)
640 goto out; 676 goto out;
641 677
642 common = &tt_global_entry->common; 678 common = &tt_global_entry->common;
643 memcpy(common->addr, tt_addr, ETH_ALEN); 679 memcpy(common->addr, tt_addr, ETH_ALEN);
644 680
645 common->flags = NO_FLAGS; 681 common->flags = flags;
646 tt_global_entry->roam_at = 0; 682 tt_global_entry->roam_at = 0;
647 atomic_set(&common->refcount, 2); 683 atomic_set(&common->refcount, 2);
648 684
@@ -684,9 +720,6 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
684 orig_node, ttvn); 720 orig_node, ttvn);
685 } 721 }
686 722
687 if (wifi)
688 tt_global_entry->common.flags |= TT_CLIENT_WIFI;
689
690 batadv_dbg(DBG_TT, bat_priv, 723 batadv_dbg(DBG_TT, bat_priv,
691 "Creating new global tt entry: %pM (via %pM)\n", 724 "Creating new global tt entry: %pM (via %pM)\n",
692 tt_global_entry->common.addr, orig_node->orig); 725 tt_global_entry->common.addr, orig_node->orig);
@@ -694,7 +727,7 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
694out_remove: 727out_remove:
695 /* remove address from local hash if present */ 728 /* remove address from local hash if present */
696 batadv_tt_local_remove(bat_priv, tt_global_entry->common.addr, 729 batadv_tt_local_remove(bat_priv, tt_global_entry->common.addr,
697 "global tt received", roaming); 730 "global tt received", flags & TT_CLIENT_ROAM);
698 ret = 1; 731 ret = 1;
699out: 732out:
700 if (tt_global_entry) 733 if (tt_global_entry)
@@ -978,12 +1011,35 @@ void batadv_tt_global_del_orig(struct bat_priv *bat_priv,
978 orig_node->tt_initialised = false; 1011 orig_node->tt_initialised = false;
979} 1012}
980 1013
981static 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)
982{ 1016{
983 struct hashtable_t *hash = bat_priv->tt_global_hash;
984 struct tt_common_entry *tt_common_entry; 1017 struct tt_common_entry *tt_common_entry;
985 struct tt_global_entry *tt_global_entry; 1018 struct tt_global_entry *tt_global_entry;
986 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;
987 struct hlist_head *head; 1043 struct hlist_head *head;
988 spinlock_t *list_lock; /* protects write access to the hash lists */ 1044 spinlock_t *list_lock; /* protects write access to the hash lists */
989 uint32_t i; 1045 uint32_t i;
@@ -993,24 +1049,7 @@ static void batadv_tt_global_roam_purge(struct bat_priv *bat_priv)
993 list_lock = &hash->list_locks[i]; 1049 list_lock = &hash->list_locks[i];
994 1050
995 spin_lock_bh(list_lock); 1051 spin_lock_bh(list_lock);
996 hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, 1052 batadv_tt_global_roam_purge_list(bat_priv, head);
997 head, hash_entry) {
998 tt_global_entry = container_of(tt_common_entry,
999 struct tt_global_entry,
1000 common);
1001 if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM))
1002 continue;
1003 if (!batadv_has_timed_out(tt_global_entry->roam_at,
1004 TT_CLIENT_ROAM_TIMEOUT))
1005 continue;
1006
1007 batadv_dbg(DBG_TT, bat_priv,
1008 "Deleting global tt entry (%pM): Roaming timeout\n",
1009 tt_global_entry->common.addr);
1010
1011 hlist_del_rcu(node);
1012 batadv_tt_global_entry_free_ref(tt_global_entry);
1013 }
1014 spin_unlock_bh(list_lock); 1053 spin_unlock_bh(list_lock);
1015 } 1054 }
1016 1055
@@ -1248,7 +1287,8 @@ static void batadv_tt_req_purge(struct bat_priv *bat_priv)
1248 1287
1249 spin_lock_bh(&bat_priv->tt_req_list_lock); 1288 spin_lock_bh(&bat_priv->tt_req_list_lock);
1250 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) {
1251 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)) {
1252 list_del(&node->list); 1292 list_del(&node->list);
1253 kfree(node); 1293 kfree(node);
1254 } 1294 }
@@ -1268,7 +1308,7 @@ static struct tt_req_node *batadv_new_tt_req_node(struct bat_priv *bat_priv,
1268 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) {
1269 if (batadv_compare_eth(tt_req_node_tmp, orig_node) && 1309 if (batadv_compare_eth(tt_req_node_tmp, orig_node) &&
1270 !batadv_has_timed_out(tt_req_node_tmp->issued_at, 1310 !batadv_has_timed_out(tt_req_node_tmp->issued_at,
1271 TT_REQUEST_TIMEOUT)) 1311 BATADV_TT_REQUEST_TIMEOUT))
1272 goto unlock; 1312 goto unlock;
1273 } 1313 }
1274 1314
@@ -1361,7 +1401,7 @@ batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn,
1361 1401
1362 memcpy(tt_change->addr, tt_common_entry->addr, 1402 memcpy(tt_change->addr, tt_common_entry->addr,
1363 ETH_ALEN); 1403 ETH_ALEN);
1364 tt_change->flags = NO_FLAGS; 1404 tt_change->flags = BATADV_NO_FLAGS;
1365 1405
1366 tt_count++; 1406 tt_count++;
1367 tt_change++; 1407 tt_change++;
@@ -1411,10 +1451,10 @@ static int batadv_send_tt_request(struct bat_priv *bat_priv,
1411 sizeof(struct tt_query_packet)); 1451 sizeof(struct tt_query_packet));
1412 1452
1413 tt_request->header.packet_type = BAT_TT_QUERY; 1453 tt_request->header.packet_type = BAT_TT_QUERY;
1414 tt_request->header.version = COMPAT_VERSION; 1454 tt_request->header.version = BATADV_COMPAT_VERSION;
1415 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);
1416 memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN); 1456 memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN);
1417 tt_request->header.ttl = TTL; 1457 tt_request->header.ttl = BATADV_TTL;
1418 tt_request->ttvn = ttvn; 1458 tt_request->ttvn = ttvn;
1419 tt_request->tt_data = htons(tt_crc); 1459 tt_request->tt_data = htons(tt_crc);
1420 tt_request->flags = TT_REQUEST; 1460 tt_request->flags = TT_REQUEST;
@@ -1545,8 +1585,8 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv,
1545 } 1585 }
1546 1586
1547 tt_response->header.packet_type = BAT_TT_QUERY; 1587 tt_response->header.packet_type = BAT_TT_QUERY;
1548 tt_response->header.version = COMPAT_VERSION; 1588 tt_response->header.version = BATADV_COMPAT_VERSION;
1549 tt_response->header.ttl = TTL; 1589 tt_response->header.ttl = BATADV_TTL;
1550 memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN); 1590 memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN);
1551 memcpy(tt_response->dst, tt_request->src, ETH_ALEN); 1591 memcpy(tt_response->dst, tt_request->src, ETH_ALEN);
1552 tt_response->flags = TT_RESPONSE; 1592 tt_response->flags = TT_RESPONSE;
@@ -1666,8 +1706,8 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv,
1666 } 1706 }
1667 1707
1668 tt_response->header.packet_type = BAT_TT_QUERY; 1708 tt_response->header.packet_type = BAT_TT_QUERY;
1669 tt_response->header.version = COMPAT_VERSION; 1709 tt_response->header.version = BATADV_COMPAT_VERSION;
1670 tt_response->header.ttl = TTL; 1710 tt_response->header.ttl = BATADV_TTL;
1671 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);
1672 memcpy(tt_response->dst, tt_request->src, ETH_ALEN); 1712 memcpy(tt_response->dst, tt_request->src, ETH_ALEN);
1673 tt_response->flags = TT_RESPONSE; 1713 tt_response->flags = TT_RESPONSE;
@@ -1721,7 +1761,6 @@ static void _batadv_tt_update_changes(struct bat_priv *bat_priv,
1721 uint16_t tt_num_changes, uint8_t ttvn) 1761 uint16_t tt_num_changes, uint8_t ttvn)
1722{ 1762{
1723 int i; 1763 int i;
1724 int is_wifi;
1725 int roams; 1764 int roams;
1726 1765
1727 for (i = 0; i < tt_num_changes; i++) { 1766 for (i = 0; i < tt_num_changes; i++) {
@@ -1729,13 +1768,12 @@ static void _batadv_tt_update_changes(struct bat_priv *bat_priv,
1729 roams = (tt_change + i)->flags & TT_CLIENT_ROAM; 1768 roams = (tt_change + i)->flags & TT_CLIENT_ROAM;
1730 batadv_tt_global_del(bat_priv, orig_node, 1769 batadv_tt_global_del(bat_priv, orig_node,
1731 (tt_change + i)->addr, 1770 (tt_change + i)->addr,
1732 "tt removed by changes", 1771 "tt removed by changes",
1733 roams); 1772 roams);
1734 } else { 1773 } else {
1735 is_wifi = (tt_change + i)->flags & TT_CLIENT_WIFI;
1736 if (!batadv_tt_global_add(bat_priv, orig_node, 1774 if (!batadv_tt_global_add(bat_priv, orig_node,
1737 (tt_change + i)->addr, ttvn, 1775 (tt_change + i)->addr,
1738 false, is_wifi)) 1776 (tt_change + i)->flags, ttvn))
1739 /* In case of problem while storing a 1777 /* In case of problem while storing a
1740 * global_entry, we stop the updating 1778 * global_entry, we stop the updating
1741 * procedure without committing the 1779 * procedure without committing the
@@ -1897,7 +1935,8 @@ static void batadv_tt_roam_purge(struct bat_priv *bat_priv)
1897 1935
1898 spin_lock_bh(&bat_priv->tt_roam_list_lock); 1936 spin_lock_bh(&bat_priv->tt_roam_list_lock);
1899 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) {
1900 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))
1901 continue; 1940 continue;
1902 1941
1903 list_del(&node->list); 1942 list_del(&node->list);
@@ -1927,10 +1966,10 @@ static bool batadv_tt_check_roam_count(struct bat_priv *bat_priv,
1927 continue; 1966 continue;
1928 1967
1929 if (batadv_has_timed_out(tt_roam_node->first_time, 1968 if (batadv_has_timed_out(tt_roam_node->first_time,
1930 ROAMING_MAX_TIME)) 1969 BATADV_ROAMING_MAX_TIME))
1931 continue; 1970 continue;
1932 1971
1933 if (!atomic_dec_not_zero(&tt_roam_node->counter)) 1972 if (!batadv_atomic_dec_not_zero(&tt_roam_node->counter))
1934 /* Sorry, you roamed too many times! */ 1973 /* Sorry, you roamed too many times! */
1935 goto unlock; 1974 goto unlock;
1936 ret = true; 1975 ret = true;
@@ -1943,7 +1982,8 @@ static bool batadv_tt_check_roam_count(struct bat_priv *bat_priv,
1943 goto unlock; 1982 goto unlock;
1944 1983
1945 tt_roam_node->first_time = jiffies; 1984 tt_roam_node->first_time = jiffies;
1946 atomic_set(&tt_roam_node->counter, ROAMING_MAX_COUNT - 1); 1985 atomic_set(&tt_roam_node->counter,
1986 BATADV_ROAMING_MAX_COUNT - 1);
1947 memcpy(tt_roam_node->addr, client, ETH_ALEN); 1987 memcpy(tt_roam_node->addr, client, ETH_ALEN);
1948 1988
1949 list_add(&tt_roam_node->list, &bat_priv->tt_roam_list); 1989 list_add(&tt_roam_node->list, &bat_priv->tt_roam_list);
@@ -1980,8 +2020,8 @@ static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
1980 sizeof(struct roam_adv_packet)); 2020 sizeof(struct roam_adv_packet));
1981 2021
1982 roam_adv_packet->header.packet_type = BAT_ROAM_ADV; 2022 roam_adv_packet->header.packet_type = BAT_ROAM_ADV;
1983 roam_adv_packet->header.version = COMPAT_VERSION; 2023 roam_adv_packet->header.version = BATADV_COMPAT_VERSION;
1984 roam_adv_packet->header.ttl = TTL; 2024 roam_adv_packet->header.ttl = BATADV_TTL;
1985 primary_if = batadv_primary_if_get_selected(bat_priv); 2025 primary_if = batadv_primary_if_get_selected(bat_priv);
1986 if (!primary_if) 2026 if (!primary_if)
1987 goto out; 2027 goto out;
@@ -2142,7 +2182,7 @@ static int batadv_tt_commit_changes(struct bat_priv *bat_priv,
2142 bat_priv->tt_poss_change = false; 2182 bat_priv->tt_poss_change = false;
2143 2183
2144 /* reset the sending counter */ 2184 /* reset the sending counter */
2145 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);
2146 2186
2147 return batadv_tt_changes_fill_buff(bat_priv, packet_buff, 2187 return batadv_tt_changes_fill_buff(bat_priv, packet_buff,
2148 packet_buff_len, packet_min_len); 2188 packet_buff_len, packet_min_len);
@@ -2162,7 +2202,7 @@ int batadv_tt_append_diff(struct bat_priv *bat_priv,
2162 2202
2163 /* if the changes have been sent often enough */ 2203 /* if the changes have been sent often enough */
2164 if ((tt_num_changes < 0) && 2204 if ((tt_num_changes < 0) &&
2165 (!atomic_dec_not_zero(&bat_priv->tt_ogm_append_cnt))) { 2205 (!batadv_atomic_dec_not_zero(&bat_priv->tt_ogm_append_cnt))) {
2166 batadv_tt_realloc_packet_buff(packet_buff, packet_buff_len, 2206 batadv_tt_realloc_packet_buff(packet_buff, packet_buff_len,
2167 packet_min_len, packet_min_len); 2207 packet_min_len, packet_min_len);
2168 tt_num_changes = 0; 2208 tt_num_changes = 0;
@@ -2220,7 +2260,8 @@ void batadv_tt_update_orig(struct bat_priv *bat_priv,
2220 if ((!orig_node->tt_initialised && ttvn == 1) || 2260 if ((!orig_node->tt_initialised && ttvn == 1) ||
2221 ttvn - orig_ttvn == 1) { 2261 ttvn - orig_ttvn == 1) {
2222 /* 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
2223 * 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.
2224 * In this case send a tt request 2265 * In this case send a tt request
2225 */ 2266 */
2226 if (!tt_num_changes) { 2267 if (!tt_num_changes) {
diff --git a/net/batman-adv/translation-table.h b/net/batman-adv/translation-table.h
index 7edc9dff8ba1..46b60bd822fe 100644
--- a/net/batman-adv/translation-table.h
+++ b/net/batman-adv/translation-table.h
@@ -32,8 +32,8 @@ void batadv_tt_global_add_orig(struct bat_priv *bat_priv,
32 struct orig_node *orig_node, 32 struct orig_node *orig_node,
33 const unsigned char *tt_buff, int tt_buff_len); 33 const unsigned char *tt_buff, int tt_buff_len);
34int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, 34int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
35 const unsigned char *addr, uint8_t ttvn, bool roaming, 35 const unsigned char *addr, uint8_t flags,
36 bool wifi); 36 uint8_t ttvn);
37int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset); 37int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset);
38void batadv_tt_global_del_orig(struct bat_priv *bat_priv, 38void batadv_tt_global_del_orig(struct bat_priv *bat_priv,
39 struct orig_node *orig_node, 39 struct orig_node *orig_node,
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 053c5d4776ce..fd538ea68117 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -22,12 +22,11 @@
22 22
23#include "packet.h" 23#include "packet.h"
24#include "bitarray.h" 24#include "bitarray.h"
25#include <linux/kernel.h>
25 26
26#define BAT_HEADER_LEN (ETH_HLEN + \ 27#define BATADV_HEADER_LEN \
27 ((sizeof(struct unicast_packet) > sizeof(struct bcast_packet) ? \ 28 (ETH_HLEN + max(sizeof(struct unicast_packet), \
28 sizeof(struct unicast_packet) : \ 29 sizeof(struct bcast_packet)))
29 sizeof(struct bcast_packet))))
30
31 30
32struct hard_iface { 31struct hard_iface {
33 struct list_head list; 32 struct list_head list;
@@ -86,7 +85,7 @@ struct orig_node {
86 bool tt_poss_change; 85 bool tt_poss_change;
87 uint32_t last_real_seqno; 86 uint32_t last_real_seqno;
88 uint8_t last_ttl; 87 uint8_t last_ttl;
89 DECLARE_BITMAP(bcast_bits, TQ_LOCAL_WINDOW_SIZE); 88 DECLARE_BITMAP(bcast_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
90 uint32_t last_bcast_seqno; 89 uint32_t last_bcast_seqno;
91 struct hlist_head neigh_list; 90 struct hlist_head neigh_list;
92 struct list_head frag_list; 91 struct list_head frag_list;
@@ -122,13 +121,13 @@ struct neigh_node {
122 struct hlist_node list; 121 struct hlist_node list;
123 uint8_t addr[ETH_ALEN]; 122 uint8_t addr[ETH_ALEN];
124 uint8_t real_packet_count; 123 uint8_t real_packet_count;
125 uint8_t tq_recv[TQ_GLOBAL_WINDOW_SIZE]; 124 uint8_t tq_recv[BATADV_TQ_GLOBAL_WINDOW_SIZE];
126 uint8_t tq_index; 125 uint8_t tq_index;
127 uint8_t tq_avg; 126 uint8_t tq_avg;
128 uint8_t last_ttl; 127 uint8_t last_ttl;
129 struct list_head bonding_list; 128 struct list_head bonding_list;
130 unsigned long last_seen; 129 unsigned long last_seen;
131 DECLARE_BITMAP(real_bits, TQ_LOCAL_WINDOW_SIZE); 130 DECLARE_BITMAP(real_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
132 atomic_t refcount; 131 atomic_t refcount;
133 struct rcu_head rcu; 132 struct rcu_head rcu;
134 struct orig_node *orig_node; 133 struct orig_node *orig_node;
@@ -210,7 +209,7 @@ struct bat_priv {
210 struct list_head tt_roam_list; 209 struct list_head tt_roam_list;
211 struct hashtable_t *vis_hash; 210 struct hashtable_t *vis_hash;
212#ifdef CONFIG_BATMAN_ADV_BLA 211#ifdef CONFIG_BATMAN_ADV_BLA
213 struct bcast_duplist_entry bcast_duplist[DUPLIST_SIZE]; 212 struct bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE];
214 int bcast_duplist_curr; 213 int bcast_duplist_curr;
215 struct bla_claim_dst claim_dest; 214 struct bla_claim_dst claim_dest;
216#endif 215#endif
@@ -349,7 +348,7 @@ struct if_list_entry {
349}; 348};
350 349
351struct debug_log { 350struct debug_log {
352 char log_buff[LOG_BUF_LEN]; 351 char log_buff[BATADV_LOG_BUF_LEN];
353 unsigned long log_start; 352 unsigned long log_start;
354 unsigned long log_end; 353 unsigned long log_end;
355 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 d021055ad262..8454d916cd01 100644
--- a/net/batman-adv/unicast.c
+++ b/net/batman-adv/unicast.c
@@ -29,9 +29,10 @@
29#include "hard-interface.h" 29#include "hard-interface.h"
30 30
31 31
32static struct sk_buff *frag_merge_packet(struct list_head *head, 32static struct sk_buff *
33 struct frag_packet_list_entry *tfp, 33batadv_frag_merge_packet(struct list_head *head,
34 struct sk_buff *skb) 34 struct frag_packet_list_entry *tfp,
35 struct sk_buff *skb)
35{ 36{
36 struct unicast_frag_packet *up = 37 struct unicast_frag_packet *up =
37 (struct unicast_frag_packet *)skb->data; 38 (struct unicast_frag_packet *)skb->data;
@@ -75,7 +76,8 @@ err:
75 return NULL; 76 return NULL;
76} 77}
77 78
78static void frag_create_entry(struct list_head *head, struct sk_buff *skb) 79static void batadv_frag_create_entry(struct list_head *head,
80 struct sk_buff *skb)
79{ 81{
80 struct frag_packet_list_entry *tfp; 82 struct frag_packet_list_entry *tfp;
81 struct unicast_frag_packet *up = 83 struct unicast_frag_packet *up =
@@ -91,12 +93,12 @@ static void frag_create_entry(struct list_head *head, struct sk_buff *skb)
91 return; 93 return;
92} 94}
93 95
94static int frag_create_buffer(struct list_head *head) 96static int batadv_frag_create_buffer(struct list_head *head)
95{ 97{
96 int i; 98 int i;
97 struct frag_packet_list_entry *tfp; 99 struct frag_packet_list_entry *tfp;
98 100
99 for (i = 0; i < FRAG_BUFFER_SIZE; i++) { 101 for (i = 0; i < BATADV_FRAG_BUFFER_SIZE; i++) {
100 tfp = kmalloc(sizeof(*tfp), GFP_ATOMIC); 102 tfp = kmalloc(sizeof(*tfp), GFP_ATOMIC);
101 if (!tfp) { 103 if (!tfp) {
102 batadv_frag_list_free(head); 104 batadv_frag_list_free(head);
@@ -111,8 +113,9 @@ static int frag_create_buffer(struct list_head *head)
111 return 0; 113 return 0;
112} 114}
113 115
114static struct frag_packet_list_entry *frag_search_packet(struct list_head *head, 116static struct frag_packet_list_entry *
115 const struct unicast_frag_packet *up) 117batadv_frag_search_packet(struct list_head *head,
118 const struct unicast_frag_packet *up)
116{ 119{
117 struct frag_packet_list_entry *tfp; 120 struct frag_packet_list_entry *tfp;
118 struct unicast_frag_packet *tmp_up = NULL; 121 struct unicast_frag_packet *tmp_up = NULL;
@@ -188,22 +191,22 @@ int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
188 orig_node->last_frag_packet = jiffies; 191 orig_node->last_frag_packet = jiffies;
189 192
190 if (list_empty(&orig_node->frag_list) && 193 if (list_empty(&orig_node->frag_list) &&
191 frag_create_buffer(&orig_node->frag_list)) { 194 batadv_frag_create_buffer(&orig_node->frag_list)) {
192 pr_debug("couldn't create frag buffer\n"); 195 pr_debug("couldn't create frag buffer\n");
193 goto out; 196 goto out;
194 } 197 }
195 198
196 tmp_frag_entry = frag_search_packet(&orig_node->frag_list, 199 tmp_frag_entry = batadv_frag_search_packet(&orig_node->frag_list,
197 unicast_packet); 200 unicast_packet);
198 201
199 if (!tmp_frag_entry) { 202 if (!tmp_frag_entry) {
200 frag_create_entry(&orig_node->frag_list, skb); 203 batadv_frag_create_entry(&orig_node->frag_list, skb);
201 ret = NET_RX_SUCCESS; 204 ret = NET_RX_SUCCESS;
202 goto out; 205 goto out;
203 } 206 }
204 207
205 *new_skb = frag_merge_packet(&orig_node->frag_list, tmp_frag_entry, 208 *new_skb = batadv_frag_merge_packet(&orig_node->frag_list,
206 skb); 209 tmp_frag_entry, skb);
207 /* if not, merge failed */ 210 /* if not, merge failed */
208 if (*new_skb) 211 if (*new_skb)
209 ret = NET_RX_SUCCESS; 212 ret = NET_RX_SUCCESS;
@@ -250,7 +253,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
250 memcpy(frag1, &tmp_uc, sizeof(tmp_uc)); 253 memcpy(frag1, &tmp_uc, sizeof(tmp_uc));
251 254
252 frag1->header.ttl--; 255 frag1->header.ttl--;
253 frag1->header.version = COMPAT_VERSION; 256 frag1->header.version = BATADV_COMPAT_VERSION;
254 frag1->header.packet_type = BAT_UNICAST_FRAG; 257 frag1->header.packet_type = BAT_UNICAST_FRAG;
255 258
256 memcpy(frag1->orig, primary_if->net_dev->dev_addr, ETH_ALEN); 259 memcpy(frag1->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
@@ -316,11 +319,11 @@ find_router:
316 319
317 unicast_packet = (struct unicast_packet *)skb->data; 320 unicast_packet = (struct unicast_packet *)skb->data;
318 321
319 unicast_packet->header.version = COMPAT_VERSION; 322 unicast_packet->header.version = BATADV_COMPAT_VERSION;
320 /* batman packet type: unicast */ 323 /* batman packet type: unicast */
321 unicast_packet->header.packet_type = BAT_UNICAST; 324 unicast_packet->header.packet_type = BAT_UNICAST;
322 /* set unicast ttl */ 325 /* set unicast ttl */
323 unicast_packet->header.ttl = TTL; 326 unicast_packet->header.ttl = BATADV_TTL;
324 /* copy the destination for faster routing */ 327 /* copy the destination for faster routing */
325 memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN); 328 memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
326 /* set the destination tt version number */ 329 /* set the destination tt version number */
diff --git a/net/batman-adv/unicast.h b/net/batman-adv/unicast.h
index 9257b83534fd..936287f552ee 100644
--- a/net/batman-adv/unicast.h
+++ b/net/batman-adv/unicast.h
@@ -22,8 +22,8 @@
22 22
23#include "packet.h" 23#include "packet.h"
24 24
25#define FRAG_TIMEOUT 10000 /* purge frag list entries after time in ms */ 25#define BATADV_FRAG_TIMEOUT 10000 /* purge frag list entries after time in ms */
26#define FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */ 26#define BATADV_FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */
27 27
28int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv, 28int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
29 struct sk_buff **new_skb); 29 struct sk_buff **new_skb);
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c
index d45989e0bbd7..74181696eef6 100644
--- a/net/batman-adv/vis.c
+++ b/net/batman-adv/vis.c
@@ -26,12 +26,12 @@
26#include "hash.h" 26#include "hash.h"
27#include "originator.h" 27#include "originator.h"
28 28
29#define MAX_VIS_PACKET_SIZE 1000 29#define BATADV_MAX_VIS_PACKET_SIZE 1000
30 30
31static void start_vis_timer(struct bat_priv *bat_priv); 31static void batadv_start_vis_timer(struct bat_priv *bat_priv);
32 32
33/* free the info */ 33/* free the info */
34static void free_info(struct kref *ref) 34static void batadv_free_info(struct kref *ref)
35{ 35{
36 struct vis_info *info = container_of(ref, struct vis_info, refcount); 36 struct vis_info *info = container_of(ref, struct vis_info, refcount);
37 struct bat_priv *bat_priv = info->bat_priv; 37 struct bat_priv *bat_priv = info->bat_priv;
@@ -50,7 +50,7 @@ static void free_info(struct kref *ref)
50} 50}
51 51
52/* Compare two vis packets, used by the hashing algorithm */ 52/* Compare two vis packets, used by the hashing algorithm */
53static int vis_info_cmp(const struct hlist_node *node, const void *data2) 53static int batadv_vis_info_cmp(const struct hlist_node *node, const void *data2)
54{ 54{
55 const struct vis_info *d1, *d2; 55 const struct vis_info *d1, *d2;
56 const struct vis_packet *p1, *p2; 56 const struct vis_packet *p1, *p2;
@@ -65,7 +65,7 @@ static int vis_info_cmp(const struct hlist_node *node, const void *data2)
65/* hash function to choose an entry in a hash table of given size 65/* hash function to choose an entry in a hash table of given size
66 * hash algorithm from http://en.wikipedia.org/wiki/Hash_table 66 * hash algorithm from http://en.wikipedia.org/wiki/Hash_table
67 */ 67 */
68static uint32_t vis_info_choose(const void *data, uint32_t size) 68static uint32_t batadv_vis_info_choose(const void *data, uint32_t size)
69{ 69{
70 const struct vis_info *vis_info = data; 70 const struct vis_info *vis_info = data;
71 const struct vis_packet *packet; 71 const struct vis_packet *packet;
@@ -88,8 +88,8 @@ static uint32_t vis_info_choose(const void *data, uint32_t size)
88 return hash % size; 88 return hash % size;
89} 89}
90 90
91static struct vis_info *vis_hash_find(struct bat_priv *bat_priv, 91static struct vis_info *batadv_vis_hash_find(struct bat_priv *bat_priv,
92 const void *data) 92 const void *data)
93{ 93{
94 struct hashtable_t *hash = bat_priv->vis_hash; 94 struct hashtable_t *hash = bat_priv->vis_hash;
95 struct hlist_head *head; 95 struct hlist_head *head;
@@ -100,12 +100,12 @@ static struct vis_info *vis_hash_find(struct bat_priv *bat_priv,
100 if (!hash) 100 if (!hash)
101 return NULL; 101 return NULL;
102 102
103 index = vis_info_choose(data, hash->size); 103 index = batadv_vis_info_choose(data, hash->size);
104 head = &hash->table[index]; 104 head = &hash->table[index];
105 105
106 rcu_read_lock(); 106 rcu_read_lock();
107 hlist_for_each_entry_rcu(vis_info, node, head, hash_entry) { 107 hlist_for_each_entry_rcu(vis_info, node, head, hash_entry) {
108 if (!vis_info_cmp(node, data)) 108 if (!batadv_vis_info_cmp(node, data))
109 continue; 109 continue;
110 110
111 vis_info_tmp = vis_info; 111 vis_info_tmp = vis_info;
@@ -119,9 +119,9 @@ static struct vis_info *vis_hash_find(struct bat_priv *bat_priv,
119/* insert interface to the list of interfaces of one originator, if it 119/* insert interface to the list of interfaces of one originator, if it
120 * does not already exist in the list 120 * does not already exist in the list
121 */ 121 */
122static void vis_data_insert_interface(const uint8_t *interface, 122static void batadv_vis_data_insert_interface(const uint8_t *interface,
123 struct hlist_head *if_list, 123 struct hlist_head *if_list,
124 bool primary) 124 bool primary)
125{ 125{
126 struct if_list_entry *entry; 126 struct if_list_entry *entry;
127 struct hlist_node *pos; 127 struct hlist_node *pos;
@@ -140,73 +140,117 @@ static void vis_data_insert_interface(const uint8_t *interface,
140 hlist_add_head(&entry->list, if_list); 140 hlist_add_head(&entry->list, if_list);
141} 141}
142 142
143static ssize_t vis_data_read_prim_sec(char *buff, 143static void batadv_vis_data_read_prim_sec(struct seq_file *seq,
144 const struct hlist_head *if_list) 144 const struct hlist_head *if_list)
145{ 145{
146 struct if_list_entry *entry; 146 struct if_list_entry *entry;
147 struct hlist_node *pos; 147 struct hlist_node *pos;
148 size_t len = 0;
149 148
150 hlist_for_each_entry(entry, pos, if_list, list) { 149 hlist_for_each_entry(entry, pos, if_list, list) {
151 if (entry->primary) 150 if (entry->primary)
152 len += sprintf(buff + len, "PRIMARY, "); 151 seq_printf(seq, "PRIMARY, ");
153 else 152 else
154 len += sprintf(buff + len, "SEC %pM, ", entry->addr); 153 seq_printf(seq, "SEC %pM, ", entry->addr);
155 } 154 }
155}
156
157/* read an entry */
158static ssize_t batadv_vis_data_read_entry(struct seq_file *seq,
159 const struct vis_info_entry *entry,
160 const uint8_t *src, bool primary)
161{
162 if (primary && entry->quality == 0)
163 return seq_printf(seq, "TT %pM, ", entry->dest);
164 else if (batadv_compare_eth(entry->src, src))
165 return seq_printf(seq, "TQ %pM %d, ", entry->dest,
166 entry->quality);
167
168 return 0;
169}
170
171static void batadv_vis_data_insert_interfaces(struct hlist_head *list,
172 struct vis_packet *packet,
173 struct vis_info_entry *entries)
174{
175 int i;
176
177 for (i = 0; i < packet->entries; i++) {
178 if (entries[i].quality == 0)
179 continue;
180
181 if (batadv_compare_eth(entries[i].src, packet->vis_orig))
182 continue;
156 183
157 return len; 184 batadv_vis_data_insert_interface(entries[i].src, list, false);
185 }
158} 186}
159 187
160static size_t vis_data_count_prim_sec(struct hlist_head *if_list) 188static void batadv_vis_data_read_entries(struct seq_file *seq,
189 struct hlist_head *list,
190 struct vis_packet *packet,
191 struct vis_info_entry *entries)
161{ 192{
193 int i;
162 struct if_list_entry *entry; 194 struct if_list_entry *entry;
163 struct hlist_node *pos; 195 struct hlist_node *pos;
164 size_t count = 0;
165 196
166 hlist_for_each_entry(entry, pos, if_list, list) { 197 hlist_for_each_entry(entry, pos, list, list) {
167 if (entry->primary) 198 seq_printf(seq, "%pM,", entry->addr);
168 count += 9;
169 else
170 count += 23;
171 }
172 199
173 return count; 200 for (i = 0; i < packet->entries; i++)
201 batadv_vis_data_read_entry(seq, &entries[i],
202 entry->addr, entry->primary);
203
204 /* add primary/secondary records */
205 if (batadv_compare_eth(entry->addr, packet->vis_orig))
206 batadv_vis_data_read_prim_sec(seq, list);
207
208 seq_printf(seq, "\n");
209 }
174} 210}
175 211
176/* read an entry */ 212static void batadv_vis_seq_print_text_bucket(struct seq_file *seq,
177static ssize_t vis_data_read_entry(char *buff, 213 const struct hlist_head *head)
178 const struct vis_info_entry *entry,
179 const uint8_t *src, bool primary)
180{ 214{
181 /* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */ 215 struct hlist_node *node;
182 if (primary && entry->quality == 0) 216 struct vis_info *info;
183 return sprintf(buff, "TT %pM, ", entry->dest); 217 struct vis_packet *packet;
184 else if (batadv_compare_eth(entry->src, src)) 218 uint8_t *entries_pos;
185 return sprintf(buff, "TQ %pM %d, ", entry->dest, 219 struct vis_info_entry *entries;
186 entry->quality); 220 struct if_list_entry *entry;
221 struct hlist_node *pos, *n;
187 222
188 return 0; 223 HLIST_HEAD(vis_if_list);
224
225 hlist_for_each_entry_rcu(info, node, head, hash_entry) {
226 packet = (struct vis_packet *)info->skb_packet->data;
227 entries_pos = (uint8_t *)packet + sizeof(*packet);
228 entries = (struct vis_info_entry *)entries_pos;
229
230 batadv_vis_data_insert_interface(packet->vis_orig, &vis_if_list,
231 true);
232 batadv_vis_data_insert_interfaces(&vis_if_list, packet,
233 entries);
234 batadv_vis_data_read_entries(seq, &vis_if_list, packet,
235 entries);
236
237 hlist_for_each_entry_safe(entry, pos, n, &vis_if_list, list) {
238 hlist_del(&entry->list);
239 kfree(entry);
240 }
241 }
189} 242}
190 243
191int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) 244int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
192{ 245{
193 struct hard_iface *primary_if; 246 struct hard_iface *primary_if;
194 struct hlist_node *node;
195 struct hlist_head *head; 247 struct hlist_head *head;
196 struct vis_info *info;
197 struct vis_packet *packet;
198 struct vis_info_entry *entries;
199 struct net_device *net_dev = (struct net_device *)seq->private; 248 struct net_device *net_dev = (struct net_device *)seq->private;
200 struct bat_priv *bat_priv = netdev_priv(net_dev); 249 struct bat_priv *bat_priv = netdev_priv(net_dev);
201 struct hashtable_t *hash = bat_priv->vis_hash; 250 struct hashtable_t *hash = bat_priv->vis_hash;
202 HLIST_HEAD(vis_if_list);
203 struct if_list_entry *entry;
204 struct hlist_node *pos, *n;
205 uint32_t i; 251 uint32_t i;
206 int j, ret = 0; 252 int ret = 0;
207 int vis_server = atomic_read(&bat_priv->vis_mode); 253 int vis_server = atomic_read(&bat_priv->vis_mode);
208 size_t buff_pos, buf_size;
209 char *buff;
210 254
211 primary_if = batadv_primary_if_get_selected(bat_priv); 255 primary_if = batadv_primary_if_get_selected(bat_priv);
212 if (!primary_if) 256 if (!primary_if)
@@ -215,120 +259,13 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
215 if (vis_server == VIS_TYPE_CLIENT_UPDATE) 259 if (vis_server == VIS_TYPE_CLIENT_UPDATE)
216 goto out; 260 goto out;
217 261
218 buf_size = 1;
219 /* Estimate length */
220 spin_lock_bh(&bat_priv->vis_hash_lock); 262 spin_lock_bh(&bat_priv->vis_hash_lock);
221 for (i = 0; i < hash->size; i++) { 263 for (i = 0; i < hash->size; i++) {
222 head = &hash->table[i]; 264 head = &hash->table[i];
223 265 batadv_vis_seq_print_text_bucket(seq, head);
224 rcu_read_lock();
225 hlist_for_each_entry_rcu(info, node, head, hash_entry) {
226 packet = (struct vis_packet *)info->skb_packet->data;
227 entries = (struct vis_info_entry *)
228 ((char *)packet + sizeof(*packet));
229
230 vis_data_insert_interface(packet->vis_orig,
231 &vis_if_list, true);
232
233 for (j = 0; j < packet->entries; j++) {
234 if (entries[j].quality == 0)
235 continue;
236 if (batadv_compare_eth(entries[j].src,
237 packet->vis_orig))
238 continue;
239 vis_data_insert_interface(entries[j].src,
240 &vis_if_list,
241 false);
242 }
243
244 hlist_for_each_entry(entry, pos, &vis_if_list, list) {
245 buf_size += 18 + 26 * packet->entries;
246
247 /* add primary/secondary records */
248 if (batadv_compare_eth(entry->addr,
249 packet->vis_orig))
250 buf_size +=
251 vis_data_count_prim_sec(&vis_if_list);
252
253 buf_size += 1;
254 }
255
256 hlist_for_each_entry_safe(entry, pos, n, &vis_if_list,
257 list) {
258 hlist_del(&entry->list);
259 kfree(entry);
260 }
261 }
262 rcu_read_unlock();
263 }
264
265 buff = kmalloc(buf_size, GFP_ATOMIC);
266 if (!buff) {
267 spin_unlock_bh(&bat_priv->vis_hash_lock);
268 ret = -ENOMEM;
269 goto out;
270 }
271 buff[0] = '\0';
272 buff_pos = 0;
273
274 for (i = 0; i < hash->size; i++) {
275 head = &hash->table[i];
276
277 rcu_read_lock();
278 hlist_for_each_entry_rcu(info, node, head, hash_entry) {
279 packet = (struct vis_packet *)info->skb_packet->data;
280 entries = (struct vis_info_entry *)
281 ((char *)packet + sizeof(*packet));
282
283 vis_data_insert_interface(packet->vis_orig,
284 &vis_if_list, true);
285
286 for (j = 0; j < packet->entries; j++) {
287 if (entries[j].quality == 0)
288 continue;
289 if (batadv_compare_eth(entries[j].src,
290 packet->vis_orig))
291 continue;
292 vis_data_insert_interface(entries[j].src,
293 &vis_if_list,
294 false);
295 }
296
297 hlist_for_each_entry(entry, pos, &vis_if_list, list) {
298 buff_pos += sprintf(buff + buff_pos, "%pM,",
299 entry->addr);
300
301 for (j = 0; j < packet->entries; j++)
302 buff_pos += vis_data_read_entry(
303 buff + buff_pos,
304 &entries[j],
305 entry->addr,
306 entry->primary);
307
308 /* add primary/secondary records */
309 if (batadv_compare_eth(entry->addr,
310 packet->vis_orig))
311 buff_pos +=
312 vis_data_read_prim_sec(buff + buff_pos,
313 &vis_if_list);
314
315 buff_pos += sprintf(buff + buff_pos, "\n");
316 }
317
318 hlist_for_each_entry_safe(entry, pos, n, &vis_if_list,
319 list) {
320 hlist_del(&entry->list);
321 kfree(entry);
322 }
323 }
324 rcu_read_unlock();
325 } 266 }
326
327 spin_unlock_bh(&bat_priv->vis_hash_lock); 267 spin_unlock_bh(&bat_priv->vis_hash_lock);
328 268
329 seq_printf(seq, "%s", buff);
330 kfree(buff);
331
332out: 269out:
333 if (primary_if) 270 if (primary_if)
334 batadv_hardif_free_ref(primary_if); 271 batadv_hardif_free_ref(primary_if);
@@ -338,7 +275,8 @@ out:
338/* add the info packet to the send list, if it was not 275/* add the info packet to the send list, if it was not
339 * already linked in. 276 * already linked in.
340 */ 277 */
341static void send_list_add(struct bat_priv *bat_priv, struct vis_info *info) 278static void batadv_send_list_add(struct bat_priv *bat_priv,
279 struct vis_info *info)
342{ 280{
343 if (list_empty(&info->send_list)) { 281 if (list_empty(&info->send_list)) {
344 kref_get(&info->refcount); 282 kref_get(&info->refcount);
@@ -349,17 +287,17 @@ static void send_list_add(struct bat_priv *bat_priv, struct vis_info *info)
349/* delete the info packet from the send list, if it was 287/* delete the info packet from the send list, if it was
350 * linked in. 288 * linked in.
351 */ 289 */
352static void send_list_del(struct vis_info *info) 290static void batadv_send_list_del(struct vis_info *info)
353{ 291{
354 if (!list_empty(&info->send_list)) { 292 if (!list_empty(&info->send_list)) {
355 list_del_init(&info->send_list); 293 list_del_init(&info->send_list);
356 kref_put(&info->refcount, free_info); 294 kref_put(&info->refcount, batadv_free_info);
357 } 295 }
358} 296}
359 297
360/* tries to add one entry to the receive list. */ 298/* tries to add one entry to the receive list. */
361static void recv_list_add(struct bat_priv *bat_priv, 299static void batadv_recv_list_add(struct bat_priv *bat_priv,
362 struct list_head *recv_list, const char *mac) 300 struct list_head *recv_list, const char *mac)
363{ 301{
364 struct recvlist_node *entry; 302 struct recvlist_node *entry;
365 303
@@ -374,8 +312,9 @@ static void recv_list_add(struct bat_priv *bat_priv,
374} 312}
375 313
376/* returns 1 if this mac is in the recv_list */ 314/* returns 1 if this mac is in the recv_list */
377static int recv_list_is_in(struct bat_priv *bat_priv, 315static int batadv_recv_list_is_in(struct bat_priv *bat_priv,
378 const struct list_head *recv_list, const char *mac) 316 const struct list_head *recv_list,
317 const char *mac)
379{ 318{
380 const struct recvlist_node *entry; 319 const struct recvlist_node *entry;
381 320
@@ -394,10 +333,10 @@ static int recv_list_is_in(struct bat_priv *bat_priv,
394 * broken.. ). vis hash must be locked outside. is_new is set when the packet 333 * broken.. ). vis hash must be locked outside. is_new is set when the packet
395 * is newer than old entries in the hash. 334 * is newer than old entries in the hash.
396 */ 335 */
397static struct vis_info *add_packet(struct bat_priv *bat_priv, 336static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv,
398 struct vis_packet *vis_packet, 337 struct vis_packet *vis_packet,
399 int vis_info_len, int *is_new, 338 int vis_info_len, int *is_new,
400 int make_broadcast) 339 int make_broadcast)
401{ 340{
402 struct vis_info *info, *old_info; 341 struct vis_info *info, *old_info;
403 struct vis_packet *search_packet, *old_packet; 342 struct vis_packet *search_packet, *old_packet;
@@ -418,16 +357,17 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv,
418 sizeof(*search_packet)); 357 sizeof(*search_packet));
419 358
420 memcpy(search_packet->vis_orig, vis_packet->vis_orig, ETH_ALEN); 359 memcpy(search_packet->vis_orig, vis_packet->vis_orig, ETH_ALEN);
421 old_info = vis_hash_find(bat_priv, &search_elem); 360 old_info = batadv_vis_hash_find(bat_priv, &search_elem);
422 kfree_skb(search_elem.skb_packet); 361 kfree_skb(search_elem.skb_packet);
423 362
424 if (old_info) { 363 if (old_info) {
425 old_packet = (struct vis_packet *)old_info->skb_packet->data; 364 old_packet = (struct vis_packet *)old_info->skb_packet->data;
426 if (!seq_after(ntohl(vis_packet->seqno), 365 if (!batadv_seq_after(ntohl(vis_packet->seqno),
427 ntohl(old_packet->seqno))) { 366 ntohl(old_packet->seqno))) {
428 if (old_packet->seqno == vis_packet->seqno) { 367 if (old_packet->seqno == vis_packet->seqno) {
429 recv_list_add(bat_priv, &old_info->recv_list, 368 batadv_recv_list_add(bat_priv,
430 vis_packet->sender_orig); 369 &old_info->recv_list,
370 vis_packet->sender_orig);
431 return old_info; 371 return old_info;
432 } else { 372 } else {
433 /* newer packet is already in hash. */ 373 /* newer packet is already in hash. */
@@ -435,10 +375,10 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv,
435 } 375 }
436 } 376 }
437 /* remove old entry */ 377 /* remove old entry */
438 batadv_hash_remove(bat_priv->vis_hash, vis_info_cmp, 378 batadv_hash_remove(bat_priv->vis_hash, batadv_vis_info_cmp,
439 vis_info_choose, old_info); 379 batadv_vis_info_choose, old_info);
440 send_list_del(old_info); 380 batadv_send_list_del(old_info);
441 kref_put(&old_info->refcount, free_info); 381 kref_put(&old_info->refcount, batadv_free_info);
442 } 382 }
443 383
444 info = kmalloc(sizeof(*info), GFP_ATOMIC); 384 info = kmalloc(sizeof(*info), GFP_ATOMIC);
@@ -473,14 +413,15 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv,
473 if (packet->entries * sizeof(struct vis_info_entry) > vis_info_len) 413 if (packet->entries * sizeof(struct vis_info_entry) > vis_info_len)
474 packet->entries = vis_info_len / sizeof(struct vis_info_entry); 414 packet->entries = vis_info_len / sizeof(struct vis_info_entry);
475 415
476 recv_list_add(bat_priv, &info->recv_list, packet->sender_orig); 416 batadv_recv_list_add(bat_priv, &info->recv_list, packet->sender_orig);
477 417
478 /* try to add it */ 418 /* try to add it */
479 hash_added = batadv_hash_add(bat_priv->vis_hash, vis_info_cmp, 419 hash_added = batadv_hash_add(bat_priv->vis_hash, batadv_vis_info_cmp,
480 vis_info_choose, info, &info->hash_entry); 420 batadv_vis_info_choose, info,
421 &info->hash_entry);
481 if (hash_added != 0) { 422 if (hash_added != 0) {
482 /* did not work (for some reason) */ 423 /* did not work (for some reason) */
483 kref_put(&info->refcount, free_info); 424 kref_put(&info->refcount, batadv_free_info);
484 info = NULL; 425 info = NULL;
485 } 426 }
486 427
@@ -499,8 +440,8 @@ void batadv_receive_server_sync_packet(struct bat_priv *bat_priv,
499 make_broadcast = (vis_server == VIS_TYPE_SERVER_SYNC); 440 make_broadcast = (vis_server == VIS_TYPE_SERVER_SYNC);
500 441
501 spin_lock_bh(&bat_priv->vis_hash_lock); 442 spin_lock_bh(&bat_priv->vis_hash_lock);
502 info = add_packet(bat_priv, vis_packet, vis_info_len, 443 info = batadv_add_packet(bat_priv, vis_packet, vis_info_len,
503 &is_new, make_broadcast); 444 &is_new, make_broadcast);
504 if (!info) 445 if (!info)
505 goto end; 446 goto end;
506 447
@@ -508,7 +449,7 @@ void batadv_receive_server_sync_packet(struct bat_priv *bat_priv,
508 * hash. 449 * hash.
509 */ 450 */
510 if (vis_server == VIS_TYPE_SERVER_SYNC && is_new) 451 if (vis_server == VIS_TYPE_SERVER_SYNC && is_new)
511 send_list_add(bat_priv, info); 452 batadv_send_list_add(bat_priv, info);
512end: 453end:
513 spin_unlock_bh(&bat_priv->vis_hash_lock); 454 spin_unlock_bh(&bat_priv->vis_hash_lock);
514} 455}
@@ -534,8 +475,8 @@ void batadv_receive_client_update_packet(struct bat_priv *bat_priv,
534 are_target = 1; 475 are_target = 1;
535 476
536 spin_lock_bh(&bat_priv->vis_hash_lock); 477 spin_lock_bh(&bat_priv->vis_hash_lock);
537 info = add_packet(bat_priv, vis_packet, vis_info_len, 478 info = batadv_add_packet(bat_priv, vis_packet, vis_info_len,
538 &is_new, are_target); 479 &is_new, are_target);
539 480
540 if (!info) 481 if (!info)
541 goto end; 482 goto end;
@@ -546,11 +487,11 @@ void batadv_receive_client_update_packet(struct bat_priv *bat_priv,
546 /* send only if we're the target server or ... */ 487 /* send only if we're the target server or ... */
547 if (are_target && is_new) { 488 if (are_target && is_new) {
548 packet->vis_type = VIS_TYPE_SERVER_SYNC; /* upgrade! */ 489 packet->vis_type = VIS_TYPE_SERVER_SYNC; /* upgrade! */
549 send_list_add(bat_priv, info); 490 batadv_send_list_add(bat_priv, info);
550 491
551 /* ... we're not the recipient (and thus need to forward). */ 492 /* ... we're not the recipient (and thus need to forward). */
552 } else if (!batadv_is_my_mac(packet->target_orig)) { 493 } else if (!batadv_is_my_mac(packet->target_orig)) {
553 send_list_add(bat_priv, info); 494 batadv_send_list_add(bat_priv, info);
554 } 495 }
555 496
556end: 497end:
@@ -562,8 +503,8 @@ end:
562 * 503 *
563 * Must be called with the originator hash locked 504 * Must be called with the originator hash locked
564 */ 505 */
565static int find_best_vis_server(struct bat_priv *bat_priv, 506static int batadv_find_best_vis_server(struct bat_priv *bat_priv,
566 struct vis_info *info) 507 struct vis_info *info)
567{ 508{
568 struct hashtable_t *hash = bat_priv->orig_hash; 509 struct hashtable_t *hash = bat_priv->orig_hash;
569 struct neigh_node *router; 510 struct neigh_node *router;
@@ -600,13 +541,15 @@ static int find_best_vis_server(struct bat_priv *bat_priv,
600} 541}
601 542
602/* Return true if the vis packet is full. */ 543/* Return true if the vis packet is full. */
603static bool vis_packet_full(const struct vis_info *info) 544static bool batadv_vis_packet_full(const struct vis_info *info)
604{ 545{
605 const struct vis_packet *packet; 546 const struct vis_packet *packet;
547 size_t num_items;
548
606 packet = (struct vis_packet *)info->skb_packet->data; 549 packet = (struct vis_packet *)info->skb_packet->data;
550 num_items = BATADV_MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry);
607 551
608 if (MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry) 552 if (num_items < packet->entries + 1)
609 < packet->entries + 1)
610 return true; 553 return true;
611 return false; 554 return false;
612} 555}
@@ -614,7 +557,7 @@ static bool vis_packet_full(const struct vis_info *info)
614/* generates a packet of own vis data, 557/* generates a packet of own vis data,
615 * returns 0 on success, -1 if no packet could be generated 558 * returns 0 on success, -1 if no packet could be generated
616 */ 559 */
617static int generate_vis_packet(struct bat_priv *bat_priv) 560static int batadv_generate_vis_packet(struct bat_priv *bat_priv)
618{ 561{
619 struct hashtable_t *hash = bat_priv->orig_hash; 562 struct hashtable_t *hash = bat_priv->orig_hash;
620 struct hlist_node *node; 563 struct hlist_node *node;
@@ -632,13 +575,13 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
632 packet->vis_type = atomic_read(&bat_priv->vis_mode); 575 packet->vis_type = atomic_read(&bat_priv->vis_mode);
633 576
634 memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN); 577 memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN);
635 packet->header.ttl = TTL; 578 packet->header.ttl = BATADV_TTL;
636 packet->seqno = htonl(ntohl(packet->seqno) + 1); 579 packet->seqno = htonl(ntohl(packet->seqno) + 1);
637 packet->entries = 0; 580 packet->entries = 0;
638 skb_trim(info->skb_packet, sizeof(*packet)); 581 skb_trim(info->skb_packet, sizeof(*packet));
639 582
640 if (packet->vis_type == VIS_TYPE_CLIENT_UPDATE) { 583 if (packet->vis_type == VIS_TYPE_CLIENT_UPDATE) {
641 best_tq = find_best_vis_server(bat_priv, info); 584 best_tq = batadv_find_best_vis_server(bat_priv, info);
642 585
643 if (best_tq < 0) 586 if (best_tq < 0)
644 return best_tq; 587 return best_tq;
@@ -675,7 +618,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
675next: 618next:
676 batadv_neigh_node_free_ref(router); 619 batadv_neigh_node_free_ref(router);
677 620
678 if (vis_packet_full(info)) 621 if (batadv_vis_packet_full(info))
679 goto unlock; 622 goto unlock;
680 } 623 }
681 rcu_read_unlock(); 624 rcu_read_unlock();
@@ -697,7 +640,7 @@ next:
697 entry->quality = 0; /* 0 means TT */ 640 entry->quality = 0; /* 0 means TT */
698 packet->entries++; 641 packet->entries++;
699 642
700 if (vis_packet_full(info)) 643 if (batadv_vis_packet_full(info))
701 goto unlock; 644 goto unlock;
702 } 645 }
703 rcu_read_unlock(); 646 rcu_read_unlock();
@@ -713,7 +656,7 @@ unlock:
713/* free old vis packets. Must be called with this vis_hash_lock 656/* free old vis packets. Must be called with this vis_hash_lock
714 * held 657 * held
715 */ 658 */
716static void purge_vis_packets(struct bat_priv *bat_priv) 659static void batadv_purge_vis_packets(struct bat_priv *bat_priv)
717{ 660{
718 uint32_t i; 661 uint32_t i;
719 struct hashtable_t *hash = bat_priv->vis_hash; 662 struct hashtable_t *hash = bat_priv->vis_hash;
@@ -731,17 +674,17 @@ static void purge_vis_packets(struct bat_priv *bat_priv)
731 continue; 674 continue;
732 675
733 if (batadv_has_timed_out(info->first_seen, 676 if (batadv_has_timed_out(info->first_seen,
734 VIS_TIMEOUT)) { 677 BATADV_VIS_TIMEOUT)) {
735 hlist_del(node); 678 hlist_del(node);
736 send_list_del(info); 679 batadv_send_list_del(info);
737 kref_put(&info->refcount, free_info); 680 kref_put(&info->refcount, batadv_free_info);
738 } 681 }
739 } 682 }
740 } 683 }
741} 684}
742 685
743static void broadcast_vis_packet(struct bat_priv *bat_priv, 686static void batadv_broadcast_vis_packet(struct bat_priv *bat_priv,
744 struct vis_info *info) 687 struct vis_info *info)
745{ 688{
746 struct neigh_node *router; 689 struct neigh_node *router;
747 struct hashtable_t *hash = bat_priv->orig_hash; 690 struct hashtable_t *hash = bat_priv->orig_hash;
@@ -774,8 +717,8 @@ static void broadcast_vis_packet(struct bat_priv *bat_priv,
774 /* don't send it if we already received the packet from 717 /* don't send it if we already received the packet from
775 * this node. 718 * this node.
776 */ 719 */
777 if (recv_list_is_in(bat_priv, &info->recv_list, 720 if (batadv_recv_list_is_in(bat_priv, &info->recv_list,
778 orig_node->orig)) { 721 orig_node->orig)) {
779 batadv_neigh_node_free_ref(router); 722 batadv_neigh_node_free_ref(router);
780 continue; 723 continue;
781 } 724 }
@@ -796,8 +739,8 @@ static void broadcast_vis_packet(struct bat_priv *bat_priv,
796 } 739 }
797} 740}
798 741
799static void unicast_vis_packet(struct bat_priv *bat_priv, 742static void batadv_unicast_vis_packet(struct bat_priv *bat_priv,
800 struct vis_info *info) 743 struct vis_info *info)
801{ 744{
802 struct orig_node *orig_node; 745 struct orig_node *orig_node;
803 struct neigh_node *router = NULL; 746 struct neigh_node *router = NULL;
@@ -825,8 +768,9 @@ out:
825 batadv_orig_node_free_ref(orig_node); 768 batadv_orig_node_free_ref(orig_node);
826} 769}
827 770
828/* only send one vis packet. called from send_vis_packets() */ 771/* only send one vis packet. called from batadv_send_vis_packets() */
829static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info) 772static void batadv_send_vis_packet(struct bat_priv *bat_priv,
773 struct vis_info *info)
830{ 774{
831 struct hard_iface *primary_if; 775 struct hard_iface *primary_if;
832 struct vis_packet *packet; 776 struct vis_packet *packet;
@@ -845,9 +789,9 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)
845 packet->header.ttl--; 789 packet->header.ttl--;
846 790
847 if (is_broadcast_ether_addr(packet->target_orig)) 791 if (is_broadcast_ether_addr(packet->target_orig))
848 broadcast_vis_packet(bat_priv, info); 792 batadv_broadcast_vis_packet(bat_priv, info);
849 else 793 else
850 unicast_vis_packet(bat_priv, info); 794 batadv_unicast_vis_packet(bat_priv, info);
851 packet->header.ttl++; /* restore TTL */ 795 packet->header.ttl++; /* restore TTL */
852 796
853out: 797out:
@@ -856,7 +800,7 @@ out:
856} 800}
857 801
858/* called from timer; send (and maybe generate) vis packet. */ 802/* called from timer; send (and maybe generate) vis packet. */
859static void send_vis_packets(struct work_struct *work) 803static void batadv_send_vis_packets(struct work_struct *work)
860{ 804{
861 struct delayed_work *delayed_work = 805 struct delayed_work *delayed_work =
862 container_of(work, struct delayed_work, work); 806 container_of(work, struct delayed_work, work);
@@ -865,11 +809,11 @@ static void send_vis_packets(struct work_struct *work)
865 struct vis_info *info; 809 struct vis_info *info;
866 810
867 spin_lock_bh(&bat_priv->vis_hash_lock); 811 spin_lock_bh(&bat_priv->vis_hash_lock);
868 purge_vis_packets(bat_priv); 812 batadv_purge_vis_packets(bat_priv);
869 813
870 if (generate_vis_packet(bat_priv) == 0) { 814 if (batadv_generate_vis_packet(bat_priv) == 0) {
871 /* schedule if generation was successful */ 815 /* schedule if generation was successful */
872 send_list_add(bat_priv, bat_priv->my_vis_info); 816 batadv_send_list_add(bat_priv, bat_priv->my_vis_info);
873 } 817 }
874 818
875 while (!list_empty(&bat_priv->vis_send_list)) { 819 while (!list_empty(&bat_priv->vis_send_list)) {
@@ -879,14 +823,14 @@ static void send_vis_packets(struct work_struct *work)
879 kref_get(&info->refcount); 823 kref_get(&info->refcount);
880 spin_unlock_bh(&bat_priv->vis_hash_lock); 824 spin_unlock_bh(&bat_priv->vis_hash_lock);
881 825
882 send_vis_packet(bat_priv, info); 826 batadv_send_vis_packet(bat_priv, info);
883 827
884 spin_lock_bh(&bat_priv->vis_hash_lock); 828 spin_lock_bh(&bat_priv->vis_hash_lock);
885 send_list_del(info); 829 batadv_send_list_del(info);
886 kref_put(&info->refcount, free_info); 830 kref_put(&info->refcount, batadv_free_info);
887 } 831 }
888 spin_unlock_bh(&bat_priv->vis_hash_lock); 832 spin_unlock_bh(&bat_priv->vis_hash_lock);
889 start_vis_timer(bat_priv); 833 batadv_start_vis_timer(bat_priv);
890} 834}
891 835
892/* init the vis server. this may only be called when if_list is already 836/* init the vis server. this may only be called when if_list is already
@@ -896,6 +840,8 @@ int batadv_vis_init(struct bat_priv *bat_priv)
896{ 840{
897 struct vis_packet *packet; 841 struct vis_packet *packet;
898 int hash_added; 842 int hash_added;
843 unsigned int len;
844 unsigned long first_seen;
899 845
900 if (bat_priv->vis_hash) 846 if (bat_priv->vis_hash)
901 return 0; 847 return 0;
@@ -908,13 +854,12 @@ int batadv_vis_init(struct bat_priv *bat_priv)
908 goto err; 854 goto err;
909 } 855 }
910 856
911 bat_priv->my_vis_info = kmalloc(MAX_VIS_PACKET_SIZE, GFP_ATOMIC); 857 bat_priv->my_vis_info = kmalloc(BATADV_MAX_VIS_PACKET_SIZE, GFP_ATOMIC);
912 if (!bat_priv->my_vis_info) 858 if (!bat_priv->my_vis_info)
913 goto err; 859 goto err;
914 860
915 bat_priv->my_vis_info->skb_packet = dev_alloc_skb(sizeof(*packet) + 861 len = sizeof(*packet) + BATADV_MAX_VIS_PACKET_SIZE + ETH_HLEN;
916 MAX_VIS_PACKET_SIZE + 862 bat_priv->my_vis_info->skb_packet = dev_alloc_skb(len);
917 ETH_HLEN);
918 if (!bat_priv->my_vis_info->skb_packet) 863 if (!bat_priv->my_vis_info->skb_packet)
919 goto free_info; 864 goto free_info;
920 865
@@ -923,32 +868,33 @@ int batadv_vis_init(struct bat_priv *bat_priv)
923 sizeof(*packet)); 868 sizeof(*packet));
924 869
925 /* prefill the vis info */ 870 /* prefill the vis info */
926 bat_priv->my_vis_info->first_seen = jiffies - 871 first_seen = jiffies - msecs_to_jiffies(BATADV_VIS_INTERVAL);
927 msecs_to_jiffies(VIS_INTERVAL); 872 bat_priv->my_vis_info->first_seen = first_seen;
928 INIT_LIST_HEAD(&bat_priv->my_vis_info->recv_list); 873 INIT_LIST_HEAD(&bat_priv->my_vis_info->recv_list);
929 INIT_LIST_HEAD(&bat_priv->my_vis_info->send_list); 874 INIT_LIST_HEAD(&bat_priv->my_vis_info->send_list);
930 kref_init(&bat_priv->my_vis_info->refcount); 875 kref_init(&bat_priv->my_vis_info->refcount);
931 bat_priv->my_vis_info->bat_priv = bat_priv; 876 bat_priv->my_vis_info->bat_priv = bat_priv;
932 packet->header.version = COMPAT_VERSION; 877 packet->header.version = BATADV_COMPAT_VERSION;
933 packet->header.packet_type = BAT_VIS; 878 packet->header.packet_type = BAT_VIS;
934 packet->header.ttl = TTL; 879 packet->header.ttl = BATADV_TTL;
935 packet->seqno = 0; 880 packet->seqno = 0;
936 packet->entries = 0; 881 packet->entries = 0;
937 882
938 INIT_LIST_HEAD(&bat_priv->vis_send_list); 883 INIT_LIST_HEAD(&bat_priv->vis_send_list);
939 884
940 hash_added = batadv_hash_add(bat_priv->vis_hash, vis_info_cmp, 885 hash_added = batadv_hash_add(bat_priv->vis_hash, batadv_vis_info_cmp,
941 vis_info_choose, bat_priv->my_vis_info, 886 batadv_vis_info_choose,
887 bat_priv->my_vis_info,
942 &bat_priv->my_vis_info->hash_entry); 888 &bat_priv->my_vis_info->hash_entry);
943 if (hash_added != 0) { 889 if (hash_added != 0) {
944 pr_err("Can't add own vis packet into hash\n"); 890 pr_err("Can't add own vis packet into hash\n");
945 /* not in hash, need to remove it manually. */ 891 /* not in hash, need to remove it manually. */
946 kref_put(&bat_priv->my_vis_info->refcount, free_info); 892 kref_put(&bat_priv->my_vis_info->refcount, batadv_free_info);
947 goto err; 893 goto err;
948 } 894 }
949 895
950 spin_unlock_bh(&bat_priv->vis_hash_lock); 896 spin_unlock_bh(&bat_priv->vis_hash_lock);
951 start_vis_timer(bat_priv); 897 batadv_start_vis_timer(bat_priv);
952 return 0; 898 return 0;
953 899
954free_info: 900free_info:
@@ -961,13 +907,13 @@ err:
961} 907}
962 908
963/* Decrease the reference count on a hash item info */ 909/* Decrease the reference count on a hash item info */
964static void free_info_ref(struct hlist_node *node, void *arg) 910static void batadv_free_info_ref(struct hlist_node *node, void *arg)
965{ 911{
966 struct vis_info *info; 912 struct vis_info *info;
967 913
968 info = container_of(node, struct vis_info, hash_entry); 914 info = container_of(node, struct vis_info, hash_entry);
969 send_list_del(info); 915 batadv_send_list_del(info);
970 kref_put(&info->refcount, free_info); 916 kref_put(&info->refcount, batadv_free_info);
971} 917}
972 918
973/* shutdown vis-server */ 919/* shutdown vis-server */
@@ -980,16 +926,16 @@ void batadv_vis_quit(struct bat_priv *bat_priv)
980 926
981 spin_lock_bh(&bat_priv->vis_hash_lock); 927 spin_lock_bh(&bat_priv->vis_hash_lock);
982 /* properly remove, kill timers ... */ 928 /* properly remove, kill timers ... */
983 batadv_hash_delete(bat_priv->vis_hash, free_info_ref, NULL); 929 batadv_hash_delete(bat_priv->vis_hash, batadv_free_info_ref, NULL);
984 bat_priv->vis_hash = NULL; 930 bat_priv->vis_hash = NULL;
985 bat_priv->my_vis_info = NULL; 931 bat_priv->my_vis_info = NULL;
986 spin_unlock_bh(&bat_priv->vis_hash_lock); 932 spin_unlock_bh(&bat_priv->vis_hash_lock);
987} 933}
988 934
989/* schedule packets for (re)transmission */ 935/* schedule packets for (re)transmission */
990static void start_vis_timer(struct bat_priv *bat_priv) 936static void batadv_start_vis_timer(struct bat_priv *bat_priv)
991{ 937{
992 INIT_DELAYED_WORK(&bat_priv->vis_work, send_vis_packets); 938 INIT_DELAYED_WORK(&bat_priv->vis_work, batadv_send_vis_packets);
993 queue_delayed_work(batadv_event_workqueue, &bat_priv->vis_work, 939 queue_delayed_work(batadv_event_workqueue, &bat_priv->vis_work,
994 msecs_to_jiffies(VIS_INTERVAL)); 940 msecs_to_jiffies(BATADV_VIS_INTERVAL));
995} 941}
diff --git a/net/batman-adv/vis.h b/net/batman-adv/vis.h
index dad595870f8f..16a1a6b7e2c3 100644
--- a/net/batman-adv/vis.h
+++ b/net/batman-adv/vis.h
@@ -21,7 +21,7 @@
21#define _NET_BATMAN_ADV_VIS_H_ 21#define _NET_BATMAN_ADV_VIS_H_
22 22
23/* timeout of vis packets in miliseconds */ 23/* timeout of vis packets in miliseconds */
24#define VIS_TIMEOUT 200000 24#define BATADV_VIS_TIMEOUT 200000
25 25
26int batadv_vis_seq_print_text(struct seq_file *seq, void *offset); 26int batadv_vis_seq_print_text(struct seq_file *seq, void *offset);
27void batadv_receive_server_sync_packet(struct bat_priv *bat_priv, 27void batadv_receive_server_sync_packet(struct bat_priv *bat_priv,