aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-06-21 16:34:09 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-21 16:34:09 -0400
commit3e428fe0382fca48795b5cf9d4f03a89cda5d84d (patch)
tree1ac10a34f71c3141c767a1bba56646c54fb78739 /net
parent1c11a0a100377159b53e08e2644185a51da2a47e (diff)
parent9cfc7bd608b97463993b4f3e4775d99022253f8d (diff)
Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge
Included changes: - first set of patches that add the batadv_ prefix to all the exported symbols - restyling of comments
Diffstat (limited to 'net')
-rw-r--r--net/batman-adv/bat_algo.h6
-rw-r--r--net/batman-adv/bat_debugfs.c35
-rw-r--r--net/batman-adv/bat_debugfs.h13
-rw-r--r--net/batman-adv/bat_iv_ogm.c205
-rw-r--r--net/batman-adv/bat_sysfs.c53
-rw-r--r--net/batman-adv/bat_sysfs.h18
-rw-r--r--net/batman-adv/bitarray.c25
-rw-r--r--net/batman-adv/bitarray.h14
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c113
-rw-r--r--net/batman-adv/bridge_loop_avoidance.h71
-rw-r--r--net/batman-adv/gateway_client.c134
-rw-r--r--net/batman-adv/gateway_client.h30
-rw-r--r--net/batman-adv/gateway_common.c18
-rw-r--r--net/batman-adv/gateway_common.h9
-rw-r--r--net/batman-adv/hard-interface.c93
-rw-r--r--net/batman-adv/hard-interface.h26
-rw-r--r--net/batman-adv/hash.c8
-rw-r--r--net/batman-adv/hash.h30
-rw-r--r--net/batman-adv/icmp_socket.c27
-rw-r--r--net/batman-adv/icmp_socket.h12
-rw-r--r--net/batman-adv/main.c117
-rw-r--r--net/batman-adv/main.h84
-rw-r--r--net/batman-adv/originator.c76
-rw-r--r--net/batman-adv/originator.h30
-rw-r--r--net/batman-adv/packet.h21
-rw-r--r--net/batman-adv/ring_buffer.c9
-rw-r--r--net/batman-adv/ring_buffer.h9
-rw-r--r--net/batman-adv/routing.c282
-rw-r--r--net/batman-adv/routing.h56
-rw-r--r--net/batman-adv/send.c60
-rw-r--r--net/batman-adv/send.h21
-rw-r--r--net/batman-adv/soft-interface.c87
-rw-r--r--net/batman-adv/soft-interface.h17
-rw-r--r--net/batman-adv/translation-table.c222
-rw-r--r--net/batman-adv/translation-table.h67
-rw-r--r--net/batman-adv/types.h29
-rw-r--r--net/batman-adv/unicast.c59
-rw-r--r--net/batman-adv/unicast.h17
-rw-r--r--net/batman-adv/vis.c96
-rw-r--r--net/batman-adv/vis.h26
40 files changed, 1171 insertions, 1154 deletions
diff --git a/net/batman-adv/bat_algo.h b/net/batman-adv/bat_algo.h
index 9852a688ba43..a0ba3bff9b36 100644
--- a/net/batman-adv/bat_algo.h
+++ b/net/batman-adv/bat_algo.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner 3 * Marek Lindner
5 * 4 *
@@ -16,12 +15,11 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_BAT_ALGO_H_ 20#ifndef _NET_BATMAN_ADV_BAT_ALGO_H_
23#define _NET_BATMAN_ADV_BAT_ALGO_H_ 21#define _NET_BATMAN_ADV_BAT_ALGO_H_
24 22
25int bat_iv_init(void); 23int batadv_iv_init(void);
26 24
27#endif /* _NET_BATMAN_ADV_BAT_ALGO_H_ */ 25#endif /* _NET_BATMAN_ADV_BAT_ALGO_H_ */
diff --git a/net/batman-adv/bat_debugfs.c b/net/batman-adv/bat_debugfs.c
index db8273c26989..4001c57a25e4 100644
--- a/net/batman-adv/bat_debugfs.c
+++ b/net/batman-adv/bat_debugfs.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner 3 * Marek Lindner
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -76,7 +74,7 @@ static int fdebug_log(struct debug_log *debug_log, const char *fmt, ...)
76 return 0; 74 return 0;
77} 75}
78 76
79int debug_log(struct bat_priv *bat_priv, const char *fmt, ...) 77int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...)
80{ 78{
81 va_list args; 79 va_list args;
82 char tmp_log_buf[256]; 80 char tmp_log_buf[256];
@@ -94,13 +92,13 @@ static int log_open(struct inode *inode, struct file *file)
94{ 92{
95 nonseekable_open(inode, file); 93 nonseekable_open(inode, file);
96 file->private_data = inode->i_private; 94 file->private_data = inode->i_private;
97 inc_module_count(); 95 batadv_inc_module_count();
98 return 0; 96 return 0;
99} 97}
100 98
101static int log_release(struct inode *inode, struct file *file) 99static int log_release(struct inode *inode, struct file *file)
102{ 100{
103 dec_module_count(); 101 batadv_dec_module_count();
104 return 0; 102 return 0;
105} 103}
106 104
@@ -224,45 +222,46 @@ static void debug_log_cleanup(struct bat_priv *bat_priv)
224 222
225static int bat_algorithms_open(struct inode *inode, struct file *file) 223static int bat_algorithms_open(struct inode *inode, struct file *file)
226{ 224{
227 return single_open(file, bat_algo_seq_print_text, NULL); 225 return single_open(file, batadv_algo_seq_print_text, NULL);
228} 226}
229 227
230static int originators_open(struct inode *inode, struct file *file) 228static int originators_open(struct inode *inode, struct file *file)
231{ 229{
232 struct net_device *net_dev = (struct net_device *)inode->i_private; 230 struct net_device *net_dev = (struct net_device *)inode->i_private;
233 return single_open(file, orig_seq_print_text, net_dev); 231 return single_open(file, batadv_orig_seq_print_text, net_dev);
234} 232}
235 233
236static int gateways_open(struct inode *inode, struct file *file) 234static int gateways_open(struct inode *inode, struct file *file)
237{ 235{
238 struct net_device *net_dev = (struct net_device *)inode->i_private; 236 struct net_device *net_dev = (struct net_device *)inode->i_private;
239 return single_open(file, gw_client_seq_print_text, net_dev); 237 return single_open(file, batadv_gw_client_seq_print_text, net_dev);
240} 238}
241 239
242static int transtable_global_open(struct inode *inode, struct file *file) 240static int transtable_global_open(struct inode *inode, struct file *file)
243{ 241{
244 struct net_device *net_dev = (struct net_device *)inode->i_private; 242 struct net_device *net_dev = (struct net_device *)inode->i_private;
245 return single_open(file, tt_global_seq_print_text, net_dev); 243 return single_open(file, batadv_tt_global_seq_print_text, net_dev);
246} 244}
247 245
248#ifdef CONFIG_BATMAN_ADV_BLA 246#ifdef CONFIG_BATMAN_ADV_BLA
249static int bla_claim_table_open(struct inode *inode, struct file *file) 247static int bla_claim_table_open(struct inode *inode, struct file *file)
250{ 248{
251 struct net_device *net_dev = (struct net_device *)inode->i_private; 249 struct net_device *net_dev = (struct net_device *)inode->i_private;
252 return single_open(file, bla_claim_table_seq_print_text, net_dev); 250 return single_open(file, batadv_bla_claim_table_seq_print_text,
251 net_dev);
253} 252}
254#endif 253#endif
255 254
256static int transtable_local_open(struct inode *inode, struct file *file) 255static int transtable_local_open(struct inode *inode, struct file *file)
257{ 256{
258 struct net_device *net_dev = (struct net_device *)inode->i_private; 257 struct net_device *net_dev = (struct net_device *)inode->i_private;
259 return single_open(file, tt_local_seq_print_text, net_dev); 258 return single_open(file, batadv_tt_local_seq_print_text, net_dev);
260} 259}
261 260
262static int vis_data_open(struct inode *inode, struct file *file) 261static int vis_data_open(struct inode *inode, struct file *file)
263{ 262{
264 struct net_device *net_dev = (struct net_device *)inode->i_private; 263 struct net_device *net_dev = (struct net_device *)inode->i_private;
265 return single_open(file, vis_seq_print_text, net_dev); 264 return single_open(file, batadv_vis_seq_print_text, net_dev);
266} 265}
267 266
268struct bat_debuginfo { 267struct bat_debuginfo {
@@ -304,7 +303,7 @@ static struct bat_debuginfo *mesh_debuginfos[] = {
304 NULL, 303 NULL,
305}; 304};
306 305
307void debugfs_init(void) 306void batadv_debugfs_init(void)
308{ 307{
309 struct bat_debuginfo *bat_debug; 308 struct bat_debuginfo *bat_debug;
310 struct dentry *file; 309 struct dentry *file;
@@ -327,7 +326,7 @@ out:
327 return; 326 return;
328} 327}
329 328
330void debugfs_destroy(void) 329void batadv_debugfs_destroy(void)
331{ 330{
332 if (bat_debugfs) { 331 if (bat_debugfs) {
333 debugfs_remove_recursive(bat_debugfs); 332 debugfs_remove_recursive(bat_debugfs);
@@ -335,7 +334,7 @@ void debugfs_destroy(void)
335 } 334 }
336} 335}
337 336
338int debugfs_add_meshif(struct net_device *dev) 337int batadv_debugfs_add_meshif(struct net_device *dev)
339{ 338{
340 struct bat_priv *bat_priv = netdev_priv(dev); 339 struct bat_priv *bat_priv = netdev_priv(dev);
341 struct bat_debuginfo **bat_debug; 340 struct bat_debuginfo **bat_debug;
@@ -348,7 +347,7 @@ int debugfs_add_meshif(struct net_device *dev)
348 if (!bat_priv->debug_dir) 347 if (!bat_priv->debug_dir)
349 goto out; 348 goto out;
350 349
351 if (bat_socket_setup(bat_priv) < 0) 350 if (batadv_socket_setup(bat_priv) < 0)
352 goto rem_attr; 351 goto rem_attr;
353 352
354 if (debug_log_setup(bat_priv) < 0) 353 if (debug_log_setup(bat_priv) < 0)
@@ -378,7 +377,7 @@ out:
378#endif /* CONFIG_DEBUG_FS */ 377#endif /* CONFIG_DEBUG_FS */
379} 378}
380 379
381void debugfs_del_meshif(struct net_device *dev) 380void batadv_debugfs_del_meshif(struct net_device *dev)
382{ 381{
383 struct bat_priv *bat_priv = netdev_priv(dev); 382 struct bat_priv *bat_priv = netdev_priv(dev);
384 383
diff --git a/net/batman-adv/bat_debugfs.h b/net/batman-adv/bat_debugfs.h
index d605c6746428..eb0d576b4f9d 100644
--- a/net/batman-adv/bat_debugfs.h
+++ b/net/batman-adv/bat_debugfs.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner 3 * Marek Lindner
5 * 4 *
@@ -16,18 +15,16 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22
23#ifndef _NET_BATMAN_ADV_DEBUGFS_H_ 20#ifndef _NET_BATMAN_ADV_DEBUGFS_H_
24#define _NET_BATMAN_ADV_DEBUGFS_H_ 21#define _NET_BATMAN_ADV_DEBUGFS_H_
25 22
26#define DEBUGFS_BAT_SUBDIR "batman_adv" 23#define DEBUGFS_BAT_SUBDIR "batman_adv"
27 24
28void debugfs_init(void); 25void batadv_debugfs_init(void);
29void debugfs_destroy(void); 26void batadv_debugfs_destroy(void);
30int debugfs_add_meshif(struct net_device *dev); 27int batadv_debugfs_add_meshif(struct net_device *dev);
31void debugfs_del_meshif(struct net_device *dev); 28void batadv_debugfs_del_meshif(struct net_device *dev);
32 29
33#endif /* _NET_BATMAN_ADV_DEBUGFS_H_ */ 30#endif /* _NET_BATMAN_ADV_DEBUGFS_H_ */
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 6e0859f4a6a9..94859d45ed6e 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -138,7 +136,10 @@ static uint8_t hop_penalty(uint8_t tq, const struct bat_priv *bat_priv)
138static int bat_iv_ogm_aggr_packet(int buff_pos, int packet_len, 136static int bat_iv_ogm_aggr_packet(int buff_pos, int packet_len,
139 int tt_num_changes) 137 int tt_num_changes)
140{ 138{
141 int next_buff_pos = buff_pos + BATMAN_OGM_HLEN + tt_len(tt_num_changes); 139 int next_buff_pos = 0;
140
141 next_buff_pos += buff_pos + BATMAN_OGM_HLEN;
142 next_buff_pos += batadv_tt_len(tt_num_changes);
142 143
143 return (next_buff_pos <= packet_len) && 144 return (next_buff_pos <= packet_len) &&
144 (next_buff_pos <= MAX_AGGREGATION_BYTES); 145 (next_buff_pos <= MAX_AGGREGATION_BYTES);
@@ -167,7 +168,8 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
167 batman_ogm_packet->tt_num_changes)) { 168 batman_ogm_packet->tt_num_changes)) {
168 169
169 /* we might have aggregated direct link packets with an 170 /* we might have aggregated direct link packets with an
170 * ordinary base packet */ 171 * ordinary base packet
172 */
171 if ((forw_packet->direct_link_flags & (1 << packet_num)) && 173 if ((forw_packet->direct_link_flags & (1 << packet_num)) &&
172 (forw_packet->if_incoming == hard_iface)) 174 (forw_packet->if_incoming == hard_iface))
173 batman_ogm_packet->flags |= DIRECTLINK; 175 batman_ogm_packet->flags |= DIRECTLINK;
@@ -188,8 +190,8 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
188 batman_ogm_packet->ttvn, hard_iface->net_dev->name, 190 batman_ogm_packet->ttvn, hard_iface->net_dev->name,
189 hard_iface->net_dev->dev_addr); 191 hard_iface->net_dev->dev_addr);
190 192
191 buff_pos += BATMAN_OGM_HLEN + 193 buff_pos += BATMAN_OGM_HLEN;
192 tt_len(batman_ogm_packet->tt_num_changes); 194 buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes);
193 packet_num++; 195 packet_num++;
194 batman_ogm_packet = (struct batman_ogm_packet *) 196 batman_ogm_packet = (struct batman_ogm_packet *)
195 (forw_packet->skb->data + buff_pos); 197 (forw_packet->skb->data + buff_pos);
@@ -201,7 +203,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
201 batadv_inc_counter(bat_priv, BAT_CNT_MGMT_TX); 203 batadv_inc_counter(bat_priv, BAT_CNT_MGMT_TX);
202 batadv_add_counter(bat_priv, BAT_CNT_MGMT_TX_BYTES, 204 batadv_add_counter(bat_priv, BAT_CNT_MGMT_TX_BYTES,
203 skb->len + ETH_HLEN); 205 skb->len + ETH_HLEN);
204 send_skb_packet(skb, hard_iface, broadcast_addr); 206 batadv_send_skb_packet(skb, hard_iface, batadv_broadcast_addr);
205 } 207 }
206} 208}
207 209
@@ -234,8 +236,9 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
234 if (!primary_if) 236 if (!primary_if)
235 goto out; 237 goto out;
236 238
237 /* multihomed peer assumed */ 239 /* multihomed peer assumed
238 /* non-primary OGMs are only broadcasted on their interface */ 240 * non-primary OGMs are only broadcasted on their interface
241 */
239 if ((directlink && (batman_ogm_packet->header.ttl == 1)) || 242 if ((directlink && (batman_ogm_packet->header.ttl == 1)) ||
240 (forw_packet->own && (forw_packet->if_incoming != primary_if))) { 243 (forw_packet->own && (forw_packet->if_incoming != primary_if))) {
241 244
@@ -250,8 +253,9 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
250 forw_packet->if_incoming->net_dev->dev_addr); 253 forw_packet->if_incoming->net_dev->dev_addr);
251 254
252 /* skb is only used once and than forw_packet is free'd */ 255 /* skb is only used once and than forw_packet is free'd */
253 send_skb_packet(forw_packet->skb, forw_packet->if_incoming, 256 batadv_send_skb_packet(forw_packet->skb,
254 broadcast_addr); 257 forw_packet->if_incoming,
258 batadv_broadcast_addr);
255 forw_packet->skb = NULL; 259 forw_packet->skb = NULL;
256 260
257 goto out; 261 goto out;
@@ -259,7 +263,7 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
259 263
260 /* broadcast on every interface */ 264 /* broadcast on every interface */
261 rcu_read_lock(); 265 rcu_read_lock();
262 list_for_each_entry_rcu(hard_iface, &hardif_list, list) { 266 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
263 if (hard_iface->soft_iface != soft_iface) 267 if (hard_iface->soft_iface != soft_iface)
264 continue; 268 continue;
265 269
@@ -288,41 +292,39 @@ static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet
288 292
289 batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data; 293 batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data;
290 294
291 /** 295 /* we can aggregate the current packet to this aggregated packet
292 * we can aggregate the current packet to this aggregated packet
293 * if: 296 * if:
294 * 297 *
295 * - the send time is within our MAX_AGGREGATION_MS time 298 * - the send time is within our MAX_AGGREGATION_MS time
296 * - the resulting packet wont be bigger than 299 * - the resulting packet wont be bigger than
297 * MAX_AGGREGATION_BYTES 300 * MAX_AGGREGATION_BYTES
298 */ 301 */
299
300 if (time_before(send_time, forw_packet->send_time) && 302 if (time_before(send_time, forw_packet->send_time) &&
301 time_after_eq(send_time + msecs_to_jiffies(MAX_AGGREGATION_MS), 303 time_after_eq(send_time + msecs_to_jiffies(MAX_AGGREGATION_MS),
302 forw_packet->send_time) && 304 forw_packet->send_time) &&
303 (aggregated_bytes <= MAX_AGGREGATION_BYTES)) { 305 (aggregated_bytes <= MAX_AGGREGATION_BYTES)) {
304 306
305 /** 307 /* check aggregation compatibility
306 * check aggregation compatibility
307 * -> direct link packets are broadcasted on 308 * -> direct link packets are broadcasted on
308 * their interface only 309 * their interface only
309 * -> aggregate packet if the current packet is 310 * -> aggregate packet if the current packet is
310 * a "global" packet as well as the base 311 * a "global" packet as well as the base
311 * packet 312 * packet
312 */ 313 */
313
314 primary_if = primary_if_get_selected(bat_priv); 314 primary_if = primary_if_get_selected(bat_priv);
315 if (!primary_if) 315 if (!primary_if)
316 goto out; 316 goto out;
317 317
318 /* packets without direct link flag and high TTL 318 /* packets without direct link flag and high TTL
319 * are flooded through the net */ 319 * are flooded through the net
320 */
320 if ((!directlink) && 321 if ((!directlink) &&
321 (!(batman_ogm_packet->flags & DIRECTLINK)) && 322 (!(batman_ogm_packet->flags & DIRECTLINK)) &&
322 (batman_ogm_packet->header.ttl != 1) && 323 (batman_ogm_packet->header.ttl != 1) &&
323 324
324 /* own packets originating non-primary 325 /* own packets originating non-primary
325 * interfaces leave only that interface */ 326 * interfaces leave only that interface
327 */
326 ((!forw_packet->own) || 328 ((!forw_packet->own) ||
327 (forw_packet->if_incoming == primary_if))) { 329 (forw_packet->if_incoming == primary_if))) {
328 res = true; 330 res = true;
@@ -330,14 +332,16 @@ static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet
330 } 332 }
331 333
332 /* if the incoming packet is sent via this one 334 /* if the incoming packet is sent via this one
333 * interface only - we still can aggregate */ 335 * interface only - we still can aggregate
336 */
334 if ((directlink) && 337 if ((directlink) &&
335 (new_batman_ogm_packet->header.ttl == 1) && 338 (new_batman_ogm_packet->header.ttl == 1) &&
336 (forw_packet->if_incoming == if_incoming) && 339 (forw_packet->if_incoming == if_incoming) &&
337 340
338 /* packets from direct neighbors or 341 /* packets from direct neighbors or
339 * own secondary interface packets 342 * own secondary interface packets
340 * (= secondary interface packets in general) */ 343 * (= secondary interface packets in general)
344 */
341 (batman_ogm_packet->flags & DIRECTLINK || 345 (batman_ogm_packet->flags & DIRECTLINK ||
342 (forw_packet->own && 346 (forw_packet->own &&
343 forw_packet->if_incoming != primary_if))) { 347 forw_packet->if_incoming != primary_if))) {
@@ -420,8 +424,8 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
420 424
421 /* start timer for this packet */ 425 /* start timer for this packet */
422 INIT_DELAYED_WORK(&forw_packet_aggr->delayed_work, 426 INIT_DELAYED_WORK(&forw_packet_aggr->delayed_work,
423 send_outstanding_bat_ogm_packet); 427 batadv_send_outstanding_bat_ogm_packet);
424 queue_delayed_work(bat_event_workqueue, 428 queue_delayed_work(batadv_event_workqueue,
425 &forw_packet_aggr->delayed_work, 429 &forw_packet_aggr->delayed_work,
426 send_time - jiffies); 430 send_time - jiffies);
427 431
@@ -453,8 +457,7 @@ static void bat_iv_ogm_queue_add(struct bat_priv *bat_priv,
453 int packet_len, struct hard_iface *if_incoming, 457 int packet_len, struct hard_iface *if_incoming,
454 int own_packet, unsigned long send_time) 458 int own_packet, unsigned long send_time)
455{ 459{
456 /** 460 /* _aggr -> pointer to the packet we want to aggregate with
457 * _aggr -> pointer to the packet we want to aggregate with
458 * _pos -> pointer to the position in the queue 461 * _pos -> pointer to the position in the queue
459 */ 462 */
460 struct forw_packet *forw_packet_aggr = NULL, *forw_packet_pos = NULL; 463 struct forw_packet *forw_packet_aggr = NULL, *forw_packet_pos = NULL;
@@ -483,13 +486,13 @@ static void bat_iv_ogm_queue_add(struct bat_priv *bat_priv,
483 } 486 }
484 487
485 /* nothing to aggregate with - either aggregation disabled or no 488 /* nothing to aggregate with - either aggregation disabled or no
486 * suitable aggregation packet found */ 489 * suitable aggregation packet found
490 */
487 if (!forw_packet_aggr) { 491 if (!forw_packet_aggr) {
488 /* the following section can run without the lock */ 492 /* the following section can run without the lock */
489 spin_unlock_bh(&bat_priv->forw_bat_list_lock); 493 spin_unlock_bh(&bat_priv->forw_bat_list_lock);
490 494
491 /** 495 /* if we could not aggregate this packet with one of the others
492 * if we could not aggregate this packet with one of the others
493 * we hold it back for a while, so that it might be aggregated 496 * we hold it back for a while, so that it might be aggregated
494 * later on 497 * later on
495 */ 498 */
@@ -555,7 +558,7 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node,
555 batman_ogm_packet->flags &= ~DIRECTLINK; 558 batman_ogm_packet->flags &= ~DIRECTLINK;
556 559
557 bat_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet, 560 bat_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet,
558 BATMAN_OGM_HLEN + tt_len(tt_num_changes), 561 BATMAN_OGM_HLEN + batadv_tt_len(tt_num_changes),
559 if_incoming, 0, bat_iv_ogm_fwd_send_time()); 562 if_incoming, 0, bat_iv_ogm_fwd_send_time());
560} 563}
561 564
@@ -599,7 +602,7 @@ static void bat_iv_ogm_schedule(struct hard_iface *hard_iface)
599 else 602 else
600 batman_ogm_packet->gw_flags = NO_FLAGS; 603 batman_ogm_packet->gw_flags = NO_FLAGS;
601 604
602 slide_own_bcast_window(hard_iface); 605 batadv_slide_own_bcast_window(hard_iface);
603 bat_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff, 606 bat_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff,
604 hard_iface->packet_len, hard_iface, 1, 607 hard_iface->packet_len, hard_iface, 1,
605 bat_iv_ogm_emit_send_time(bat_priv)); 608 bat_iv_ogm_emit_send_time(bat_priv));
@@ -633,7 +636,7 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
633 (tmp_neigh_node->if_incoming == if_incoming) && 636 (tmp_neigh_node->if_incoming == if_incoming) &&
634 atomic_inc_not_zero(&tmp_neigh_node->refcount)) { 637 atomic_inc_not_zero(&tmp_neigh_node->refcount)) {
635 if (neigh_node) 638 if (neigh_node)
636 neigh_node_free_ref(neigh_node); 639 batadv_neigh_node_free_ref(neigh_node);
637 neigh_node = tmp_neigh_node; 640 neigh_node = tmp_neigh_node;
638 continue; 641 continue;
639 } 642 }
@@ -642,17 +645,17 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
642 continue; 645 continue;
643 646
644 spin_lock_bh(&tmp_neigh_node->lq_update_lock); 647 spin_lock_bh(&tmp_neigh_node->lq_update_lock);
645 ring_buffer_set(tmp_neigh_node->tq_recv, 648 batadv_ring_buffer_set(tmp_neigh_node->tq_recv,
646 &tmp_neigh_node->tq_index, 0); 649 &tmp_neigh_node->tq_index, 0);
647 tmp_neigh_node->tq_avg = 650 tmp_neigh_node->tq_avg =
648 ring_buffer_avg(tmp_neigh_node->tq_recv); 651 batadv_ring_buffer_avg(tmp_neigh_node->tq_recv);
649 spin_unlock_bh(&tmp_neigh_node->lq_update_lock); 652 spin_unlock_bh(&tmp_neigh_node->lq_update_lock);
650 } 653 }
651 654
652 if (!neigh_node) { 655 if (!neigh_node) {
653 struct orig_node *orig_tmp; 656 struct orig_node *orig_tmp;
654 657
655 orig_tmp = get_orig_node(bat_priv, ethhdr->h_source); 658 orig_tmp = batadv_get_orig_node(bat_priv, ethhdr->h_source);
656 if (!orig_tmp) 659 if (!orig_tmp)
657 goto unlock; 660 goto unlock;
658 661
@@ -660,7 +663,7 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
660 orig_node, orig_tmp, 663 orig_node, orig_tmp,
661 batman_ogm_packet->seqno); 664 batman_ogm_packet->seqno);
662 665
663 orig_node_free_ref(orig_tmp); 666 batadv_orig_node_free_ref(orig_tmp);
664 if (!neigh_node) 667 if (!neigh_node)
665 goto unlock; 668 goto unlock;
666 } else 669 } else
@@ -673,10 +676,10 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
673 neigh_node->last_seen = jiffies; 676 neigh_node->last_seen = jiffies;
674 677
675 spin_lock_bh(&neigh_node->lq_update_lock); 678 spin_lock_bh(&neigh_node->lq_update_lock);
676 ring_buffer_set(neigh_node->tq_recv, 679 batadv_ring_buffer_set(neigh_node->tq_recv,
677 &neigh_node->tq_index, 680 &neigh_node->tq_index,
678 batman_ogm_packet->tq); 681 batman_ogm_packet->tq);
679 neigh_node->tq_avg = ring_buffer_avg(neigh_node->tq_recv); 682 neigh_node->tq_avg = batadv_ring_buffer_avg(neigh_node->tq_recv);
680 spin_unlock_bh(&neigh_node->lq_update_lock); 683 spin_unlock_bh(&neigh_node->lq_update_lock);
681 684
682 if (!is_duplicate) { 685 if (!is_duplicate) {
@@ -684,11 +687,12 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
684 neigh_node->last_ttl = batman_ogm_packet->header.ttl; 687 neigh_node->last_ttl = batman_ogm_packet->header.ttl;
685 } 688 }
686 689
687 bonding_candidate_add(orig_node, neigh_node); 690 batadv_bonding_candidate_add(orig_node, neigh_node);
688 691
689 /* if this neighbor already is our next hop there is nothing 692 /* if this neighbor already is our next hop there is nothing
690 * to change */ 693 * to change
691 router = orig_node_get_router(orig_node); 694 */
695 router = batadv_orig_node_get_router(orig_node);
692 if (router == neigh_node) 696 if (router == neigh_node)
693 goto update_tt; 697 goto update_tt;
694 698
@@ -697,7 +701,8 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
697 goto update_tt; 701 goto update_tt;
698 702
699 /* if the TQ is the same and the link not more symmetric we 703 /* if the TQ is the same and the link not more symmetric we
700 * won't consider it either */ 704 * won't consider it either
705 */
701 if (router && (neigh_node->tq_avg == router->tq_avg)) { 706 if (router && (neigh_node->tq_avg == router->tq_avg)) {
702 orig_node_tmp = router->orig_node; 707 orig_node_tmp = router->orig_node;
703 spin_lock_bh(&orig_node_tmp->ogm_cnt_lock); 708 spin_lock_bh(&orig_node_tmp->ogm_cnt_lock);
@@ -715,22 +720,23 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
715 goto update_tt; 720 goto update_tt;
716 } 721 }
717 722
718 update_route(bat_priv, orig_node, neigh_node); 723 batadv_update_route(bat_priv, orig_node, neigh_node);
719 724
720update_tt: 725update_tt:
721 /* I have to check for transtable changes only if the OGM has been 726 /* I have to check for transtable changes only if the OGM has been
722 * sent through a primary interface */ 727 * sent through a primary interface
728 */
723 if (((batman_ogm_packet->orig != ethhdr->h_source) && 729 if (((batman_ogm_packet->orig != ethhdr->h_source) &&
724 (batman_ogm_packet->header.ttl > 2)) || 730 (batman_ogm_packet->header.ttl > 2)) ||
725 (batman_ogm_packet->flags & PRIMARIES_FIRST_HOP)) 731 (batman_ogm_packet->flags & PRIMARIES_FIRST_HOP))
726 tt_update_orig(bat_priv, orig_node, tt_buff, 732 batadv_tt_update_orig(bat_priv, orig_node, tt_buff,
727 batman_ogm_packet->tt_num_changes, 733 batman_ogm_packet->tt_num_changes,
728 batman_ogm_packet->ttvn, 734 batman_ogm_packet->ttvn,
729 ntohs(batman_ogm_packet->tt_crc)); 735 ntohs(batman_ogm_packet->tt_crc));
730 736
731 if (orig_node->gw_flags != batman_ogm_packet->gw_flags) 737 if (orig_node->gw_flags != batman_ogm_packet->gw_flags)
732 gw_node_update(bat_priv, orig_node, 738 batadv_gw_node_update(bat_priv, orig_node,
733 batman_ogm_packet->gw_flags); 739 batman_ogm_packet->gw_flags);
734 740
735 orig_node->gw_flags = batman_ogm_packet->gw_flags; 741 orig_node->gw_flags = batman_ogm_packet->gw_flags;
736 742
@@ -738,7 +744,7 @@ update_tt:
738 if ((orig_node->gw_flags) && 744 if ((orig_node->gw_flags) &&
739 (atomic_read(&bat_priv->gw_mode) == GW_MODE_CLIENT) && 745 (atomic_read(&bat_priv->gw_mode) == GW_MODE_CLIENT) &&
740 (atomic_read(&bat_priv->gw_sel_class) > 2)) 746 (atomic_read(&bat_priv->gw_sel_class) > 2))
741 gw_check_election(bat_priv, orig_node); 747 batadv_gw_check_election(bat_priv, orig_node);
742 748
743 goto out; 749 goto out;
744 750
@@ -746,9 +752,9 @@ unlock:
746 rcu_read_unlock(); 752 rcu_read_unlock();
747out: 753out:
748 if (neigh_node) 754 if (neigh_node)
749 neigh_node_free_ref(neigh_node); 755 batadv_neigh_node_free_ref(neigh_node);
750 if (router) 756 if (router)
751 neigh_node_free_ref(router); 757 batadv_neigh_node_free_ref(router);
752} 758}
753 759
754static int bat_iv_ogm_calc_tq(struct orig_node *orig_node, 760static int bat_iv_ogm_calc_tq(struct orig_node *orig_node,
@@ -808,15 +814,17 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node,
808 total_count = (orig_eq_count > neigh_rq_count ? 814 total_count = (orig_eq_count > neigh_rq_count ?
809 neigh_rq_count : orig_eq_count); 815 neigh_rq_count : orig_eq_count);
810 816
811 /* if we have too few packets (too less data) we set tq_own to zero */ 817 /* if we have too few packets (too less data) we set tq_own to zero
812 /* if we receive too few packets it is not considered bidirectional */ 818 * if we receive too few packets it is not considered bidirectional
819 */
813 if ((total_count < TQ_LOCAL_BIDRECT_SEND_MINIMUM) || 820 if ((total_count < TQ_LOCAL_BIDRECT_SEND_MINIMUM) ||
814 (neigh_rq_count < TQ_LOCAL_BIDRECT_RECV_MINIMUM)) 821 (neigh_rq_count < TQ_LOCAL_BIDRECT_RECV_MINIMUM))
815 tq_own = 0; 822 tq_own = 0;
816 else 823 else
817 /* neigh_node->real_packet_count is never zero as we 824 /* neigh_node->real_packet_count is never zero as we
818 * only purge old information when getting new 825 * only purge old information when getting new
819 * information */ 826 * information
827 */
820 tq_own = (TQ_MAX_VALUE * total_count) / neigh_rq_count; 828 tq_own = (TQ_MAX_VALUE * total_count) / neigh_rq_count;
821 829
822 /* 1 - ((1-x) ** 3), normalized to TQ_MAX_VALUE this does 830 /* 1 - ((1-x) ** 3), normalized to TQ_MAX_VALUE this does
@@ -842,13 +850,14 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node,
842 neigh_rq_count, tq_own, tq_asym_penalty, batman_ogm_packet->tq); 850 neigh_rq_count, tq_own, tq_asym_penalty, batman_ogm_packet->tq);
843 851
844 /* if link has the minimum required transmission quality 852 /* if link has the minimum required transmission quality
845 * consider it bidirectional */ 853 * consider it bidirectional
854 */
846 if (batman_ogm_packet->tq >= TQ_TOTAL_BIDRECT_LIMIT) 855 if (batman_ogm_packet->tq >= TQ_TOTAL_BIDRECT_LIMIT)
847 ret = 1; 856 ret = 1;
848 857
849out: 858out:
850 if (neigh_node) 859 if (neigh_node)
851 neigh_node_free_ref(neigh_node); 860 batadv_neigh_node_free_ref(neigh_node);
852 return ret; 861 return ret;
853} 862}
854 863
@@ -875,7 +884,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
875 int set_mark, ret = -1; 884 int set_mark, ret = -1;
876 uint32_t seqno = ntohl(batman_ogm_packet->seqno); 885 uint32_t seqno = ntohl(batman_ogm_packet->seqno);
877 886
878 orig_node = get_orig_node(bat_priv, batman_ogm_packet->orig); 887 orig_node = batadv_get_orig_node(bat_priv, batman_ogm_packet->orig);
879 if (!orig_node) 888 if (!orig_node)
880 return 0; 889 return 0;
881 890
@@ -884,8 +893,8 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
884 893
885 /* signalize caller that the packet is to be dropped. */ 894 /* signalize caller that the packet is to be dropped. */
886 if (!hlist_empty(&orig_node->neigh_list) && 895 if (!hlist_empty(&orig_node->neigh_list) &&
887 window_protected(bat_priv, seq_diff, 896 batadv_window_protected(bat_priv, seq_diff,
888 &orig_node->batman_seqno_reset)) 897 &orig_node->batman_seqno_reset))
889 goto out; 898 goto out;
890 899
891 rcu_read_lock(); 900 rcu_read_lock();
@@ -903,9 +912,9 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
903 set_mark = 0; 912 set_mark = 0;
904 913
905 /* if the window moved, set the update flag. */ 914 /* if the window moved, set the update flag. */
906 need_update |= bit_get_packet(bat_priv, 915 need_update |= batadv_bit_get_packet(bat_priv,
907 tmp_neigh_node->real_bits, 916 tmp_neigh_node->real_bits,
908 seq_diff, set_mark); 917 seq_diff, set_mark);
909 918
910 tmp_neigh_node->real_packet_count = 919 tmp_neigh_node->real_packet_count =
911 bitmap_weight(tmp_neigh_node->real_bits, 920 bitmap_weight(tmp_neigh_node->real_bits,
@@ -924,7 +933,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
924 933
925out: 934out:
926 spin_unlock_bh(&orig_node->ogm_cnt_lock); 935 spin_unlock_bh(&orig_node->ogm_cnt_lock);
927 orig_node_free_ref(orig_node); 936 batadv_orig_node_free_ref(orig_node);
928 return ret; 937 return ret;
929} 938}
930 939
@@ -980,7 +989,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
980 batman_ogm_packet->header.version, has_directlink_flag); 989 batman_ogm_packet->header.version, has_directlink_flag);
981 990
982 rcu_read_lock(); 991 rcu_read_lock();
983 list_for_each_entry_rcu(hard_iface, &hardif_list, list) { 992 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
984 if (hard_iface->if_status != IF_ACTIVE) 993 if (hard_iface->if_status != IF_ACTIVE)
985 continue; 994 continue;
986 995
@@ -1029,13 +1038,15 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1029 unsigned long *word; 1038 unsigned long *word;
1030 int offset; 1039 int offset;
1031 1040
1032 orig_neigh_node = get_orig_node(bat_priv, ethhdr->h_source); 1041 orig_neigh_node = batadv_get_orig_node(bat_priv,
1042 ethhdr->h_source);
1033 if (!orig_neigh_node) 1043 if (!orig_neigh_node)
1034 return; 1044 return;
1035 1045
1036 /* neighbor has to indicate direct link and it has to 1046 /* neighbor has to indicate direct link and it has to
1037 * come via the corresponding interface */ 1047 * come via the corresponding interface
1038 /* save packet seqno for bidirectional check */ 1048 * save packet seqno for bidirectional check
1049 */
1039 if (has_directlink_flag && 1050 if (has_directlink_flag &&
1040 compare_eth(if_incoming->net_dev->dev_addr, 1051 compare_eth(if_incoming->net_dev->dev_addr,
1041 batman_ogm_packet->orig)) { 1052 batman_ogm_packet->orig)) {
@@ -1053,7 +1064,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1053 1064
1054 bat_dbg(DBG_BATMAN, bat_priv, 1065 bat_dbg(DBG_BATMAN, bat_priv,
1055 "Drop packet: originator packet from myself (via neighbor)\n"); 1066 "Drop packet: originator packet from myself (via neighbor)\n");
1056 orig_node_free_ref(orig_neigh_node); 1067 batadv_orig_node_free_ref(orig_neigh_node);
1057 return; 1068 return;
1058 } 1069 }
1059 1070
@@ -1071,7 +1082,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1071 return; 1082 return;
1072 } 1083 }
1073 1084
1074 orig_node = get_orig_node(bat_priv, batman_ogm_packet->orig); 1085 orig_node = batadv_get_orig_node(bat_priv, batman_ogm_packet->orig);
1075 if (!orig_node) 1086 if (!orig_node)
1076 return; 1087 return;
1077 1088
@@ -1091,9 +1102,9 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1091 goto out; 1102 goto out;
1092 } 1103 }
1093 1104
1094 router = orig_node_get_router(orig_node); 1105 router = batadv_orig_node_get_router(orig_node);
1095 if (router) 1106 if (router)
1096 router_router = orig_node_get_router(router->orig_node); 1107 router_router = batadv_orig_node_get_router(router->orig_node);
1097 1108
1098 if ((router && router->tq_avg != 0) && 1109 if ((router && router->tq_avg != 0) &&
1099 (compare_eth(router->addr, ethhdr->h_source))) 1110 (compare_eth(router->addr, ethhdr->h_source)))
@@ -1112,17 +1123,19 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1112 } 1123 }
1113 1124
1114 /* if sender is a direct neighbor the sender mac equals 1125 /* if sender is a direct neighbor the sender mac equals
1115 * originator mac */ 1126 * originator mac
1127 */
1116 orig_neigh_node = (is_single_hop_neigh ? 1128 orig_neigh_node = (is_single_hop_neigh ?
1117 orig_node : 1129 orig_node :
1118 get_orig_node(bat_priv, ethhdr->h_source)); 1130 batadv_get_orig_node(bat_priv, ethhdr->h_source));
1119 if (!orig_neigh_node) 1131 if (!orig_neigh_node)
1120 goto out; 1132 goto out;
1121 1133
1122 orig_neigh_router = orig_node_get_router(orig_neigh_node); 1134 orig_neigh_router = batadv_orig_node_get_router(orig_neigh_node);
1123 1135
1124 /* drop packet if sender is not a direct neighbor and if we 1136 /* drop packet if sender is not a direct neighbor and if we
1125 * don't route towards it */ 1137 * don't route towards it
1138 */
1126 if (!is_single_hop_neigh && (!orig_neigh_router)) { 1139 if (!is_single_hop_neigh && (!orig_neigh_router)) {
1127 bat_dbg(DBG_BATMAN, bat_priv, 1140 bat_dbg(DBG_BATMAN, bat_priv,
1128 "Drop packet: OGM via unknown neighbor!\n"); 1141 "Drop packet: OGM via unknown neighbor!\n");
@@ -1132,10 +1145,12 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1132 is_bidirectional = bat_iv_ogm_calc_tq(orig_node, orig_neigh_node, 1145 is_bidirectional = bat_iv_ogm_calc_tq(orig_node, orig_neigh_node,
1133 batman_ogm_packet, if_incoming); 1146 batman_ogm_packet, if_incoming);
1134 1147
1135 bonding_save_primary(orig_node, orig_neigh_node, batman_ogm_packet); 1148 batadv_bonding_save_primary(orig_node, orig_neigh_node,
1149 batman_ogm_packet);
1136 1150
1137 /* update ranking if it is not a duplicate or has the same 1151 /* update ranking if it is not a duplicate or has the same
1138 * seqno and similar ttl as the non-duplicate */ 1152 * seqno and similar ttl as the non-duplicate
1153 */
1139 if (is_bidirectional && 1154 if (is_bidirectional &&
1140 (!is_duplicate || 1155 (!is_duplicate ||
1141 ((orig_node->last_real_seqno == ntohl(batman_ogm_packet->seqno)) && 1156 ((orig_node->last_real_seqno == ntohl(batman_ogm_packet->seqno)) &&
@@ -1178,16 +1193,16 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1178 1193
1179out_neigh: 1194out_neigh:
1180 if ((orig_neigh_node) && (!is_single_hop_neigh)) 1195 if ((orig_neigh_node) && (!is_single_hop_neigh))
1181 orig_node_free_ref(orig_neigh_node); 1196 batadv_orig_node_free_ref(orig_neigh_node);
1182out: 1197out:
1183 if (router) 1198 if (router)
1184 neigh_node_free_ref(router); 1199 batadv_neigh_node_free_ref(router);
1185 if (router_router) 1200 if (router_router)
1186 neigh_node_free_ref(router_router); 1201 batadv_neigh_node_free_ref(router_router);
1187 if (orig_neigh_router) 1202 if (orig_neigh_router)
1188 neigh_node_free_ref(orig_neigh_router); 1203 batadv_neigh_node_free_ref(orig_neigh_router);
1189 1204
1190 orig_node_free_ref(orig_node); 1205 batadv_orig_node_free_ref(orig_node);
1191} 1206}
1192 1207
1193static int bat_iv_ogm_receive(struct sk_buff *skb, 1208static int bat_iv_ogm_receive(struct sk_buff *skb,
@@ -1200,7 +1215,7 @@ static int bat_iv_ogm_receive(struct sk_buff *skb,
1200 unsigned char *tt_buff, *packet_buff; 1215 unsigned char *tt_buff, *packet_buff;
1201 bool ret; 1216 bool ret;
1202 1217
1203 ret = check_management_packet(skb, if_incoming, BATMAN_OGM_HLEN); 1218 ret = batadv_check_management_packet(skb, if_incoming, BATMAN_OGM_HLEN);
1204 if (!ret) 1219 if (!ret)
1205 return NET_RX_DROP; 1220 return NET_RX_DROP;
1206 1221
@@ -1226,8 +1241,8 @@ static int bat_iv_ogm_receive(struct sk_buff *skb,
1226 bat_iv_ogm_process(ethhdr, batman_ogm_packet, 1241 bat_iv_ogm_process(ethhdr, batman_ogm_packet,
1227 tt_buff, if_incoming); 1242 tt_buff, if_incoming);
1228 1243
1229 buff_pos += BATMAN_OGM_HLEN + 1244 buff_pos += BATMAN_OGM_HLEN;
1230 tt_len(batman_ogm_packet->tt_num_changes); 1245 buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes);
1231 1246
1232 batman_ogm_packet = (struct batman_ogm_packet *) 1247 batman_ogm_packet = (struct batman_ogm_packet *)
1233 (packet_buff + buff_pos); 1248 (packet_buff + buff_pos);
@@ -1248,23 +1263,23 @@ static struct bat_algo_ops batman_iv __read_mostly = {
1248 .bat_ogm_emit = bat_iv_ogm_emit, 1263 .bat_ogm_emit = bat_iv_ogm_emit,
1249}; 1264};
1250 1265
1251int __init bat_iv_init(void) 1266int __init batadv_iv_init(void)
1252{ 1267{
1253 int ret; 1268 int ret;
1254 1269
1255 /* batman originator packet */ 1270 /* batman originator packet */
1256 ret = recv_handler_register(BAT_IV_OGM, bat_iv_ogm_receive); 1271 ret = batadv_recv_handler_register(BAT_IV_OGM, bat_iv_ogm_receive);
1257 if (ret < 0) 1272 if (ret < 0)
1258 goto out; 1273 goto out;
1259 1274
1260 ret = bat_algo_register(&batman_iv); 1275 ret = batadv_algo_register(&batman_iv);
1261 if (ret < 0) 1276 if (ret < 0)
1262 goto handler_unregister; 1277 goto handler_unregister;
1263 1278
1264 goto out; 1279 goto out;
1265 1280
1266handler_unregister: 1281handler_unregister:
1267 recv_handler_unregister(BAT_IV_OGM); 1282 batadv_recv_handler_unregister(BAT_IV_OGM);
1268out: 1283out:
1269 return ret; 1284 return ret;
1270} 1285}
diff --git a/net/batman-adv/bat_sysfs.c b/net/batman-adv/bat_sysfs.c
index dc1edbee63df..8196fa6ff22e 100644
--- a/net/batman-adv/bat_sysfs.c
+++ b/net/batman-adv/bat_sysfs.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner 3 * Marek Lindner
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -84,7 +82,8 @@ ssize_t show_##_name(struct kobject *kobj, \
84} \ 82} \
85 83
86/* Use this, if you are going to turn a [name] in the soft-interface 84/* Use this, if you are going to turn a [name] in the soft-interface
87 * (bat_priv) on or off */ 85 * (bat_priv) on or off
86 */
88#define BAT_ATTR_SIF_BOOL(_name, _mode, _post_func) \ 87#define BAT_ATTR_SIF_BOOL(_name, _mode, _post_func) \
89 static BAT_ATTR_SIF_STORE_BOOL(_name, _post_func) \ 88 static BAT_ATTR_SIF_STORE_BOOL(_name, _post_func) \
90 static BAT_ATTR_SIF_SHOW_BOOL(_name) \ 89 static BAT_ATTR_SIF_SHOW_BOOL(_name) \
@@ -110,7 +109,8 @@ ssize_t show_##_name(struct kobject *kobj, \
110} \ 109} \
111 110
112/* Use this, if you are going to set [name] in the soft-interface 111/* Use this, if you are going to set [name] in the soft-interface
113 * (bat_priv) to an unsigned integer value */ 112 * (bat_priv) to an unsigned integer value
113 */
114#define BAT_ATTR_SIF_UINT(_name, _mode, _min, _max, _post_func) \ 114#define BAT_ATTR_SIF_UINT(_name, _mode, _min, _max, _post_func) \
115 static BAT_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \ 115 static BAT_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \
116 static BAT_ATTR_SIF_SHOW_UINT(_name) \ 116 static BAT_ATTR_SIF_SHOW_UINT(_name) \
@@ -122,9 +122,10 @@ ssize_t store_##_name(struct kobject *kobj, struct attribute *attr, \
122 char *buff, size_t count) \ 122 char *buff, size_t count) \
123{ \ 123{ \
124 struct net_device *net_dev = kobj_to_netdev(kobj); \ 124 struct net_device *net_dev = kobj_to_netdev(kobj); \
125 struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev); \ 125 struct hard_iface *hard_iface; \
126 ssize_t length; \ 126 ssize_t length; \
127 \ 127 \
128 hard_iface = batadv_hardif_get_by_netdev(net_dev); \
128 if (!hard_iface) \ 129 if (!hard_iface) \
129 return 0; \ 130 return 0; \
130 \ 131 \
@@ -140,9 +141,10 @@ ssize_t show_##_name(struct kobject *kobj, \
140 struct attribute *attr, char *buff) \ 141 struct attribute *attr, char *buff) \
141{ \ 142{ \
142 struct net_device *net_dev = kobj_to_netdev(kobj); \ 143 struct net_device *net_dev = kobj_to_netdev(kobj); \
143 struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev); \ 144 struct hard_iface *hard_iface; \
144 ssize_t length; \ 145 ssize_t length; \
145 \ 146 \
147 hard_iface = batadv_hardif_get_by_netdev(net_dev); \
146 if (!hard_iface) \ 148 if (!hard_iface) \
147 return 0; \ 149 return 0; \
148 \ 150 \
@@ -153,7 +155,8 @@ ssize_t show_##_name(struct kobject *kobj, \
153} 155}
154 156
155/* Use this, if you are going to set [name] in hard_iface to an 157/* Use this, if you are going to set [name] in hard_iface to an
156 * unsigned integer value*/ 158 * unsigned integer value
159 */
157#define BAT_ATTR_HIF_UINT(_name, _mode, _min, _max, _post_func) \ 160#define BAT_ATTR_HIF_UINT(_name, _mode, _min, _max, _post_func) \
158 static BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \ 161 static BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \
159 static BAT_ATTR_HIF_SHOW_UINT(_name) \ 162 static BAT_ATTR_HIF_SHOW_UINT(_name) \
@@ -326,7 +329,7 @@ static ssize_t show_bat_algo(struct kobject *kobj, struct attribute *attr,
326static void post_gw_deselect(struct net_device *net_dev) 329static void post_gw_deselect(struct net_device *net_dev)
327{ 330{
328 struct bat_priv *bat_priv = netdev_priv(net_dev); 331 struct bat_priv *bat_priv = netdev_priv(net_dev);
329 gw_deselect(bat_priv); 332 batadv_gw_deselect(bat_priv);
330} 333}
331 334
332static ssize_t show_gw_mode(struct kobject *kobj, struct attribute *attr, 335static ssize_t show_gw_mode(struct kobject *kobj, struct attribute *attr,
@@ -397,7 +400,7 @@ static ssize_t store_gw_mode(struct kobject *kobj, struct attribute *attr,
397 bat_info(net_dev, "Changing gw mode from: %s to: %s\n", 400 bat_info(net_dev, "Changing gw mode from: %s to: %s\n",
398 curr_gw_mode_str, buff); 401 curr_gw_mode_str, buff);
399 402
400 gw_deselect(bat_priv); 403 batadv_gw_deselect(bat_priv);
401 atomic_set(&bat_priv->gw_mode, (unsigned int)gw_mode_tmp); 404 atomic_set(&bat_priv->gw_mode, (unsigned int)gw_mode_tmp);
402 return count; 405 return count;
403} 406}
@@ -409,7 +412,7 @@ static ssize_t show_gw_bwidth(struct kobject *kobj, struct attribute *attr,
409 int down, up; 412 int down, up;
410 int gw_bandwidth = atomic_read(&bat_priv->gw_bandwidth); 413 int gw_bandwidth = atomic_read(&bat_priv->gw_bandwidth);
411 414
412 gw_bandwidth_to_kbit(gw_bandwidth, &down, &up); 415 batadv_gw_bandwidth_to_kbit(gw_bandwidth, &down, &up);
413 return sprintf(buff, "%i%s/%i%s\n", 416 return sprintf(buff, "%i%s/%i%s\n",
414 (down > 2048 ? down / 1024 : down), 417 (down > 2048 ? down / 1024 : down),
415 (down > 2048 ? "MBit" : "KBit"), 418 (down > 2048 ? "MBit" : "KBit"),
@@ -425,7 +428,7 @@ static ssize_t store_gw_bwidth(struct kobject *kobj, struct attribute *attr,
425 if (buff[count - 1] == '\n') 428 if (buff[count - 1] == '\n')
426 buff[count - 1] = '\0'; 429 buff[count - 1] = '\0';
427 430
428 return gw_bandwidth_set(net_dev, buff, count); 431 return batadv_gw_bandwidth_set(net_dev, buff, count);
429} 432}
430 433
431BAT_ATTR_SIF_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL); 434BAT_ATTR_SIF_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL);
@@ -433,7 +436,7 @@ BAT_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
433#ifdef CONFIG_BATMAN_ADV_BLA 436#ifdef CONFIG_BATMAN_ADV_BLA
434BAT_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL); 437BAT_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL);
435#endif 438#endif
436BAT_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, update_min_mtu); 439BAT_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu);
437BAT_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL); 440BAT_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL);
438static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode); 441static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode);
439static BAT_ATTR(routing_algo, S_IRUGO, show_bat_algo, NULL); 442static BAT_ATTR(routing_algo, S_IRUGO, show_bat_algo, NULL);
@@ -469,7 +472,7 @@ static struct bat_attribute *mesh_attrs[] = {
469 NULL, 472 NULL,
470}; 473};
471 474
472int sysfs_add_meshif(struct net_device *dev) 475int batadv_sysfs_add_meshif(struct net_device *dev)
473{ 476{
474 struct kobject *batif_kobject = &dev->dev.kobj; 477 struct kobject *batif_kobject = &dev->dev.kobj;
475 struct bat_priv *bat_priv = netdev_priv(dev); 478 struct bat_priv *bat_priv = netdev_priv(dev);
@@ -507,7 +510,7 @@ out:
507 return -ENOMEM; 510 return -ENOMEM;
508} 511}
509 512
510void sysfs_del_meshif(struct net_device *dev) 513void batadv_sysfs_del_meshif(struct net_device *dev)
511{ 514{
512 struct bat_priv *bat_priv = netdev_priv(dev); 515 struct bat_priv *bat_priv = netdev_priv(dev);
513 struct bat_attribute **bat_attr; 516 struct bat_attribute **bat_attr;
@@ -523,7 +526,7 @@ static ssize_t show_mesh_iface(struct kobject *kobj, struct attribute *attr,
523 char *buff) 526 char *buff)
524{ 527{
525 struct net_device *net_dev = kobj_to_netdev(kobj); 528 struct net_device *net_dev = kobj_to_netdev(kobj);
526 struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev); 529 struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
527 ssize_t length; 530 ssize_t length;
528 531
529 if (!hard_iface) 532 if (!hard_iface)
@@ -541,7 +544,7 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
541 char *buff, size_t count) 544 char *buff, size_t count)
542{ 545{
543 struct net_device *net_dev = kobj_to_netdev(kobj); 546 struct net_device *net_dev = kobj_to_netdev(kobj);
544 struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev); 547 struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
545 int status_tmp = -1; 548 int status_tmp = -1;
546 int ret = count; 549 int ret = count;
547 550
@@ -576,15 +579,15 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
576 } 579 }
577 580
578 if (status_tmp == IF_NOT_IN_USE) { 581 if (status_tmp == IF_NOT_IN_USE) {
579 hardif_disable_interface(hard_iface); 582 batadv_hardif_disable_interface(hard_iface);
580 goto unlock; 583 goto unlock;
581 } 584 }
582 585
583 /* if the interface already is in use */ 586 /* if the interface already is in use */
584 if (hard_iface->if_status != IF_NOT_IN_USE) 587 if (hard_iface->if_status != IF_NOT_IN_USE)
585 hardif_disable_interface(hard_iface); 588 batadv_hardif_disable_interface(hard_iface);
586 589
587 ret = hardif_enable_interface(hard_iface, buff); 590 ret = batadv_hardif_enable_interface(hard_iface, buff);
588 591
589unlock: 592unlock:
590 rtnl_unlock(); 593 rtnl_unlock();
@@ -597,7 +600,7 @@ static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr,
597 char *buff) 600 char *buff)
598{ 601{
599 struct net_device *net_dev = kobj_to_netdev(kobj); 602 struct net_device *net_dev = kobj_to_netdev(kobj);
600 struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev); 603 struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
601 ssize_t length; 604 ssize_t length;
602 605
603 if (!hard_iface) 606 if (!hard_iface)
@@ -637,7 +640,7 @@ static struct bat_attribute *batman_attrs[] = {
637 NULL, 640 NULL,
638}; 641};
639 642
640int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev) 643int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
641{ 644{
642 struct kobject *hardif_kobject = &dev->dev.kobj; 645 struct kobject *hardif_kobject = &dev->dev.kobj;
643 struct bat_attribute **bat_attr; 646 struct bat_attribute **bat_attr;
@@ -671,14 +674,14 @@ out:
671 return -ENOMEM; 674 return -ENOMEM;
672} 675}
673 676
674void sysfs_del_hardif(struct kobject **hardif_obj) 677void batadv_sysfs_del_hardif(struct kobject **hardif_obj)
675{ 678{
676 kobject_put(*hardif_obj); 679 kobject_put(*hardif_obj);
677 *hardif_obj = NULL; 680 *hardif_obj = NULL;
678} 681}
679 682
680int throw_uevent(struct bat_priv *bat_priv, enum uev_type type, 683int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
681 enum uev_action action, const char *data) 684 enum uev_action action, const char *data)
682{ 685{
683 int ret = -ENOMEM; 686 int ret = -ENOMEM;
684 struct hard_iface *primary_if = NULL; 687 struct hard_iface *primary_if = NULL;
diff --git a/net/batman-adv/bat_sysfs.h b/net/batman-adv/bat_sysfs.h
index fece77ae586e..367227707d52 100644
--- a/net/batman-adv/bat_sysfs.h
+++ b/net/batman-adv/bat_sysfs.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner 3 * Marek Lindner
5 * 4 *
@@ -16,10 +15,8 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22
23#ifndef _NET_BATMAN_ADV_SYSFS_H_ 20#ifndef _NET_BATMAN_ADV_SYSFS_H_
24#define _NET_BATMAN_ADV_SYSFS_H_ 21#define _NET_BATMAN_ADV_SYSFS_H_
25 22
@@ -34,11 +31,12 @@ struct bat_attribute {
34 char *buf, size_t count); 31 char *buf, size_t count);
35}; 32};
36 33
37int sysfs_add_meshif(struct net_device *dev); 34int batadv_sysfs_add_meshif(struct net_device *dev);
38void sysfs_del_meshif(struct net_device *dev); 35void batadv_sysfs_del_meshif(struct net_device *dev);
39int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev); 36int batadv_sysfs_add_hardif(struct kobject **hardif_obj,
40void sysfs_del_hardif(struct kobject **hardif_obj); 37 struct net_device *dev);
41int throw_uevent(struct bat_priv *bat_priv, enum uev_type type, 38void batadv_sysfs_del_hardif(struct kobject **hardif_obj);
42 enum uev_action action, const char *data); 39int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
40 enum uev_action action, const char *data);
43 41
44#endif /* _NET_BATMAN_ADV_SYSFS_H_ */ 42#endif /* _NET_BATMAN_ADV_SYSFS_H_ */
diff --git a/net/batman-adv/bitarray.c b/net/batman-adv/bitarray.c
index 07ae6e1b8aca..838abbc73c6c 100644
--- a/net/batman-adv/bitarray.c
+++ b/net/batman-adv/bitarray.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Simon Wunderlich, Marek Lindner 3 * Simon Wunderlich, Marek Lindner
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -25,7 +23,7 @@
25#include <linux/bitops.h> 23#include <linux/bitops.h>
26 24
27/* shift the packet array by n places. */ 25/* shift the packet array by n places. */
28static void bat_bitmap_shift_left(unsigned long *seq_bits, int32_t n) 26static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n)
29{ 27{
30 if (n <= 0 || n >= TQ_LOCAL_WINDOW_SIZE) 28 if (n <= 0 || n >= TQ_LOCAL_WINDOW_SIZE)
31 return; 29 return;
@@ -40,14 +38,14 @@ static void bat_bitmap_shift_left(unsigned long *seq_bits, int32_t n)
40 * 1 if the window was moved (either new or very old) 38 * 1 if the window was moved (either new or very old)
41 * 0 if the window was not moved/shifted. 39 * 0 if the window was not moved/shifted.
42 */ 40 */
43int bit_get_packet(void *priv, unsigned long *seq_bits, 41int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
44 int32_t seq_num_diff, int set_mark) 42 int32_t seq_num_diff, int set_mark)
45{ 43{
46 struct bat_priv *bat_priv = priv; 44 struct bat_priv *bat_priv = priv;
47 45
48 /* sequence number is slightly older. We already got a sequence number 46 /* sequence number is slightly older. We already got a sequence number
49 * higher than this one, so we just mark it. */ 47 * higher than this one, so we just mark it.
50 48 */
51 if ((seq_num_diff <= 0) && (seq_num_diff > -TQ_LOCAL_WINDOW_SIZE)) { 49 if ((seq_num_diff <= 0) && (seq_num_diff > -TQ_LOCAL_WINDOW_SIZE)) {
52 if (set_mark) 50 if (set_mark)
53 bat_set_bit(seq_bits, -seq_num_diff); 51 bat_set_bit(seq_bits, -seq_num_diff);
@@ -55,10 +53,10 @@ int bit_get_packet(void *priv, unsigned long *seq_bits,
55 } 53 }
56 54
57 /* sequence number is slightly newer, so we shift the window and 55 /* sequence number is slightly newer, so we shift the window and
58 * set the mark if required */ 56 * set the mark if required
59 57 */
60 if ((seq_num_diff > 0) && (seq_num_diff < TQ_LOCAL_WINDOW_SIZE)) { 58 if ((seq_num_diff > 0) && (seq_num_diff < TQ_LOCAL_WINDOW_SIZE)) {
61 bat_bitmap_shift_left(seq_bits, seq_num_diff); 59 batadv_bitmap_shift_left(seq_bits, seq_num_diff);
62 60
63 if (set_mark) 61 if (set_mark)
64 bat_set_bit(seq_bits, 0); 62 bat_set_bit(seq_bits, 0);
@@ -66,7 +64,6 @@ int bit_get_packet(void *priv, unsigned long *seq_bits,
66 } 64 }
67 65
68 /* sequence number is much newer, probably missed a lot of packets */ 66 /* sequence number is much newer, probably missed a lot of packets */
69
70 if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) && 67 if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) &&
71 (seq_num_diff < EXPECTED_SEQNO_RANGE)) { 68 (seq_num_diff < EXPECTED_SEQNO_RANGE)) {
72 bat_dbg(DBG_BATMAN, bat_priv, 69 bat_dbg(DBG_BATMAN, bat_priv,
@@ -81,8 +78,8 @@ int bit_get_packet(void *priv, unsigned long *seq_bits,
81 /* received a much older packet. The other host either restarted 78 /* received a much older packet. The other host either restarted
82 * or the old packet got delayed somewhere in the network. The 79 * or the old packet got delayed somewhere in the network. The
83 * packet should be dropped without calling this function if the 80 * packet should be dropped without calling this function if the
84 * seqno window is protected. */ 81 * seqno window is protected.
85 82 */
86 if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || 83 if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) ||
87 (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { 84 (seq_num_diff >= EXPECTED_SEQNO_RANGE)) {
88 85
diff --git a/net/batman-adv/bitarray.h b/net/batman-adv/bitarray.h
index 1835c15cda41..8ab542632343 100644
--- a/net/batman-adv/bitarray.h
+++ b/net/batman-adv/bitarray.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Simon Wunderlich, Marek Lindner 3 * Simon Wunderlich, Marek Lindner
5 * 4 *
@@ -16,14 +15,14 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_BITARRAY_H_ 20#ifndef _NET_BATMAN_ADV_BITARRAY_H_
23#define _NET_BATMAN_ADV_BITARRAY_H_ 21#define _NET_BATMAN_ADV_BITARRAY_H_
24 22
25/* returns true if the corresponding bit in the given seq_bits indicates true 23/* returns true if the corresponding bit in the given seq_bits indicates true
26 * and curr_seqno is within range of last_seqno */ 24 * and curr_seqno is within range of last_seqno
25 */
27static inline int bat_test_bit(const unsigned long *seq_bits, 26static inline int bat_test_bit(const unsigned long *seq_bits,
28 uint32_t last_seqno, uint32_t curr_seqno) 27 uint32_t last_seqno, uint32_t curr_seqno)
29{ 28{
@@ -47,8 +46,9 @@ static inline void bat_set_bit(unsigned long *seq_bits, int32_t n)
47} 46}
48 47
49/* receive and process one packet, returns 1 if received seq_num is considered 48/* receive and process one packet, returns 1 if received seq_num is considered
50 * new, 0 if old */ 49 * new, 0 if old
51int bit_get_packet(void *priv, unsigned long *seq_bits, 50 */
52 int32_t seq_num_diff, int set_mark); 51int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
52 int32_t seq_num_diff, int set_mark);
53 53
54#endif /* _NET_BATMAN_ADV_BITARRAY_H_ */ 54#endif /* _NET_BATMAN_ADV_BITARRAY_H_ */
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 314e37b272a7..52c0d637d581 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Simon Wunderlich 3 * Simon Wunderlich
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -123,8 +121,7 @@ static void claim_free_ref(struct claim *claim)
123 call_rcu(&claim->rcu, claim_free_rcu); 121 call_rcu(&claim->rcu, claim_free_rcu);
124} 122}
125 123
126/** 124/* @bat_priv: the bat priv with all the soft interface information
127 * @bat_priv: the bat priv with all the soft interface information
128 * @data: search data (may be local/static data) 125 * @data: search data (may be local/static data)
129 * 126 *
130 * looks for a claim in the hash, and returns it if found 127 * looks for a claim in the hash, and returns it if found
@@ -162,8 +159,7 @@ static struct claim *claim_hash_find(struct bat_priv *bat_priv,
162 return claim_tmp; 159 return claim_tmp;
163} 160}
164 161
165/** 162/* @bat_priv: the bat priv with all the soft interface information
166 * @bat_priv: the bat priv with all the soft interface information
167 * @addr: the address of the originator 163 * @addr: the address of the originator
168 * @vid: the VLAN ID 164 * @vid: the VLAN ID
169 * 165 *
@@ -241,8 +237,7 @@ static void bla_del_backbone_claims(struct backbone_gw *backbone_gw)
241 backbone_gw->crc = BLA_CRC_INIT; 237 backbone_gw->crc = BLA_CRC_INIT;
242} 238}
243 239
244/** 240/* @bat_priv: the bat priv with all the soft interface information
245 * @bat_priv: the bat priv with all the soft interface information
246 * @orig: the mac address to be announced within the claim 241 * @orig: the mac address to be announced within the claim
247 * @vid: the VLAN ID 242 * @vid: the VLAN ID
248 * @claimtype: the type of the claim (CLAIM, UNCLAIM, ANNOUNCE, ...) 243 * @claimtype: the type of the claim (CLAIM, UNCLAIM, ANNOUNCE, ...)
@@ -347,8 +342,7 @@ out:
347 hardif_free_ref(primary_if); 342 hardif_free_ref(primary_if);
348} 343}
349 344
350/** 345/* @bat_priv: the bat priv with all the soft interface information
351 * @bat_priv: the bat priv with all the soft interface information
352 * @orig: the mac address of the originator 346 * @orig: the mac address of the originator
353 * @vid: the VLAN ID 347 * @vid: the VLAN ID
354 * 348 *
@@ -397,9 +391,9 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv,
397 /* this is a gateway now, remove any tt entries */ 391 /* this is a gateway now, remove any tt entries */
398 orig_node = orig_hash_find(bat_priv, orig); 392 orig_node = orig_hash_find(bat_priv, orig);
399 if (orig_node) { 393 if (orig_node) {
400 tt_global_del_orig(bat_priv, orig_node, 394 batadv_tt_global_del_orig(bat_priv, orig_node,
401 "became a backbone gateway"); 395 "became a backbone gateway");
402 orig_node_free_ref(orig_node); 396 batadv_orig_node_free_ref(orig_node);
403 } 397 }
404 return entry; 398 return entry;
405} 399}
@@ -422,8 +416,7 @@ static void bla_update_own_backbone_gw(struct bat_priv *bat_priv,
422 backbone_gw_free_ref(backbone_gw); 416 backbone_gw_free_ref(backbone_gw);
423} 417}
424 418
425/** 419/* @bat_priv: the bat priv with all the soft interface information
426 * @bat_priv: the bat priv with all the soft interface information
427 * @vid: the vid where the request came on 420 * @vid: the vid where the request came on
428 * 421 *
429 * Repeat all of our own claims, and finally send an ANNOUNCE frame 422 * Repeat all of our own claims, and finally send an ANNOUNCE frame
@@ -468,8 +461,7 @@ static void bla_answer_request(struct bat_priv *bat_priv,
468 backbone_gw_free_ref(backbone_gw); 461 backbone_gw_free_ref(backbone_gw);
469} 462}
470 463
471/** 464/* @backbone_gw: the backbone gateway from whom we are out of sync
472 * @backbone_gw: the backbone gateway from whom we are out of sync
473 * 465 *
474 * When the crc is wrong, ask the backbone gateway for a full table update. 466 * When the crc is wrong, ask the backbone gateway for a full table update.
475 * After the request, it will repeat all of his own claims and finally 467 * After the request, it will repeat all of his own claims and finally
@@ -495,8 +487,7 @@ static void bla_send_request(struct backbone_gw *backbone_gw)
495 } 487 }
496} 488}
497 489
498/** 490/* @bat_priv: the bat priv with all the soft interface information
499 * @bat_priv: the bat priv with all the soft interface information
500 * @backbone_gw: our backbone gateway which should be announced 491 * @backbone_gw: our backbone gateway which should be announced
501 * 492 *
502 * This function sends an announcement. It is called from multiple 493 * This function sends an announcement. It is called from multiple
@@ -516,8 +507,7 @@ static void bla_send_announce(struct bat_priv *bat_priv,
516 507
517} 508}
518 509
519/** 510/* @bat_priv: the bat priv with all the soft interface information
520 * @bat_priv: the bat priv with all the soft interface information
521 * @mac: the mac address of the claim 511 * @mac: the mac address of the claim
522 * @vid: the VLAN ID of the frame 512 * @vid: the VLAN ID of the frame
523 * @backbone_gw: the backbone gateway which claims it 513 * @backbone_gw: the backbone gateway which claims it
@@ -731,8 +721,7 @@ static int handle_claim(struct bat_priv *bat_priv,
731 return 1; 721 return 1;
732} 722}
733 723
734/** 724/* @bat_priv: the bat priv with all the soft interface information
735 * @bat_priv: the bat priv with all the soft interface information
736 * @hw_src: the Hardware source in the ARP Header 725 * @hw_src: the Hardware source in the ARP Header
737 * @hw_dst: the Hardware destination in the ARP Header 726 * @hw_dst: the Hardware destination in the ARP Header
738 * @ethhdr: pointer to the Ethernet header of the claim frame 727 * @ethhdr: pointer to the Ethernet header of the claim frame
@@ -804,14 +793,13 @@ static int check_claim_group(struct bat_priv *bat_priv,
804 bla_dst_own->group = bla_dst->group; 793 bla_dst_own->group = bla_dst->group;
805 } 794 }
806 795
807 orig_node_free_ref(orig_node); 796 batadv_orig_node_free_ref(orig_node);
808 797
809 return 2; 798 return 2;
810} 799}
811 800
812 801
813/** 802/* @bat_priv: the bat priv with all the soft interface information
814 * @bat_priv: the bat priv with all the soft interface information
815 * @skb: the frame to be checked 803 * @skb: the frame to be checked
816 * 804 *
817 * Check if this is a claim frame, and process it accordingly. 805 * Check if this is a claim frame, and process it accordingly.
@@ -860,7 +848,6 @@ static int bla_process_claim(struct bat_priv *bat_priv,
860 /* Check whether the ARP frame carries a valid 848 /* Check whether the ARP frame carries a valid
861 * IP information 849 * IP information
862 */ 850 */
863
864 if (arphdr->ar_hrd != htons(ARPHRD_ETHER)) 851 if (arphdr->ar_hrd != htons(ARPHRD_ETHER))
865 return 0; 852 return 0;
866 if (arphdr->ar_pro != htons(ETH_P_IP)) 853 if (arphdr->ar_pro != htons(ETH_P_IP))
@@ -963,8 +950,7 @@ purge_now:
963 } 950 }
964} 951}
965 952
966/** 953/* @bat_priv: the bat priv with all the soft interface information
967 * @bat_priv: the bat priv with all the soft interface information
968 * @primary_if: the selected primary interface, may be NULL if now is set 954 * @primary_if: the selected primary interface, may be NULL if now is set
969 * @now: whether the whole hash shall be wiped now 955 * @now: whether the whole hash shall be wiped now
970 * 956 *
@@ -1011,17 +997,15 @@ purge_now:
1011 } 997 }
1012} 998}
1013 999
1014/** 1000/* @bat_priv: the bat priv with all the soft interface information
1015 * @bat_priv: the bat priv with all the soft interface information
1016 * @primary_if: the new selected primary_if 1001 * @primary_if: the new selected primary_if
1017 * @oldif: the old primary interface, may be NULL 1002 * @oldif: the old primary interface, may be NULL
1018 * 1003 *
1019 * Update the backbone gateways when the own orig address changes. 1004 * Update the backbone gateways when the own orig address changes.
1020 *
1021 */ 1005 */
1022void bla_update_orig_address(struct bat_priv *bat_priv, 1006void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
1023 struct hard_iface *primary_if, 1007 struct hard_iface *primary_if,
1024 struct hard_iface *oldif) 1008 struct hard_iface *oldif)
1025{ 1009{
1026 struct backbone_gw *backbone_gw; 1010 struct backbone_gw *backbone_gw;
1027 struct hlist_node *node; 1011 struct hlist_node *node;
@@ -1070,7 +1054,7 @@ void bla_update_orig_address(struct bat_priv *bat_priv,
1070static void bla_start_timer(struct bat_priv *bat_priv) 1054static void bla_start_timer(struct bat_priv *bat_priv)
1071{ 1055{
1072 INIT_DELAYED_WORK(&bat_priv->bla_work, bla_periodic_work); 1056 INIT_DELAYED_WORK(&bat_priv->bla_work, bla_periodic_work);
1073 queue_delayed_work(bat_event_workqueue, &bat_priv->bla_work, 1057 queue_delayed_work(batadv_event_workqueue, &bat_priv->bla_work,
1074 msecs_to_jiffies(BLA_PERIOD_LENGTH)); 1058 msecs_to_jiffies(BLA_PERIOD_LENGTH));
1075} 1059}
1076 1060
@@ -1136,7 +1120,7 @@ static struct lock_class_key claim_hash_lock_class_key;
1136static struct lock_class_key backbone_hash_lock_class_key; 1120static struct lock_class_key backbone_hash_lock_class_key;
1137 1121
1138/* initialize all bla structures */ 1122/* initialize all bla structures */
1139int bla_init(struct bat_priv *bat_priv) 1123int batadv_bla_init(struct bat_priv *bat_priv)
1140{ 1124{
1141 int i; 1125 int i;
1142 uint8_t claim_dest[ETH_ALEN] = {0xff, 0x43, 0x05, 0x00, 0x00, 0x00}; 1126 uint8_t claim_dest[ETH_ALEN] = {0xff, 0x43, 0x05, 0x00, 0x00, 0x00};
@@ -1166,8 +1150,8 @@ int bla_init(struct bat_priv *bat_priv)
1166 if (bat_priv->claim_hash) 1150 if (bat_priv->claim_hash)
1167 return 0; 1151 return 0;
1168 1152
1169 bat_priv->claim_hash = hash_new(128); 1153 bat_priv->claim_hash = batadv_hash_new(128);
1170 bat_priv->backbone_hash = hash_new(32); 1154 bat_priv->backbone_hash = batadv_hash_new(32);
1171 1155
1172 if (!bat_priv->claim_hash || !bat_priv->backbone_hash) 1156 if (!bat_priv->claim_hash || !bat_priv->backbone_hash)
1173 return -ENOMEM; 1157 return -ENOMEM;
@@ -1183,8 +1167,7 @@ int bla_init(struct bat_priv *bat_priv)
1183 return 0; 1167 return 0;
1184} 1168}
1185 1169
1186/** 1170/* @bat_priv: the bat priv with all the soft interface information
1187 * @bat_priv: the bat priv with all the soft interface information
1188 * @bcast_packet: originator mac address 1171 * @bcast_packet: originator mac address
1189 * @hdr_size: maximum length of the frame 1172 * @hdr_size: maximum length of the frame
1190 * 1173 *
@@ -1196,12 +1179,10 @@ int bla_init(struct bat_priv *bat_priv)
1196 * with a good chance that it is the same packet. If it is furthermore 1179 * with a good chance that it is the same packet. If it is furthermore
1197 * sent by another host, drop it. We allow equal packets from 1180 * sent by another host, drop it. We allow equal packets from
1198 * the same host however as this might be intended. 1181 * the same host however as this might be intended.
1199 * 1182 */
1200 **/ 1183int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
1201 1184 struct bcast_packet *bcast_packet,
1202int bla_check_bcast_duplist(struct bat_priv *bat_priv, 1185 int hdr_size)
1203 struct bcast_packet *bcast_packet,
1204 int hdr_size)
1205{ 1186{
1206 int i, length, curr; 1187 int i, length, curr;
1207 uint8_t *content; 1188 uint8_t *content;
@@ -1250,17 +1231,14 @@ int bla_check_bcast_duplist(struct bat_priv *bat_priv,
1250 1231
1251 1232
1252 1233
1253/** 1234/* @bat_priv: the bat priv with all the soft interface information
1254 * @bat_priv: the bat priv with all the soft interface information
1255 * @orig: originator mac address 1235 * @orig: originator mac address
1256 * 1236 *
1257 * check if the originator is a gateway for any VLAN ID. 1237 * check if the originator is a gateway for any VLAN ID.
1258 * 1238 *
1259 * returns 1 if it is found, 0 otherwise 1239 * returns 1 if it is found, 0 otherwise
1260 *
1261 */ 1240 */
1262 1241int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig)
1263int bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig)
1264{ 1242{
1265 struct hashtable_t *hash = bat_priv->backbone_hash; 1243 struct hashtable_t *hash = bat_priv->backbone_hash;
1266 struct hlist_head *head; 1244 struct hlist_head *head;
@@ -1291,18 +1269,16 @@ int bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig)
1291} 1269}
1292 1270
1293 1271
1294/** 1272/* @skb: the frame to be checked
1295 * @skb: the frame to be checked
1296 * @orig_node: the orig_node of the frame 1273 * @orig_node: the orig_node of the frame
1297 * @hdr_size: maximum length of the frame 1274 * @hdr_size: maximum length of the frame
1298 * 1275 *
1299 * bla_is_backbone_gw inspects the skb for the VLAN ID and returns 1 1276 * bla_is_backbone_gw inspects the skb for the VLAN ID and returns 1
1300 * if the orig_node is also a gateway on the soft interface, otherwise it 1277 * if the orig_node is also a gateway on the soft interface, otherwise it
1301 * returns 0. 1278 * returns 0.
1302 *
1303 */ 1279 */
1304int bla_is_backbone_gw(struct sk_buff *skb, 1280int batadv_bla_is_backbone_gw(struct sk_buff *skb,
1305 struct orig_node *orig_node, int hdr_size) 1281 struct orig_node *orig_node, int hdr_size)
1306{ 1282{
1307 struct ethhdr *ethhdr; 1283 struct ethhdr *ethhdr;
1308 struct vlan_ethhdr *vhdr; 1284 struct vlan_ethhdr *vhdr;
@@ -1328,7 +1304,6 @@ int bla_is_backbone_gw(struct sk_buff *skb,
1328 } 1304 }
1329 1305
1330 /* see if this originator is a backbone gw for this VLAN */ 1306 /* see if this originator is a backbone gw for this VLAN */
1331
1332 backbone_gw = backbone_hash_find(orig_node->bat_priv, 1307 backbone_gw = backbone_hash_find(orig_node->bat_priv,
1333 orig_node->orig, vid); 1308 orig_node->orig, vid);
1334 if (!backbone_gw) 1309 if (!backbone_gw)
@@ -1339,7 +1314,7 @@ int bla_is_backbone_gw(struct sk_buff *skb,
1339} 1314}
1340 1315
1341/* free all bla structures (for softinterface free or module unload) */ 1316/* free all bla structures (for softinterface free or module unload) */
1342void bla_free(struct bat_priv *bat_priv) 1317void batadv_bla_free(struct bat_priv *bat_priv)
1343{ 1318{
1344 struct hard_iface *primary_if; 1319 struct hard_iface *primary_if;
1345 1320
@@ -1348,20 +1323,19 @@ void bla_free(struct bat_priv *bat_priv)
1348 1323
1349 if (bat_priv->claim_hash) { 1324 if (bat_priv->claim_hash) {
1350 bla_purge_claims(bat_priv, primary_if, 1); 1325 bla_purge_claims(bat_priv, primary_if, 1);
1351 hash_destroy(bat_priv->claim_hash); 1326 batadv_hash_destroy(bat_priv->claim_hash);
1352 bat_priv->claim_hash = NULL; 1327 bat_priv->claim_hash = NULL;
1353 } 1328 }
1354 if (bat_priv->backbone_hash) { 1329 if (bat_priv->backbone_hash) {
1355 bla_purge_backbone_gw(bat_priv, 1); 1330 bla_purge_backbone_gw(bat_priv, 1);
1356 hash_destroy(bat_priv->backbone_hash); 1331 batadv_hash_destroy(bat_priv->backbone_hash);
1357 bat_priv->backbone_hash = NULL; 1332 bat_priv->backbone_hash = NULL;
1358 } 1333 }
1359 if (primary_if) 1334 if (primary_if)
1360 hardif_free_ref(primary_if); 1335 hardif_free_ref(primary_if);
1361} 1336}
1362 1337
1363/** 1338/* @bat_priv: the bat priv with all the soft interface information
1364 * @bat_priv: the bat priv with all the soft interface information
1365 * @skb: the frame to be checked 1339 * @skb: the frame to be checked
1366 * @vid: the VLAN ID of the frame 1340 * @vid: the VLAN ID of the frame
1367 * 1341 *
@@ -1372,9 +1346,8 @@ void bla_free(struct bat_priv *bat_priv)
1372 * in these cases, the skb is further handled by this function and 1346 * in these cases, the skb is further handled by this function and
1373 * returns 1, otherwise it returns 0 and the caller shall further 1347 * returns 1, otherwise it returns 0 and the caller shall further
1374 * process the skb. 1348 * process the skb.
1375 *
1376 */ 1349 */
1377int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) 1350int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
1378{ 1351{
1379 struct ethhdr *ethhdr; 1352 struct ethhdr *ethhdr;
1380 struct claim search_claim, *claim = NULL; 1353 struct claim search_claim, *claim = NULL;
@@ -1449,8 +1422,7 @@ out:
1449 return ret; 1422 return ret;
1450} 1423}
1451 1424
1452/** 1425/* @bat_priv: the bat priv with all the soft interface information
1453 * @bat_priv: the bat priv with all the soft interface information
1454 * @skb: the frame to be checked 1426 * @skb: the frame to be checked
1455 * @vid: the VLAN ID of the frame 1427 * @vid: the VLAN ID of the frame
1456 * 1428 *
@@ -1461,9 +1433,8 @@ out:
1461 * in these cases, the skb is further handled by this function and 1433 * in these cases, the skb is further handled by this function and
1462 * returns 1, otherwise it returns 0 and the caller shall further 1434 * returns 1, otherwise it returns 0 and the caller shall further
1463 * process the skb. 1435 * process the skb.
1464 *
1465 */ 1436 */
1466int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) 1437int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
1467{ 1438{
1468 struct ethhdr *ethhdr; 1439 struct ethhdr *ethhdr;
1469 struct claim search_claim, *claim = NULL; 1440 struct claim search_claim, *claim = NULL;
@@ -1537,7 +1508,7 @@ out:
1537 return ret; 1508 return ret;
1538} 1509}
1539 1510
1540int bla_claim_table_seq_print_text(struct seq_file *seq, void *offset) 1511int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
1541{ 1512{
1542 struct net_device *net_dev = (struct net_device *)seq->private; 1513 struct net_device *net_dev = (struct net_device *)seq->private;
1543 struct bat_priv *bat_priv = netdev_priv(net_dev); 1514 struct bat_priv *bat_priv = netdev_priv(net_dev);
diff --git a/net/batman-adv/bridge_loop_avoidance.h b/net/batman-adv/bridge_loop_avoidance.h
index e39f93acc28f..9818b1e4c59e 100644
--- a/net/batman-adv/bridge_loop_avoidance.h
+++ b/net/batman-adv/bridge_loop_avoidance.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Simon Wunderlich 3 * Simon Wunderlich
5 * 4 *
@@ -16,80 +15,82 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_BLA_H_ 20#ifndef _NET_BATMAN_ADV_BLA_H_
23#define _NET_BATMAN_ADV_BLA_H_ 21#define _NET_BATMAN_ADV_BLA_H_
24 22
25#ifdef CONFIG_BATMAN_ADV_BLA 23#ifdef CONFIG_BATMAN_ADV_BLA
26int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid); 24int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid);
27int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid); 25int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid);
28int bla_is_backbone_gw(struct sk_buff *skb, 26int batadv_bla_is_backbone_gw(struct sk_buff *skb,
29 struct orig_node *orig_node, int hdr_size); 27 struct orig_node *orig_node, int hdr_size);
30int bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); 28int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);
31int bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig); 29int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig);
32int bla_check_bcast_duplist(struct bat_priv *bat_priv, 30int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
33 struct bcast_packet *bcast_packet, int hdr_size); 31 struct bcast_packet *bcast_packet,
34void bla_update_orig_address(struct bat_priv *bat_priv, 32 int hdr_size);
35 struct hard_iface *primary_if, 33void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
36 struct hard_iface *oldif); 34 struct hard_iface *primary_if,
37int bla_init(struct bat_priv *bat_priv); 35 struct hard_iface *oldif);
38void bla_free(struct bat_priv *bat_priv); 36int batadv_bla_init(struct bat_priv *bat_priv);
37void batadv_bla_free(struct bat_priv *bat_priv);
39 38
40#define BLA_CRC_INIT 0 39#define BLA_CRC_INIT 0
41#else /* ifdef CONFIG_BATMAN_ADV_BLA */ 40#else /* ifdef CONFIG_BATMAN_ADV_BLA */
42 41
43static inline int 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,
44 short vid) 43 short vid)
45{ 44{
46 return 0; 45 return 0;
47} 46}
48 47
49static inline int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, 48static inline int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb,
50 short vid) 49 short vid)
51{ 50{
52 return 0; 51 return 0;
53} 52}
54 53
55static inline int bla_is_backbone_gw(struct sk_buff *skb, 54static inline int batadv_bla_is_backbone_gw(struct sk_buff *skb,
56 struct orig_node *orig_node, 55 struct orig_node *orig_node,
57 int hdr_size) 56 int hdr_size)
58{ 57{
59 return 0; 58 return 0;
60} 59}
61 60
62static inline int bla_claim_table_seq_print_text(struct seq_file *seq, 61static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq,
63 void *offset) 62 void *offset)
64{ 63{
65 return 0; 64 return 0;
66} 65}
67 66
68static inline int bla_is_backbone_gw_orig(struct bat_priv *bat_priv, 67static inline int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv,
69 uint8_t *orig) 68 uint8_t *orig)
70{ 69{
71 return 0; 70 return 0;
72} 71}
73 72
74static inline int bla_check_bcast_duplist(struct bat_priv *bat_priv, 73static inline int
75 struct bcast_packet *bcast_packet, 74batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
76 int hdr_size) 75 struct bcast_packet *bcast_packet,
76 int hdr_size)
77{ 77{
78 return 0; 78 return 0;
79} 79}
80 80
81static inline void bla_update_orig_address(struct bat_priv *bat_priv, 81static inline void
82 struct hard_iface *primary_if, 82batadv_bla_update_orig_address(struct bat_priv *bat_priv,
83 struct hard_iface *oldif) 83 struct hard_iface *primary_if,
84 struct hard_iface *oldif)
84{ 85{
85} 86}
86 87
87static inline int bla_init(struct bat_priv *bat_priv) 88static inline int batadv_bla_init(struct bat_priv *bat_priv)
88{ 89{
89 return 1; 90 return 1;
90} 91}
91 92
92static inline void bla_free(struct bat_priv *bat_priv) 93static inline void batadv_bla_free(struct bat_priv *bat_priv)
93{ 94{
94} 95}
95 96
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 47f7186dcefc..0d90fffd9efb 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner 3 * Marek Lindner
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -33,7 +31,8 @@
33#include <linux/if_vlan.h> 31#include <linux/if_vlan.h>
34 32
35/* 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
36 * the beginning of the dhcp header */ 34 * the beginning of the dhcp header
35 */
37#define DHCP_OPTIONS_OFFSET 240 36#define DHCP_OPTIONS_OFFSET 240
38#define DHCP_REQUEST 3 37#define DHCP_REQUEST 3
39 38
@@ -60,7 +59,7 @@ out:
60 return gw_node; 59 return gw_node;
61} 60}
62 61
63struct orig_node *gw_get_selected_orig(struct bat_priv *bat_priv) 62struct orig_node *batadv_gw_get_selected_orig(struct bat_priv *bat_priv)
64{ 63{
65 struct gw_node *gw_node; 64 struct gw_node *gw_node;
66 struct orig_node *orig_node = NULL; 65 struct orig_node *orig_node = NULL;
@@ -103,7 +102,7 @@ static void gw_select(struct bat_priv *bat_priv, struct gw_node *new_gw_node)
103 spin_unlock_bh(&bat_priv->gw_list_lock); 102 spin_unlock_bh(&bat_priv->gw_list_lock);
104} 103}
105 104
106void gw_deselect(struct bat_priv *bat_priv) 105void batadv_gw_deselect(struct bat_priv *bat_priv)
107{ 106{
108 atomic_set(&bat_priv->gw_reselect, 1); 107 atomic_set(&bat_priv->gw_reselect, 1);
109} 108}
@@ -116,13 +115,15 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv)
116 uint32_t max_gw_factor = 0, tmp_gw_factor = 0; 115 uint32_t max_gw_factor = 0, tmp_gw_factor = 0;
117 uint8_t max_tq = 0; 116 uint8_t max_tq = 0;
118 int down, up; 117 int down, up;
118 struct orig_node *orig_node;
119 119
120 rcu_read_lock(); 120 rcu_read_lock();
121 hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) { 121 hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) {
122 if (gw_node->deleted) 122 if (gw_node->deleted)
123 continue; 123 continue;
124 124
125 router = orig_node_get_router(gw_node->orig_node); 125 orig_node = gw_node->orig_node;
126 router = batadv_orig_node_get_router(orig_node);
126 if (!router) 127 if (!router)
127 continue; 128 continue;
128 129
@@ -131,8 +132,8 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv)
131 132
132 switch (atomic_read(&bat_priv->gw_sel_class)) { 133 switch (atomic_read(&bat_priv->gw_sel_class)) {
133 case 1: /* fast connection */ 134 case 1: /* fast connection */
134 gw_bandwidth_to_kbit(gw_node->orig_node->gw_flags, 135 batadv_gw_bandwidth_to_kbit(orig_node->gw_flags,
135 &down, &up); 136 &down, &up);
136 137
137 tmp_gw_factor = (router->tq_avg * router->tq_avg * 138 tmp_gw_factor = (router->tq_avg * router->tq_avg *
138 down * 100 * 100) / 139 down * 100 * 100) /
@@ -149,14 +150,13 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv)
149 } 150 }
150 break; 151 break;
151 152
152 default: /** 153 default: /* 2: stable connection (use best statistic)
153 * 2: stable connection (use best statistic)
154 * 3: fast-switch (use best statistic but change as 154 * 3: fast-switch (use best statistic but change as
155 * soon as a better gateway appears) 155 * soon as a better gateway appears)
156 * XX: late-switch (use best statistic but change as 156 * XX: late-switch (use best statistic but change as
157 * soon as a better gateway appears which has 157 * soon as a better gateway appears which has
158 * $routing_class more tq points) 158 * $routing_class more tq points)
159 **/ 159 */
160 if (router->tq_avg > max_tq) { 160 if (router->tq_avg > max_tq) {
161 if (curr_gw) 161 if (curr_gw)
162 gw_node_free_ref(curr_gw); 162 gw_node_free_ref(curr_gw);
@@ -175,25 +175,24 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv)
175 gw_node_free_ref(gw_node); 175 gw_node_free_ref(gw_node);
176 176
177next: 177next:
178 neigh_node_free_ref(router); 178 batadv_neigh_node_free_ref(router);
179 } 179 }
180 rcu_read_unlock(); 180 rcu_read_unlock();
181 181
182 return curr_gw; 182 return curr_gw;
183} 183}
184 184
185void gw_election(struct bat_priv *bat_priv) 185void batadv_gw_election(struct bat_priv *bat_priv)
186{ 186{
187 struct gw_node *curr_gw = NULL, *next_gw = NULL; 187 struct gw_node *curr_gw = NULL, *next_gw = NULL;
188 struct neigh_node *router = NULL; 188 struct neigh_node *router = NULL;
189 char gw_addr[18] = { '\0' }; 189 char gw_addr[18] = { '\0' };
190 190
191 /** 191 /* The batman daemon checks here if we already passed a full originator
192 * The batman daemon checks here if we already passed a full originator
193 * cycle in order to make sure we don't choose the first gateway we 192 * cycle in order to make sure we don't choose the first gateway we
194 * hear about. This check is based on the daemon's uptime which we 193 * hear about. This check is based on the daemon's uptime which we
195 * don't have. 194 * don't have.
196 **/ 195 */
197 if (atomic_read(&bat_priv->gw_mode) != GW_MODE_CLIENT) 196 if (atomic_read(&bat_priv->gw_mode) != GW_MODE_CLIENT)
198 goto out; 197 goto out;
199 198
@@ -210,9 +209,9 @@ void gw_election(struct bat_priv *bat_priv)
210 if (next_gw) { 209 if (next_gw) {
211 sprintf(gw_addr, "%pM", next_gw->orig_node->orig); 210 sprintf(gw_addr, "%pM", next_gw->orig_node->orig);
212 211
213 router = orig_node_get_router(next_gw->orig_node); 212 router = batadv_orig_node_get_router(next_gw->orig_node);
214 if (!router) { 213 if (!router) {
215 gw_deselect(bat_priv); 214 batadv_gw_deselect(bat_priv);
216 goto out; 215 goto out;
217 } 216 }
218 } 217 }
@@ -220,19 +219,19 @@ void gw_election(struct bat_priv *bat_priv)
220 if ((curr_gw) && (!next_gw)) { 219 if ((curr_gw) && (!next_gw)) {
221 bat_dbg(DBG_BATMAN, bat_priv, 220 bat_dbg(DBG_BATMAN, bat_priv,
222 "Removing selected gateway - no gateway in range\n"); 221 "Removing selected gateway - no gateway in range\n");
223 throw_uevent(bat_priv, UEV_GW, UEV_DEL, NULL); 222 batadv_throw_uevent(bat_priv, UEV_GW, UEV_DEL, NULL);
224 } else if ((!curr_gw) && (next_gw)) { 223 } else if ((!curr_gw) && (next_gw)) {
225 bat_dbg(DBG_BATMAN, bat_priv, 224 bat_dbg(DBG_BATMAN, bat_priv,
226 "Adding route to gateway %pM (gw_flags: %i, tq: %i)\n", 225 "Adding route to gateway %pM (gw_flags: %i, tq: %i)\n",
227 next_gw->orig_node->orig, next_gw->orig_node->gw_flags, 226 next_gw->orig_node->orig, next_gw->orig_node->gw_flags,
228 router->tq_avg); 227 router->tq_avg);
229 throw_uevent(bat_priv, UEV_GW, UEV_ADD, gw_addr); 228 batadv_throw_uevent(bat_priv, UEV_GW, UEV_ADD, gw_addr);
230 } else { 229 } else {
231 bat_dbg(DBG_BATMAN, bat_priv, 230 bat_dbg(DBG_BATMAN, bat_priv,
232 "Changing route to gateway %pM (gw_flags: %i, tq: %i)\n", 231 "Changing route to gateway %pM (gw_flags: %i, tq: %i)\n",
233 next_gw->orig_node->orig, next_gw->orig_node->gw_flags, 232 next_gw->orig_node->orig, next_gw->orig_node->gw_flags,
234 router->tq_avg); 233 router->tq_avg);
235 throw_uevent(bat_priv, UEV_GW, UEV_CHANGE, gw_addr); 234 batadv_throw_uevent(bat_priv, UEV_GW, UEV_CHANGE, gw_addr);
236 } 235 }
237 236
238 gw_select(bat_priv, next_gw); 237 gw_select(bat_priv, next_gw);
@@ -243,20 +242,21 @@ out:
243 if (next_gw) 242 if (next_gw)
244 gw_node_free_ref(next_gw); 243 gw_node_free_ref(next_gw);
245 if (router) 244 if (router)
246 neigh_node_free_ref(router); 245 batadv_neigh_node_free_ref(router);
247} 246}
248 247
249void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node) 248void batadv_gw_check_election(struct bat_priv *bat_priv,
249 struct orig_node *orig_node)
250{ 250{
251 struct orig_node *curr_gw_orig; 251 struct orig_node *curr_gw_orig;
252 struct neigh_node *router_gw = NULL, *router_orig = NULL; 252 struct neigh_node *router_gw = NULL, *router_orig = NULL;
253 uint8_t gw_tq_avg, orig_tq_avg; 253 uint8_t gw_tq_avg, orig_tq_avg;
254 254
255 curr_gw_orig = gw_get_selected_orig(bat_priv); 255 curr_gw_orig = batadv_gw_get_selected_orig(bat_priv);
256 if (!curr_gw_orig) 256 if (!curr_gw_orig)
257 goto deselect; 257 goto deselect;
258 258
259 router_gw = orig_node_get_router(curr_gw_orig); 259 router_gw = batadv_orig_node_get_router(curr_gw_orig);
260 if (!router_gw) 260 if (!router_gw)
261 goto deselect; 261 goto deselect;
262 262
@@ -264,7 +264,7 @@ void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node)
264 if (curr_gw_orig == orig_node) 264 if (curr_gw_orig == orig_node)
265 goto out; 265 goto out;
266 266
267 router_orig = orig_node_get_router(orig_node); 267 router_orig = batadv_orig_node_get_router(orig_node);
268 if (!router_orig) 268 if (!router_orig)
269 goto out; 269 goto out;
270 270
@@ -275,10 +275,9 @@ void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node)
275 if (orig_tq_avg < gw_tq_avg) 275 if (orig_tq_avg < gw_tq_avg)
276 goto out; 276 goto out;
277 277
278 /** 278 /* if the routing class is greater than 3 the value tells us how much
279 * if the routing class is greater than 3 the value tells us how much
280 * greater the TQ value of the new gateway must be 279 * greater the TQ value of the new gateway must be
281 **/ 280 */
282 if ((atomic_read(&bat_priv->gw_sel_class) > 3) && 281 if ((atomic_read(&bat_priv->gw_sel_class) > 3) &&
283 (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_sel_class))) 282 (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_sel_class)))
284 goto out; 283 goto out;
@@ -288,14 +287,14 @@ void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node)
288 gw_tq_avg, orig_tq_avg); 287 gw_tq_avg, orig_tq_avg);
289 288
290deselect: 289deselect:
291 gw_deselect(bat_priv); 290 batadv_gw_deselect(bat_priv);
292out: 291out:
293 if (curr_gw_orig) 292 if (curr_gw_orig)
294 orig_node_free_ref(curr_gw_orig); 293 batadv_orig_node_free_ref(curr_gw_orig);
295 if (router_gw) 294 if (router_gw)
296 neigh_node_free_ref(router_gw); 295 batadv_neigh_node_free_ref(router_gw);
297 if (router_orig) 296 if (router_orig)
298 neigh_node_free_ref(router_orig); 297 batadv_neigh_node_free_ref(router_orig);
299 298
300 return; 299 return;
301} 300}
@@ -318,7 +317,7 @@ static void gw_node_add(struct bat_priv *bat_priv,
318 hlist_add_head_rcu(&gw_node->list, &bat_priv->gw_list); 317 hlist_add_head_rcu(&gw_node->list, &bat_priv->gw_list);
319 spin_unlock_bh(&bat_priv->gw_list_lock); 318 spin_unlock_bh(&bat_priv->gw_list_lock);
320 319
321 gw_bandwidth_to_kbit(new_gwflags, &down, &up); 320 batadv_gw_bandwidth_to_kbit(new_gwflags, &down, &up);
322 bat_dbg(DBG_BATMAN, bat_priv, 321 bat_dbg(DBG_BATMAN, bat_priv,
323 "Found new gateway %pM -> gw_class: %i - %i%s/%i%s\n", 322 "Found new gateway %pM -> gw_class: %i - %i%s/%i%s\n",
324 orig_node->orig, new_gwflags, 323 orig_node->orig, new_gwflags,
@@ -328,14 +327,13 @@ static void gw_node_add(struct bat_priv *bat_priv,
328 (up > 2048 ? "MBit" : "KBit")); 327 (up > 2048 ? "MBit" : "KBit"));
329} 328}
330 329
331void gw_node_update(struct bat_priv *bat_priv, 330void batadv_gw_node_update(struct bat_priv *bat_priv,
332 struct orig_node *orig_node, uint8_t new_gwflags) 331 struct orig_node *orig_node, uint8_t new_gwflags)
333{ 332{
334 struct hlist_node *node; 333 struct hlist_node *node;
335 struct gw_node *gw_node, *curr_gw; 334 struct gw_node *gw_node, *curr_gw;
336 335
337 /** 336 /* Note: We don't need a NULL check here, since curr_gw never gets
338 * Note: We don't need a NULL check here, since curr_gw never gets
339 * dereferenced. If curr_gw is NULL we also should not exit as we may 337 * dereferenced. If curr_gw is NULL we also should not exit as we may
340 * have this gateway in our list (duplication check!) even though we 338 * have this gateway in our list (duplication check!) even though we
341 * have no currently selected gateway. 339 * have no currently selected gateway.
@@ -374,7 +372,7 @@ void gw_node_update(struct bat_priv *bat_priv,
374 goto unlock; 372 goto unlock;
375 373
376deselect: 374deselect:
377 gw_deselect(bat_priv); 375 batadv_gw_deselect(bat_priv);
378unlock: 376unlock:
379 rcu_read_unlock(); 377 rcu_read_unlock();
380 378
@@ -382,12 +380,13 @@ unlock:
382 gw_node_free_ref(curr_gw); 380 gw_node_free_ref(curr_gw);
383} 381}
384 382
385void gw_node_delete(struct bat_priv *bat_priv, struct orig_node *orig_node) 383void batadv_gw_node_delete(struct bat_priv *bat_priv,
384 struct orig_node *orig_node)
386{ 385{
387 gw_node_update(bat_priv, orig_node, 0); 386 batadv_gw_node_update(bat_priv, orig_node, 0);
388} 387}
389 388
390void gw_node_purge(struct bat_priv *bat_priv) 389void batadv_gw_node_purge(struct bat_priv *bat_priv)
391{ 390{
392 struct gw_node *gw_node, *curr_gw; 391 struct gw_node *gw_node, *curr_gw;
393 struct hlist_node *node, *node_tmp; 392 struct hlist_node *node, *node_tmp;
@@ -416,15 +415,13 @@ void gw_node_purge(struct bat_priv *bat_priv)
416 415
417 /* gw_deselect() needs to acquire the gw_list_lock */ 416 /* gw_deselect() needs to acquire the gw_list_lock */
418 if (do_deselect) 417 if (do_deselect)
419 gw_deselect(bat_priv); 418 batadv_gw_deselect(bat_priv);
420 419
421 if (curr_gw) 420 if (curr_gw)
422 gw_node_free_ref(curr_gw); 421 gw_node_free_ref(curr_gw);
423} 422}
424 423
425/** 424/* fails if orig_node has no router */
426 * fails if orig_node has no router
427 */
428static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq, 425static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq,
429 const struct gw_node *gw_node) 426 const struct gw_node *gw_node)
430{ 427{
@@ -432,9 +429,9 @@ static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq,
432 struct neigh_node *router; 429 struct neigh_node *router;
433 int down, up, ret = -1; 430 int down, up, ret = -1;
434 431
435 gw_bandwidth_to_kbit(gw_node->orig_node->gw_flags, &down, &up); 432 batadv_gw_bandwidth_to_kbit(gw_node->orig_node->gw_flags, &down, &up);
436 433
437 router = orig_node_get_router(gw_node->orig_node); 434 router = batadv_orig_node_get_router(gw_node->orig_node);
438 if (!router) 435 if (!router)
439 goto out; 436 goto out;
440 437
@@ -451,14 +448,14 @@ static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq,
451 (up > 2048 ? up / 1024 : up), 448 (up > 2048 ? up / 1024 : up),
452 (up > 2048 ? "MBit" : "KBit")); 449 (up > 2048 ? "MBit" : "KBit"));
453 450
454 neigh_node_free_ref(router); 451 batadv_neigh_node_free_ref(router);
455 if (curr_gw) 452 if (curr_gw)
456 gw_node_free_ref(curr_gw); 453 gw_node_free_ref(curr_gw);
457out: 454out:
458 return ret; 455 return ret;
459} 456}
460 457
461int gw_client_seq_print_text(struct seq_file *seq, void *offset) 458int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
462{ 459{
463 struct net_device *net_dev = (struct net_device *)seq->private; 460 struct net_device *net_dev = (struct net_device *)seq->private;
464 struct bat_priv *bat_priv = netdev_priv(net_dev); 461 struct bat_priv *bat_priv = netdev_priv(net_dev);
@@ -530,12 +527,14 @@ static bool is_type_dhcprequest(struct sk_buff *skb, int header_len)
530 /* Access the dhcp option lists. Each entry is made up by: 527 /* Access the dhcp option lists. Each entry is made up by:
531 * - octet 1: option type 528 * - octet 1: option type
532 * - octet 2: option data len (only if type != 255 and 0) 529 * - octet 2: option data len (only if type != 255 and 0)
533 * - octet 3: option data */ 530 * - octet 3: option data
531 */
534 while (*p != 255 && !ret) { 532 while (*p != 255 && !ret) {
535 /* p now points to the first octet: option type */ 533 /* p now points to the first octet: option type */
536 if (*p == 53) { 534 if (*p == 53) {
537 /* type 53 is the message type option. 535 /* type 53 is the message type option.
538 * Jump the len octet and go to the data octet */ 536 * Jump the len octet and go to the data octet
537 */
539 if (pkt_len < 2) 538 if (pkt_len < 2)
540 goto out; 539 goto out;
541 p += 2; 540 p += 2;
@@ -568,7 +567,7 @@ out:
568 return ret; 567 return ret;
569} 568}
570 569
571bool gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len) 570bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
572{ 571{
573 struct ethhdr *ethhdr; 572 struct ethhdr *ethhdr;
574 struct iphdr *iphdr; 573 struct iphdr *iphdr;
@@ -634,8 +633,8 @@ bool gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
634 return true; 633 return true;
635} 634}
636 635
637bool gw_out_of_range(struct bat_priv *bat_priv, 636bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
638 struct sk_buff *skb, struct ethhdr *ethhdr) 637 struct sk_buff *skb, struct ethhdr *ethhdr)
639{ 638{
640 struct neigh_node *neigh_curr = NULL, *neigh_old = NULL; 639 struct neigh_node *neigh_curr = NULL, *neigh_old = NULL;
641 struct orig_node *orig_dst_node = NULL; 640 struct orig_node *orig_dst_node = NULL;
@@ -644,12 +643,12 @@ bool gw_out_of_range(struct bat_priv *bat_priv,
644 unsigned int header_len = 0; 643 unsigned int header_len = 0;
645 uint8_t curr_tq_avg; 644 uint8_t curr_tq_avg;
646 645
647 ret = gw_is_dhcp_target(skb, &header_len); 646 ret = batadv_gw_is_dhcp_target(skb, &header_len);
648 if (!ret) 647 if (!ret)
649 goto out; 648 goto out;
650 649
651 orig_dst_node = transtable_search(bat_priv, ethhdr->h_source, 650 orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
652 ethhdr->h_dest); 651 ethhdr->h_dest);
653 if (!orig_dst_node) 652 if (!orig_dst_node)
654 goto out; 653 goto out;
655 654
@@ -663,7 +662,8 @@ bool gw_out_of_range(struct bat_priv *bat_priv,
663 switch (atomic_read(&bat_priv->gw_mode)) { 662 switch (atomic_read(&bat_priv->gw_mode)) {
664 case GW_MODE_SERVER: 663 case GW_MODE_SERVER:
665 /* If we are a GW then we are our best GW. We can artificially 664 /* If we are a GW then we are our best GW. We can artificially
666 * set the tq towards ourself as the maximum value */ 665 * set the tq towards ourself as the maximum value
666 */
667 curr_tq_avg = TQ_MAX_VALUE; 667 curr_tq_avg = TQ_MAX_VALUE;
668 break; 668 break;
669 case GW_MODE_CLIENT: 669 case GW_MODE_CLIENT:
@@ -677,8 +677,10 @@ bool gw_out_of_range(struct bat_priv *bat_priv,
677 677
678 /* If the dhcp packet has been sent to a different gw, 678 /* If the dhcp packet has been sent to a different gw,
679 * we have to evaluate whether the old gw is still 679 * we have to evaluate whether the old gw is still
680 * reliable enough */ 680 * reliable enough
681 neigh_curr = find_router(bat_priv, curr_gw->orig_node, NULL); 681 */
682 neigh_curr = batadv_find_router(bat_priv, curr_gw->orig_node,
683 NULL);
682 if (!neigh_curr) 684 if (!neigh_curr)
683 goto out; 685 goto out;
684 686
@@ -689,7 +691,7 @@ bool gw_out_of_range(struct bat_priv *bat_priv,
689 goto out; 691 goto out;
690 } 692 }
691 693
692 neigh_old = find_router(bat_priv, orig_dst_node, NULL); 694 neigh_old = batadv_find_router(bat_priv, orig_dst_node, NULL);
693 if (!neigh_old) 695 if (!neigh_old)
694 goto out; 696 goto out;
695 697
@@ -698,12 +700,12 @@ bool gw_out_of_range(struct bat_priv *bat_priv,
698 700
699out: 701out:
700 if (orig_dst_node) 702 if (orig_dst_node)
701 orig_node_free_ref(orig_dst_node); 703 batadv_orig_node_free_ref(orig_dst_node);
702 if (curr_gw) 704 if (curr_gw)
703 gw_node_free_ref(curr_gw); 705 gw_node_free_ref(curr_gw);
704 if (neigh_old) 706 if (neigh_old)
705 neigh_node_free_ref(neigh_old); 707 batadv_neigh_node_free_ref(neigh_old);
706 if (neigh_curr) 708 if (neigh_curr)
707 neigh_node_free_ref(neigh_curr); 709 batadv_neigh_node_free_ref(neigh_curr);
708 return out_of_range; 710 return out_of_range;
709} 711}
diff --git a/net/batman-adv/gateway_client.h b/net/batman-adv/gateway_client.h
index bf56a5aea10b..4529d42894ef 100644
--- a/net/batman-adv/gateway_client.h
+++ b/net/batman-adv/gateway_client.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner 3 * Marek Lindner
5 * 4 *
@@ -16,23 +15,24 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ 20#ifndef _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
23#define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ 21#define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
24 22
25void gw_deselect(struct bat_priv *bat_priv); 23void batadv_gw_deselect(struct bat_priv *bat_priv);
26void gw_election(struct bat_priv *bat_priv); 24void batadv_gw_election(struct bat_priv *bat_priv);
27struct orig_node *gw_get_selected_orig(struct bat_priv *bat_priv); 25struct orig_node *batadv_gw_get_selected_orig(struct bat_priv *bat_priv);
28void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node); 26void batadv_gw_check_election(struct bat_priv *bat_priv,
29void gw_node_update(struct bat_priv *bat_priv, 27 struct orig_node *orig_node);
30 struct orig_node *orig_node, uint8_t new_gwflags); 28void batadv_gw_node_update(struct bat_priv *bat_priv,
31void gw_node_delete(struct bat_priv *bat_priv, struct orig_node *orig_node); 29 struct orig_node *orig_node, uint8_t new_gwflags);
32void gw_node_purge(struct bat_priv *bat_priv); 30void batadv_gw_node_delete(struct bat_priv *bat_priv,
33int gw_client_seq_print_text(struct seq_file *seq, void *offset); 31 struct orig_node *orig_node);
34bool gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len); 32void batadv_gw_node_purge(struct bat_priv *bat_priv);
35bool gw_out_of_range(struct bat_priv *bat_priv, 33int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset);
36 struct sk_buff *skb, struct ethhdr *ethhdr); 34bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len);
35bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
36 struct sk_buff *skb, struct ethhdr *ethhdr);
37 37
38#endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */ 38#endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */
diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c
index 6e3b052b935d..3700562cf276 100644
--- a/net/batman-adv/gateway_common.c
+++ b/net/batman-adv/gateway_common.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner 3 * Marek Lindner
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -59,7 +57,7 @@ static void kbit_to_gw_bandwidth(int down, int up, long *gw_srv_class)
59} 57}
60 58
61/* returns the up and downspeeds in kbit, calculated from the class */ 59/* returns the up and downspeeds in kbit, calculated from the class */
62void gw_bandwidth_to_kbit(uint8_t gw_srv_class, int *down, int *up) 60void batadv_gw_bandwidth_to_kbit(uint8_t gw_srv_class, int *down, int *up)
63{ 61{
64 int sbit = (gw_srv_class & 0x80) >> 7; 62 int sbit = (gw_srv_class & 0x80) >> 7;
65 int dpart = (gw_srv_class & 0x78) >> 3; 63 int dpart = (gw_srv_class & 0x78) >> 3;
@@ -136,7 +134,8 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
136 return true; 134 return true;
137} 135}
138 136
139ssize_t gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count) 137ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
138 size_t count)
140{ 139{
141 struct bat_priv *bat_priv = netdev_priv(net_dev); 140 struct bat_priv *bat_priv = netdev_priv(net_dev);
142 long gw_bandwidth_tmp = 0; 141 long gw_bandwidth_tmp = 0;
@@ -155,17 +154,16 @@ ssize_t gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count)
155 154
156 kbit_to_gw_bandwidth(down, up, &gw_bandwidth_tmp); 155 kbit_to_gw_bandwidth(down, up, &gw_bandwidth_tmp);
157 156
158 /** 157 /* the gw bandwidth we guessed above might not match the given
159 * the gw bandwidth we guessed above might not match the given
160 * speeds, hence we need to calculate it back to show the number 158 * speeds, hence we need to calculate it back to show the number
161 * that is going to be propagated 159 * that is going to be propagated
162 **/ 160 */
163 gw_bandwidth_to_kbit((uint8_t)gw_bandwidth_tmp, &down, &up); 161 batadv_gw_bandwidth_to_kbit((uint8_t)gw_bandwidth_tmp, &down, &up);
164 162
165 if (atomic_read(&bat_priv->gw_bandwidth) == gw_bandwidth_tmp) 163 if (atomic_read(&bat_priv->gw_bandwidth) == gw_bandwidth_tmp)
166 return count; 164 return count;
167 165
168 gw_deselect(bat_priv); 166 batadv_gw_deselect(bat_priv);
169 bat_info(net_dev, 167 bat_info(net_dev,
170 "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",
171 atomic_read(&bat_priv->gw_bandwidth), gw_bandwidth_tmp, 169 atomic_read(&bat_priv->gw_bandwidth), gw_bandwidth_tmp,
diff --git a/net/batman-adv/gateway_common.h b/net/batman-adv/gateway_common.h
index b8fb11c4f927..6f8a4d0cbbb6 100644
--- a/net/batman-adv/gateway_common.h
+++ b/net/batman-adv/gateway_common.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner 3 * Marek Lindner
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_GATEWAY_COMMON_H_ 20#ifndef _NET_BATMAN_ADV_GATEWAY_COMMON_H_
@@ -32,7 +30,8 @@ enum gw_modes {
32#define GW_MODE_CLIENT_NAME "client" 30#define GW_MODE_CLIENT_NAME "client"
33#define GW_MODE_SERVER_NAME "server" 31#define GW_MODE_SERVER_NAME "server"
34 32
35void 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);
36ssize_t gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count); 34ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
35 size_t count);
37 36
38#endif /* _NET_BATMAN_ADV_GATEWAY_COMMON_H_ */ 37#endif /* _NET_BATMAN_ADV_GATEWAY_COMMON_H_ */
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index ce78c6d645c6..2a4d394771b8 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -32,7 +30,7 @@
32 30
33#include <linux/if_arp.h> 31#include <linux/if_arp.h>
34 32
35void hardif_free_rcu(struct rcu_head *rcu) 33void batadv_hardif_free_rcu(struct rcu_head *rcu)
36{ 34{
37 struct hard_iface *hard_iface; 35 struct hard_iface *hard_iface;
38 36
@@ -41,12 +39,12 @@ void hardif_free_rcu(struct rcu_head *rcu)
41 kfree(hard_iface); 39 kfree(hard_iface);
42} 40}
43 41
44struct hard_iface *hardif_get_by_netdev(const struct net_device *net_dev) 42struct hard_iface *batadv_hardif_get_by_netdev(const struct net_device *net_dev)
45{ 43{
46 struct hard_iface *hard_iface; 44 struct hard_iface *hard_iface;
47 45
48 rcu_read_lock(); 46 rcu_read_lock();
49 list_for_each_entry_rcu(hard_iface, &hardif_list, list) { 47 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
50 if (hard_iface->net_dev == net_dev && 48 if (hard_iface->net_dev == net_dev &&
51 atomic_inc_not_zero(&hard_iface->refcount)) 49 atomic_inc_not_zero(&hard_iface->refcount))
52 goto out; 50 goto out;
@@ -71,13 +69,9 @@ static int is_valid_iface(const struct net_device *net_dev)
71 return 0; 69 return 0;
72 70
73 /* no batman over batman */ 71 /* no batman over batman */
74 if (softif_is_valid(net_dev)) 72 if (batadv_softif_is_valid(net_dev))
75 return 0; 73 return 0;
76 74
77 /* Device is being bridged */
78 /* if (net_dev->priv_flags & IFF_BRIDGE_PORT)
79 return 0; */
80
81 return 1; 75 return 1;
82} 76}
83 77
@@ -86,7 +80,7 @@ static struct hard_iface *hardif_get_active(const struct net_device *soft_iface)
86 struct hard_iface *hard_iface; 80 struct hard_iface *hard_iface;
87 81
88 rcu_read_lock(); 82 rcu_read_lock();
89 list_for_each_entry_rcu(hard_iface, &hardif_list, list) { 83 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
90 if (hard_iface->soft_iface != soft_iface) 84 if (hard_iface->soft_iface != soft_iface)
91 continue; 85 continue;
92 86
@@ -118,7 +112,7 @@ static void primary_if_update_addr(struct bat_priv *bat_priv,
118 memcpy(vis_packet->sender_orig, 112 memcpy(vis_packet->sender_orig,
119 primary_if->net_dev->dev_addr, ETH_ALEN); 113 primary_if->net_dev->dev_addr, ETH_ALEN);
120 114
121 bla_update_orig_address(bat_priv, primary_if, oldif); 115 batadv_bla_update_orig_address(bat_priv, primary_if, oldif);
122out: 116out:
123 if (primary_if) 117 if (primary_if)
124 hardif_free_ref(primary_if); 118 hardif_free_ref(primary_if);
@@ -161,7 +155,7 @@ static void check_known_mac_addr(const struct net_device *net_dev)
161 const struct hard_iface *hard_iface; 155 const struct hard_iface *hard_iface;
162 156
163 rcu_read_lock(); 157 rcu_read_lock();
164 list_for_each_entry_rcu(hard_iface, &hardif_list, list) { 158 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
165 if ((hard_iface->if_status != IF_ACTIVE) && 159 if ((hard_iface->if_status != IF_ACTIVE) &&
166 (hard_iface->if_status != IF_TO_BE_ACTIVATED)) 160 (hard_iface->if_status != IF_TO_BE_ACTIVATED))
167 continue; 161 continue;
@@ -180,19 +174,20 @@ static void check_known_mac_addr(const struct net_device *net_dev)
180 rcu_read_unlock(); 174 rcu_read_unlock();
181} 175}
182 176
183int hardif_min_mtu(struct net_device *soft_iface) 177int batadv_hardif_min_mtu(struct net_device *soft_iface)
184{ 178{
185 const struct bat_priv *bat_priv = netdev_priv(soft_iface); 179 const struct bat_priv *bat_priv = netdev_priv(soft_iface);
186 const struct hard_iface *hard_iface; 180 const struct hard_iface *hard_iface;
187 /* allow big frames if all devices are capable to do so 181 /* allow big frames if all devices are capable to do so
188 * (have MTU > 1500 + BAT_HEADER_LEN) */ 182 * (have MTU > 1500 + BAT_HEADER_LEN)
183 */
189 int min_mtu = ETH_DATA_LEN; 184 int min_mtu = ETH_DATA_LEN;
190 185
191 if (atomic_read(&bat_priv->fragmentation)) 186 if (atomic_read(&bat_priv->fragmentation))
192 goto out; 187 goto out;
193 188
194 rcu_read_lock(); 189 rcu_read_lock();
195 list_for_each_entry_rcu(hard_iface, &hardif_list, list) { 190 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
196 if ((hard_iface->if_status != IF_ACTIVE) && 191 if ((hard_iface->if_status != IF_ACTIVE) &&
197 (hard_iface->if_status != IF_TO_BE_ACTIVATED)) 192 (hard_iface->if_status != IF_TO_BE_ACTIVATED))
198 continue; 193 continue;
@@ -209,11 +204,11 @@ out:
209} 204}
210 205
211/* adjusts the MTU if a new interface with a smaller MTU appeared. */ 206/* adjusts the MTU if a new interface with a smaller MTU appeared. */
212void update_min_mtu(struct net_device *soft_iface) 207void batadv_update_min_mtu(struct net_device *soft_iface)
213{ 208{
214 int min_mtu; 209 int min_mtu;
215 210
216 min_mtu = hardif_min_mtu(soft_iface); 211 min_mtu = batadv_hardif_min_mtu(soft_iface);
217 if (soft_iface->mtu != min_mtu) 212 if (soft_iface->mtu != min_mtu)
218 soft_iface->mtu = min_mtu; 213 soft_iface->mtu = min_mtu;
219} 214}
@@ -231,8 +226,7 @@ static void hardif_activate_interface(struct hard_iface *hard_iface)
231 bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface); 226 bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface);
232 hard_iface->if_status = IF_TO_BE_ACTIVATED; 227 hard_iface->if_status = IF_TO_BE_ACTIVATED;
233 228
234 /** 229 /* the first active interface becomes our primary interface or
235 * the first active interface becomes our primary interface or
236 * the next active interface after the old primary interface was removed 230 * the next active interface after the old primary interface was removed
237 */ 231 */
238 primary_if = primary_if_get_selected(bat_priv); 232 primary_if = primary_if_get_selected(bat_priv);
@@ -242,7 +236,7 @@ static void hardif_activate_interface(struct hard_iface *hard_iface)
242 bat_info(hard_iface->soft_iface, "Interface activated: %s\n", 236 bat_info(hard_iface->soft_iface, "Interface activated: %s\n",
243 hard_iface->net_dev->name); 237 hard_iface->net_dev->name);
244 238
245 update_min_mtu(hard_iface->soft_iface); 239 batadv_update_min_mtu(hard_iface->soft_iface);
246 240
247out: 241out:
248 if (primary_if) 242 if (primary_if)
@@ -260,11 +254,11 @@ static void hardif_deactivate_interface(struct hard_iface *hard_iface)
260 bat_info(hard_iface->soft_iface, "Interface deactivated: %s\n", 254 bat_info(hard_iface->soft_iface, "Interface deactivated: %s\n",
261 hard_iface->net_dev->name); 255 hard_iface->net_dev->name);
262 256
263 update_min_mtu(hard_iface->soft_iface); 257 batadv_update_min_mtu(hard_iface->soft_iface);
264} 258}
265 259
266int hardif_enable_interface(struct hard_iface *hard_iface, 260int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
267 const char *iface_name) 261 const char *iface_name)
268{ 262{
269 struct bat_priv *bat_priv; 263 struct bat_priv *bat_priv;
270 struct net_device *soft_iface; 264 struct net_device *soft_iface;
@@ -284,7 +278,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
284 soft_iface = dev_get_by_name(&init_net, iface_name); 278 soft_iface = dev_get_by_name(&init_net, iface_name);
285 279
286 if (!soft_iface) { 280 if (!soft_iface) {
287 soft_iface = softif_create(iface_name); 281 soft_iface = batadv_softif_create(iface_name);
288 282
289 if (!soft_iface) { 283 if (!soft_iface) {
290 ret = -ENOMEM; 284 ret = -ENOMEM;
@@ -295,7 +289,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
295 dev_hold(soft_iface); 289 dev_hold(soft_iface);
296 } 290 }
297 291
298 if (!softif_is_valid(soft_iface)) { 292 if (!batadv_softif_is_valid(soft_iface)) {
299 pr_err("Can't create batman mesh interface %s: already exists as regular interface\n", 293 pr_err("Can't create batman mesh interface %s: already exists as regular interface\n",
300 soft_iface->name); 294 soft_iface->name);
301 ret = -EINVAL; 295 ret = -EINVAL;
@@ -312,10 +306,10 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
312 hard_iface->if_num = bat_priv->num_ifaces; 306 hard_iface->if_num = bat_priv->num_ifaces;
313 bat_priv->num_ifaces++; 307 bat_priv->num_ifaces++;
314 hard_iface->if_status = IF_INACTIVE; 308 hard_iface->if_status = IF_INACTIVE;
315 orig_hash_add_if(hard_iface, bat_priv->num_ifaces); 309 batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces);
316 310
317 hard_iface->batman_adv_ptype.type = __constant_htons(ETH_P_BATMAN); 311 hard_iface->batman_adv_ptype.type = __constant_htons(ETH_P_BATMAN);
318 hard_iface->batman_adv_ptype.func = batman_skb_recv; 312 hard_iface->batman_adv_ptype.func = batadv_batman_skb_recv;
319 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev; 313 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
320 dev_add_pack(&hard_iface->batman_adv_ptype); 314 dev_add_pack(&hard_iface->batman_adv_ptype);
321 315
@@ -345,7 +339,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
345 hard_iface->net_dev->name); 339 hard_iface->net_dev->name);
346 340
347 /* begin scheduling originator messages on that interface */ 341 /* begin scheduling originator messages on that interface */
348 schedule_bat_ogm(hard_iface); 342 batadv_schedule_bat_ogm(hard_iface);
349 343
350out: 344out:
351 return 0; 345 return 0;
@@ -357,7 +351,7 @@ err:
357 return ret; 351 return ret;
358} 352}
359 353
360void hardif_disable_interface(struct hard_iface *hard_iface) 354void batadv_hardif_disable_interface(struct hard_iface *hard_iface)
361{ 355{
362 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 356 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
363 struct hard_iface *primary_if = NULL; 357 struct hard_iface *primary_if = NULL;
@@ -373,7 +367,7 @@ void hardif_disable_interface(struct hard_iface *hard_iface)
373 dev_remove_pack(&hard_iface->batman_adv_ptype); 367 dev_remove_pack(&hard_iface->batman_adv_ptype);
374 368
375 bat_priv->num_ifaces--; 369 bat_priv->num_ifaces--;
376 orig_hash_del_if(hard_iface, bat_priv->num_ifaces); 370 batadv_orig_hash_del_if(hard_iface, bat_priv->num_ifaces);
377 371
378 primary_if = primary_if_get_selected(bat_priv); 372 primary_if = primary_if_get_selected(bat_priv);
379 if (hard_iface == primary_if) { 373 if (hard_iface == primary_if) {
@@ -390,13 +384,13 @@ void hardif_disable_interface(struct hard_iface *hard_iface)
390 hard_iface->if_status = IF_NOT_IN_USE; 384 hard_iface->if_status = IF_NOT_IN_USE;
391 385
392 /* delete all references to this hard_iface */ 386 /* delete all references to this hard_iface */
393 purge_orig_ref(bat_priv); 387 batadv_purge_orig_ref(bat_priv);
394 purge_outstanding_packets(bat_priv, hard_iface); 388 batadv_purge_outstanding_packets(bat_priv, hard_iface);
395 dev_put(hard_iface->soft_iface); 389 dev_put(hard_iface->soft_iface);
396 390
397 /* nobody uses this interface anymore */ 391 /* nobody uses this interface anymore */
398 if (!bat_priv->num_ifaces) 392 if (!bat_priv->num_ifaces)
399 softif_destroy(hard_iface->soft_iface); 393 batadv_softif_destroy(hard_iface->soft_iface);
400 394
401 hard_iface->soft_iface = NULL; 395 hard_iface->soft_iface = NULL;
402 hardif_free_ref(hard_iface); 396 hardif_free_ref(hard_iface);
@@ -423,7 +417,7 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
423 if (!hard_iface) 417 if (!hard_iface)
424 goto release_dev; 418 goto release_dev;
425 419
426 ret = sysfs_add_hardif(&hard_iface->hardif_obj, net_dev); 420 ret = batadv_sysfs_add_hardif(&hard_iface->hardif_obj, net_dev);
427 if (ret) 421 if (ret)
428 goto free_if; 422 goto free_if;
429 423
@@ -436,10 +430,9 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
436 atomic_set(&hard_iface->refcount, 2); 430 atomic_set(&hard_iface->refcount, 2);
437 431
438 check_known_mac_addr(hard_iface->net_dev); 432 check_known_mac_addr(hard_iface->net_dev);
439 list_add_tail_rcu(&hard_iface->list, &hardif_list); 433 list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list);
440 434
441 /** 435 /* This can't be called via a bat_priv callback because
442 * This can't be called via a bat_priv callback because
443 * we have no bat_priv yet. 436 * we have no bat_priv yet.
444 */ 437 */
445 atomic_set(&hard_iface->seqno, 1); 438 atomic_set(&hard_iface->seqno, 1);
@@ -461,23 +454,23 @@ static void hardif_remove_interface(struct hard_iface *hard_iface)
461 454
462 /* first deactivate interface */ 455 /* first deactivate interface */
463 if (hard_iface->if_status != IF_NOT_IN_USE) 456 if (hard_iface->if_status != IF_NOT_IN_USE)
464 hardif_disable_interface(hard_iface); 457 batadv_hardif_disable_interface(hard_iface);
465 458
466 if (hard_iface->if_status != IF_NOT_IN_USE) 459 if (hard_iface->if_status != IF_NOT_IN_USE)
467 return; 460 return;
468 461
469 hard_iface->if_status = IF_TO_BE_REMOVED; 462 hard_iface->if_status = IF_TO_BE_REMOVED;
470 sysfs_del_hardif(&hard_iface->hardif_obj); 463 batadv_sysfs_del_hardif(&hard_iface->hardif_obj);
471 hardif_free_ref(hard_iface); 464 hardif_free_ref(hard_iface);
472} 465}
473 466
474void hardif_remove_interfaces(void) 467void batadv_hardif_remove_interfaces(void)
475{ 468{
476 struct hard_iface *hard_iface, *hard_iface_tmp; 469 struct hard_iface *hard_iface, *hard_iface_tmp;
477 470
478 rtnl_lock(); 471 rtnl_lock();
479 list_for_each_entry_safe(hard_iface, hard_iface_tmp, 472 list_for_each_entry_safe(hard_iface, hard_iface_tmp,
480 &hardif_list, list) { 473 &batadv_hardif_list, list) {
481 list_del_rcu(&hard_iface->list); 474 list_del_rcu(&hard_iface->list);
482 hardif_remove_interface(hard_iface); 475 hardif_remove_interface(hard_iface);
483 } 476 }
@@ -488,7 +481,7 @@ static int hard_if_event(struct notifier_block *this,
488 unsigned long event, void *ptr) 481 unsigned long event, void *ptr)
489{ 482{
490 struct net_device *net_dev = ptr; 483 struct net_device *net_dev = ptr;
491 struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev); 484 struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
492 struct hard_iface *primary_if = NULL; 485 struct hard_iface *primary_if = NULL;
493 struct bat_priv *bat_priv; 486 struct bat_priv *bat_priv;
494 487
@@ -513,7 +506,7 @@ static int hard_if_event(struct notifier_block *this,
513 break; 506 break;
514 case NETDEV_CHANGEMTU: 507 case NETDEV_CHANGEMTU:
515 if (hard_iface->soft_iface) 508 if (hard_iface->soft_iface)
516 update_min_mtu(hard_iface->soft_iface); 509 batadv_update_min_mtu(hard_iface->soft_iface);
517 break; 510 break;
518 case NETDEV_CHANGEADDR: 511 case NETDEV_CHANGEADDR:
519 if (hard_iface->if_status == IF_NOT_IN_USE) 512 if (hard_iface->if_status == IF_NOT_IN_USE)
@@ -544,8 +537,9 @@ out:
544} 537}
545 538
546/* This function returns true if the interface represented by ifindex is a 539/* This function returns true if the interface represented by ifindex is a
547 * 802.11 wireless device */ 540 * 802.11 wireless device
548bool is_wifi_iface(int ifindex) 541 */
542bool batadv_is_wifi_iface(int ifindex)
549{ 543{
550 struct net_device *net_device = NULL; 544 struct net_device *net_device = NULL;
551 bool ret = false; 545 bool ret = false;
@@ -559,7 +553,8 @@ bool is_wifi_iface(int ifindex)
559 553
560#ifdef CONFIG_WIRELESS_EXT 554#ifdef CONFIG_WIRELESS_EXT
561 /* pre-cfg80211 drivers have to implement WEXT, so it is possible to 555 /* pre-cfg80211 drivers have to implement WEXT, so it is possible to
562 * check for wireless_handlers != NULL */ 556 * check for wireless_handlers != NULL
557 */
563 if (net_device->wireless_handlers) 558 if (net_device->wireless_handlers)
564 ret = true; 559 ret = true;
565 else 560 else
@@ -573,6 +568,6 @@ out:
573 return ret; 568 return ret;
574} 569}
575 570
576struct notifier_block hard_if_notifier = { 571struct notifier_block batadv_hard_if_notifier = {
577 .notifier_call = hard_if_event, 572 .notifier_call = hard_if_event,
578}; 573};
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index e68c5655e616..6bc12c0eb2f0 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_ 20#ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_
@@ -31,23 +29,23 @@ enum hard_if_state {
31 IF_I_WANT_YOU 29 IF_I_WANT_YOU
32}; 30};
33 31
34extern struct notifier_block hard_if_notifier; 32extern struct notifier_block batadv_hard_if_notifier;
35 33
36struct hard_iface* 34struct hard_iface*
37hardif_get_by_netdev(const struct net_device *net_dev); 35batadv_hardif_get_by_netdev(const struct net_device *net_dev);
38int hardif_enable_interface(struct hard_iface *hard_iface, 36int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
39 const char *iface_name); 37 const char *iface_name);
40void hardif_disable_interface(struct hard_iface *hard_iface); 38void batadv_hardif_disable_interface(struct hard_iface *hard_iface);
41void hardif_remove_interfaces(void); 39void batadv_hardif_remove_interfaces(void);
42int hardif_min_mtu(struct net_device *soft_iface); 40int batadv_hardif_min_mtu(struct net_device *soft_iface);
43void update_min_mtu(struct net_device *soft_iface); 41void batadv_update_min_mtu(struct net_device *soft_iface);
44void hardif_free_rcu(struct rcu_head *rcu); 42void batadv_hardif_free_rcu(struct rcu_head *rcu);
45bool is_wifi_iface(int ifindex); 43bool batadv_is_wifi_iface(int ifindex);
46 44
47static inline void hardif_free_ref(struct hard_iface *hard_iface) 45static inline void hardif_free_ref(struct hard_iface *hard_iface)
48{ 46{
49 if (atomic_dec_and_test(&hard_iface->refcount)) 47 if (atomic_dec_and_test(&hard_iface->refcount))
50 call_rcu(&hard_iface->rcu, hardif_free_rcu); 48 call_rcu(&hard_iface->rcu, batadv_hardif_free_rcu);
51} 49}
52 50
53static inline struct hard_iface *primary_if_get_selected( 51static inline struct hard_iface *primary_if_get_selected(
diff --git a/net/batman-adv/hash.c b/net/batman-adv/hash.c
index 5b2eabe7c4e0..e39f8f4bb165 100644
--- a/net/batman-adv/hash.c
+++ b/net/batman-adv/hash.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Simon Wunderlich, Marek Lindner 3 * Simon Wunderlich, Marek Lindner
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -34,7 +32,7 @@ static void hash_init(struct hashtable_t *hash)
34} 32}
35 33
36/* free only the hashtable and the hash itself. */ 34/* free only the hashtable and the hash itself. */
37void hash_destroy(struct hashtable_t *hash) 35void batadv_hash_destroy(struct hashtable_t *hash)
38{ 36{
39 kfree(hash->list_locks); 37 kfree(hash->list_locks);
40 kfree(hash->table); 38 kfree(hash->table);
@@ -42,7 +40,7 @@ void hash_destroy(struct hashtable_t *hash)
42} 40}
43 41
44/* allocates and clears the hash */ 42/* allocates and clears the hash */
45struct hashtable_t *hash_new(uint32_t size) 43struct hashtable_t *batadv_hash_new(uint32_t size)
46{ 44{
47 struct hashtable_t *hash; 45 struct hashtable_t *hash;
48 46
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h
index 3d67ce49fc31..eba8f2a55ccc 100644
--- a/net/batman-adv/hash.h
+++ b/net/batman-adv/hash.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Simon Wunderlich, Marek Lindner 3 * Simon Wunderlich, Marek Lindner
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_HASH_H_ 20#ifndef _NET_BATMAN_ADV_HASH_H_
@@ -24,15 +22,15 @@
24 22
25#include <linux/list.h> 23#include <linux/list.h>
26 24
27/* callback to a compare function. should 25/* callback to a compare function. should compare 2 element datas for their
28 * compare 2 element datas for their keys, 26 * keys, return 0 if same and not 0 if not same
29 * return 0 if same and not 0 if not 27 */
30 * same */
31typedef int (*hashdata_compare_cb)(const struct hlist_node *, const void *); 28typedef int (*hashdata_compare_cb)(const struct hlist_node *, const void *);
32 29
33/* the hashfunction, should return an index 30/* the hashfunction, should return an index
34 * based on the key in the data of the first 31 * based on the key in the data of the first
35 * argument and the size the second */ 32 * argument and the size the second
33 */
36typedef uint32_t (*hashdata_choose_cb)(const void *, uint32_t); 34typedef uint32_t (*hashdata_choose_cb)(const void *, uint32_t);
37typedef void (*hashdata_free_cb)(struct hlist_node *, void *); 35typedef void (*hashdata_free_cb)(struct hlist_node *, void *);
38 36
@@ -43,18 +41,19 @@ struct hashtable_t {
43}; 41};
44 42
45/* allocates and clears the hash */ 43/* allocates and clears the hash */
46struct hashtable_t *hash_new(uint32_t size); 44struct hashtable_t *batadv_hash_new(uint32_t size);
47 45
48/* set class key for all locks */ 46/* set class key for all locks */
49void batadv_hash_set_lock_class(struct hashtable_t *hash, 47void batadv_hash_set_lock_class(struct hashtable_t *hash,
50 struct lock_class_key *key); 48 struct lock_class_key *key);
51 49
52/* free only the hashtable and the hash itself. */ 50/* free only the hashtable and the hash itself. */
53void hash_destroy(struct hashtable_t *hash); 51void batadv_hash_destroy(struct hashtable_t *hash);
54 52
55/* remove the hash structure. if hashdata_free_cb != NULL, this function will be 53/* remove the hash structure. if hashdata_free_cb != NULL, this function will be
56 * called to remove the elements inside of the hash. if you don't remove the 54 * called to remove the elements inside of the hash. if you don't remove the
57 * elements, memory might be leaked. */ 55 * elements, memory might be leaked.
56 */
58static inline void hash_delete(struct hashtable_t *hash, 57static inline void hash_delete(struct hashtable_t *hash,
59 hashdata_free_cb free_cb, void *arg) 58 hashdata_free_cb free_cb, void *arg)
60{ 59{
@@ -77,11 +76,10 @@ static inline void hash_delete(struct hashtable_t *hash,
77 spin_unlock_bh(list_lock); 76 spin_unlock_bh(list_lock);
78 } 77 }
79 78
80 hash_destroy(hash); 79 batadv_hash_destroy(hash);
81} 80}
82 81
83/** 82/* hash_add - adds data to the hashtable
84 * hash_add - adds data to the hashtable
85 * @hash: storage hash table 83 * @hash: storage hash table
86 * @compare: callback to determine if 2 hash elements are identical 84 * @compare: callback to determine if 2 hash elements are identical
87 * @choose: callback calculating the hash index 85 * @choose: callback calculating the hash index
@@ -91,7 +89,6 @@ static inline void hash_delete(struct hashtable_t *hash,
91 * Returns 0 on success, 1 if the element already is in the hash 89 * Returns 0 on success, 1 if the element already is in the hash
92 * and -1 on error. 90 * and -1 on error.
93 */ 91 */
94
95static inline int hash_add(struct hashtable_t *hash, 92static inline int hash_add(struct hashtable_t *hash,
96 hashdata_compare_cb compare, 93 hashdata_compare_cb compare,
97 hashdata_choose_cb choose, 94 hashdata_choose_cb choose,
@@ -134,7 +131,8 @@ out:
134/* removes data from hash, if found. returns pointer do data on success, so you 131/* removes data from hash, if found. returns pointer do data on success, so you
135 * can remove the used structure yourself, or NULL on error . data could be the 132 * can remove the used structure yourself, or NULL on error . data could be the
136 * structure you use with just the key filled, we just need the key for 133 * structure you use with just the key filled, we just need the key for
137 * comparing. */ 134 * comparing.
135 */
138static inline void *hash_remove(struct hashtable_t *hash, 136static inline void *hash_remove(struct hashtable_t *hash,
139 hashdata_compare_cb compare, 137 hashdata_compare_cb compare,
140 hashdata_choose_cb choose, void *data) 138 hashdata_choose_cb choose, void *data)
diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c
index d27db8192e93..40c5e189e6fd 100644
--- a/net/batman-adv/icmp_socket.c
+++ b/net/batman-adv/icmp_socket.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner 3 * Marek Lindner
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -34,7 +32,7 @@ static void bat_socket_add_packet(struct socket_client *socket_client,
34 struct icmp_packet_rr *icmp_packet, 32 struct icmp_packet_rr *icmp_packet,
35 size_t icmp_len); 33 size_t icmp_len);
36 34
37void bat_socket_init(void) 35void batadv_socket_init(void)
38{ 36{
39 memset(socket_client_hash, 0, sizeof(socket_client_hash)); 37 memset(socket_client_hash, 0, sizeof(socket_client_hash));
40} 38}
@@ -73,7 +71,7 @@ static int bat_socket_open(struct inode *inode, struct file *file)
73 71
74 file->private_data = socket_client; 72 file->private_data = socket_client;
75 73
76 inc_module_count(); 74 batadv_inc_module_count();
77 return 0; 75 return 0;
78} 76}
79 77
@@ -98,7 +96,7 @@ static int bat_socket_release(struct inode *inode, struct file *file)
98 spin_unlock_bh(&socket_client->lock); 96 spin_unlock_bh(&socket_client->lock);
99 97
100 kfree(socket_client); 98 kfree(socket_client);
101 dec_module_count(); 99 batadv_dec_module_count();
102 100
103 return 0; 101 return 0;
104} 102}
@@ -219,7 +217,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
219 if (!orig_node) 217 if (!orig_node)
220 goto dst_unreach; 218 goto dst_unreach;
221 219
222 neigh_node = orig_node_get_router(orig_node); 220 neigh_node = batadv_orig_node_get_router(orig_node);
223 if (!neigh_node) 221 if (!neigh_node)
224 goto dst_unreach; 222 goto dst_unreach;
225 223
@@ -236,7 +234,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
236 memcpy(icmp_packet->rr, 234 memcpy(icmp_packet->rr,
237 neigh_node->if_incoming->net_dev->dev_addr, ETH_ALEN); 235 neigh_node->if_incoming->net_dev->dev_addr, ETH_ALEN);
238 236
239 send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); 237 batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
240 goto out; 238 goto out;
241 239
242dst_unreach: 240dst_unreach:
@@ -248,9 +246,9 @@ out:
248 if (primary_if) 246 if (primary_if)
249 hardif_free_ref(primary_if); 247 hardif_free_ref(primary_if);
250 if (neigh_node) 248 if (neigh_node)
251 neigh_node_free_ref(neigh_node); 249 batadv_neigh_node_free_ref(neigh_node);
252 if (orig_node) 250 if (orig_node)
253 orig_node_free_ref(orig_node); 251 batadv_orig_node_free_ref(orig_node);
254 return len; 252 return len;
255} 253}
256 254
@@ -276,7 +274,7 @@ static const struct file_operations fops = {
276 .llseek = no_llseek, 274 .llseek = no_llseek,
277}; 275};
278 276
279int bat_socket_setup(struct bat_priv *bat_priv) 277int batadv_socket_setup(struct bat_priv *bat_priv)
280{ 278{
281 struct dentry *d; 279 struct dentry *d;
282 280
@@ -312,7 +310,8 @@ static void bat_socket_add_packet(struct socket_client *socket_client,
312 spin_lock_bh(&socket_client->lock); 310 spin_lock_bh(&socket_client->lock);
313 311
314 /* while waiting for the lock the socket_client could have been 312 /* while waiting for the lock the socket_client could have been
315 * deleted */ 313 * deleted
314 */
316 if (!socket_client_hash[icmp_packet->uid]) { 315 if (!socket_client_hash[icmp_packet->uid]) {
317 spin_unlock_bh(&socket_client->lock); 316 spin_unlock_bh(&socket_client->lock);
318 kfree(socket_packet); 317 kfree(socket_packet);
@@ -336,8 +335,8 @@ static void bat_socket_add_packet(struct socket_client *socket_client,
336 wake_up(&socket_client->queue_wait); 335 wake_up(&socket_client->queue_wait);
337} 336}
338 337
339void bat_socket_receive_packet(struct icmp_packet_rr *icmp_packet, 338void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet,
340 size_t icmp_len) 339 size_t icmp_len)
341{ 340{
342 struct socket_client *hash = socket_client_hash[icmp_packet->uid]; 341 struct socket_client *hash = socket_client_hash[icmp_packet->uid];
343 342
diff --git a/net/batman-adv/icmp_socket.h b/net/batman-adv/icmp_socket.h
index 380ed4c2443a..a62ab80df9bd 100644
--- a/net/batman-adv/icmp_socket.h
+++ b/net/batman-adv/icmp_socket.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner 3 * Marek Lindner
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ 20#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_
@@ -24,9 +22,9 @@
24 22
25#define ICMP_SOCKET "socket" 23#define ICMP_SOCKET "socket"
26 24
27void bat_socket_init(void); 25void batadv_socket_init(void);
28int bat_socket_setup(struct bat_priv *bat_priv); 26int batadv_socket_setup(struct bat_priv *bat_priv);
29void bat_socket_receive_packet(struct icmp_packet_rr *icmp_packet, 27void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet,
30 size_t icmp_len); 28 size_t icmp_len);
31 29
32#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ 30#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 46ba302d2d01..d56d6b2e1924 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -37,38 +35,40 @@
37 35
38 36
39/* List manipulations on hardif_list have to be rtnl_lock()'ed, 37/* List manipulations on hardif_list have to be rtnl_lock()'ed,
40 * list traversals just rcu-locked */ 38 * list traversals just rcu-locked
41struct list_head hardif_list; 39 */
40struct list_head batadv_hardif_list;
42static int (*recv_packet_handler[256])(struct sk_buff *, struct hard_iface *); 41static int (*recv_packet_handler[256])(struct sk_buff *, struct hard_iface *);
43char bat_routing_algo[20] = "BATMAN_IV"; 42char batadv_routing_algo[20] = "BATMAN_IV";
44static struct hlist_head bat_algo_list; 43static struct hlist_head bat_algo_list;
45 44
46unsigned char broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 45unsigned char batadv_broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
47 46
48struct workqueue_struct *bat_event_workqueue; 47struct workqueue_struct *batadv_event_workqueue;
49 48
50static void recv_handler_init(void); 49static void recv_handler_init(void);
51 50
52static int __init batman_init(void) 51static int __init batman_init(void)
53{ 52{
54 INIT_LIST_HEAD(&hardif_list); 53 INIT_LIST_HEAD(&batadv_hardif_list);
55 INIT_HLIST_HEAD(&bat_algo_list); 54 INIT_HLIST_HEAD(&bat_algo_list);
56 55
57 recv_handler_init(); 56 recv_handler_init();
58 57
59 bat_iv_init(); 58 batadv_iv_init();
60 59
61 /* the name should not be longer than 10 chars - see 60 /* the name should not be longer than 10 chars - see
62 * http://lwn.net/Articles/23634/ */ 61 * http://lwn.net/Articles/23634/
63 bat_event_workqueue = create_singlethread_workqueue("bat_events"); 62 */
63 batadv_event_workqueue = create_singlethread_workqueue("bat_events");
64 64
65 if (!bat_event_workqueue) 65 if (!batadv_event_workqueue)
66 return -ENOMEM; 66 return -ENOMEM;
67 67
68 bat_socket_init(); 68 batadv_socket_init();
69 debugfs_init(); 69 batadv_debugfs_init();
70 70
71 register_netdevice_notifier(&hard_if_notifier); 71 register_netdevice_notifier(&batadv_hard_if_notifier);
72 72
73 pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n", 73 pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n",
74 SOURCE_VERSION, COMPAT_VERSION); 74 SOURCE_VERSION, COMPAT_VERSION);
@@ -78,18 +78,18 @@ static int __init batman_init(void)
78 78
79static void __exit batman_exit(void) 79static void __exit batman_exit(void)
80{ 80{
81 debugfs_destroy(); 81 batadv_debugfs_destroy();
82 unregister_netdevice_notifier(&hard_if_notifier); 82 unregister_netdevice_notifier(&batadv_hard_if_notifier);
83 hardif_remove_interfaces(); 83 batadv_hardif_remove_interfaces();
84 84
85 flush_workqueue(bat_event_workqueue); 85 flush_workqueue(batadv_event_workqueue);
86 destroy_workqueue(bat_event_workqueue); 86 destroy_workqueue(batadv_event_workqueue);
87 bat_event_workqueue = NULL; 87 batadv_event_workqueue = NULL;
88 88
89 rcu_barrier(); 89 rcu_barrier();
90} 90}
91 91
92int mesh_init(struct net_device *soft_iface) 92int batadv_mesh_init(struct net_device *soft_iface)
93{ 93{
94 struct bat_priv *bat_priv = netdev_priv(soft_iface); 94 struct bat_priv *bat_priv = netdev_priv(soft_iface);
95 int ret; 95 int ret;
@@ -111,21 +111,21 @@ int mesh_init(struct net_device *soft_iface)
111 INIT_LIST_HEAD(&bat_priv->tt_req_list); 111 INIT_LIST_HEAD(&bat_priv->tt_req_list);
112 INIT_LIST_HEAD(&bat_priv->tt_roam_list); 112 INIT_LIST_HEAD(&bat_priv->tt_roam_list);
113 113
114 ret = originator_init(bat_priv); 114 ret = batadv_originator_init(bat_priv);
115 if (ret < 0) 115 if (ret < 0)
116 goto err; 116 goto err;
117 117
118 ret = tt_init(bat_priv); 118 ret = batadv_tt_init(bat_priv);
119 if (ret < 0) 119 if (ret < 0)
120 goto err; 120 goto err;
121 121
122 tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX); 122 batadv_tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX);
123 123
124 ret = vis_init(bat_priv); 124 ret = batadv_vis_init(bat_priv);
125 if (ret < 0) 125 if (ret < 0)
126 goto err; 126 goto err;
127 127
128 ret = bla_init(bat_priv); 128 ret = batadv_bla_init(bat_priv);
129 if (ret < 0) 129 if (ret < 0)
130 goto err; 130 goto err;
131 131
@@ -135,48 +135,48 @@ int mesh_init(struct net_device *soft_iface)
135 return 0; 135 return 0;
136 136
137err: 137err:
138 mesh_free(soft_iface); 138 batadv_mesh_free(soft_iface);
139 return ret; 139 return ret;
140} 140}
141 141
142void mesh_free(struct net_device *soft_iface) 142void batadv_mesh_free(struct net_device *soft_iface)
143{ 143{
144 struct bat_priv *bat_priv = netdev_priv(soft_iface); 144 struct bat_priv *bat_priv = netdev_priv(soft_iface);
145 145
146 atomic_set(&bat_priv->mesh_state, MESH_DEACTIVATING); 146 atomic_set(&bat_priv->mesh_state, MESH_DEACTIVATING);
147 147
148 purge_outstanding_packets(bat_priv, NULL); 148 batadv_purge_outstanding_packets(bat_priv, NULL);
149 149
150 vis_quit(bat_priv); 150 batadv_vis_quit(bat_priv);
151 151
152 gw_node_purge(bat_priv); 152 batadv_gw_node_purge(bat_priv);
153 originator_free(bat_priv); 153 batadv_originator_free(bat_priv);
154 154
155 tt_free(bat_priv); 155 batadv_tt_free(bat_priv);
156 156
157 bla_free(bat_priv); 157 batadv_bla_free(bat_priv);
158 158
159 free_percpu(bat_priv->bat_counters); 159 free_percpu(bat_priv->bat_counters);
160 160
161 atomic_set(&bat_priv->mesh_state, MESH_INACTIVE); 161 atomic_set(&bat_priv->mesh_state, MESH_INACTIVE);
162} 162}
163 163
164void inc_module_count(void) 164void batadv_inc_module_count(void)
165{ 165{
166 try_module_get(THIS_MODULE); 166 try_module_get(THIS_MODULE);
167} 167}
168 168
169void dec_module_count(void) 169void batadv_dec_module_count(void)
170{ 170{
171 module_put(THIS_MODULE); 171 module_put(THIS_MODULE);
172} 172}
173 173
174int is_my_mac(const uint8_t *addr) 174int batadv_is_my_mac(const uint8_t *addr)
175{ 175{
176 const struct hard_iface *hard_iface; 176 const struct hard_iface *hard_iface;
177 177
178 rcu_read_lock(); 178 rcu_read_lock();
179 list_for_each_entry_rcu(hard_iface, &hardif_list, list) { 179 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
180 if (hard_iface->if_status != IF_ACTIVE) 180 if (hard_iface->if_status != IF_ACTIVE)
181 continue; 181 continue;
182 182
@@ -198,8 +198,9 @@ static int recv_unhandled_packet(struct sk_buff *skb,
198/* incoming packets with the batman ethertype received on any active hard 198/* incoming packets with the batman ethertype received on any active hard
199 * interface 199 * interface
200 */ 200 */
201int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, 201int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
202 struct packet_type *ptype, struct net_device *orig_dev) 202 struct packet_type *ptype,
203 struct net_device *orig_dev)
203{ 204{
204 struct bat_priv *bat_priv; 205 struct bat_priv *bat_priv;
205 struct batman_ogm_packet *batman_ogm_packet; 206 struct batman_ogm_packet *batman_ogm_packet;
@@ -272,24 +273,24 @@ static void recv_handler_init(void)
272 recv_packet_handler[i] = recv_unhandled_packet; 273 recv_packet_handler[i] = recv_unhandled_packet;
273 274
274 /* batman icmp packet */ 275 /* batman icmp packet */
275 recv_packet_handler[BAT_ICMP] = recv_icmp_packet; 276 recv_packet_handler[BAT_ICMP] = batadv_recv_icmp_packet;
276 /* unicast packet */ 277 /* unicast packet */
277 recv_packet_handler[BAT_UNICAST] = recv_unicast_packet; 278 recv_packet_handler[BAT_UNICAST] = batadv_recv_unicast_packet;
278 /* fragmented unicast packet */ 279 /* fragmented unicast packet */
279 recv_packet_handler[BAT_UNICAST_FRAG] = recv_ucast_frag_packet; 280 recv_packet_handler[BAT_UNICAST_FRAG] = batadv_recv_ucast_frag_packet;
280 /* broadcast packet */ 281 /* broadcast packet */
281 recv_packet_handler[BAT_BCAST] = recv_bcast_packet; 282 recv_packet_handler[BAT_BCAST] = batadv_recv_bcast_packet;
282 /* vis packet */ 283 /* vis packet */
283 recv_packet_handler[BAT_VIS] = recv_vis_packet; 284 recv_packet_handler[BAT_VIS] = batadv_recv_vis_packet;
284 /* Translation table query (request or response) */ 285 /* Translation table query (request or response) */
285 recv_packet_handler[BAT_TT_QUERY] = recv_tt_query; 286 recv_packet_handler[BAT_TT_QUERY] = batadv_recv_tt_query;
286 /* Roaming advertisement */ 287 /* Roaming advertisement */
287 recv_packet_handler[BAT_ROAM_ADV] = recv_roam_adv; 288 recv_packet_handler[BAT_ROAM_ADV] = batadv_recv_roam_adv;
288} 289}
289 290
290int recv_handler_register(uint8_t packet_type, 291int batadv_recv_handler_register(uint8_t packet_type,
291 int (*recv_handler)(struct sk_buff *, 292 int (*recv_handler)(struct sk_buff *,
292 struct hard_iface *)) 293 struct hard_iface *))
293{ 294{
294 if (recv_packet_handler[packet_type] != &recv_unhandled_packet) 295 if (recv_packet_handler[packet_type] != &recv_unhandled_packet)
295 return -EBUSY; 296 return -EBUSY;
@@ -298,7 +299,7 @@ int recv_handler_register(uint8_t packet_type,
298 return 0; 299 return 0;
299} 300}
300 301
301void recv_handler_unregister(uint8_t packet_type) 302void batadv_recv_handler_unregister(uint8_t packet_type)
302{ 303{
303 recv_packet_handler[packet_type] = recv_unhandled_packet; 304 recv_packet_handler[packet_type] = recv_unhandled_packet;
304} 305}
@@ -319,7 +320,7 @@ static struct bat_algo_ops *bat_algo_get(char *name)
319 return bat_algo_ops; 320 return bat_algo_ops;
320} 321}
321 322
322int bat_algo_register(struct bat_algo_ops *bat_algo_ops) 323int batadv_algo_register(struct bat_algo_ops *bat_algo_ops)
323{ 324{
324 struct bat_algo_ops *bat_algo_ops_tmp; 325 struct bat_algo_ops *bat_algo_ops_tmp;
325 int ret; 326 int ret;
@@ -353,7 +354,7 @@ out:
353 return ret; 354 return ret;
354} 355}
355 356
356int bat_algo_select(struct bat_priv *bat_priv, char *name) 357int batadv_algo_select(struct bat_priv *bat_priv, char *name)
357{ 358{
358 struct bat_algo_ops *bat_algo_ops; 359 struct bat_algo_ops *bat_algo_ops;
359 int ret = -EINVAL; 360 int ret = -EINVAL;
@@ -369,7 +370,7 @@ out:
369 return ret; 370 return ret;
370} 371}
371 372
372int bat_algo_seq_print_text(struct seq_file *seq, void *offset) 373int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
373{ 374{
374 struct bat_algo_ops *bat_algo_ops; 375 struct bat_algo_ops *bat_algo_ops;
375 struct hlist_node *node; 376 struct hlist_node *node;
@@ -407,8 +408,8 @@ static const struct kernel_param_ops param_ops_ra = {
407}; 408};
408 409
409static struct kparam_string __param_string_ra = { 410static struct kparam_string __param_string_ra = {
410 .maxlen = sizeof(bat_routing_algo), 411 .maxlen = sizeof(batadv_routing_algo),
411 .string = bat_routing_algo, 412 .string = batadv_routing_algo,
412}; 413};
413 414
414module_param_cb(routing_algo, &param_ops_ra, &__param_string_ra, 0644); 415module_param_cb(routing_algo, &param_ops_ra, &__param_string_ra, 0644);
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 6e0cbdc48321..4b06b7621e7a 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_MAIN_H_ 20#ifndef _NET_BATMAN_ADV_MAIN_H_
@@ -36,19 +34,21 @@
36#define TQ_MAX_VALUE 255 34#define TQ_MAX_VALUE 255
37#define JITTER 20 35#define JITTER 20
38 36
39 /* Time To Live of broadcast messages */ 37/* Time To Live of broadcast messages */
40#define TTL 50 38#define TTL 50
41 39
42/* 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
43 * -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE */ 41 * -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE
42 */
44#define PURGE_TIMEOUT 200000 /* 200 seconds */ 43#define PURGE_TIMEOUT 200000 /* 200 seconds */
45#define TT_LOCAL_TIMEOUT 3600000 /* in miliseconds */ 44#define TT_LOCAL_TIMEOUT 3600000 /* in miliseconds */
46#define TT_CLIENT_ROAM_TIMEOUT 600000 /* in miliseconds */ 45#define TT_CLIENT_ROAM_TIMEOUT 600000 /* in miliseconds */
47/* sliding packet range of received originator messages in sequence numbers 46/* sliding packet range of received originator messages in sequence numbers
48 * (should be a multiple of our word size) */ 47 * (should be a multiple of our word size)
48 */
49#define TQ_LOCAL_WINDOW_SIZE 64 49#define TQ_LOCAL_WINDOW_SIZE 64
50#define TT_REQUEST_TIMEOUT 3000 /* miliseconds we have to keep 50/* miliseconds we have to keep pending tt_req */
51 * pending tt_req */ 51#define TT_REQUEST_TIMEOUT 3000
52 52
53#define TQ_GLOBAL_WINDOW_SIZE 5 53#define TQ_GLOBAL_WINDOW_SIZE 5
54#define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1 54#define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1
@@ -57,8 +57,10 @@
57 57
58#define TT_OGM_APPEND_MAX 3 /* number of OGMs sent with the last tt diff */ 58#define TT_OGM_APPEND_MAX 3 /* number of OGMs sent with the last tt diff */
59 59
60#define ROAMING_MAX_TIME 20000 /* Time in which a client can roam at most 60/* Time in which a client can roam at most ROAMING_MAX_COUNT times in
61 * ROAMING_MAX_COUNT times in miliseconds*/ 61 * miliseconds
62 */
63#define ROAMING_MAX_TIME 20000
62#define ROAMING_MAX_COUNT 5 64#define ROAMING_MAX_COUNT 5
63 65
64#define NO_FLAGS 0 66#define NO_FLAGS 0
@@ -72,11 +74,13 @@
72#define VIS_INTERVAL 5000 /* 5 seconds */ 74#define VIS_INTERVAL 5000 /* 5 seconds */
73 75
74/* how much worse secondary interfaces may be to be considered as bonding 76/* how much worse secondary interfaces may be to be considered as bonding
75 * candidates */ 77 * candidates
78 */
76#define BONDING_TQ_THRESHOLD 50 79#define BONDING_TQ_THRESHOLD 50
77 80
78/* should not be bigger than 512 bytes or change the size of 81/* should not be bigger than 512 bytes or change the size of
79 * forw_packet->direct_link_flags */ 82 * forw_packet->direct_link_flags
83 */
80#define MAX_AGGREGATION_BYTES 512 84#define MAX_AGGREGATION_BYTES 512
81#define MAX_AGGREGATION_MS 100 85#define MAX_AGGREGATION_MS 100
82 86
@@ -145,34 +149,36 @@ enum dbg_level {
145#include <linux/seq_file.h> 149#include <linux/seq_file.h>
146#include "types.h" 150#include "types.h"
147 151
148extern char bat_routing_algo[]; 152extern char batadv_routing_algo[];
149extern struct list_head hardif_list; 153extern struct list_head batadv_hardif_list;
150 154
151extern unsigned char broadcast_addr[]; 155extern unsigned char batadv_broadcast_addr[];
152extern struct workqueue_struct *bat_event_workqueue; 156extern struct workqueue_struct *batadv_event_workqueue;
153 157
154int mesh_init(struct net_device *soft_iface); 158int batadv_mesh_init(struct net_device *soft_iface);
155void mesh_free(struct net_device *soft_iface); 159void batadv_mesh_free(struct net_device *soft_iface);
156void inc_module_count(void); 160void batadv_inc_module_count(void);
157void dec_module_count(void); 161void batadv_dec_module_count(void);
158int is_my_mac(const uint8_t *addr); 162int batadv_is_my_mac(const uint8_t *addr);
159int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, 163int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
160 struct packet_type *ptype, struct net_device *orig_dev); 164 struct packet_type *ptype,
161int recv_handler_register(uint8_t packet_type, 165 struct net_device *orig_dev);
162 int (*recv_handler)(struct sk_buff *, 166int batadv_recv_handler_register(uint8_t packet_type,
163 struct hard_iface *)); 167 int (*recv_handler)(struct sk_buff *,
164void recv_handler_unregister(uint8_t packet_type); 168 struct hard_iface *));
165int bat_algo_register(struct bat_algo_ops *bat_algo_ops); 169void batadv_recv_handler_unregister(uint8_t packet_type);
166int bat_algo_select(struct bat_priv *bat_priv, char *name); 170int batadv_algo_register(struct bat_algo_ops *bat_algo_ops);
167int bat_algo_seq_print_text(struct seq_file *seq, void *offset); 171int batadv_algo_select(struct bat_priv *bat_priv, char *name);
172int batadv_algo_seq_print_text(struct seq_file *seq, void *offset);
168 173
169#ifdef CONFIG_BATMAN_ADV_DEBUG 174#ifdef CONFIG_BATMAN_ADV_DEBUG
170int debug_log(struct bat_priv *bat_priv, const char *fmt, ...) __printf(2, 3); 175int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...)
176__printf(2, 3);
171 177
172#define bat_dbg(type, bat_priv, fmt, arg...) \ 178#define bat_dbg(type, bat_priv, fmt, arg...) \
173 do { \ 179 do { \
174 if (atomic_read(&bat_priv->log_level) & type) \ 180 if (atomic_read(&bat_priv->log_level) & type) \
175 debug_log(bat_priv, fmt, ## arg); \ 181 batadv_debug_log(bat_priv, fmt, ## arg);\
176 } \ 182 } \
177 while (0) 183 while (0)
178#else /* !CONFIG_BATMAN_ADV_DEBUG */ 184#else /* !CONFIG_BATMAN_ADV_DEBUG */
@@ -199,19 +205,16 @@ static inline void bat_dbg(int type __always_unused,
199 pr_err("%s: " fmt, _netdev->name, ## arg); \ 205 pr_err("%s: " fmt, _netdev->name, ## arg); \
200 } while (0) 206 } while (0)
201 207
202/** 208/* returns 1 if they are the same ethernet addr
203 * returns 1 if they are the same ethernet addr
204 * 209 *
205 * note: can't use compare_ether_addr() as it requires aligned memory 210 * note: can't use compare_ether_addr() as it requires aligned memory
206 */ 211 */
207
208static inline int compare_eth(const void *data1, const void *data2) 212static inline int compare_eth(const void *data1, const void *data2)
209{ 213{
210 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); 214 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
211} 215}
212 216
213/** 217/* has_timed_out - compares current time (jiffies) and timestamp + timeout
214 * has_timed_out - compares current time (jiffies) and timestamp + timeout
215 * @timestamp: base value to compare with (in jiffies) 218 * @timestamp: base value to compare with (in jiffies)
216 * @timeout: added to base value before comparing (in milliseconds) 219 * @timeout: added to base value before comparing (in milliseconds)
217 * 220 *
@@ -235,7 +238,8 @@ static inline bool has_timed_out(unsigned long timestamp, unsigned int timeout)
235 * - when adding nothing - it is neither a predecessor nor a successor 238 * - when adding nothing - it is neither a predecessor nor a successor
236 * - before adding more than 127 to the starting value - it is a predecessor, 239 * - before adding more than 127 to the starting value - it is a predecessor,
237 * - when adding 128 - it is neither a predecessor nor a successor, 240 * - when adding 128 - it is neither a predecessor nor a successor,
238 * - after adding more than 127 to the starting value - it is a successor */ 241 * - after adding more than 127 to the starting value - it is a successor
242 */
239#define seq_before(x, y) ({typeof(x) _d1 = (x); \ 243#define seq_before(x, y) ({typeof(x) _d1 = (x); \
240 typeof(y) _d2 = (y); \ 244 typeof(y) _d2 = (y); \
241 typeof(x) _dummy = (_d1 - _d2); \ 245 typeof(x) _dummy = (_d1 - _d2); \
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index cf83c5422e9a..86e7e082c2bc 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2009-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -35,7 +33,7 @@ static void purge_orig(struct work_struct *work);
35static void start_purge_timer(struct bat_priv *bat_priv) 33static void start_purge_timer(struct bat_priv *bat_priv)
36{ 34{
37 INIT_DELAYED_WORK(&bat_priv->orig_work, purge_orig); 35 INIT_DELAYED_WORK(&bat_priv->orig_work, purge_orig);
38 queue_delayed_work(bat_event_workqueue, 36 queue_delayed_work(batadv_event_workqueue,
39 &bat_priv->orig_work, msecs_to_jiffies(1000)); 37 &bat_priv->orig_work, msecs_to_jiffies(1000));
40} 38}
41 39
@@ -47,12 +45,12 @@ static int compare_orig(const struct hlist_node *node, const void *data2)
47 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); 45 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
48} 46}
49 47
50int originator_init(struct bat_priv *bat_priv) 48int batadv_originator_init(struct bat_priv *bat_priv)
51{ 49{
52 if (bat_priv->orig_hash) 50 if (bat_priv->orig_hash)
53 return 0; 51 return 0;
54 52
55 bat_priv->orig_hash = hash_new(1024); 53 bat_priv->orig_hash = batadv_hash_new(1024);
56 54
57 if (!bat_priv->orig_hash) 55 if (!bat_priv->orig_hash)
58 goto err; 56 goto err;
@@ -64,14 +62,14 @@ err:
64 return -ENOMEM; 62 return -ENOMEM;
65} 63}
66 64
67void neigh_node_free_ref(struct neigh_node *neigh_node) 65void batadv_neigh_node_free_ref(struct neigh_node *neigh_node)
68{ 66{
69 if (atomic_dec_and_test(&neigh_node->refcount)) 67 if (atomic_dec_and_test(&neigh_node->refcount))
70 kfree_rcu(neigh_node, rcu); 68 kfree_rcu(neigh_node, rcu);
71} 69}
72 70
73/* increases the refcounter of a found router */ 71/* increases the refcounter of a found router */
74struct neigh_node *orig_node_get_router(struct orig_node *orig_node) 72struct neigh_node *batadv_orig_node_get_router(struct orig_node *orig_node)
75{ 73{
76 struct neigh_node *router; 74 struct neigh_node *router;
77 75
@@ -126,21 +124,21 @@ static void orig_node_free_rcu(struct rcu_head *rcu)
126 list_for_each_entry_safe(neigh_node, tmp_neigh_node, 124 list_for_each_entry_safe(neigh_node, tmp_neigh_node,
127 &orig_node->bond_list, bonding_list) { 125 &orig_node->bond_list, bonding_list) {
128 list_del_rcu(&neigh_node->bonding_list); 126 list_del_rcu(&neigh_node->bonding_list);
129 neigh_node_free_ref(neigh_node); 127 batadv_neigh_node_free_ref(neigh_node);
130 } 128 }
131 129
132 /* for all neighbors towards this originator ... */ 130 /* for all neighbors towards this originator ... */
133 hlist_for_each_entry_safe(neigh_node, node, node_tmp, 131 hlist_for_each_entry_safe(neigh_node, node, node_tmp,
134 &orig_node->neigh_list, list) { 132 &orig_node->neigh_list, list) {
135 hlist_del_rcu(&neigh_node->list); 133 hlist_del_rcu(&neigh_node->list);
136 neigh_node_free_ref(neigh_node); 134 batadv_neigh_node_free_ref(neigh_node);
137 } 135 }
138 136
139 spin_unlock_bh(&orig_node->neigh_list_lock); 137 spin_unlock_bh(&orig_node->neigh_list_lock);
140 138
141 frag_list_free(&orig_node->frag_list); 139 batadv_frag_list_free(&orig_node->frag_list);
142 tt_global_del_orig(orig_node->bat_priv, orig_node, 140 batadv_tt_global_del_orig(orig_node->bat_priv, orig_node,
143 "originator timed out"); 141 "originator timed out");
144 142
145 kfree(orig_node->tt_buff); 143 kfree(orig_node->tt_buff);
146 kfree(orig_node->bcast_own); 144 kfree(orig_node->bcast_own);
@@ -148,13 +146,13 @@ static void orig_node_free_rcu(struct rcu_head *rcu)
148 kfree(orig_node); 146 kfree(orig_node);
149} 147}
150 148
151void orig_node_free_ref(struct orig_node *orig_node) 149void batadv_orig_node_free_ref(struct orig_node *orig_node)
152{ 150{
153 if (atomic_dec_and_test(&orig_node->refcount)) 151 if (atomic_dec_and_test(&orig_node->refcount))
154 call_rcu(&orig_node->rcu, orig_node_free_rcu); 152 call_rcu(&orig_node->rcu, orig_node_free_rcu);
155} 153}
156 154
157void originator_free(struct bat_priv *bat_priv) 155void batadv_originator_free(struct bat_priv *bat_priv)
158{ 156{
159 struct hashtable_t *hash = bat_priv->orig_hash; 157 struct hashtable_t *hash = bat_priv->orig_hash;
160 struct hlist_node *node, *node_tmp; 158 struct hlist_node *node, *node_tmp;
@@ -179,17 +177,19 @@ void originator_free(struct bat_priv *bat_priv)
179 head, hash_entry) { 177 head, hash_entry) {
180 178
181 hlist_del_rcu(node); 179 hlist_del_rcu(node);
182 orig_node_free_ref(orig_node); 180 batadv_orig_node_free_ref(orig_node);
183 } 181 }
184 spin_unlock_bh(list_lock); 182 spin_unlock_bh(list_lock);
185 } 183 }
186 184
187 hash_destroy(hash); 185 batadv_hash_destroy(hash);
188} 186}
189 187
190/* this function finds or creates an originator entry for the given 188/* this function finds or creates an originator entry for the given
191 * address if it does not exits */ 189 * address if it does not exits
192struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr) 190 */
191struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
192 const uint8_t *addr)
193{ 193{
194 struct orig_node *orig_node; 194 struct orig_node *orig_node;
195 int size; 195 int size;
@@ -306,8 +306,8 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv,
306 neigh_purged = true; 306 neigh_purged = true;
307 307
308 hlist_del_rcu(&neigh_node->list); 308 hlist_del_rcu(&neigh_node->list);
309 bonding_candidate_del(orig_node, neigh_node); 309 batadv_bonding_candidate_del(orig_node, neigh_node);
310 neigh_node_free_ref(neigh_node); 310 batadv_neigh_node_free_ref(neigh_node);
311 } else { 311 } else {
312 if ((!*best_neigh_node) || 312 if ((!*best_neigh_node) ||
313 (neigh_node->tq_avg > (*best_neigh_node)->tq_avg)) 313 (neigh_node->tq_avg > (*best_neigh_node)->tq_avg))
@@ -333,7 +333,8 @@ static bool purge_orig_node(struct bat_priv *bat_priv,
333 } else { 333 } else {
334 if (purge_orig_neighbors(bat_priv, orig_node, 334 if (purge_orig_neighbors(bat_priv, orig_node,
335 &best_neigh_node)) 335 &best_neigh_node))
336 update_route(bat_priv, orig_node, best_neigh_node); 336 batadv_update_route(bat_priv, orig_node,
337 best_neigh_node);
337 } 338 }
338 339
339 return false; 340 return false;
@@ -361,21 +362,22 @@ static void _purge_orig(struct bat_priv *bat_priv)
361 head, hash_entry) { 362 head, hash_entry) {
362 if (purge_orig_node(bat_priv, orig_node)) { 363 if (purge_orig_node(bat_priv, orig_node)) {
363 if (orig_node->gw_flags) 364 if (orig_node->gw_flags)
364 gw_node_delete(bat_priv, orig_node); 365 batadv_gw_node_delete(bat_priv,
366 orig_node);
365 hlist_del_rcu(node); 367 hlist_del_rcu(node);
366 orig_node_free_ref(orig_node); 368 batadv_orig_node_free_ref(orig_node);
367 continue; 369 continue;
368 } 370 }
369 371
370 if (has_timed_out(orig_node->last_frag_packet, 372 if (has_timed_out(orig_node->last_frag_packet,
371 FRAG_TIMEOUT)) 373 FRAG_TIMEOUT))
372 frag_list_free(&orig_node->frag_list); 374 batadv_frag_list_free(&orig_node->frag_list);
373 } 375 }
374 spin_unlock_bh(list_lock); 376 spin_unlock_bh(list_lock);
375 } 377 }
376 378
377 gw_node_purge(bat_priv); 379 batadv_gw_node_purge(bat_priv);
378 gw_election(bat_priv); 380 batadv_gw_election(bat_priv);
379} 381}
380 382
381static void purge_orig(struct work_struct *work) 383static void purge_orig(struct work_struct *work)
@@ -389,12 +391,12 @@ static void purge_orig(struct work_struct *work)
389 start_purge_timer(bat_priv); 391 start_purge_timer(bat_priv);
390} 392}
391 393
392void purge_orig_ref(struct bat_priv *bat_priv) 394void batadv_purge_orig_ref(struct bat_priv *bat_priv)
393{ 395{
394 _purge_orig(bat_priv); 396 _purge_orig(bat_priv);
395} 397}
396 398
397int orig_seq_print_text(struct seq_file *seq, void *offset) 399int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
398{ 400{
399 struct net_device *net_dev = (struct net_device *)seq->private; 401 struct net_device *net_dev = (struct net_device *)seq->private;
400 struct bat_priv *bat_priv = netdev_priv(net_dev); 402 struct bat_priv *bat_priv = netdev_priv(net_dev);
@@ -438,7 +440,7 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
438 440
439 rcu_read_lock(); 441 rcu_read_lock();
440 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { 442 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
441 neigh_node = orig_node_get_router(orig_node); 443 neigh_node = batadv_orig_node_get_router(orig_node);
442 if (!neigh_node) 444 if (!neigh_node)
443 continue; 445 continue;
444 446
@@ -467,7 +469,7 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
467 batman_count++; 469 batman_count++;
468 470
469next: 471next:
470 neigh_node_free_ref(neigh_node); 472 batadv_neigh_node_free_ref(neigh_node);
471 } 473 }
472 rcu_read_unlock(); 474 rcu_read_unlock();
473 } 475 }
@@ -507,7 +509,7 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
507 return 0; 509 return 0;
508} 510}
509 511
510int orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num) 512int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num)
511{ 513{
512 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 514 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
513 struct hashtable_t *hash = bat_priv->orig_hash; 515 struct hashtable_t *hash = bat_priv->orig_hash;
@@ -518,7 +520,8 @@ int orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num)
518 int ret; 520 int ret;
519 521
520 /* resize all orig nodes because orig_node->bcast_own(_sum) depend on 522 /* resize all orig nodes because orig_node->bcast_own(_sum) depend on
521 * if_num */ 523 * if_num
524 */
522 for (i = 0; i < hash->size; i++) { 525 for (i = 0; i < hash->size; i++) {
523 head = &hash->table[i]; 526 head = &hash->table[i];
524 527
@@ -589,7 +592,7 @@ free_own_sum:
589 return 0; 592 return 0;
590} 593}
591 594
592int orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num) 595int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num)
593{ 596{
594 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 597 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
595 struct hashtable_t *hash = bat_priv->orig_hash; 598 struct hashtable_t *hash = bat_priv->orig_hash;
@@ -601,7 +604,8 @@ int orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num)
601 int ret; 604 int ret;
602 605
603 /* resize all orig nodes because orig_node->bcast_own(_sum) depend on 606 /* resize all orig nodes because orig_node->bcast_own(_sum) depend on
604 * if_num */ 607 * if_num
608 */
605 for (i = 0; i < hash->size; i++) { 609 for (i = 0; i < hash->size; i++) {
606 head = &hash->table[i]; 610 head = &hash->table[i];
607 611
@@ -620,7 +624,7 @@ int orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num)
620 624
621 /* renumber remaining batman interfaces _inside_ of orig_hash_lock */ 625 /* renumber remaining batman interfaces _inside_ of orig_hash_lock */
622 rcu_read_lock(); 626 rcu_read_lock();
623 list_for_each_entry_rcu(hard_iface_tmp, &hardif_list, list) { 627 list_for_each_entry_rcu(hard_iface_tmp, &batadv_hardif_list, list) {
624 if (hard_iface_tmp->if_status == IF_NOT_IN_USE) 628 if (hard_iface_tmp->if_status == IF_NOT_IN_USE)
625 continue; 629 continue;
626 630
diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h
index f74d0d693359..a72171997056 100644
--- a/net/batman-adv/originator.h
+++ b/net/batman-adv/originator.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_ORIGINATOR_H_ 20#ifndef _NET_BATMAN_ADV_ORIGINATOR_H_
@@ -24,23 +22,25 @@
24 22
25#include "hash.h" 23#include "hash.h"
26 24
27int originator_init(struct bat_priv *bat_priv); 25int batadv_originator_init(struct bat_priv *bat_priv);
28void originator_free(struct bat_priv *bat_priv); 26void batadv_originator_free(struct bat_priv *bat_priv);
29void purge_orig_ref(struct bat_priv *bat_priv); 27void batadv_purge_orig_ref(struct bat_priv *bat_priv);
30void orig_node_free_ref(struct orig_node *orig_node); 28void batadv_orig_node_free_ref(struct orig_node *orig_node);
31struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr); 29struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
30 const uint8_t *addr);
32struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface, 31struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface,
33 const uint8_t *neigh_addr, 32 const uint8_t *neigh_addr,
34 uint32_t seqno); 33 uint32_t seqno);
35void neigh_node_free_ref(struct neigh_node *neigh_node); 34void batadv_neigh_node_free_ref(struct neigh_node *neigh_node);
36struct neigh_node *orig_node_get_router(struct orig_node *orig_node); 35struct neigh_node *batadv_orig_node_get_router(struct orig_node *orig_node);
37int orig_seq_print_text(struct seq_file *seq, void *offset); 36int batadv_orig_seq_print_text(struct seq_file *seq, void *offset);
38int orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num); 37int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num);
39int orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num); 38int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num);
40 39
41 40
42/* hashfunction to choose an entry in a hash table of given size */ 41/* hashfunction to choose an entry in a hash table of given size
43/* hash algorithm from http://en.wikipedia.org/wiki/Hash_table */ 42 * hash algorithm from http://en.wikipedia.org/wiki/Hash_table
43 */
44static inline uint32_t choose_orig(const void *data, uint32_t size) 44static inline uint32_t choose_orig(const void *data, uint32_t size)
45{ 45{
46 const unsigned char *key = data; 46 const unsigned char *key = data;
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 033d99490e82..c90219cd648e 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_PACKET_H_ 20#ifndef _NET_BATMAN_ADV_PACKET_H_
@@ -81,7 +79,8 @@ enum tt_query_flags {
81 79
82/* TT_CLIENT flags. 80/* TT_CLIENT flags.
83 * Flags from 1 to 1 << 7 are sent on the wire, while flags from 1 << 8 to 81 * Flags from 1 to 1 << 7 are sent on the wire, while flags from 1 << 8 to
84 * 1 << 15 are used for local computation only */ 82 * 1 << 15 are used for local computation only
83 */
85enum tt_client_flags { 84enum tt_client_flags {
86 TT_CLIENT_DEL = 1 << 0, 85 TT_CLIENT_DEL = 1 << 0,
87 TT_CLIENT_ROAM = 1 << 1, 86 TT_CLIENT_ROAM = 1 << 1,
@@ -142,7 +141,8 @@ struct icmp_packet {
142#define BAT_RR_LEN 16 141#define BAT_RR_LEN 16
143 142
144/* icmp_packet_rr must start with all fields from imcp_packet 143/* icmp_packet_rr must start with all fields from imcp_packet
145 * as this is assumed by code that handles ICMP packets */ 144 * as this is assumed by code that handles ICMP packets
145 */
146struct icmp_packet_rr { 146struct icmp_packet_rr {
147 struct batman_header header; 147 struct batman_header header;
148 uint8_t msg_type; /* see ICMP message types above */ 148 uint8_t msg_type; /* see ICMP message types above */
@@ -192,7 +192,8 @@ struct tt_query_packet {
192 struct batman_header header; 192 struct batman_header header;
193 /* the flag field is a combination of: 193 /* the flag field is a combination of:
194 * - TT_REQUEST or TT_RESPONSE 194 * - TT_REQUEST or TT_RESPONSE
195 * - TT_FULL_TABLE */ 195 * - TT_FULL_TABLE
196 */
196 uint8_t flags; 197 uint8_t flags;
197 uint8_t dst[ETH_ALEN]; 198 uint8_t dst[ETH_ALEN];
198 uint8_t src[ETH_ALEN]; 199 uint8_t src[ETH_ALEN];
@@ -200,13 +201,15 @@ struct tt_query_packet {
200 * if TT_REQUEST: ttvn that triggered the 201 * if TT_REQUEST: ttvn that triggered the
201 * request 202 * request
202 * if TT_RESPONSE: new ttvn for the src 203 * if TT_RESPONSE: new ttvn for the src
203 * orig_node */ 204 * orig_node
205 */
204 uint8_t ttvn; 206 uint8_t ttvn;
205 /* tt_data field is: 207 /* tt_data field is:
206 * if TT_REQUEST: crc associated with the 208 * if TT_REQUEST: crc associated with the
207 * ttvn 209 * ttvn
208 * if TT_RESPONSE: table_size */ 210 * if TT_RESPONSE: table_size
209 __be16 tt_data; 211 */
212 __be16 tt_data;
210} __packed; 213} __packed;
211 214
212struct roam_adv_packet { 215struct roam_adv_packet {
diff --git a/net/batman-adv/ring_buffer.c b/net/batman-adv/ring_buffer.c
index fd63951d118d..aff1ca2990f1 100644
--- a/net/batman-adv/ring_buffer.c
+++ b/net/batman-adv/ring_buffer.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner 3 * Marek Lindner
5 * 4 *
@@ -16,19 +15,19 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
23#include "ring_buffer.h" 21#include "ring_buffer.h"
24 22
25void ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index, uint8_t value) 23void batadv_ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index,
24 uint8_t value)
26{ 25{
27 lq_recv[*lq_index] = value; 26 lq_recv[*lq_index] = value;
28 *lq_index = (*lq_index + 1) % TQ_GLOBAL_WINDOW_SIZE; 27 *lq_index = (*lq_index + 1) % TQ_GLOBAL_WINDOW_SIZE;
29} 28}
30 29
31uint8_t ring_buffer_avg(const uint8_t lq_recv[]) 30uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[])
32{ 31{
33 const uint8_t *ptr; 32 const uint8_t *ptr;
34 uint16_t count = 0, i = 0, sum = 0; 33 uint16_t count = 0, i = 0, sum = 0;
diff --git a/net/batman-adv/ring_buffer.h b/net/batman-adv/ring_buffer.h
index 8b58bd82767d..fda8c17df273 100644
--- a/net/batman-adv/ring_buffer.h
+++ b/net/batman-adv/ring_buffer.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner 3 * Marek Lindner
5 * 4 *
@@ -16,13 +15,13 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_RING_BUFFER_H_ 20#ifndef _NET_BATMAN_ADV_RING_BUFFER_H_
23#define _NET_BATMAN_ADV_RING_BUFFER_H_ 21#define _NET_BATMAN_ADV_RING_BUFFER_H_
24 22
25void ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index, uint8_t value); 23void batadv_ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index,
26uint8_t ring_buffer_avg(const uint8_t lq_recv[]); 24 uint8_t value);
25uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[]);
27 26
28#endif /* _NET_BATMAN_ADV_RING_BUFFER_H_ */ 27#endif /* _NET_BATMAN_ADV_RING_BUFFER_H_ */
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 9cfd23c6d64a..79f63cf11be4 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -34,7 +32,7 @@
34static int route_unicast_packet(struct sk_buff *skb, 32static int route_unicast_packet(struct sk_buff *skb,
35 struct hard_iface *recv_if); 33 struct hard_iface *recv_if);
36 34
37void slide_own_bcast_window(struct hard_iface *hard_iface) 35void batadv_slide_own_bcast_window(struct hard_iface *hard_iface)
38{ 36{
39 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 37 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
40 struct hashtable_t *hash = bat_priv->orig_hash; 38 struct hashtable_t *hash = bat_priv->orig_hash;
@@ -54,7 +52,7 @@ void slide_own_bcast_window(struct hard_iface *hard_iface)
54 word_index = hard_iface->if_num * NUM_WORDS; 52 word_index = hard_iface->if_num * NUM_WORDS;
55 word = &(orig_node->bcast_own[word_index]); 53 word = &(orig_node->bcast_own[word_index]);
56 54
57 bit_get_packet(bat_priv, word, 1, 0); 55 batadv_bit_get_packet(bat_priv, word, 1, 0);
58 orig_node->bcast_own_sum[hard_iface->if_num] = 56 orig_node->bcast_own_sum[hard_iface->if_num] =
59 bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE); 57 bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE);
60 spin_unlock_bh(&orig_node->ogm_cnt_lock); 58 spin_unlock_bh(&orig_node->ogm_cnt_lock);
@@ -69,14 +67,14 @@ static void _update_route(struct bat_priv *bat_priv,
69{ 67{
70 struct neigh_node *curr_router; 68 struct neigh_node *curr_router;
71 69
72 curr_router = orig_node_get_router(orig_node); 70 curr_router = batadv_orig_node_get_router(orig_node);
73 71
74 /* route deleted */ 72 /* route deleted */
75 if ((curr_router) && (!neigh_node)) { 73 if ((curr_router) && (!neigh_node)) {
76 bat_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n", 74 bat_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n",
77 orig_node->orig); 75 orig_node->orig);
78 tt_global_del_orig(bat_priv, orig_node, 76 batadv_tt_global_del_orig(bat_priv, orig_node,
79 "Deleted route towards originator"); 77 "Deleted route towards originator");
80 78
81 /* route added */ 79 /* route added */
82 } else if ((!curr_router) && (neigh_node)) { 80 } else if ((!curr_router) && (neigh_node)) {
@@ -93,7 +91,7 @@ static void _update_route(struct bat_priv *bat_priv,
93 } 91 }
94 92
95 if (curr_router) 93 if (curr_router)
96 neigh_node_free_ref(curr_router); 94 batadv_neigh_node_free_ref(curr_router);
97 95
98 /* increase refcount of new best neighbor */ 96 /* increase refcount of new best neighbor */
99 if (neigh_node && !atomic_inc_not_zero(&neigh_node->refcount)) 97 if (neigh_node && !atomic_inc_not_zero(&neigh_node->refcount))
@@ -105,30 +103,30 @@ static void _update_route(struct bat_priv *bat_priv,
105 103
106 /* decrease refcount of previous best neighbor */ 104 /* decrease refcount of previous best neighbor */
107 if (curr_router) 105 if (curr_router)
108 neigh_node_free_ref(curr_router); 106 batadv_neigh_node_free_ref(curr_router);
109} 107}
110 108
111void update_route(struct bat_priv *bat_priv, struct orig_node *orig_node, 109void batadv_update_route(struct bat_priv *bat_priv, struct orig_node *orig_node,
112 struct neigh_node *neigh_node) 110 struct neigh_node *neigh_node)
113{ 111{
114 struct neigh_node *router = NULL; 112 struct neigh_node *router = NULL;
115 113
116 if (!orig_node) 114 if (!orig_node)
117 goto out; 115 goto out;
118 116
119 router = orig_node_get_router(orig_node); 117 router = batadv_orig_node_get_router(orig_node);
120 118
121 if (router != neigh_node) 119 if (router != neigh_node)
122 _update_route(bat_priv, orig_node, neigh_node); 120 _update_route(bat_priv, orig_node, neigh_node);
123 121
124out: 122out:
125 if (router) 123 if (router)
126 neigh_node_free_ref(router); 124 batadv_neigh_node_free_ref(router);
127} 125}
128 126
129/* caller must hold the neigh_list_lock */ 127/* caller must hold the neigh_list_lock */
130void bonding_candidate_del(struct orig_node *orig_node, 128void batadv_bonding_candidate_del(struct orig_node *orig_node,
131 struct neigh_node *neigh_node) 129 struct neigh_node *neigh_node)
132{ 130{
133 /* this neighbor is not part of our candidate list */ 131 /* this neighbor is not part of our candidate list */
134 if (list_empty(&neigh_node->bonding_list)) 132 if (list_empty(&neigh_node->bonding_list))
@@ -136,15 +134,15 @@ void bonding_candidate_del(struct orig_node *orig_node,
136 134
137 list_del_rcu(&neigh_node->bonding_list); 135 list_del_rcu(&neigh_node->bonding_list);
138 INIT_LIST_HEAD(&neigh_node->bonding_list); 136 INIT_LIST_HEAD(&neigh_node->bonding_list);
139 neigh_node_free_ref(neigh_node); 137 batadv_neigh_node_free_ref(neigh_node);
140 atomic_dec(&orig_node->bond_candidates); 138 atomic_dec(&orig_node->bond_candidates);
141 139
142out: 140out:
143 return; 141 return;
144} 142}
145 143
146void bonding_candidate_add(struct orig_node *orig_node, 144void batadv_bonding_candidate_add(struct orig_node *orig_node,
147 struct neigh_node *neigh_node) 145 struct neigh_node *neigh_node)
148{ 146{
149 struct hlist_node *node; 147 struct hlist_node *node;
150 struct neigh_node *tmp_neigh_node, *router = NULL; 148 struct neigh_node *tmp_neigh_node, *router = NULL;
@@ -157,7 +155,7 @@ void bonding_candidate_add(struct orig_node *orig_node,
157 neigh_node->orig_node->primary_addr)) 155 neigh_node->orig_node->primary_addr))
158 goto candidate_del; 156 goto candidate_del;
159 157
160 router = orig_node_get_router(orig_node); 158 router = batadv_orig_node_get_router(orig_node);
161 if (!router) 159 if (!router)
162 goto candidate_del; 160 goto candidate_del;
163 161
@@ -165,8 +163,7 @@ void bonding_candidate_add(struct orig_node *orig_node,
165 if (neigh_node->tq_avg < router->tq_avg - BONDING_TQ_THRESHOLD) 163 if (neigh_node->tq_avg < router->tq_avg - BONDING_TQ_THRESHOLD)
166 goto candidate_del; 164 goto candidate_del;
167 165
168 /** 166 /* check if we have another candidate with the same mac address or
169 * check if we have another candidate with the same mac address or
170 * interface. If we do, we won't select this candidate because of 167 * interface. If we do, we won't select this candidate because of
171 * possible interference. 168 * possible interference.
172 */ 169 */
@@ -177,7 +174,8 @@ void bonding_candidate_add(struct orig_node *orig_node,
177 continue; 174 continue;
178 175
179 /* we only care if the other candidate is even 176 /* we only care if the other candidate is even
180 * considered as candidate. */ 177 * considered as candidate.
178 */
181 if (list_empty(&tmp_neigh_node->bonding_list)) 179 if (list_empty(&tmp_neigh_node->bonding_list))
182 continue; 180 continue;
183 181
@@ -204,19 +202,20 @@ void bonding_candidate_add(struct orig_node *orig_node,
204 goto out; 202 goto out;
205 203
206candidate_del: 204candidate_del:
207 bonding_candidate_del(orig_node, neigh_node); 205 batadv_bonding_candidate_del(orig_node, neigh_node);
208 206
209out: 207out:
210 spin_unlock_bh(&orig_node->neigh_list_lock); 208 spin_unlock_bh(&orig_node->neigh_list_lock);
211 209
212 if (router) 210 if (router)
213 neigh_node_free_ref(router); 211 batadv_neigh_node_free_ref(router);
214} 212}
215 213
216/* copy primary address for bonding */ 214/* copy primary address for bonding */
217void bonding_save_primary(const struct orig_node *orig_node, 215void
218 struct orig_node *orig_neigh_node, 216batadv_bonding_save_primary(const struct orig_node *orig_node,
219 const struct batman_ogm_packet *batman_ogm_packet) 217 struct orig_node *orig_neigh_node,
218 const struct batman_ogm_packet *batman_ogm_packet)
220{ 219{
221 if (!(batman_ogm_packet->flags & PRIMARIES_FIRST_HOP)) 220 if (!(batman_ogm_packet->flags & PRIMARIES_FIRST_HOP))
222 return; 221 return;
@@ -229,8 +228,8 @@ void bonding_save_primary(const struct orig_node *orig_node,
229 * 0 if the packet is to be accepted 228 * 0 if the packet is to be accepted
230 * 1 if the packet is to be ignored. 229 * 1 if the packet is to be ignored.
231 */ 230 */
232int window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, 231int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
233 unsigned long *last_reset) 232 unsigned long *last_reset)
234{ 233{
235 if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || 234 if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) ||
236 (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { 235 (seq_num_diff >= EXPECTED_SEQNO_RANGE)) {
@@ -245,9 +244,9 @@ int window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
245 return 0; 244 return 0;
246} 245}
247 246
248bool check_management_packet(struct sk_buff *skb, 247bool batadv_check_management_packet(struct sk_buff *skb,
249 struct hard_iface *hard_iface, 248 struct hard_iface *hard_iface,
250 int header_len) 249 int header_len)
251{ 250{
252 struct ethhdr *ethhdr; 251 struct ethhdr *ethhdr;
253 252
@@ -289,7 +288,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
289 288
290 /* add data to device queue */ 289 /* add data to device queue */
291 if (icmp_packet->msg_type != ECHO_REQUEST) { 290 if (icmp_packet->msg_type != ECHO_REQUEST) {
292 bat_socket_receive_packet(icmp_packet, icmp_len); 291 batadv_socket_receive_packet(icmp_packet, icmp_len);
293 goto out; 292 goto out;
294 } 293 }
295 294
@@ -303,7 +302,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
303 if (!orig_node) 302 if (!orig_node)
304 goto out; 303 goto out;
305 304
306 router = orig_node_get_router(orig_node); 305 router = batadv_orig_node_get_router(orig_node);
307 if (!router) 306 if (!router)
308 goto out; 307 goto out;
309 308
@@ -318,16 +317,16 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
318 icmp_packet->msg_type = ECHO_REPLY; 317 icmp_packet->msg_type = ECHO_REPLY;
319 icmp_packet->header.ttl = TTL; 318 icmp_packet->header.ttl = TTL;
320 319
321 send_skb_packet(skb, router->if_incoming, router->addr); 320 batadv_send_skb_packet(skb, router->if_incoming, router->addr);
322 ret = NET_RX_SUCCESS; 321 ret = NET_RX_SUCCESS;
323 322
324out: 323out:
325 if (primary_if) 324 if (primary_if)
326 hardif_free_ref(primary_if); 325 hardif_free_ref(primary_if);
327 if (router) 326 if (router)
328 neigh_node_free_ref(router); 327 batadv_neigh_node_free_ref(router);
329 if (orig_node) 328 if (orig_node)
330 orig_node_free_ref(orig_node); 329 batadv_orig_node_free_ref(orig_node);
331 return ret; 330 return ret;
332} 331}
333 332
@@ -358,7 +357,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
358 if (!orig_node) 357 if (!orig_node)
359 goto out; 358 goto out;
360 359
361 router = orig_node_get_router(orig_node); 360 router = batadv_orig_node_get_router(orig_node);
362 if (!router) 361 if (!router)
363 goto out; 362 goto out;
364 363
@@ -373,21 +372,21 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
373 icmp_packet->msg_type = TTL_EXCEEDED; 372 icmp_packet->msg_type = TTL_EXCEEDED;
374 icmp_packet->header.ttl = TTL; 373 icmp_packet->header.ttl = TTL;
375 374
376 send_skb_packet(skb, router->if_incoming, router->addr); 375 batadv_send_skb_packet(skb, router->if_incoming, router->addr);
377 ret = NET_RX_SUCCESS; 376 ret = NET_RX_SUCCESS;
378 377
379out: 378out:
380 if (primary_if) 379 if (primary_if)
381 hardif_free_ref(primary_if); 380 hardif_free_ref(primary_if);
382 if (router) 381 if (router)
383 neigh_node_free_ref(router); 382 batadv_neigh_node_free_ref(router);
384 if (orig_node) 383 if (orig_node)
385 orig_node_free_ref(orig_node); 384 batadv_orig_node_free_ref(orig_node);
386 return ret; 385 return ret;
387} 386}
388 387
389 388
390int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if) 389int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
391{ 390{
392 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 391 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
393 struct icmp_packet_rr *icmp_packet; 392 struct icmp_packet_rr *icmp_packet;
@@ -397,9 +396,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
397 int hdr_size = sizeof(struct icmp_packet); 396 int hdr_size = sizeof(struct icmp_packet);
398 int ret = NET_RX_DROP; 397 int ret = NET_RX_DROP;
399 398
400 /** 399 /* we truncate all incoming icmp packets if they don't match our size */
401 * we truncate all incoming icmp packets if they don't match our size
402 */
403 if (skb->len >= sizeof(struct icmp_packet_rr)) 400 if (skb->len >= sizeof(struct icmp_packet_rr))
404 hdr_size = sizeof(struct icmp_packet_rr); 401 hdr_size = sizeof(struct icmp_packet_rr);
405 402
@@ -418,7 +415,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
418 goto out; 415 goto out;
419 416
420 /* not for me */ 417 /* not for me */
421 if (!is_my_mac(ethhdr->h_dest)) 418 if (!batadv_is_my_mac(ethhdr->h_dest))
422 goto out; 419 goto out;
423 420
424 icmp_packet = (struct icmp_packet_rr *)skb->data; 421 icmp_packet = (struct icmp_packet_rr *)skb->data;
@@ -432,7 +429,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
432 } 429 }
433 430
434 /* packet for me */ 431 /* packet for me */
435 if (is_my_mac(icmp_packet->dst)) 432 if (batadv_is_my_mac(icmp_packet->dst))
436 return recv_my_icmp_packet(bat_priv, skb, hdr_size); 433 return recv_my_icmp_packet(bat_priv, skb, hdr_size);
437 434
438 /* TTL exceeded */ 435 /* TTL exceeded */
@@ -444,7 +441,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
444 if (!orig_node) 441 if (!orig_node)
445 goto out; 442 goto out;
446 443
447 router = orig_node_get_router(orig_node); 444 router = batadv_orig_node_get_router(orig_node);
448 if (!router) 445 if (!router)
449 goto out; 446 goto out;
450 447
@@ -458,14 +455,14 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
458 icmp_packet->header.ttl--; 455 icmp_packet->header.ttl--;
459 456
460 /* route it */ 457 /* route it */
461 send_skb_packet(skb, router->if_incoming, router->addr); 458 batadv_send_skb_packet(skb, router->if_incoming, router->addr);
462 ret = NET_RX_SUCCESS; 459 ret = NET_RX_SUCCESS;
463 460
464out: 461out:
465 if (router) 462 if (router)
466 neigh_node_free_ref(router); 463 batadv_neigh_node_free_ref(router);
467 if (orig_node) 464 if (orig_node)
468 orig_node_free_ref(orig_node); 465 batadv_orig_node_free_ref(orig_node);
469 return ret; 466 return ret;
470} 467}
471 468
@@ -473,7 +470,8 @@ out:
473 * robin fashion over the remaining interfaces. 470 * robin fashion over the remaining interfaces.
474 * 471 *
475 * This method rotates the bonding list and increases the 472 * This method rotates the bonding list and increases the
476 * returned router's refcount. */ 473 * returned router's refcount.
474 */
477static struct neigh_node *find_bond_router(struct orig_node *primary_orig, 475static struct neigh_node *find_bond_router(struct orig_node *primary_orig,
478 const struct hard_iface *recv_if) 476 const struct hard_iface *recv_if)
479{ 477{
@@ -506,10 +504,12 @@ static struct neigh_node *find_bond_router(struct orig_node *primary_orig,
506 goto out; 504 goto out;
507 505
508 /* selected should point to the next element 506 /* selected should point to the next element
509 * after the current router */ 507 * after the current router
508 */
510 spin_lock_bh(&primary_orig->neigh_list_lock); 509 spin_lock_bh(&primary_orig->neigh_list_lock);
511 /* this is a list_move(), which unfortunately 510 /* this is a list_move(), which unfortunately
512 * does not exist as rcu version */ 511 * does not exist as rcu version
512 */
513 list_del_rcu(&primary_orig->bond_list); 513 list_del_rcu(&primary_orig->bond_list);
514 list_add_rcu(&primary_orig->bond_list, 514 list_add_rcu(&primary_orig->bond_list,
515 &router->bonding_list); 515 &router->bonding_list);
@@ -524,7 +524,8 @@ out:
524 * remaining candidates which are not using 524 * remaining candidates which are not using
525 * this interface. 525 * this interface.
526 * 526 *
527 * Increases the returned router's refcount */ 527 * Increases the returned router's refcount
528 */
528static struct neigh_node *find_ifalter_router(struct orig_node *primary_orig, 529static struct neigh_node *find_ifalter_router(struct orig_node *primary_orig,
529 const struct hard_iface *recv_if) 530 const struct hard_iface *recv_if)
530{ 531{
@@ -545,19 +546,21 @@ static struct neigh_node *find_ifalter_router(struct orig_node *primary_orig,
545 continue; 546 continue;
546 547
547 /* if we don't have a router yet 548 /* if we don't have a router yet
548 * or this one is better, choose it. */ 549 * or this one is better, choose it.
550 */
549 if ((!router) || 551 if ((!router) ||
550 (tmp_neigh_node->tq_avg > router->tq_avg)) { 552 (tmp_neigh_node->tq_avg > router->tq_avg)) {
551 /* decrement refcount of 553 /* decrement refcount of
552 * previously selected router */ 554 * previously selected router
555 */
553 if (router) 556 if (router)
554 neigh_node_free_ref(router); 557 batadv_neigh_node_free_ref(router);
555 558
556 router = tmp_neigh_node; 559 router = tmp_neigh_node;
557 atomic_inc_not_zero(&router->refcount); 560 atomic_inc_not_zero(&router->refcount);
558 } 561 }
559 562
560 neigh_node_free_ref(tmp_neigh_node); 563 batadv_neigh_node_free_ref(tmp_neigh_node);
561 } 564 }
562 565
563 /* use the first candidate if nothing was found. */ 566 /* use the first candidate if nothing was found. */
@@ -569,7 +572,7 @@ static struct neigh_node *find_ifalter_router(struct orig_node *primary_orig,
569 return router; 572 return router;
570} 573}
571 574
572int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) 575int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
573{ 576{
574 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 577 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
575 struct tt_query_packet *tt_query; 578 struct tt_query_packet *tt_query;
@@ -601,8 +604,9 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
601 batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_RX); 604 batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_RX);
602 605
603 /* If we cannot provide an answer the tt_request is 606 /* If we cannot provide an answer the tt_request is
604 * forwarded */ 607 * forwarded
605 if (!send_tt_response(bat_priv, tt_query)) { 608 */
609 if (!batadv_send_tt_response(bat_priv, tt_query)) {
606 bat_dbg(DBG_TT, bat_priv, 610 bat_dbg(DBG_TT, bat_priv,
607 "Routing TT_REQUEST to %pM [%c]\n", 611 "Routing TT_REQUEST to %pM [%c]\n",
608 tt_query->dst, 612 tt_query->dst,
@@ -613,22 +617,23 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
613 case TT_RESPONSE: 617 case TT_RESPONSE:
614 batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_RX); 618 batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_RX);
615 619
616 if (is_my_mac(tt_query->dst)) { 620 if (batadv_is_my_mac(tt_query->dst)) {
617 /* packet needs to be linearized to access the TT 621 /* packet needs to be linearized to access the TT
618 * changes */ 622 * changes
623 */
619 if (skb_linearize(skb) < 0) 624 if (skb_linearize(skb) < 0)
620 goto out; 625 goto out;
621 /* skb_linearize() possibly changed skb->data */ 626 /* skb_linearize() possibly changed skb->data */
622 tt_query = (struct tt_query_packet *)skb->data; 627 tt_query = (struct tt_query_packet *)skb->data;
623 628
624 tt_size = tt_len(ntohs(tt_query->tt_data)); 629 tt_size = batadv_tt_len(ntohs(tt_query->tt_data));
625 630
626 /* Ensure we have all the claimed data */ 631 /* Ensure we have all the claimed data */
627 if (unlikely(skb_headlen(skb) < 632 if (unlikely(skb_headlen(skb) <
628 sizeof(struct tt_query_packet) + tt_size)) 633 sizeof(struct tt_query_packet) + tt_size))
629 goto out; 634 goto out;
630 635
631 handle_tt_response(bat_priv, tt_query); 636 batadv_handle_tt_response(bat_priv, tt_query);
632 } else { 637 } else {
633 bat_dbg(DBG_TT, bat_priv, 638 bat_dbg(DBG_TT, bat_priv,
634 "Routing TT_RESPONSE to %pM [%c]\n", 639 "Routing TT_RESPONSE to %pM [%c]\n",
@@ -644,7 +649,7 @@ out:
644 return NET_RX_DROP; 649 return NET_RX_DROP;
645} 650}
646 651
647int recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) 652int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
648{ 653{
649 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 654 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
650 struct roam_adv_packet *roam_adv_packet; 655 struct roam_adv_packet *roam_adv_packet;
@@ -669,14 +674,14 @@ int recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
669 674
670 roam_adv_packet = (struct roam_adv_packet *)skb->data; 675 roam_adv_packet = (struct roam_adv_packet *)skb->data;
671 676
672 if (!is_my_mac(roam_adv_packet->dst)) 677 if (!batadv_is_my_mac(roam_adv_packet->dst))
673 return route_unicast_packet(skb, recv_if); 678 return route_unicast_packet(skb, recv_if);
674 679
675 /* check if it is a backbone gateway. we don't accept 680 /* check if it is a backbone gateway. we don't accept
676 * roaming advertisement from it, as it has the same 681 * roaming advertisement from it, as it has the same
677 * entries as we have. 682 * entries as we have.
678 */ 683 */
679 if (bla_is_backbone_gw_orig(bat_priv, roam_adv_packet->src)) 684 if (batadv_bla_is_backbone_gw_orig(bat_priv, roam_adv_packet->src))
680 goto out; 685 goto out;
681 686
682 orig_node = orig_hash_find(bat_priv, roam_adv_packet->src); 687 orig_node = orig_hash_find(bat_priv, roam_adv_packet->src);
@@ -687,15 +692,17 @@ int recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
687 "Received ROAMING_ADV from %pM (client %pM)\n", 692 "Received ROAMING_ADV from %pM (client %pM)\n",
688 roam_adv_packet->src, roam_adv_packet->client); 693 roam_adv_packet->src, roam_adv_packet->client);
689 694
690 tt_global_add(bat_priv, orig_node, roam_adv_packet->client, 695 batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client,
691 atomic_read(&orig_node->last_ttvn) + 1, true, false); 696 atomic_read(&orig_node->last_ttvn) + 1, true,
697 false);
692 698
693 /* Roaming phase starts: I have new information but the ttvn has not 699 /* Roaming phase starts: I have new information but the ttvn has not
694 * been incremented yet. This flag will make me check all the incoming 700 * been incremented yet. This flag will make me check all the incoming
695 * packets for the correct destination. */ 701 * packets for the correct destination.
702 */
696 bat_priv->tt_poss_change = true; 703 bat_priv->tt_poss_change = true;
697 704
698 orig_node_free_ref(orig_node); 705 batadv_orig_node_free_ref(orig_node);
699out: 706out:
700 /* returning NET_RX_DROP will make the caller function kfree the skb */ 707 /* returning NET_RX_DROP will make the caller function kfree the skb */
701 return NET_RX_DROP; 708 return NET_RX_DROP;
@@ -703,10 +710,11 @@ out:
703 710
704/* find a suitable router for this originator, and use 711/* find a suitable router for this originator, and use
705 * bonding if possible. increases the found neighbors 712 * bonding if possible. increases the found neighbors
706 * refcount.*/ 713 * refcount.
707struct neigh_node *find_router(struct bat_priv *bat_priv, 714 */
708 struct orig_node *orig_node, 715struct neigh_node *batadv_find_router(struct bat_priv *bat_priv,
709 const struct hard_iface *recv_if) 716 struct orig_node *orig_node,
717 const struct hard_iface *recv_if)
710{ 718{
711 struct orig_node *primary_orig_node; 719 struct orig_node *primary_orig_node;
712 struct orig_node *router_orig; 720 struct orig_node *router_orig;
@@ -717,12 +725,13 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,
717 if (!orig_node) 725 if (!orig_node)
718 return NULL; 726 return NULL;
719 727
720 router = orig_node_get_router(orig_node); 728 router = batadv_orig_node_get_router(orig_node);
721 if (!router) 729 if (!router)
722 goto err; 730 goto err;
723 731
724 /* without bonding, the first node should 732 /* without bonding, the first node should
725 * always choose the default router. */ 733 * always choose the default router.
734 */
726 bonding_enabled = atomic_read(&bat_priv->bonding); 735 bonding_enabled = atomic_read(&bat_priv->bonding);
727 736
728 rcu_read_lock(); 737 rcu_read_lock();
@@ -735,13 +744,14 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,
735 goto return_router; 744 goto return_router;
736 745
737 /* if we have something in the primary_addr, we can search 746 /* if we have something in the primary_addr, we can search
738 * for a potential bonding candidate. */ 747 * for a potential bonding candidate.
748 */
739 if (compare_eth(router_orig->primary_addr, zero_mac)) 749 if (compare_eth(router_orig->primary_addr, zero_mac))
740 goto return_router; 750 goto return_router;
741 751
742 /* find the orig_node which has the primary interface. might 752 /* find the orig_node which has the primary interface. might
743 * even be the same as our router_orig in many cases */ 753 * even be the same as our router_orig in many cases
744 754 */
745 if (compare_eth(router_orig->primary_addr, router_orig->orig)) { 755 if (compare_eth(router_orig->primary_addr, router_orig->orig)) {
746 primary_orig_node = router_orig; 756 primary_orig_node = router_orig;
747 } else { 757 } else {
@@ -750,19 +760,20 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,
750 if (!primary_orig_node) 760 if (!primary_orig_node)
751 goto return_router; 761 goto return_router;
752 762
753 orig_node_free_ref(primary_orig_node); 763 batadv_orig_node_free_ref(primary_orig_node);
754 } 764 }
755 765
756 /* with less than 2 candidates, we can't do any 766 /* with less than 2 candidates, we can't do any
757 * bonding and prefer the original router. */ 767 * bonding and prefer the original router.
768 */
758 if (atomic_read(&primary_orig_node->bond_candidates) < 2) 769 if (atomic_read(&primary_orig_node->bond_candidates) < 2)
759 goto return_router; 770 goto return_router;
760 771
761 /* all nodes between should choose a candidate which 772 /* all nodes between should choose a candidate which
762 * is is not on the interface where the packet came 773 * is is not on the interface where the packet came
763 * in. */ 774 * in.
764 775 */
765 neigh_node_free_ref(router); 776 batadv_neigh_node_free_ref(router);
766 777
767 if (bonding_enabled) 778 if (bonding_enabled)
768 router = find_bond_router(primary_orig_node, recv_if); 779 router = find_bond_router(primary_orig_node, recv_if);
@@ -779,7 +790,7 @@ err_unlock:
779 rcu_read_unlock(); 790 rcu_read_unlock();
780err: 791err:
781 if (router) 792 if (router)
782 neigh_node_free_ref(router); 793 batadv_neigh_node_free_ref(router);
783 return NULL; 794 return NULL;
784} 795}
785 796
@@ -802,7 +813,7 @@ static int check_unicast_packet(struct sk_buff *skb, int hdr_size)
802 return -1; 813 return -1;
803 814
804 /* not for me */ 815 /* not for me */
805 if (!is_my_mac(ethhdr->h_dest)) 816 if (!batadv_is_my_mac(ethhdr->h_dest))
806 return -1; 817 return -1;
807 818
808 return 0; 819 return 0;
@@ -834,7 +845,7 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
834 goto out; 845 goto out;
835 846
836 /* find_router() increases neigh_nodes refcount if found. */ 847 /* find_router() increases neigh_nodes refcount if found. */
837 neigh_node = find_router(bat_priv, orig_node, recv_if); 848 neigh_node = batadv_find_router(bat_priv, orig_node, recv_if);
838 849
839 if (!neigh_node) 850 if (!neigh_node)
840 goto out; 851 goto out;
@@ -848,15 +859,16 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
848 if (unicast_packet->header.packet_type == BAT_UNICAST && 859 if (unicast_packet->header.packet_type == BAT_UNICAST &&
849 atomic_read(&bat_priv->fragmentation) && 860 atomic_read(&bat_priv->fragmentation) &&
850 skb->len > neigh_node->if_incoming->net_dev->mtu) { 861 skb->len > neigh_node->if_incoming->net_dev->mtu) {
851 ret = frag_send_skb(skb, bat_priv, 862 ret = batadv_frag_send_skb(skb, bat_priv,
852 neigh_node->if_incoming, neigh_node->addr); 863 neigh_node->if_incoming,
864 neigh_node->addr);
853 goto out; 865 goto out;
854 } 866 }
855 867
856 if (unicast_packet->header.packet_type == BAT_UNICAST_FRAG && 868 if (unicast_packet->header.packet_type == BAT_UNICAST_FRAG &&
857 frag_can_reassemble(skb, neigh_node->if_incoming->net_dev->mtu)) { 869 frag_can_reassemble(skb, neigh_node->if_incoming->net_dev->mtu)) {
858 870
859 ret = frag_reassemble_skb(skb, bat_priv, &new_skb); 871 ret = batadv_frag_reassemble_skb(skb, bat_priv, &new_skb);
860 872
861 if (ret == NET_RX_DROP) 873 if (ret == NET_RX_DROP)
862 goto out; 874 goto out;
@@ -880,14 +892,14 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
880 skb->len + ETH_HLEN); 892 skb->len + ETH_HLEN);
881 893
882 /* route it */ 894 /* route it */
883 send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); 895 batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
884 ret = NET_RX_SUCCESS; 896 ret = NET_RX_SUCCESS;
885 897
886out: 898out:
887 if (neigh_node) 899 if (neigh_node)
888 neigh_node_free_ref(neigh_node); 900 batadv_neigh_node_free_ref(neigh_node);
889 if (orig_node) 901 if (orig_node)
890 orig_node_free_ref(orig_node); 902 batadv_orig_node_free_ref(orig_node);
891 return ret; 903 return ret;
892} 904}
893 905
@@ -906,7 +918,7 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
906 918
907 unicast_packet = (struct unicast_packet *)skb->data; 919 unicast_packet = (struct unicast_packet *)skb->data;
908 920
909 if (is_my_mac(unicast_packet->dest)) { 921 if (batadv_is_my_mac(unicast_packet->dest)) {
910 tt_poss_change = bat_priv->tt_poss_change; 922 tt_poss_change = bat_priv->tt_poss_change;
911 curr_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); 923 curr_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn);
912 } else { 924 } else {
@@ -917,7 +929,7 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
917 929
918 curr_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn); 930 curr_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn);
919 tt_poss_change = orig_node->tt_poss_change; 931 tt_poss_change = orig_node->tt_poss_change;
920 orig_node_free_ref(orig_node); 932 batadv_orig_node_free_ref(orig_node);
921 } 933 }
922 934
923 /* Check whether I have to reroute the packet */ 935 /* Check whether I have to reroute the packet */
@@ -933,13 +945,15 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
933 /* we don't have an updated route for this client, so we should 945 /* we don't have an updated route for this client, so we should
934 * not try to reroute the packet!! 946 * not try to reroute the packet!!
935 */ 947 */
936 if (tt_global_client_is_roaming(bat_priv, ethhdr->h_dest)) 948 if (batadv_tt_global_client_is_roaming(bat_priv,
949 ethhdr->h_dest))
937 return 1; 950 return 1;
938 951
939 orig_node = transtable_search(bat_priv, NULL, ethhdr->h_dest); 952 orig_node = batadv_transtable_search(bat_priv, NULL,
953 ethhdr->h_dest);
940 954
941 if (!orig_node) { 955 if (!orig_node) {
942 if (!is_my_client(bat_priv, ethhdr->h_dest)) 956 if (!batadv_is_my_client(bat_priv, ethhdr->h_dest))
943 return 0; 957 return 0;
944 primary_if = primary_if_get_selected(bat_priv); 958 primary_if = primary_if_get_selected(bat_priv);
945 if (!primary_if) 959 if (!primary_if)
@@ -952,7 +966,7 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
952 ETH_ALEN); 966 ETH_ALEN);
953 curr_ttvn = (uint8_t) 967 curr_ttvn = (uint8_t)
954 atomic_read(&orig_node->last_ttvn); 968 atomic_read(&orig_node->last_ttvn);
955 orig_node_free_ref(orig_node); 969 batadv_orig_node_free_ref(orig_node);
956 } 970 }
957 971
958 bat_dbg(DBG_ROUTES, bat_priv, 972 bat_dbg(DBG_ROUTES, bat_priv,
@@ -965,7 +979,7 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
965 return 1; 979 return 1;
966} 980}
967 981
968int recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) 982int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
969{ 983{
970 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 984 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
971 struct unicast_packet *unicast_packet; 985 struct unicast_packet *unicast_packet;
@@ -980,15 +994,17 @@ int recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
980 unicast_packet = (struct unicast_packet *)skb->data; 994 unicast_packet = (struct unicast_packet *)skb->data;
981 995
982 /* packet for me */ 996 /* packet for me */
983 if (is_my_mac(unicast_packet->dest)) { 997 if (batadv_is_my_mac(unicast_packet->dest)) {
984 interface_rx(recv_if->soft_iface, skb, recv_if, hdr_size); 998 batadv_interface_rx(recv_if->soft_iface, skb, recv_if,
999 hdr_size);
985 return NET_RX_SUCCESS; 1000 return NET_RX_SUCCESS;
986 } 1001 }
987 1002
988 return route_unicast_packet(skb, recv_if); 1003 return route_unicast_packet(skb, recv_if);
989} 1004}
990 1005
991int recv_ucast_frag_packet(struct sk_buff *skb, struct hard_iface *recv_if) 1006int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
1007 struct hard_iface *recv_if)
992{ 1008{
993 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 1009 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
994 struct unicast_frag_packet *unicast_packet; 1010 struct unicast_frag_packet *unicast_packet;
@@ -1005,9 +1021,9 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1005 unicast_packet = (struct unicast_frag_packet *)skb->data; 1021 unicast_packet = (struct unicast_frag_packet *)skb->data;
1006 1022
1007 /* packet for me */ 1023 /* packet for me */
1008 if (is_my_mac(unicast_packet->dest)) { 1024 if (batadv_is_my_mac(unicast_packet->dest)) {
1009 1025
1010 ret = frag_reassemble_skb(skb, bat_priv, &new_skb); 1026 ret = batadv_frag_reassemble_skb(skb, bat_priv, &new_skb);
1011 1027
1012 if (ret == NET_RX_DROP) 1028 if (ret == NET_RX_DROP)
1013 return NET_RX_DROP; 1029 return NET_RX_DROP;
@@ -1016,8 +1032,8 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1016 if (!new_skb) 1032 if (!new_skb)
1017 return NET_RX_SUCCESS; 1033 return NET_RX_SUCCESS;
1018 1034
1019 interface_rx(recv_if->soft_iface, new_skb, recv_if, 1035 batadv_interface_rx(recv_if->soft_iface, new_skb, recv_if,
1020 sizeof(struct unicast_packet)); 1036 sizeof(struct unicast_packet));
1021 return NET_RX_SUCCESS; 1037 return NET_RX_SUCCESS;
1022 } 1038 }
1023 1039
@@ -1025,7 +1041,7 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1025} 1041}
1026 1042
1027 1043
1028int recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if) 1044int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1029{ 1045{
1030 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 1046 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
1031 struct orig_node *orig_node = NULL; 1047 struct orig_node *orig_node = NULL;
@@ -1050,13 +1066,13 @@ int recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1050 goto out; 1066 goto out;
1051 1067
1052 /* ignore broadcasts sent by myself */ 1068 /* ignore broadcasts sent by myself */
1053 if (is_my_mac(ethhdr->h_source)) 1069 if (batadv_is_my_mac(ethhdr->h_source))
1054 goto out; 1070 goto out;
1055 1071
1056 bcast_packet = (struct bcast_packet *)skb->data; 1072 bcast_packet = (struct bcast_packet *)skb->data;
1057 1073
1058 /* ignore broadcasts originated by myself */ 1074 /* ignore broadcasts originated by myself */
1059 if (is_my_mac(bcast_packet->orig)) 1075 if (batadv_is_my_mac(bcast_packet->orig))
1060 goto out; 1076 goto out;
1061 1077
1062 if (bcast_packet->header.ttl < 2) 1078 if (bcast_packet->header.ttl < 2)
@@ -1077,32 +1093,33 @@ int recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1077 seq_diff = ntohl(bcast_packet->seqno) - orig_node->last_bcast_seqno; 1093 seq_diff = ntohl(bcast_packet->seqno) - orig_node->last_bcast_seqno;
1078 1094
1079 /* check whether the packet is old and the host just restarted. */ 1095 /* check whether the packet is old and the host just restarted. */
1080 if (window_protected(bat_priv, seq_diff, 1096 if (batadv_window_protected(bat_priv, seq_diff,
1081 &orig_node->bcast_seqno_reset)) 1097 &orig_node->bcast_seqno_reset))
1082 goto spin_unlock; 1098 goto spin_unlock;
1083 1099
1084 /* mark broadcast in flood history, update window position 1100 /* mark broadcast in flood history, update window position
1085 * if required. */ 1101 * if required.
1086 if (bit_get_packet(bat_priv, orig_node->bcast_bits, seq_diff, 1)) 1102 */
1103 if (batadv_bit_get_packet(bat_priv, orig_node->bcast_bits, seq_diff, 1))
1087 orig_node->last_bcast_seqno = ntohl(bcast_packet->seqno); 1104 orig_node->last_bcast_seqno = ntohl(bcast_packet->seqno);
1088 1105
1089 spin_unlock_bh(&orig_node->bcast_seqno_lock); 1106 spin_unlock_bh(&orig_node->bcast_seqno_lock);
1090 1107
1091 /* check whether this has been sent by another originator before */ 1108 /* check whether this has been sent by another originator before */
1092 if (bla_check_bcast_duplist(bat_priv, bcast_packet, hdr_size)) 1109 if (batadv_bla_check_bcast_duplist(bat_priv, bcast_packet, hdr_size))
1093 goto out; 1110 goto out;
1094 1111
1095 /* rebroadcast packet */ 1112 /* rebroadcast packet */
1096 add_bcast_packet_to_list(bat_priv, skb, 1); 1113 batadv_add_bcast_packet_to_list(bat_priv, skb, 1);
1097 1114
1098 /* don't hand the broadcast up if it is from an originator 1115 /* don't hand the broadcast up if it is from an originator
1099 * from the same backbone. 1116 * from the same backbone.
1100 */ 1117 */
1101 if (bla_is_backbone_gw(skb, orig_node, hdr_size)) 1118 if (batadv_bla_is_backbone_gw(skb, orig_node, hdr_size))
1102 goto out; 1119 goto out;
1103 1120
1104 /* broadcast for me */ 1121 /* broadcast for me */
1105 interface_rx(recv_if->soft_iface, skb, recv_if, hdr_size); 1122 batadv_interface_rx(recv_if->soft_iface, skb, recv_if, hdr_size);
1106 ret = NET_RX_SUCCESS; 1123 ret = NET_RX_SUCCESS;
1107 goto out; 1124 goto out;
1108 1125
@@ -1110,11 +1127,11 @@ spin_unlock:
1110 spin_unlock_bh(&orig_node->bcast_seqno_lock); 1127 spin_unlock_bh(&orig_node->bcast_seqno_lock);
1111out: 1128out:
1112 if (orig_node) 1129 if (orig_node)
1113 orig_node_free_ref(orig_node); 1130 batadv_orig_node_free_ref(orig_node);
1114 return ret; 1131 return ret;
1115} 1132}
1116 1133
1117int recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if) 1134int batadv_recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1118{ 1135{
1119 struct vis_packet *vis_packet; 1136 struct vis_packet *vis_packet;
1120 struct ethhdr *ethhdr; 1137 struct ethhdr *ethhdr;
@@ -1132,25 +1149,25 @@ int recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1132 ethhdr = (struct ethhdr *)skb_mac_header(skb); 1149 ethhdr = (struct ethhdr *)skb_mac_header(skb);
1133 1150
1134 /* not for me */ 1151 /* not for me */
1135 if (!is_my_mac(ethhdr->h_dest)) 1152 if (!batadv_is_my_mac(ethhdr->h_dest))
1136 return NET_RX_DROP; 1153 return NET_RX_DROP;
1137 1154
1138 /* ignore own packets */ 1155 /* ignore own packets */
1139 if (is_my_mac(vis_packet->vis_orig)) 1156 if (batadv_is_my_mac(vis_packet->vis_orig))
1140 return NET_RX_DROP; 1157 return NET_RX_DROP;
1141 1158
1142 if (is_my_mac(vis_packet->sender_orig)) 1159 if (batadv_is_my_mac(vis_packet->sender_orig))
1143 return NET_RX_DROP; 1160 return NET_RX_DROP;
1144 1161
1145 switch (vis_packet->vis_type) { 1162 switch (vis_packet->vis_type) {
1146 case VIS_TYPE_SERVER_SYNC: 1163 case VIS_TYPE_SERVER_SYNC:
1147 receive_server_sync_packet(bat_priv, vis_packet, 1164 batadv_receive_server_sync_packet(bat_priv, vis_packet,
1148 skb_headlen(skb)); 1165 skb_headlen(skb));
1149 break; 1166 break;
1150 1167
1151 case VIS_TYPE_CLIENT_UPDATE: 1168 case VIS_TYPE_CLIENT_UPDATE:
1152 receive_client_update_packet(bat_priv, vis_packet, 1169 batadv_receive_client_update_packet(bat_priv, vis_packet,
1153 skb_headlen(skb)); 1170 skb_headlen(skb));
1154 break; 1171 break;
1155 1172
1156 default: /* ignore unknown packet */ 1173 default: /* ignore unknown packet */
@@ -1158,6 +1175,7 @@ int recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1158 } 1175 }
1159 1176
1160 /* We take a copy of the data in the packet, so we should 1177 /* We take a copy of the data in the packet, so we should
1161 always free the skbuf. */ 1178 * always free the skbuf.
1179 */
1162 return NET_RX_DROP; 1180 return NET_RX_DROP;
1163} 1181}
diff --git a/net/batman-adv/routing.h b/net/batman-adv/routing.h
index d6bbbebb6567..c3fd219e8e53 100644
--- a/net/batman-adv/routing.h
+++ b/net/batman-adv/routing.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
5 * 4 *
@@ -16,36 +15,37 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_ROUTING_H_ 20#ifndef _NET_BATMAN_ADV_ROUTING_H_
23#define _NET_BATMAN_ADV_ROUTING_H_ 21#define _NET_BATMAN_ADV_ROUTING_H_
24 22
25void slide_own_bcast_window(struct hard_iface *hard_iface); 23void batadv_slide_own_bcast_window(struct hard_iface *hard_iface);
26bool check_management_packet(struct sk_buff *skb, 24bool batadv_check_management_packet(struct sk_buff *skb,
27 struct hard_iface *hard_iface, 25 struct hard_iface *hard_iface,
28 int header_len); 26 int header_len);
29void update_route(struct bat_priv *bat_priv, struct orig_node *orig_node, 27void batadv_update_route(struct bat_priv *bat_priv, struct orig_node *orig_node,
30 struct neigh_node *neigh_node); 28 struct neigh_node *neigh_node);
31int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if); 29int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if);
32int recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if); 30int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if);
33int recv_ucast_frag_packet(struct sk_buff *skb, struct hard_iface *recv_if); 31int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
34int recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if); 32 struct hard_iface *recv_if);
35int recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if); 33int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if);
36int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if); 34int batadv_recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if);
37int recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if); 35int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if);
38struct neigh_node *find_router(struct bat_priv *bat_priv, 36int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if);
39 struct orig_node *orig_node, 37struct neigh_node *batadv_find_router(struct bat_priv *bat_priv,
40 const struct hard_iface *recv_if); 38 struct orig_node *orig_node,
41void bonding_candidate_del(struct orig_node *orig_node, 39 const struct hard_iface *recv_if);
42 struct neigh_node *neigh_node); 40void batadv_bonding_candidate_del(struct orig_node *orig_node,
43void bonding_candidate_add(struct orig_node *orig_node, 41 struct neigh_node *neigh_node);
44 struct neigh_node *neigh_node); 42void batadv_bonding_candidate_add(struct orig_node *orig_node,
45void bonding_save_primary(const struct orig_node *orig_node, 43 struct neigh_node *neigh_node);
46 struct orig_node *orig_neigh_node, 44void batadv_bonding_save_primary(const struct orig_node *orig_node,
47 const struct batman_ogm_packet *batman_ogm_packet); 45 struct orig_node *orig_neigh_node,
48int window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, 46 const struct batman_ogm_packet
49 unsigned long *last_reset); 47 *batman_ogm_packet);
48int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
49 unsigned long *last_reset);
50 50
51#endif /* _NET_BATMAN_ADV_ROUTING_H_ */ 51#endif /* _NET_BATMAN_ADV_ROUTING_H_ */
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 79f8973810c0..2c92a32ec6c6 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -32,9 +30,10 @@
32static void send_outstanding_bcast_packet(struct work_struct *work); 30static void send_outstanding_bcast_packet(struct work_struct *work);
33 31
34/* send out an already prepared packet to the given address via the 32/* send out an already prepared packet to the given address via the
35 * specified batman interface */ 33 * specified batman interface
36int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface, 34 */
37 const uint8_t *dst_addr) 35int batadv_send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
36 const uint8_t *dst_addr)
38{ 37{
39 struct ethhdr *ethhdr; 38 struct ethhdr *ethhdr;
40 39
@@ -51,7 +50,7 @@ int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
51 } 50 }
52 51
53 /* push to the ethernet header. */ 52 /* push to the ethernet header. */
54 if (my_skb_head_push(skb, ETH_HLEN) < 0) 53 if (batadv_skb_head_push(skb, ETH_HLEN) < 0)
55 goto send_skb_err; 54 goto send_skb_err;
56 55
57 skb_reset_mac_header(skb); 56 skb_reset_mac_header(skb);
@@ -69,15 +68,15 @@ int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
69 68
70 /* dev_queue_xmit() returns a negative result on error. However on 69 /* dev_queue_xmit() returns a negative result on error. However on
71 * congestion and traffic shaping, it drops and returns NET_XMIT_DROP 70 * congestion and traffic shaping, it drops and returns NET_XMIT_DROP
72 * (which is > 0). This will not be treated as an error. */ 71 * (which is > 0). This will not be treated as an error.
73 72 */
74 return dev_queue_xmit(skb); 73 return dev_queue_xmit(skb);
75send_skb_err: 74send_skb_err:
76 kfree_skb(skb); 75 kfree_skb(skb);
77 return NET_XMIT_DROP; 76 return NET_XMIT_DROP;
78} 77}
79 78
80void schedule_bat_ogm(struct hard_iface *hard_iface) 79void batadv_schedule_bat_ogm(struct hard_iface *hard_iface)
81{ 80{
82 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 81 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
83 82
@@ -85,8 +84,7 @@ void schedule_bat_ogm(struct hard_iface *hard_iface)
85 (hard_iface->if_status == IF_TO_BE_REMOVED)) 84 (hard_iface->if_status == IF_TO_BE_REMOVED))
86 return; 85 return;
87 86
88 /** 87 /* the interface gets activated here to avoid race conditions between
89 * the interface gets activated here to avoid race conditions between
90 * the moment of activating the interface in 88 * the moment of activating the interface in
91 * hardif_activate_interface() where the originator mac is set and 89 * hardif_activate_interface() where the originator mac is set and
92 * outdated packets (especially uninitialized mac addresses) in the 90 * outdated packets (especially uninitialized mac addresses) in the
@@ -121,7 +119,7 @@ static void _add_bcast_packet_to_list(struct bat_priv *bat_priv,
121 /* start timer for this packet */ 119 /* start timer for this packet */
122 INIT_DELAYED_WORK(&forw_packet->delayed_work, 120 INIT_DELAYED_WORK(&forw_packet->delayed_work,
123 send_outstanding_bcast_packet); 121 send_outstanding_bcast_packet);
124 queue_delayed_work(bat_event_workqueue, &forw_packet->delayed_work, 122 queue_delayed_work(batadv_event_workqueue, &forw_packet->delayed_work,
125 send_time); 123 send_time);
126} 124}
127 125
@@ -132,9 +130,11 @@ static void _add_bcast_packet_to_list(struct bat_priv *bat_priv,
132 * errors. 130 * errors.
133 * 131 *
134 * The skb is not consumed, so the caller should make sure that the 132 * The skb is not consumed, so the caller should make sure that the
135 * skb is freed. */ 133 * skb is freed.
136int add_bcast_packet_to_list(struct bat_priv *bat_priv, 134 */
137 const struct sk_buff *skb, unsigned long delay) 135int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
136 const struct sk_buff *skb,
137 unsigned long delay)
138{ 138{
139 struct hard_iface *primary_if = NULL; 139 struct hard_iface *primary_if = NULL;
140 struct forw_packet *forw_packet; 140 struct forw_packet *forw_packet;
@@ -204,14 +204,15 @@ static void send_outstanding_bcast_packet(struct work_struct *work)
204 204
205 /* rebroadcast packet */ 205 /* rebroadcast packet */
206 rcu_read_lock(); 206 rcu_read_lock();
207 list_for_each_entry_rcu(hard_iface, &hardif_list, list) { 207 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
208 if (hard_iface->soft_iface != soft_iface) 208 if (hard_iface->soft_iface != soft_iface)
209 continue; 209 continue;
210 210
211 /* send a copy of the saved skb */ 211 /* send a copy of the saved skb */
212 skb1 = skb_clone(forw_packet->skb, GFP_ATOMIC); 212 skb1 = skb_clone(forw_packet->skb, GFP_ATOMIC);
213 if (skb1) 213 if (skb1)
214 send_skb_packet(skb1, hard_iface, broadcast_addr); 214 batadv_send_skb_packet(skb1, hard_iface,
215 batadv_broadcast_addr);
215 } 216 }
216 rcu_read_unlock(); 217 rcu_read_unlock();
217 218
@@ -229,7 +230,7 @@ out:
229 atomic_inc(&bat_priv->bcast_queue_left); 230 atomic_inc(&bat_priv->bcast_queue_left);
230} 231}
231 232
232void send_outstanding_bat_ogm_packet(struct work_struct *work) 233void batadv_send_outstanding_bat_ogm_packet(struct work_struct *work)
233{ 234{
234 struct delayed_work *delayed_work = 235 struct delayed_work *delayed_work =
235 container_of(work, struct delayed_work, work); 236 container_of(work, struct delayed_work, work);
@@ -247,13 +248,12 @@ void send_outstanding_bat_ogm_packet(struct work_struct *work)
247 248
248 bat_priv->bat_algo_ops->bat_ogm_emit(forw_packet); 249 bat_priv->bat_algo_ops->bat_ogm_emit(forw_packet);
249 250
250 /** 251 /* we have to have at least one packet in the queue
251 * we have to have at least one packet in the queue
252 * to determine the queues wake up time unless we are 252 * to determine the queues wake up time unless we are
253 * shutting down 253 * shutting down
254 */ 254 */
255 if (forw_packet->own) 255 if (forw_packet->own)
256 schedule_bat_ogm(forw_packet->if_incoming); 256 batadv_schedule_bat_ogm(forw_packet->if_incoming);
257 257
258out: 258out:
259 /* don't count own packet */ 259 /* don't count own packet */
@@ -263,8 +263,8 @@ out:
263 forw_packet_free(forw_packet); 263 forw_packet_free(forw_packet);
264} 264}
265 265
266void purge_outstanding_packets(struct bat_priv *bat_priv, 266void batadv_purge_outstanding_packets(struct bat_priv *bat_priv,
267 const struct hard_iface *hard_iface) 267 const struct hard_iface *hard_iface)
268{ 268{
269 struct forw_packet *forw_packet; 269 struct forw_packet *forw_packet;
270 struct hlist_node *tmp_node, *safe_tmp_node; 270 struct hlist_node *tmp_node, *safe_tmp_node;
@@ -283,8 +283,7 @@ void purge_outstanding_packets(struct bat_priv *bat_priv,
283 hlist_for_each_entry_safe(forw_packet, tmp_node, safe_tmp_node, 283 hlist_for_each_entry_safe(forw_packet, tmp_node, safe_tmp_node,
284 &bat_priv->forw_bcast_list, list) { 284 &bat_priv->forw_bcast_list, list) {
285 285
286 /** 286 /* if purge_outstanding_packets() was called with an argument
287 * if purge_outstanding_packets() was called with an argument
288 * we delete only packets belonging to the given interface 287 * we delete only packets belonging to the given interface
289 */ 288 */
290 if ((hard_iface) && 289 if ((hard_iface) &&
@@ -293,8 +292,7 @@ void purge_outstanding_packets(struct bat_priv *bat_priv,
293 292
294 spin_unlock_bh(&bat_priv->forw_bcast_list_lock); 293 spin_unlock_bh(&bat_priv->forw_bcast_list_lock);
295 294
296 /** 295 /* send_outstanding_bcast_packet() will lock the list to
297 * send_outstanding_bcast_packet() will lock the list to
298 * delete the item from the list 296 * delete the item from the list
299 */ 297 */
300 pending = cancel_delayed_work_sync(&forw_packet->delayed_work); 298 pending = cancel_delayed_work_sync(&forw_packet->delayed_work);
@@ -312,8 +310,7 @@ void purge_outstanding_packets(struct bat_priv *bat_priv,
312 hlist_for_each_entry_safe(forw_packet, tmp_node, safe_tmp_node, 310 hlist_for_each_entry_safe(forw_packet, tmp_node, safe_tmp_node,
313 &bat_priv->forw_bat_list, list) { 311 &bat_priv->forw_bat_list, list) {
314 312
315 /** 313 /* if purge_outstanding_packets() was called with an argument
316 * if purge_outstanding_packets() was called with an argument
317 * we delete only packets belonging to the given interface 314 * we delete only packets belonging to the given interface
318 */ 315 */
319 if ((hard_iface) && 316 if ((hard_iface) &&
@@ -322,8 +319,7 @@ void purge_outstanding_packets(struct bat_priv *bat_priv,
322 319
323 spin_unlock_bh(&bat_priv->forw_bat_list_lock); 320 spin_unlock_bh(&bat_priv->forw_bat_list_lock);
324 321
325 /** 322 /* send_outstanding_bat_packet() will lock the list to
326 * send_outstanding_bat_packet() will lock the list to
327 * delete the item from the list 323 * delete the item from the list
328 */ 324 */
329 pending = cancel_delayed_work_sync(&forw_packet->delayed_work); 325 pending = cancel_delayed_work_sync(&forw_packet->delayed_work);
diff --git a/net/batman-adv/send.h b/net/batman-adv/send.h
index 824ef06f9b01..e3ac75ba432b 100644
--- a/net/batman-adv/send.h
+++ b/net/batman-adv/send.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
5 * 4 *
@@ -16,19 +15,19 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_SEND_H_ 20#ifndef _NET_BATMAN_ADV_SEND_H_
23#define _NET_BATMAN_ADV_SEND_H_ 21#define _NET_BATMAN_ADV_SEND_H_
24 22
25int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface, 23int batadv_send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
26 const uint8_t *dst_addr); 24 const uint8_t *dst_addr);
27void schedule_bat_ogm(struct hard_iface *hard_iface); 25void batadv_schedule_bat_ogm(struct hard_iface *hard_iface);
28int add_bcast_packet_to_list(struct bat_priv *bat_priv, 26int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
29 const struct sk_buff *skb, unsigned long delay); 27 const struct sk_buff *skb,
30void send_outstanding_bat_ogm_packet(struct work_struct *work); 28 unsigned long delay);
31void purge_outstanding_packets(struct bat_priv *bat_priv, 29void batadv_send_outstanding_bat_ogm_packet(struct work_struct *work);
32 const struct hard_iface *hard_iface); 30void batadv_purge_outstanding_packets(struct bat_priv *bat_priv,
31 const struct hard_iface *hard_iface);
33 32
34#endif /* _NET_BATMAN_ADV_SEND_H_ */ 33#endif /* _NET_BATMAN_ADV_SEND_H_ */
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 304a7ba09e03..0658781febde 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -61,12 +59,11 @@ static const struct ethtool_ops bat_ethtool_ops = {
61 .get_sset_count = batadv_get_sset_count, 59 .get_sset_count = batadv_get_sset_count,
62}; 60};
63 61
64int my_skb_head_push(struct sk_buff *skb, unsigned int len) 62int batadv_skb_head_push(struct sk_buff *skb, unsigned int len)
65{ 63{
66 int result; 64 int result;
67 65
68 /** 66 /* TODO: We must check if we can release all references to non-payload
69 * TODO: We must check if we can release all references to non-payload
70 * data using skb_header_release in our skbs to allow skb_cow_header to 67 * data using skb_header_release in our skbs to allow skb_cow_header to
71 * work optimally. This means that those skbs are not allowed to read 68 * work optimally. This means that those skbs are not allowed to read
72 * or write any data which is before the current position of skb->data 69 * or write any data which is before the current position of skb->data
@@ -109,9 +106,9 @@ static int interface_set_mac_addr(struct net_device *dev, void *p)
109 106
110 /* only modify transtable if it has been initialized before */ 107 /* only modify transtable if it has been initialized before */
111 if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) { 108 if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) {
112 tt_local_remove(bat_priv, dev->dev_addr, 109 batadv_tt_local_remove(bat_priv, dev->dev_addr,
113 "mac address changed", false); 110 "mac address changed", false);
114 tt_local_add(dev, addr->sa_data, NULL_IFINDEX); 111 batadv_tt_local_add(dev, addr->sa_data, NULL_IFINDEX);
115 } 112 }
116 113
117 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); 114 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
@@ -122,7 +119,7 @@ static int interface_set_mac_addr(struct net_device *dev, void *p)
122static int interface_change_mtu(struct net_device *dev, int new_mtu) 119static int interface_change_mtu(struct net_device *dev, int new_mtu)
123{ 120{
124 /* check ranges */ 121 /* check ranges */
125 if ((new_mtu < 68) || (new_mtu > hardif_min_mtu(dev))) 122 if ((new_mtu < 68) || (new_mtu > batadv_hardif_min_mtu(dev)))
126 return -EINVAL; 123 return -EINVAL;
127 124
128 dev->mtu = new_mtu; 125 dev->mtu = new_mtu;
@@ -162,11 +159,11 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
162 goto dropped; 159 goto dropped;
163 } 160 }
164 161
165 if (bla_tx(bat_priv, skb, vid)) 162 if (batadv_bla_tx(bat_priv, skb, vid))
166 goto dropped; 163 goto dropped;
167 164
168 /* Register the client MAC in the transtable */ 165 /* Register the client MAC in the transtable */
169 tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif); 166 batadv_tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
170 167
171 /* don't accept stp packets. STP does not help in meshes. 168 /* don't accept stp packets. STP does not help in meshes.
172 * better use the bridge loop avoidance ... 169 * better use the bridge loop avoidance ...
@@ -180,15 +177,17 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
180 switch (atomic_read(&bat_priv->gw_mode)) { 177 switch (atomic_read(&bat_priv->gw_mode)) {
181 case GW_MODE_SERVER: 178 case GW_MODE_SERVER:
182 /* gateway servers should not send dhcp 179 /* gateway servers should not send dhcp
183 * requests into the mesh */ 180 * requests into the mesh
184 ret = gw_is_dhcp_target(skb, &header_len); 181 */
182 ret = batadv_gw_is_dhcp_target(skb, &header_len);
185 if (ret) 183 if (ret)
186 goto dropped; 184 goto dropped;
187 break; 185 break;
188 case GW_MODE_CLIENT: 186 case GW_MODE_CLIENT:
189 /* gateway clients should send dhcp requests 187 /* gateway clients should send dhcp requests
190 * via unicast to their gateway */ 188 * via unicast to their gateway
191 ret = gw_is_dhcp_target(skb, &header_len); 189 */
190 ret = batadv_gw_is_dhcp_target(skb, &header_len);
192 if (ret) 191 if (ret)
193 do_bcast = false; 192 do_bcast = false;
194 break; 193 break;
@@ -204,7 +203,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
204 if (!primary_if) 203 if (!primary_if)
205 goto dropped; 204 goto dropped;
206 205
207 if (my_skb_head_push(skb, sizeof(*bcast_packet)) < 0) 206 if (batadv_skb_head_push(skb, sizeof(*bcast_packet)) < 0)
208 goto dropped; 207 goto dropped;
209 208
210 bcast_packet = (struct bcast_packet *)skb->data; 209 bcast_packet = (struct bcast_packet *)skb->data;
@@ -215,7 +214,8 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
215 bcast_packet->header.packet_type = BAT_BCAST; 214 bcast_packet->header.packet_type = BAT_BCAST;
216 215
217 /* hw address of first interface is the orig mac because only 216 /* hw address of first interface is the orig mac because only
218 * this mac is known throughout the mesh */ 217 * this mac is known throughout the mesh
218 */
219 memcpy(bcast_packet->orig, 219 memcpy(bcast_packet->orig,
220 primary_if->net_dev->dev_addr, ETH_ALEN); 220 primary_if->net_dev->dev_addr, ETH_ALEN);
221 221
@@ -223,21 +223,22 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
223 bcast_packet->seqno = 223 bcast_packet->seqno =
224 htonl(atomic_inc_return(&bat_priv->bcast_seqno)); 224 htonl(atomic_inc_return(&bat_priv->bcast_seqno));
225 225
226 add_bcast_packet_to_list(bat_priv, skb, 1); 226 batadv_add_bcast_packet_to_list(bat_priv, skb, 1);
227 227
228 /* a copy is stored in the bcast list, therefore removing 228 /* a copy is stored in the bcast list, therefore removing
229 * the original skb. */ 229 * the original skb.
230 */
230 kfree_skb(skb); 231 kfree_skb(skb);
231 232
232 /* unicast packet */ 233 /* unicast packet */
233 } else { 234 } else {
234 if (atomic_read(&bat_priv->gw_mode) != GW_MODE_OFF) { 235 if (atomic_read(&bat_priv->gw_mode) != GW_MODE_OFF) {
235 ret = gw_out_of_range(bat_priv, skb, ethhdr); 236 ret = batadv_gw_out_of_range(bat_priv, skb, ethhdr);
236 if (ret) 237 if (ret)
237 goto dropped; 238 goto dropped;
238 } 239 }
239 240
240 ret = unicast_send_skb(skb, bat_priv); 241 ret = batadv_unicast_send_skb(skb, bat_priv);
241 if (ret != 0) 242 if (ret != 0)
242 goto dropped_freed; 243 goto dropped_freed;
243 } 244 }
@@ -256,9 +257,9 @@ end:
256 return NETDEV_TX_OK; 257 return NETDEV_TX_OK;
257} 258}
258 259
259void interface_rx(struct net_device *soft_iface, 260void batadv_interface_rx(struct net_device *soft_iface,
260 struct sk_buff *skb, struct hard_iface *recv_if, 261 struct sk_buff *skb, struct hard_iface *recv_if,
261 int hdr_size) 262 int hdr_size)
262{ 263{
263 struct bat_priv *bat_priv = netdev_priv(soft_iface); 264 struct bat_priv *bat_priv = netdev_priv(soft_iface);
264 struct ethhdr *ethhdr; 265 struct ethhdr *ethhdr;
@@ -294,22 +295,23 @@ void interface_rx(struct net_device *soft_iface,
294 295
295 /* should not be necessary anymore as we use skb_pull_rcsum() 296 /* should not be necessary anymore as we use skb_pull_rcsum()
296 * TODO: please verify this and remove this TODO 297 * TODO: please verify this and remove this TODO
297 * -- Dec 21st 2009, Simon Wunderlich */ 298 * -- Dec 21st 2009, Simon Wunderlich
299 */
298 300
299/* skb->ip_summed = CHECKSUM_UNNECESSARY;*/ 301 /* skb->ip_summed = CHECKSUM_UNNECESSARY; */
300 302
301 bat_priv->stats.rx_packets++; 303 bat_priv->stats.rx_packets++;
302 bat_priv->stats.rx_bytes += skb->len + ETH_HLEN; 304 bat_priv->stats.rx_bytes += skb->len + ETH_HLEN;
303 305
304 soft_iface->last_rx = jiffies; 306 soft_iface->last_rx = jiffies;
305 307
306 if (is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest)) 308 if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest))
307 goto dropped; 309 goto dropped;
308 310
309 /* Let the bridge loop avoidance check the packet. If will 311 /* Let the bridge loop avoidance check the packet. If will
310 * not handle it, we can safely push it up. 312 * not handle it, we can safely push it up.
311 */ 313 */
312 if (bla_rx(bat_priv, skb, vid)) 314 if (batadv_bla_rx(bat_priv, skb, vid))
313 goto out; 315 goto out;
314 316
315 netif_rx(skb); 317 netif_rx(skb);
@@ -341,8 +343,7 @@ static void interface_setup(struct net_device *dev)
341 dev->destructor = free_netdev; 343 dev->destructor = free_netdev;
342 dev->tx_queue_len = 0; 344 dev->tx_queue_len = 0;
343 345
344 /** 346 /* can't call min_mtu, because the needed variables
345 * can't call min_mtu, because the needed variables
346 * have not been initialized yet 347 * have not been initialized yet
347 */ 348 */
348 dev->mtu = ETH_DATA_LEN; 349 dev->mtu = ETH_DATA_LEN;
@@ -357,7 +358,7 @@ static void interface_setup(struct net_device *dev)
357 memset(priv, 0, sizeof(*priv)); 358 memset(priv, 0, sizeof(*priv));
358} 359}
359 360
360struct net_device *softif_create(const char *name) 361struct net_device *batadv_softif_create(const char *name)
361{ 362{
362 struct net_device *soft_iface; 363 struct net_device *soft_iface;
363 struct bat_priv *bat_priv; 364 struct bat_priv *bat_priv;
@@ -411,28 +412,28 @@ struct net_device *softif_create(const char *name)
411 if (!bat_priv->bat_counters) 412 if (!bat_priv->bat_counters)
412 goto unreg_soft_iface; 413 goto unreg_soft_iface;
413 414
414 ret = bat_algo_select(bat_priv, bat_routing_algo); 415 ret = batadv_algo_select(bat_priv, batadv_routing_algo);
415 if (ret < 0) 416 if (ret < 0)
416 goto free_bat_counters; 417 goto free_bat_counters;
417 418
418 ret = sysfs_add_meshif(soft_iface); 419 ret = batadv_sysfs_add_meshif(soft_iface);
419 if (ret < 0) 420 if (ret < 0)
420 goto free_bat_counters; 421 goto free_bat_counters;
421 422
422 ret = debugfs_add_meshif(soft_iface); 423 ret = batadv_debugfs_add_meshif(soft_iface);
423 if (ret < 0) 424 if (ret < 0)
424 goto unreg_sysfs; 425 goto unreg_sysfs;
425 426
426 ret = mesh_init(soft_iface); 427 ret = batadv_mesh_init(soft_iface);
427 if (ret < 0) 428 if (ret < 0)
428 goto unreg_debugfs; 429 goto unreg_debugfs;
429 430
430 return soft_iface; 431 return soft_iface;
431 432
432unreg_debugfs: 433unreg_debugfs:
433 debugfs_del_meshif(soft_iface); 434 batadv_debugfs_del_meshif(soft_iface);
434unreg_sysfs: 435unreg_sysfs:
435 sysfs_del_meshif(soft_iface); 436 batadv_sysfs_del_meshif(soft_iface);
436free_bat_counters: 437free_bat_counters:
437 free_percpu(bat_priv->bat_counters); 438 free_percpu(bat_priv->bat_counters);
438unreg_soft_iface: 439unreg_soft_iface:
@@ -445,15 +446,15 @@ out:
445 return NULL; 446 return NULL;
446} 447}
447 448
448void softif_destroy(struct net_device *soft_iface) 449void batadv_softif_destroy(struct net_device *soft_iface)
449{ 450{
450 debugfs_del_meshif(soft_iface); 451 batadv_debugfs_del_meshif(soft_iface);
451 sysfs_del_meshif(soft_iface); 452 batadv_sysfs_del_meshif(soft_iface);
452 mesh_free(soft_iface); 453 batadv_mesh_free(soft_iface);
453 unregister_netdevice(soft_iface); 454 unregister_netdevice(soft_iface);
454} 455}
455 456
456int softif_is_valid(const struct net_device *net_dev) 457int batadv_softif_is_valid(const struct net_device *net_dev)
457{ 458{
458 if (net_dev->netdev_ops->ndo_start_xmit == interface_tx) 459 if (net_dev->netdev_ops->ndo_start_xmit == interface_tx)
459 return 1; 460 return 1;
diff --git a/net/batman-adv/soft-interface.h b/net/batman-adv/soft-interface.h
index 020300673884..2711ba5b1233 100644
--- a/net/batman-adv/soft-interface.h
+++ b/net/batman-adv/soft-interface.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner 3 * Marek Lindner
5 * 4 *
@@ -16,18 +15,16 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_SOFT_INTERFACE_H_ 20#ifndef _NET_BATMAN_ADV_SOFT_INTERFACE_H_
23#define _NET_BATMAN_ADV_SOFT_INTERFACE_H_ 21#define _NET_BATMAN_ADV_SOFT_INTERFACE_H_
24 22
25int my_skb_head_push(struct sk_buff *skb, unsigned int len); 23int batadv_skb_head_push(struct sk_buff *skb, unsigned int len);
26void interface_rx(struct net_device *soft_iface, 24void batadv_interface_rx(struct net_device *soft_iface, struct sk_buff *skb,
27 struct sk_buff *skb, struct hard_iface *recv_if, 25 struct hard_iface *recv_if, int hdr_size);
28 int hdr_size); 26struct net_device *batadv_softif_create(const char *name);
29struct net_device *softif_create(const char *name); 27void batadv_softif_destroy(struct net_device *soft_iface);
30void softif_destroy(struct net_device *soft_iface); 28int batadv_softif_is_valid(const struct net_device *net_dev);
31int softif_is_valid(const struct net_device *net_dev);
32 29
33#endif /* _NET_BATMAN_ADV_SOFT_INTERFACE_H_ */ 30#endif /* _NET_BATMAN_ADV_SOFT_INTERFACE_H_ */
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index a1a51cc9d88e..5180d50e909d 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich, Antonio Quartulli 3 * Marek Lindner, Simon Wunderlich, Antonio Quartulli
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -48,7 +46,7 @@ static int compare_tt(const struct hlist_node *node, const void *data2)
48static void tt_start_timer(struct bat_priv *bat_priv) 46static void tt_start_timer(struct bat_priv *bat_priv)
49{ 47{
50 INIT_DELAYED_WORK(&bat_priv->tt_work, tt_purge); 48 INIT_DELAYED_WORK(&bat_priv->tt_work, tt_purge);
51 queue_delayed_work(bat_event_workqueue, &bat_priv->tt_work, 49 queue_delayed_work(batadv_event_workqueue, &bat_priv->tt_work,
52 msecs_to_jiffies(5000)); 50 msecs_to_jiffies(5000));
53} 51}
54 52
@@ -142,7 +140,7 @@ static void tt_orig_list_entry_free_rcu(struct rcu_head *rcu)
142 140
143 orig_entry = container_of(rcu, struct tt_orig_list_entry, rcu); 141 orig_entry = container_of(rcu, struct tt_orig_list_entry, rcu);
144 atomic_dec(&orig_entry->orig_node->tt_size); 142 atomic_dec(&orig_entry->orig_node->tt_size);
145 orig_node_free_ref(orig_entry->orig_node); 143 batadv_orig_node_free_ref(orig_entry->orig_node);
146 kfree(orig_entry); 144 kfree(orig_entry);
147} 145}
148 146
@@ -173,7 +171,7 @@ static void tt_local_event(struct bat_priv *bat_priv, const uint8_t *addr,
173 atomic_set(&bat_priv->tt_ogm_append_cnt, 0); 171 atomic_set(&bat_priv->tt_ogm_append_cnt, 0);
174} 172}
175 173
176int tt_len(int changes_num) 174int batadv_tt_len(int changes_num)
177{ 175{
178 return changes_num * sizeof(struct tt_change); 176 return changes_num * sizeof(struct tt_change);
179} 177}
@@ -183,7 +181,7 @@ static int tt_local_init(struct bat_priv *bat_priv)
183 if (bat_priv->tt_local_hash) 181 if (bat_priv->tt_local_hash)
184 return 0; 182 return 0;
185 183
186 bat_priv->tt_local_hash = hash_new(1024); 184 bat_priv->tt_local_hash = batadv_hash_new(1024);
187 185
188 if (!bat_priv->tt_local_hash) 186 if (!bat_priv->tt_local_hash)
189 return -ENOMEM; 187 return -ENOMEM;
@@ -191,8 +189,8 @@ static int tt_local_init(struct bat_priv *bat_priv)
191 return 0; 189 return 0;
192} 190}
193 191
194void tt_local_add(struct net_device *soft_iface, const uint8_t *addr, 192void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
195 int ifindex) 193 int ifindex)
196{ 194{
197 struct bat_priv *bat_priv = netdev_priv(soft_iface); 195 struct bat_priv *bat_priv = netdev_priv(soft_iface);
198 struct tt_local_entry *tt_local_entry = NULL; 196 struct tt_local_entry *tt_local_entry = NULL;
@@ -221,7 +219,7 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
221 219
222 memcpy(tt_local_entry->common.addr, addr, ETH_ALEN); 220 memcpy(tt_local_entry->common.addr, addr, ETH_ALEN);
223 tt_local_entry->common.flags = NO_FLAGS; 221 tt_local_entry->common.flags = NO_FLAGS;
224 if (is_wifi_iface(ifindex)) 222 if (batadv_is_wifi_iface(ifindex))
225 tt_local_entry->common.flags |= TT_CLIENT_WIFI; 223 tt_local_entry->common.flags |= TT_CLIENT_WIFI;
226 atomic_set(&tt_local_entry->common.refcount, 2); 224 atomic_set(&tt_local_entry->common.refcount, 2);
227 tt_local_entry->last_seen = jiffies; 225 tt_local_entry->last_seen = jiffies;
@@ -232,7 +230,8 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
232 230
233 /* The local entry has to be marked as NEW to avoid to send it in 231 /* The local entry has to be marked as NEW to avoid to send it in
234 * a full table response going out before the next ttvn increment 232 * a full table response going out before the next ttvn increment
235 * (consistency check) */ 233 * (consistency check)
234 */
236 tt_local_entry->common.flags |= TT_CLIENT_NEW; 235 tt_local_entry->common.flags |= TT_CLIENT_NEW;
237 236
238 hash_added = hash_add(bat_priv->tt_local_hash, compare_tt, choose_orig, 237 hash_added = hash_add(bat_priv->tt_local_hash, compare_tt, choose_orig,
@@ -302,7 +301,7 @@ static void tt_prepare_packet_buff(struct bat_priv *bat_priv,
302 primary_if = primary_if_get_selected(bat_priv); 301 primary_if = primary_if_get_selected(bat_priv);
303 302
304 req_len = min_packet_len; 303 req_len = min_packet_len;
305 req_len += tt_len(atomic_read(&bat_priv->tt_local_changes)); 304 req_len += batadv_tt_len(atomic_read(&bat_priv->tt_local_changes));
306 305
307 /* if we have too many changes for one packet don't send any 306 /* if we have too many changes for one packet don't send any
308 * and wait for the tt table request which will be fragmented 307 * and wait for the tt table request which will be fragmented
@@ -332,7 +331,7 @@ static int tt_changes_fill_buff(struct bat_priv *bat_priv,
332 tt_buff = *packet_buff + min_packet_len; 331 tt_buff = *packet_buff + min_packet_len;
333 332
334 if (new_len > 0) 333 if (new_len > 0)
335 tot_changes = new_len / tt_len(1); 334 tot_changes = new_len / batadv_tt_len(1);
336 335
337 spin_lock_bh(&bat_priv->tt_changes_list_lock); 336 spin_lock_bh(&bat_priv->tt_changes_list_lock);
338 atomic_set(&bat_priv->tt_local_changes, 0); 337 atomic_set(&bat_priv->tt_local_changes, 0);
@@ -340,7 +339,7 @@ static int tt_changes_fill_buff(struct bat_priv *bat_priv,
340 list_for_each_entry_safe(entry, safe, &bat_priv->tt_changes_list, 339 list_for_each_entry_safe(entry, safe, &bat_priv->tt_changes_list,
341 list) { 340 list) {
342 if (count < tot_changes) { 341 if (count < tot_changes) {
343 memcpy(tt_buff + tt_len(count), 342 memcpy(tt_buff + batadv_tt_len(count),
344 &entry->change, sizeof(struct tt_change)); 343 &entry->change, sizeof(struct tt_change));
345 count++; 344 count++;
346 } 345 }
@@ -370,7 +369,7 @@ static int tt_changes_fill_buff(struct bat_priv *bat_priv,
370 return count; 369 return count;
371} 370}
372 371
373int tt_local_seq_print_text(struct seq_file *seq, void *offset) 372int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset)
374{ 373{
375 struct net_device *net_dev = (struct net_device *)seq->private; 374 struct net_device *net_dev = (struct net_device *)seq->private;
376 struct bat_priv *bat_priv = netdev_priv(net_dev); 375 struct bat_priv *bat_priv = netdev_priv(net_dev);
@@ -437,7 +436,8 @@ static void tt_local_set_pending(struct bat_priv *bat_priv,
437 436
438 /* The local client has to be marked as "pending to be removed" but has 437 /* The local client has to be marked as "pending to be removed" but has
439 * to be kept in the table in order to send it in a full table 438 * to be kept in the table in order to send it in a full table
440 * response issued before the net ttvn increment (consistency check) */ 439 * response issued before the net ttvn increment (consistency check)
440 */
441 tt_local_entry->common.flags |= TT_CLIENT_PENDING; 441 tt_local_entry->common.flags |= TT_CLIENT_PENDING;
442 442
443 bat_dbg(DBG_TT, bat_priv, 443 bat_dbg(DBG_TT, bat_priv,
@@ -445,8 +445,8 @@ static void tt_local_set_pending(struct bat_priv *bat_priv,
445 tt_local_entry->common.addr, message); 445 tt_local_entry->common.addr, message);
446} 446}
447 447
448void tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, 448void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr,
449 const char *message, bool roaming) 449 const char *message, bool roaming)
450{ 450{
451 struct tt_local_entry *tt_local_entry = NULL; 451 struct tt_local_entry *tt_local_entry = NULL;
452 452
@@ -531,7 +531,7 @@ static void tt_local_table_free(struct bat_priv *bat_priv)
531 spin_unlock_bh(list_lock); 531 spin_unlock_bh(list_lock);
532 } 532 }
533 533
534 hash_destroy(hash); 534 batadv_hash_destroy(hash);
535 535
536 bat_priv->tt_local_hash = NULL; 536 bat_priv->tt_local_hash = NULL;
537} 537}
@@ -541,7 +541,7 @@ static int tt_global_init(struct bat_priv *bat_priv)
541 if (bat_priv->tt_global_hash) 541 if (bat_priv->tt_global_hash)
542 return 0; 542 return 0;
543 543
544 bat_priv->tt_global_hash = hash_new(1024); 544 bat_priv->tt_global_hash = batadv_hash_new(1024);
545 545
546 if (!bat_priv->tt_global_hash) 546 if (!bat_priv->tt_global_hash)
547 return -ENOMEM; 547 return -ENOMEM;
@@ -611,9 +611,9 @@ static void tt_global_add_orig_entry(struct tt_global_entry *tt_global_entry,
611} 611}
612 612
613/* caller must hold orig_node refcount */ 613/* caller must hold orig_node refcount */
614int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, 614int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
615 const unsigned char *tt_addr, uint8_t ttvn, bool roaming, 615 const unsigned char *tt_addr, uint8_t ttvn,
616 bool wifi) 616 bool roaming, bool wifi)
617{ 617{
618 struct tt_global_entry *tt_global_entry = NULL; 618 struct tt_global_entry *tt_global_entry = NULL;
619 int ret = 0; 619 int ret = 0;
@@ -677,8 +677,8 @@ int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
677 677
678out_remove: 678out_remove:
679 /* remove address from local hash if present */ 679 /* remove address from local hash if present */
680 tt_local_remove(bat_priv, tt_global_entry->common.addr, 680 batadv_tt_local_remove(bat_priv, tt_global_entry->common.addr,
681 "global tt received", roaming); 681 "global tt received", roaming);
682 ret = 1; 682 ret = 1;
683out: 683out:
684 if (tt_global_entry) 684 if (tt_global_entry)
@@ -714,7 +714,7 @@ static void tt_global_print_entry(struct tt_global_entry *tt_global_entry,
714 } 714 }
715} 715}
716 716
717int tt_global_seq_print_text(struct seq_file *seq, void *offset) 717int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset)
718{ 718{
719 struct net_device *net_dev = (struct net_device *)seq->private; 719 struct net_device *net_dev = (struct net_device *)seq->private;
720 struct bat_priv *bat_priv = netdev_priv(net_dev); 720 struct bat_priv *bat_priv = netdev_priv(net_dev);
@@ -898,8 +898,8 @@ static void tt_global_del(struct bat_priv *bat_priv,
898 * If there are other originators left, we directly delete 898 * If there are other originators left, we directly delete
899 * the originator. 899 * the originator.
900 * 2) the client roamed to us => we can directly delete 900 * 2) the client roamed to us => we can directly delete
901 * the global entry, since it is useless now. */ 901 * the global entry, since it is useless now.
902 902 */
903 tt_local_entry = tt_local_hash_find(bat_priv, 903 tt_local_entry = tt_local_hash_find(bat_priv,
904 tt_global_entry->common.addr); 904 tt_global_entry->common.addr);
905 if (tt_local_entry) { 905 if (tt_local_entry) {
@@ -919,8 +919,8 @@ out:
919 tt_local_entry_free_ref(tt_local_entry); 919 tt_local_entry_free_ref(tt_local_entry);
920} 920}
921 921
922void tt_global_del_orig(struct bat_priv *bat_priv, 922void batadv_tt_global_del_orig(struct bat_priv *bat_priv,
923 struct orig_node *orig_node, const char *message) 923 struct orig_node *orig_node, const char *message)
924{ 924{
925 struct tt_global_entry *tt_global_entry; 925 struct tt_global_entry *tt_global_entry;
926 struct tt_common_entry *tt_common_entry; 926 struct tt_common_entry *tt_common_entry;
@@ -1031,7 +1031,7 @@ static void tt_global_table_free(struct bat_priv *bat_priv)
1031 spin_unlock_bh(list_lock); 1031 spin_unlock_bh(list_lock);
1032 } 1032 }
1033 1033
1034 hash_destroy(hash); 1034 batadv_hash_destroy(hash);
1035 1035
1036 bat_priv->tt_global_hash = NULL; 1036 bat_priv->tt_global_hash = NULL;
1037} 1037}
@@ -1048,8 +1048,9 @@ static bool _is_ap_isolated(struct tt_local_entry *tt_local_entry,
1048 return ret; 1048 return ret;
1049} 1049}
1050 1050
1051struct orig_node *transtable_search(struct bat_priv *bat_priv, 1051struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv,
1052 const uint8_t *src, const uint8_t *addr) 1052 const uint8_t *src,
1053 const uint8_t *addr)
1053{ 1054{
1054 struct tt_local_entry *tt_local_entry = NULL; 1055 struct tt_local_entry *tt_local_entry = NULL;
1055 struct tt_global_entry *tt_global_entry = NULL; 1056 struct tt_global_entry *tt_global_entry = NULL;
@@ -1071,7 +1072,8 @@ struct orig_node *transtable_search(struct bat_priv *bat_priv,
1071 goto out; 1072 goto out;
1072 1073
1073 /* check whether the clients should not communicate due to AP 1074 /* check whether the clients should not communicate due to AP
1074 * isolation */ 1075 * isolation
1076 */
1075 if (tt_local_entry && _is_ap_isolated(tt_local_entry, tt_global_entry)) 1077 if (tt_local_entry && _is_ap_isolated(tt_local_entry, tt_global_entry))
1076 goto out; 1078 goto out;
1077 1079
@@ -1080,7 +1082,7 @@ struct orig_node *transtable_search(struct bat_priv *bat_priv,
1080 rcu_read_lock(); 1082 rcu_read_lock();
1081 head = &tt_global_entry->orig_list; 1083 head = &tt_global_entry->orig_list;
1082 hlist_for_each_entry_rcu(orig_entry, node, head, list) { 1084 hlist_for_each_entry_rcu(orig_entry, node, head, list) {
1083 router = orig_node_get_router(orig_entry->orig_node); 1085 router = batadv_orig_node_get_router(orig_entry->orig_node);
1084 if (!router) 1086 if (!router)
1085 continue; 1087 continue;
1086 1088
@@ -1088,7 +1090,7 @@ struct orig_node *transtable_search(struct bat_priv *bat_priv,
1088 orig_node = orig_entry->orig_node; 1090 orig_node = orig_entry->orig_node;
1089 best_tq = router->tq_avg; 1091 best_tq = router->tq_avg;
1090 } 1092 }
1091 neigh_node_free_ref(router); 1093 batadv_neigh_node_free_ref(router);
1092 } 1094 }
1093 /* found anything? */ 1095 /* found anything? */
1094 if (orig_node && !atomic_inc_not_zero(&orig_node->refcount)) 1096 if (orig_node && !atomic_inc_not_zero(&orig_node->refcount))
@@ -1170,7 +1172,8 @@ static uint16_t batadv_tt_local_crc(struct bat_priv *bat_priv)
1170 hlist_for_each_entry_rcu(tt_common_entry, node, 1172 hlist_for_each_entry_rcu(tt_common_entry, node,
1171 head, hash_entry) { 1173 head, hash_entry) {
1172 /* not yet committed clients have not to be taken into 1174 /* not yet committed clients have not to be taken into
1173 * account while computing the CRC */ 1175 * account while computing the CRC
1176 */
1174 if (tt_common_entry->flags & TT_CLIENT_NEW) 1177 if (tt_common_entry->flags & TT_CLIENT_NEW)
1175 continue; 1178 continue;
1176 total_one = 0; 1179 total_one = 0;
@@ -1204,10 +1207,11 @@ static void tt_save_orig_buffer(struct bat_priv *bat_priv,
1204 const unsigned char *tt_buff, 1207 const unsigned char *tt_buff,
1205 uint8_t tt_num_changes) 1208 uint8_t tt_num_changes)
1206{ 1209{
1207 uint16_t tt_buff_len = tt_len(tt_num_changes); 1210 uint16_t tt_buff_len = batadv_tt_len(tt_num_changes);
1208 1211
1209 /* Replace the old buffer only if I received something in the 1212 /* Replace the old buffer only if I received something in the
1210 * last OGM (the OGM could carry no changes) */ 1213 * last OGM (the OGM could carry no changes)
1214 */
1211 spin_lock_bh(&orig_node->tt_buff_lock); 1215 spin_lock_bh(&orig_node->tt_buff_lock);
1212 if (tt_buff_len > 0) { 1216 if (tt_buff_len > 0) {
1213 kfree(orig_node->tt_buff); 1217 kfree(orig_node->tt_buff);
@@ -1236,7 +1240,8 @@ static void tt_req_purge(struct bat_priv *bat_priv)
1236} 1240}
1237 1241
1238/* returns the pointer to the new tt_req_node struct if no request 1242/* returns the pointer to the new tt_req_node struct if no request
1239 * has already been issued for this orig_node, NULL otherwise */ 1243 * has already been issued for this orig_node, NULL otherwise
1244 */
1240static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv, 1245static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv,
1241 struct orig_node *orig_node) 1246 struct orig_node *orig_node)
1242{ 1247{
@@ -1346,7 +1351,8 @@ static struct sk_buff *tt_response_fill_table(uint16_t tt_len, uint8_t ttvn,
1346 rcu_read_unlock(); 1351 rcu_read_unlock();
1347 1352
1348 /* store in the message the number of entries we have successfully 1353 /* store in the message the number of entries we have successfully
1349 * copied */ 1354 * copied
1355 */
1350 tt_response->tt_data = htons(tt_count); 1356 tt_response->tt_data = htons(tt_count);
1351 1357
1352out: 1358out:
@@ -1369,7 +1375,8 @@ static int send_tt_request(struct bat_priv *bat_priv,
1369 goto out; 1375 goto out;
1370 1376
1371 /* The new tt_req will be issued only if I'm not waiting for a 1377 /* The new tt_req will be issued only if I'm not waiting for a
1372 * reply from the same orig_node yet */ 1378 * reply from the same orig_node yet
1379 */
1373 tt_req_node = new_tt_req_node(bat_priv, dst_orig_node); 1380 tt_req_node = new_tt_req_node(bat_priv, dst_orig_node);
1374 if (!tt_req_node) 1381 if (!tt_req_node)
1375 goto out; 1382 goto out;
@@ -1395,7 +1402,7 @@ static int send_tt_request(struct bat_priv *bat_priv,
1395 if (full_table) 1402 if (full_table)
1396 tt_request->flags |= TT_FULL_TABLE; 1403 tt_request->flags |= TT_FULL_TABLE;
1397 1404
1398 neigh_node = orig_node_get_router(dst_orig_node); 1405 neigh_node = batadv_orig_node_get_router(dst_orig_node);
1399 if (!neigh_node) 1406 if (!neigh_node)
1400 goto out; 1407 goto out;
1401 1408
@@ -1406,12 +1413,12 @@ static int send_tt_request(struct bat_priv *bat_priv,
1406 1413
1407 batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_TX); 1414 batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_TX);
1408 1415
1409 send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); 1416 batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
1410 ret = 0; 1417 ret = 0;
1411 1418
1412out: 1419out:
1413 if (neigh_node) 1420 if (neigh_node)
1414 neigh_node_free_ref(neigh_node); 1421 batadv_neigh_node_free_ref(neigh_node);
1415 if (primary_if) 1422 if (primary_if)
1416 hardif_free_ref(primary_if); 1423 hardif_free_ref(primary_if);
1417 if (ret) 1424 if (ret)
@@ -1453,7 +1460,7 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
1453 if (!res_dst_orig_node) 1460 if (!res_dst_orig_node)
1454 goto out; 1461 goto out;
1455 1462
1456 neigh_node = orig_node_get_router(res_dst_orig_node); 1463 neigh_node = batadv_orig_node_get_router(res_dst_orig_node);
1457 if (!neigh_node) 1464 if (!neigh_node)
1458 goto out; 1465 goto out;
1459 1466
@@ -1477,7 +1484,8 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
1477 full_table = false; 1484 full_table = false;
1478 1485
1479 /* In this version, fragmentation is not implemented, then 1486 /* In this version, fragmentation is not implemented, then
1480 * I'll send only one packet with as much TT entries as I can */ 1487 * I'll send only one packet with as much TT entries as I can
1488 */
1481 if (!full_table) { 1489 if (!full_table) {
1482 spin_lock_bh(&req_dst_orig_node->tt_buff_lock); 1490 spin_lock_bh(&req_dst_orig_node->tt_buff_lock);
1483 tt_len = req_dst_orig_node->tt_buff_len; 1491 tt_len = req_dst_orig_node->tt_buff_len;
@@ -1532,7 +1540,7 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
1532 1540
1533 batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_TX); 1541 batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_TX);
1534 1542
1535 send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); 1543 batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
1536 ret = true; 1544 ret = true;
1537 goto out; 1545 goto out;
1538 1546
@@ -1541,11 +1549,11 @@ unlock:
1541 1549
1542out: 1550out:
1543 if (res_dst_orig_node) 1551 if (res_dst_orig_node)
1544 orig_node_free_ref(res_dst_orig_node); 1552 batadv_orig_node_free_ref(res_dst_orig_node);
1545 if (req_dst_orig_node) 1553 if (req_dst_orig_node)
1546 orig_node_free_ref(req_dst_orig_node); 1554 batadv_orig_node_free_ref(req_dst_orig_node);
1547 if (neigh_node) 1555 if (neigh_node)
1548 neigh_node_free_ref(neigh_node); 1556 batadv_neigh_node_free_ref(neigh_node);
1549 if (primary_if) 1557 if (primary_if)
1550 hardif_free_ref(primary_if); 1558 hardif_free_ref(primary_if);
1551 if (!ret) 1559 if (!ret)
@@ -1580,7 +1588,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
1580 if (!orig_node) 1588 if (!orig_node)
1581 goto out; 1589 goto out;
1582 1590
1583 neigh_node = orig_node_get_router(orig_node); 1591 neigh_node = batadv_orig_node_get_router(orig_node);
1584 if (!neigh_node) 1592 if (!neigh_node)
1585 goto out; 1593 goto out;
1586 1594
@@ -1589,7 +1597,8 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
1589 goto out; 1597 goto out;
1590 1598
1591 /* If the full table has been explicitly requested or the gap 1599 /* If the full table has been explicitly requested or the gap
1592 * is too big send the whole local translation table */ 1600 * is too big send the whole local translation table
1601 */
1593 if (tt_request->flags & TT_FULL_TABLE || my_ttvn != req_ttvn || 1602 if (tt_request->flags & TT_FULL_TABLE || my_ttvn != req_ttvn ||
1594 !bat_priv->tt_buff) 1603 !bat_priv->tt_buff)
1595 full_table = true; 1604 full_table = true;
@@ -1597,7 +1606,8 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
1597 full_table = false; 1606 full_table = false;
1598 1607
1599 /* In this version, fragmentation is not implemented, then 1608 /* In this version, fragmentation is not implemented, then
1600 * I'll send only one packet with as much TT entries as I can */ 1609 * I'll send only one packet with as much TT entries as I can
1610 */
1601 if (!full_table) { 1611 if (!full_table) {
1602 spin_lock_bh(&bat_priv->tt_buff_lock); 1612 spin_lock_bh(&bat_priv->tt_buff_lock);
1603 tt_len = bat_priv->tt_buff_len; 1613 tt_len = bat_priv->tt_buff_len;
@@ -1650,7 +1660,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
1650 1660
1651 batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_TX); 1661 batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_TX);
1652 1662
1653 send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); 1663 batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
1654 ret = true; 1664 ret = true;
1655 goto out; 1665 goto out;
1656 1666
@@ -1658,9 +1668,9 @@ unlock:
1658 spin_unlock_bh(&bat_priv->tt_buff_lock); 1668 spin_unlock_bh(&bat_priv->tt_buff_lock);
1659out: 1669out:
1660 if (orig_node) 1670 if (orig_node)
1661 orig_node_free_ref(orig_node); 1671 batadv_orig_node_free_ref(orig_node);
1662 if (neigh_node) 1672 if (neigh_node)
1663 neigh_node_free_ref(neigh_node); 1673 batadv_neigh_node_free_ref(neigh_node);
1664 if (primary_if) 1674 if (primary_if)
1665 hardif_free_ref(primary_if); 1675 hardif_free_ref(primary_if);
1666 if (!ret) 1676 if (!ret)
@@ -1669,12 +1679,12 @@ out:
1669 return true; 1679 return true;
1670} 1680}
1671 1681
1672bool send_tt_response(struct bat_priv *bat_priv, 1682bool batadv_send_tt_response(struct bat_priv *bat_priv,
1673 struct tt_query_packet *tt_request) 1683 struct tt_query_packet *tt_request)
1674{ 1684{
1675 if (is_my_mac(tt_request->dst)) { 1685 if (batadv_is_my_mac(tt_request->dst)) {
1676 /* don't answer backbone gws! */ 1686 /* don't answer backbone gws! */
1677 if (bla_is_backbone_gw_orig(bat_priv, tt_request->src)) 1687 if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_request->src))
1678 return true; 1688 return true;
1679 1689
1680 return send_my_tt_response(bat_priv, tt_request); 1690 return send_my_tt_response(bat_priv, tt_request);
@@ -1689,18 +1699,19 @@ static void _tt_update_changes(struct bat_priv *bat_priv,
1689 uint16_t tt_num_changes, uint8_t ttvn) 1699 uint16_t tt_num_changes, uint8_t ttvn)
1690{ 1700{
1691 int i; 1701 int i;
1702 int is_wifi;
1692 1703
1693 for (i = 0; i < tt_num_changes; i++) { 1704 for (i = 0; i < tt_num_changes; i++) {
1694 if ((tt_change + i)->flags & TT_CLIENT_DEL) 1705 if ((tt_change + i)->flags & TT_CLIENT_DEL) {
1695 tt_global_del(bat_priv, orig_node, 1706 tt_global_del(bat_priv, orig_node,
1696 (tt_change + i)->addr, 1707 (tt_change + i)->addr,
1697 "tt removed by changes", 1708 "tt removed by changes",
1698 (tt_change + i)->flags & TT_CLIENT_ROAM); 1709 (tt_change + i)->flags & TT_CLIENT_ROAM);
1699 else 1710 } else {
1700 if (!tt_global_add(bat_priv, orig_node, 1711 is_wifi = (tt_change + i)->flags & TT_CLIENT_WIFI;
1701 (tt_change + i)->addr, ttvn, false, 1712 if (!batadv_tt_global_add(bat_priv, orig_node,
1702 (tt_change + i)->flags & 1713 (tt_change + i)->addr, ttvn,
1703 TT_CLIENT_WIFI)) 1714 false, is_wifi))
1704 /* In case of problem while storing a 1715 /* In case of problem while storing a
1705 * global_entry, we stop the updating 1716 * global_entry, we stop the updating
1706 * procedure without committing the 1717 * procedure without committing the
@@ -1708,6 +1719,7 @@ static void _tt_update_changes(struct bat_priv *bat_priv,
1708 * corrupted data on tt_request 1719 * corrupted data on tt_request
1709 */ 1720 */
1710 return; 1721 return;
1722 }
1711 } 1723 }
1712 orig_node->tt_initialised = true; 1724 orig_node->tt_initialised = true;
1713} 1725}
@@ -1722,7 +1734,7 @@ static void tt_fill_gtable(struct bat_priv *bat_priv,
1722 goto out; 1734 goto out;
1723 1735
1724 /* Purge the old table first.. */ 1736 /* Purge the old table first.. */
1725 tt_global_del_orig(bat_priv, orig_node, "Received full table"); 1737 batadv_tt_global_del_orig(bat_priv, orig_node, "Received full table");
1726 1738
1727 _tt_update_changes(bat_priv, orig_node, 1739 _tt_update_changes(bat_priv, orig_node,
1728 (struct tt_change *)(tt_response + 1), 1740 (struct tt_change *)(tt_response + 1),
@@ -1738,7 +1750,7 @@ static void tt_fill_gtable(struct bat_priv *bat_priv,
1738 1750
1739out: 1751out:
1740 if (orig_node) 1752 if (orig_node)
1741 orig_node_free_ref(orig_node); 1753 batadv_orig_node_free_ref(orig_node);
1742} 1754}
1743 1755
1744static void tt_update_changes(struct bat_priv *bat_priv, 1756static void tt_update_changes(struct bat_priv *bat_priv,
@@ -1754,7 +1766,7 @@ static void tt_update_changes(struct bat_priv *bat_priv,
1754 atomic_set(&orig_node->last_ttvn, ttvn); 1766 atomic_set(&orig_node->last_ttvn, ttvn);
1755} 1767}
1756 1768
1757bool is_my_client(struct bat_priv *bat_priv, const uint8_t *addr) 1769bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr)
1758{ 1770{
1759 struct tt_local_entry *tt_local_entry = NULL; 1771 struct tt_local_entry *tt_local_entry = NULL;
1760 bool ret = false; 1772 bool ret = false;
@@ -1763,7 +1775,8 @@ bool is_my_client(struct bat_priv *bat_priv, const uint8_t *addr)
1763 if (!tt_local_entry) 1775 if (!tt_local_entry)
1764 goto out; 1776 goto out;
1765 /* Check if the client has been logically deleted (but is kept for 1777 /* Check if the client has been logically deleted (but is kept for
1766 * consistency purpose) */ 1778 * consistency purpose)
1779 */
1767 if (tt_local_entry->common.flags & TT_CLIENT_PENDING) 1780 if (tt_local_entry->common.flags & TT_CLIENT_PENDING)
1768 goto out; 1781 goto out;
1769 ret = true; 1782 ret = true;
@@ -1773,8 +1786,8 @@ out:
1773 return ret; 1786 return ret;
1774} 1787}
1775 1788
1776void handle_tt_response(struct bat_priv *bat_priv, 1789void batadv_handle_tt_response(struct bat_priv *bat_priv,
1777 struct tt_query_packet *tt_response) 1790 struct tt_query_packet *tt_response)
1778{ 1791{
1779 struct tt_req_node *node, *safe; 1792 struct tt_req_node *node, *safe;
1780 struct orig_node *orig_node = NULL; 1793 struct orig_node *orig_node = NULL;
@@ -1786,7 +1799,7 @@ void handle_tt_response(struct bat_priv *bat_priv,
1786 (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); 1799 (tt_response->flags & TT_FULL_TABLE ? 'F' : '.'));
1787 1800
1788 /* we should have never asked a backbone gw */ 1801 /* we should have never asked a backbone gw */
1789 if (bla_is_backbone_gw_orig(bat_priv, tt_response->src)) 1802 if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_response->src))
1790 goto out; 1803 goto out;
1791 1804
1792 orig_node = orig_hash_find(bat_priv, tt_response->src); 1805 orig_node = orig_hash_find(bat_priv, tt_response->src);
@@ -1814,14 +1827,15 @@ void handle_tt_response(struct bat_priv *bat_priv,
1814 /* Recalculate the CRC for this orig_node and store it */ 1827 /* Recalculate the CRC for this orig_node and store it */
1815 orig_node->tt_crc = tt_global_crc(bat_priv, orig_node); 1828 orig_node->tt_crc = tt_global_crc(bat_priv, orig_node);
1816 /* Roaming phase is over: tables are in sync again. I can 1829 /* Roaming phase is over: tables are in sync again. I can
1817 * unset the flag */ 1830 * unset the flag
1831 */
1818 orig_node->tt_poss_change = false; 1832 orig_node->tt_poss_change = false;
1819out: 1833out:
1820 if (orig_node) 1834 if (orig_node)
1821 orig_node_free_ref(orig_node); 1835 batadv_orig_node_free_ref(orig_node);
1822} 1836}
1823 1837
1824int tt_init(struct bat_priv *bat_priv) 1838int batadv_tt_init(struct bat_priv *bat_priv)
1825{ 1839{
1826 int ret; 1840 int ret;
1827 1841
@@ -1871,7 +1885,8 @@ static void tt_roam_purge(struct bat_priv *bat_priv)
1871 * maximum number of possible roaming phases. In this case the ROAMING_ADV 1885 * maximum number of possible roaming phases. In this case the ROAMING_ADV
1872 * will not be sent. 1886 * will not be sent.
1873 * 1887 *
1874 * returns true if the ROAMING_ADV can be sent, false otherwise */ 1888 * returns true if the ROAMING_ADV can be sent, false otherwise
1889 */
1875static bool tt_check_roam_count(struct bat_priv *bat_priv, 1890static bool tt_check_roam_count(struct bat_priv *bat_priv,
1876 uint8_t *client) 1891 uint8_t *client)
1877{ 1892{
@@ -1880,7 +1895,8 @@ static bool tt_check_roam_count(struct bat_priv *bat_priv,
1880 1895
1881 spin_lock_bh(&bat_priv->tt_roam_list_lock); 1896 spin_lock_bh(&bat_priv->tt_roam_list_lock);
1882 /* The new tt_req will be issued only if I'm not waiting for a 1897 /* The new tt_req will be issued only if I'm not waiting for a
1883 * reply from the same orig_node yet */ 1898 * reply from the same orig_node yet
1899 */
1884 list_for_each_entry(tt_roam_node, &bat_priv->tt_roam_list, list) { 1900 list_for_each_entry(tt_roam_node, &bat_priv->tt_roam_list, list) {
1885 if (!compare_eth(tt_roam_node->addr, client)) 1901 if (!compare_eth(tt_roam_node->addr, client))
1886 continue; 1902 continue;
@@ -1923,7 +1939,8 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
1923 struct hard_iface *primary_if; 1939 struct hard_iface *primary_if;
1924 1940
1925 /* before going on we have to check whether the client has 1941 /* before going on we have to check whether the client has
1926 * already roamed to us too many times */ 1942 * already roamed to us too many times
1943 */
1927 if (!tt_check_roam_count(bat_priv, client)) 1944 if (!tt_check_roam_count(bat_priv, client))
1928 goto out; 1945 goto out;
1929 1946
@@ -1947,7 +1964,7 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
1947 memcpy(roam_adv_packet->dst, orig_node->orig, ETH_ALEN); 1964 memcpy(roam_adv_packet->dst, orig_node->orig, ETH_ALEN);
1948 memcpy(roam_adv_packet->client, client, ETH_ALEN); 1965 memcpy(roam_adv_packet->client, client, ETH_ALEN);
1949 1966
1950 neigh_node = orig_node_get_router(orig_node); 1967 neigh_node = batadv_orig_node_get_router(orig_node);
1951 if (!neigh_node) 1968 if (!neigh_node)
1952 goto out; 1969 goto out;
1953 1970
@@ -1957,12 +1974,12 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
1957 1974
1958 batadv_inc_counter(bat_priv, BAT_CNT_TT_ROAM_ADV_TX); 1975 batadv_inc_counter(bat_priv, BAT_CNT_TT_ROAM_ADV_TX);
1959 1976
1960 send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); 1977 batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
1961 ret = 0; 1978 ret = 0;
1962 1979
1963out: 1980out:
1964 if (neigh_node) 1981 if (neigh_node)
1965 neigh_node_free_ref(neigh_node); 1982 batadv_neigh_node_free_ref(neigh_node);
1966 if (ret) 1983 if (ret)
1967 kfree_skb(skb); 1984 kfree_skb(skb);
1968 return; 1985 return;
@@ -1983,7 +2000,7 @@ static void tt_purge(struct work_struct *work)
1983 tt_start_timer(bat_priv); 2000 tt_start_timer(bat_priv);
1984} 2001}
1985 2002
1986void tt_free(struct bat_priv *bat_priv) 2003void batadv_tt_free(struct bat_priv *bat_priv)
1987{ 2004{
1988 cancel_delayed_work_sync(&bat_priv->tt_work); 2005 cancel_delayed_work_sync(&bat_priv->tt_work);
1989 2006
@@ -1997,7 +2014,8 @@ void tt_free(struct bat_priv *bat_priv)
1997} 2014}
1998 2015
1999/* This function will enable or disable the specified flags for all the entries 2016/* This function will enable or disable the specified flags for all the entries
2000 * in the given hash table and returns the number of modified entries */ 2017 * in the given hash table and returns the number of modified entries
2018 */
2001static uint16_t tt_set_flags(struct hashtable_t *hash, uint16_t flags, 2019static uint16_t tt_set_flags(struct hashtable_t *hash, uint16_t flags,
2002 bool enable) 2020 bool enable)
2003{ 2021{
@@ -2125,7 +2143,8 @@ int batadv_tt_append_diff(struct bat_priv *bat_priv,
2125 return tt_num_changes; 2143 return tt_num_changes;
2126} 2144}
2127 2145
2128bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst) 2146bool batadv_is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src,
2147 uint8_t *dst)
2129{ 2148{
2130 struct tt_local_entry *tt_local_entry = NULL; 2149 struct tt_local_entry *tt_local_entry = NULL;
2131 struct tt_global_entry *tt_global_entry = NULL; 2150 struct tt_global_entry *tt_global_entry = NULL;
@@ -2155,24 +2174,27 @@ out:
2155 return ret; 2174 return ret;
2156} 2175}
2157 2176
2158void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, 2177void batadv_tt_update_orig(struct bat_priv *bat_priv,
2159 const unsigned char *tt_buff, uint8_t tt_num_changes, 2178 struct orig_node *orig_node,
2160 uint8_t ttvn, uint16_t tt_crc) 2179 const unsigned char *tt_buff, uint8_t tt_num_changes,
2180 uint8_t ttvn, uint16_t tt_crc)
2161{ 2181{
2162 uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn); 2182 uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn);
2163 bool full_table = true; 2183 bool full_table = true;
2164 2184
2165 /* don't care about a backbone gateways updates. */ 2185 /* don't care about a backbone gateways updates. */
2166 if (bla_is_backbone_gw_orig(bat_priv, orig_node->orig)) 2186 if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig))
2167 return; 2187 return;
2168 2188
2169 /* orig table not initialised AND first diff is in the OGM OR the ttvn 2189 /* orig table not initialised AND first diff is in the OGM OR the ttvn
2170 * increased by one -> we can apply the attached changes */ 2190 * increased by one -> we can apply the attached changes
2191 */
2171 if ((!orig_node->tt_initialised && ttvn == 1) || 2192 if ((!orig_node->tt_initialised && ttvn == 1) ||
2172 ttvn - orig_ttvn == 1) { 2193 ttvn - orig_ttvn == 1) {
2173 /* the OGM could not contain the changes due to their size or 2194 /* the OGM could not contain the changes due to their size or
2174 * because they have already been sent TT_OGM_APPEND_MAX times. 2195 * because they have already been sent TT_OGM_APPEND_MAX times.
2175 * In this case send a tt request */ 2196 * In this case send a tt request
2197 */
2176 if (!tt_num_changes) { 2198 if (!tt_num_changes) {
2177 full_table = false; 2199 full_table = false;
2178 goto request_table; 2200 goto request_table;
@@ -2183,7 +2205,8 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
2183 2205
2184 /* Even if we received the precomputed crc with the OGM, we 2206 /* Even if we received the precomputed crc with the OGM, we
2185 * prefer to recompute it to spot any possible inconsistency 2207 * prefer to recompute it to spot any possible inconsistency
2186 * in the global table */ 2208 * in the global table
2209 */
2187 orig_node->tt_crc = tt_global_crc(bat_priv, orig_node); 2210 orig_node->tt_crc = tt_global_crc(bat_priv, orig_node);
2188 2211
2189 /* The ttvn alone is not enough to guarantee consistency 2212 /* The ttvn alone is not enough to guarantee consistency
@@ -2193,17 +2216,19 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
2193 * consistent or not. E.g. a node could disconnect while its 2216 * consistent or not. E.g. a node could disconnect while its
2194 * ttvn is X and reconnect on ttvn = X + TTVN_MAX: in this case 2217 * ttvn is X and reconnect on ttvn = X + TTVN_MAX: in this case
2195 * checking the CRC value is mandatory to detect the 2218 * checking the CRC value is mandatory to detect the
2196 * inconsistency */ 2219 * inconsistency
2220 */
2197 if (orig_node->tt_crc != tt_crc) 2221 if (orig_node->tt_crc != tt_crc)
2198 goto request_table; 2222 goto request_table;
2199 2223
2200 /* Roaming phase is over: tables are in sync again. I can 2224 /* Roaming phase is over: tables are in sync again. I can
2201 * unset the flag */ 2225 * unset the flag
2226 */
2202 orig_node->tt_poss_change = false; 2227 orig_node->tt_poss_change = false;
2203 } else { 2228 } else {
2204 /* if we missed more than one change or our tables are not 2229 /* if we missed more than one change or our tables are not
2205 * in sync anymore -> request fresh tt data */ 2230 * in sync anymore -> request fresh tt data
2206 2231 */
2207 if (!orig_node->tt_initialised || ttvn != orig_ttvn || 2232 if (!orig_node->tt_initialised || ttvn != orig_ttvn ||
2208 orig_node->tt_crc != tt_crc) { 2233 orig_node->tt_crc != tt_crc) {
2209request_table: 2234request_table:
@@ -2222,7 +2247,8 @@ request_table:
2222 * originator to another one. This entry is kept is still kept for consistency 2247 * originator to another one. This entry is kept is still kept for consistency
2223 * purposes 2248 * purposes
2224 */ 2249 */
2225bool tt_global_client_is_roaming(struct bat_priv *bat_priv, uint8_t *addr) 2250bool batadv_tt_global_client_is_roaming(struct bat_priv *bat_priv,
2251 uint8_t *addr)
2226{ 2252{
2227 struct tt_global_entry *tt_global_entry; 2253 struct tt_global_entry *tt_global_entry;
2228 bool ret = false; 2254 bool ret = false;
diff --git a/net/batman-adv/translation-table.h b/net/batman-adv/translation-table.h
index d6ea30f9b026..7edc9dff8ba1 100644
--- a/net/batman-adv/translation-table.h
+++ b/net/batman-adv/translation-table.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich, Antonio Quartulli 3 * Marek Lindner, Simon Wunderlich, Antonio Quartulli
5 * 4 *
@@ -16,43 +15,49 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ 20#ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
23#define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ 21#define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
24 22
25int tt_len(int changes_num); 23int batadv_tt_len(int changes_num);
26int tt_init(struct bat_priv *bat_priv); 24int batadv_tt_init(struct bat_priv *bat_priv);
27void tt_local_add(struct net_device *soft_iface, const uint8_t *addr, 25void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
28 int ifindex); 26 int ifindex);
29void tt_local_remove(struct bat_priv *bat_priv, 27void batadv_tt_local_remove(struct bat_priv *bat_priv,
30 const uint8_t *addr, const char *message, bool roaming); 28 const uint8_t *addr, const char *message,
31int tt_local_seq_print_text(struct seq_file *seq, void *offset); 29 bool roaming);
32void tt_global_add_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, 30int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset);
33 const unsigned char *tt_buff, int tt_buff_len); 31void batadv_tt_global_add_orig(struct bat_priv *bat_priv,
34int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, 32 struct orig_node *orig_node,
35 const unsigned char *addr, uint8_t ttvn, bool roaming, 33 const unsigned char *tt_buff, int tt_buff_len);
36 bool wifi); 34int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
37int tt_global_seq_print_text(struct seq_file *seq, void *offset); 35 const unsigned char *addr, uint8_t ttvn, bool roaming,
38void tt_global_del_orig(struct bat_priv *bat_priv, 36 bool wifi);
39 struct orig_node *orig_node, const char *message); 37int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset);
40struct orig_node *transtable_search(struct bat_priv *bat_priv, 38void batadv_tt_global_del_orig(struct bat_priv *bat_priv,
41 const uint8_t *src, const uint8_t *addr); 39 struct orig_node *orig_node,
42void tt_free(struct bat_priv *bat_priv); 40 const char *message);
43bool send_tt_response(struct bat_priv *bat_priv, 41struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv,
44 struct tt_query_packet *tt_request); 42 const uint8_t *src,
45bool is_my_client(struct bat_priv *bat_priv, const uint8_t *addr); 43 const uint8_t *addr);
46void handle_tt_response(struct bat_priv *bat_priv, 44void batadv_tt_free(struct bat_priv *bat_priv);
47 struct tt_query_packet *tt_response); 45bool batadv_send_tt_response(struct bat_priv *bat_priv,
48bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst); 46 struct tt_query_packet *tt_request);
49void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, 47bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr);
50 const unsigned char *tt_buff, uint8_t tt_num_changes, 48void batadv_handle_tt_response(struct bat_priv *bat_priv,
51 uint8_t ttvn, uint16_t tt_crc); 49 struct tt_query_packet *tt_response);
50bool batadv_is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src,
51 uint8_t *dst);
52void batadv_tt_update_orig(struct bat_priv *bat_priv,
53 struct orig_node *orig_node,
54 const unsigned char *tt_buff, uint8_t tt_num_changes,
55 uint8_t ttvn, uint16_t tt_crc);
52int batadv_tt_append_diff(struct bat_priv *bat_priv, 56int batadv_tt_append_diff(struct bat_priv *bat_priv,
53 unsigned char **packet_buff, int *packet_buff_len, 57 unsigned char **packet_buff, int *packet_buff_len,
54 int packet_min_len); 58 int packet_min_len);
55bool tt_global_client_is_roaming(struct bat_priv *bat_priv, uint8_t *addr); 59bool batadv_tt_global_client_is_roaming(struct bat_priv *bat_priv,
60 uint8_t *addr);
56 61
57 62
58#endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */ 63#endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index bf71d525445a..053c5d4776ce 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Marek Lindner, Simon Wunderlich 3 * Marek Lindner, Simon Wunderlich
5 * 4 *
@@ -16,11 +15,8 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22
23
24#ifndef _NET_BATMAN_ADV_TYPES_H_ 20#ifndef _NET_BATMAN_ADV_TYPES_H_
25#define _NET_BATMAN_ADV_TYPES_H_ 21#define _NET_BATMAN_ADV_TYPES_H_
26 22
@@ -49,8 +45,7 @@ struct hard_iface {
49 struct rcu_head rcu; 45 struct rcu_head rcu;
50}; 46};
51 47
52/** 48/* orig_node - structure for orig_list maintaining nodes of mesh
53 * orig_node - structure for orig_list maintaining nodes of mesh
54 * @primary_addr: hosts primary interface address 49 * @primary_addr: hosts primary interface address
55 * @last_seen: when last packet from this node was received 50 * @last_seen: when last packet from this node was received
56 * @bcast_seqno_reset: time when the broadcast seqno window was reset 51 * @bcast_seqno_reset: time when the broadcast seqno window was reset
@@ -86,7 +81,8 @@ struct orig_node {
86 * If true, then I sent a Roaming_adv to this orig_node and I have to 81 * If true, then I sent a Roaming_adv to this orig_node and I have to
87 * inspect every packet directed to it to check whether it is still 82 * inspect every packet directed to it to check whether it is still
88 * the true destination or not. This flag will be reset to false as 83 * the true destination or not. This flag will be reset to false as
89 * soon as I receive a new TTVN from this orig_node */ 84 * soon as I receive a new TTVN from this orig_node
85 */
90 bool tt_poss_change; 86 bool tt_poss_change;
91 uint32_t last_real_seqno; 87 uint32_t last_real_seqno;
92 uint8_t last_ttl; 88 uint8_t last_ttl;
@@ -101,7 +97,8 @@ struct orig_node {
101 struct bat_priv *bat_priv; 97 struct bat_priv *bat_priv;
102 unsigned long last_frag_packet; 98 unsigned long last_frag_packet;
103 /* ogm_cnt_lock protects: bcast_own, bcast_own_sum, 99 /* ogm_cnt_lock protects: bcast_own, bcast_own_sum,
104 * neigh_node->real_bits, neigh_node->real_packet_count */ 100 * neigh_node->real_bits, neigh_node->real_packet_count
101 */
105 spinlock_t ogm_cnt_lock; 102 spinlock_t ogm_cnt_lock;
106 /* bcast_seqno_lock protects bcast_bits, last_bcast_seqno */ 103 /* bcast_seqno_lock protects bcast_bits, last_bcast_seqno */
107 spinlock_t bcast_seqno_lock; 104 spinlock_t bcast_seqno_lock;
@@ -118,8 +115,7 @@ struct gw_node {
118 struct rcu_head rcu; 115 struct rcu_head rcu;
119}; 116};
120 117
121/** 118/* neigh_node
122 * neigh_node
123 * @last_seen: when last packet via this neighbor was received 119 * @last_seen: when last packet via this neighbor was received
124 */ 120 */
125struct neigh_node { 121struct neigh_node {
@@ -191,7 +187,8 @@ struct bat_priv {
191 * If true, then I received a Roaming_adv and I have to inspect every 187 * If true, then I received a Roaming_adv and I have to inspect every
192 * packet directed to me to check whether I am still the true 188 * packet directed to me to check whether I am still the true
193 * destination or not. This flag will be reset to false as soon as I 189 * destination or not. This flag will be reset to false as soon as I
194 * increase my TTVN */ 190 * increase my TTVN
191 */
195 bool tt_poss_change; 192 bool tt_poss_change;
196 char num_ifaces; 193 char num_ifaces;
197 struct debug_log *debug_log; 194 struct debug_log *debug_log;
@@ -326,8 +323,7 @@ struct tt_roam_node {
326 struct list_head list; 323 struct list_head list;
327}; 324};
328 325
329/** 326/* forw_packet - structure for forw_list maintaining packets to be
330 * forw_packet - structure for forw_list maintaining packets to be
331 * send/forwarded 327 * send/forwarded
332 */ 328 */
333struct forw_packet { 329struct forw_packet {
@@ -369,7 +365,8 @@ struct frag_packet_list_entry {
369struct vis_info { 365struct vis_info {
370 unsigned long first_seen; 366 unsigned long first_seen;
371 /* list of server-neighbors we received a vis-packet 367 /* list of server-neighbors we received a vis-packet
372 * from. we should not reply to them. */ 368 * from. we should not reply to them.
369 */
373 struct list_head recv_list; 370 struct list_head recv_list;
374 struct list_head send_list; 371 struct list_head send_list;
375 struct kref refcount; 372 struct kref refcount;
@@ -377,7 +374,7 @@ struct vis_info {
377 struct bat_priv *bat_priv; 374 struct bat_priv *bat_priv;
378 /* this packet might be part of the vis send queue. */ 375 /* this packet might be part of the vis send queue. */
379 struct sk_buff *skb_packet; 376 struct sk_buff *skb_packet;
380 /* vis_info may follow here*/ 377 /* vis_info may follow here */
381} __packed; 378} __packed;
382 379
383struct vis_info_entry { 380struct vis_info_entry {
diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
index 74175c210858..b2b76df69607 100644
--- a/net/batman-adv/unicast.c
+++ b/net/batman-adv/unicast.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Andreas Langer 3 * Andreas Langer
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -101,7 +99,7 @@ static int frag_create_buffer(struct list_head *head)
101 for (i = 0; i < FRAG_BUFFER_SIZE; i++) { 99 for (i = 0; i < FRAG_BUFFER_SIZE; i++) {
102 tfp = kmalloc(sizeof(*tfp), GFP_ATOMIC); 100 tfp = kmalloc(sizeof(*tfp), GFP_ATOMIC);
103 if (!tfp) { 101 if (!tfp) {
104 frag_list_free(head); 102 batadv_frag_list_free(head);
105 return -ENOMEM; 103 return -ENOMEM;
106 } 104 }
107 tfp->skb = NULL; 105 tfp->skb = NULL;
@@ -151,7 +149,7 @@ mov_tail:
151 return NULL; 149 return NULL;
152} 150}
153 151
154void frag_list_free(struct list_head *head) 152void batadv_frag_list_free(struct list_head *head)
155{ 153{
156 struct frag_packet_list_entry *pf, *tmp_pf; 154 struct frag_packet_list_entry *pf, *tmp_pf;
157 155
@@ -172,8 +170,8 @@ void frag_list_free(struct list_head *head)
172 * or the skb could be reassembled (skb_new will point to the new packet and 170 * or the skb could be reassembled (skb_new will point to the new packet and
173 * skb was freed) 171 * skb was freed)
174 */ 172 */
175int frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv, 173int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
176 struct sk_buff **new_skb) 174 struct sk_buff **new_skb)
177{ 175{
178 struct orig_node *orig_node; 176 struct orig_node *orig_node;
179 struct frag_packet_list_entry *tmp_frag_entry; 177 struct frag_packet_list_entry *tmp_frag_entry;
@@ -212,12 +210,12 @@ int frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
212 210
213out: 211out:
214 if (orig_node) 212 if (orig_node)
215 orig_node_free_ref(orig_node); 213 batadv_orig_node_free_ref(orig_node);
216 return ret; 214 return ret;
217} 215}
218 216
219int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, 217int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
220 struct hard_iface *hard_iface, const uint8_t dstaddr[]) 218 struct hard_iface *hard_iface, const uint8_t dstaddr[])
221{ 219{
222 struct unicast_packet tmp_uc, *unicast_packet; 220 struct unicast_packet tmp_uc, *unicast_packet;
223 struct hard_iface *primary_if; 221 struct hard_iface *primary_if;
@@ -242,8 +240,8 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
242 memcpy(&tmp_uc, unicast_packet, uc_hdr_len); 240 memcpy(&tmp_uc, unicast_packet, uc_hdr_len);
243 skb_split(skb, frag_skb, data_len / 2 + uc_hdr_len); 241 skb_split(skb, frag_skb, data_len / 2 + uc_hdr_len);
244 242
245 if (my_skb_head_push(skb, ucf_hdr_len - uc_hdr_len) < 0 || 243 if (batadv_skb_head_push(skb, ucf_hdr_len - uc_hdr_len) < 0 ||
246 my_skb_head_push(frag_skb, ucf_hdr_len) < 0) 244 batadv_skb_head_push(frag_skb, ucf_hdr_len) < 0)
247 goto drop_frag; 245 goto drop_frag;
248 246
249 frag1 = (struct unicast_frag_packet *)skb->data; 247 frag1 = (struct unicast_frag_packet *)skb->data;
@@ -268,8 +266,8 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
268 frag1->seqno = htons(seqno - 1); 266 frag1->seqno = htons(seqno - 1);
269 frag2->seqno = htons(seqno); 267 frag2->seqno = htons(seqno);
270 268
271 send_skb_packet(skb, hard_iface, dstaddr); 269 batadv_send_skb_packet(skb, hard_iface, dstaddr);
272 send_skb_packet(frag_skb, hard_iface, dstaddr); 270 batadv_send_skb_packet(frag_skb, hard_iface, dstaddr);
273 ret = NET_RX_SUCCESS; 271 ret = NET_RX_SUCCESS;
274 goto out; 272 goto out;
275 273
@@ -283,7 +281,7 @@ out:
283 return ret; 281 return ret;
284} 282}
285 283
286int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv) 284int batadv_unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
287{ 285{
288 struct ethhdr *ethhdr = (struct ethhdr *)skb->data; 286 struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
289 struct unicast_packet *unicast_packet; 287 struct unicast_packet *unicast_packet;
@@ -294,28 +292,26 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
294 292
295 /* get routing information */ 293 /* get routing information */
296 if (is_multicast_ether_addr(ethhdr->h_dest)) { 294 if (is_multicast_ether_addr(ethhdr->h_dest)) {
297 orig_node = gw_get_selected_orig(bat_priv); 295 orig_node = batadv_gw_get_selected_orig(bat_priv);
298 if (orig_node) 296 if (orig_node)
299 goto find_router; 297 goto find_router;
300 } 298 }
301 299
302 /* check for tt host - increases orig_node refcount. 300 /* check for tt host - increases orig_node refcount.
303 * returns NULL in case of AP isolation */ 301 * returns NULL in case of AP isolation
304 orig_node = transtable_search(bat_priv, ethhdr->h_source, 302 */
305 ethhdr->h_dest); 303 orig_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
306 304 ethhdr->h_dest);
307find_router: 305find_router:
308 /** 306 /* find_router():
309 * find_router():
310 * - if orig_node is NULL it returns NULL 307 * - if orig_node is NULL it returns NULL
311 * - increases neigh_nodes refcount if found. 308 * - increases neigh_nodes refcount if found.
312 */ 309 */
313 neigh_node = find_router(bat_priv, orig_node, NULL); 310 neigh_node = batadv_find_router(bat_priv, orig_node, NULL);
314
315 if (!neigh_node) 311 if (!neigh_node)
316 goto out; 312 goto out;
317 313
318 if (my_skb_head_push(skb, sizeof(*unicast_packet)) < 0) 314 if (batadv_skb_head_push(skb, sizeof(*unicast_packet)) < 0)
319 goto out; 315 goto out;
320 316
321 unicast_packet = (struct unicast_packet *)skb->data; 317 unicast_packet = (struct unicast_packet *)skb->data;
@@ -336,7 +332,7 @@ find_router:
336 * try to reroute it because the ttvn contained in the header is less 332 * try to reroute it because the ttvn contained in the header is less
337 * than the current one 333 * than the current one
338 */ 334 */
339 if (tt_global_client_is_roaming(bat_priv, ethhdr->h_dest)) 335 if (batadv_tt_global_client_is_roaming(bat_priv, ethhdr->h_dest))
340 unicast_packet->ttvn = unicast_packet->ttvn - 1; 336 unicast_packet->ttvn = unicast_packet->ttvn - 1;
341 337
342 if (atomic_read(&bat_priv->fragmentation) && 338 if (atomic_read(&bat_priv->fragmentation) &&
@@ -344,20 +340,21 @@ find_router:
344 neigh_node->if_incoming->net_dev->mtu) { 340 neigh_node->if_incoming->net_dev->mtu) {
345 /* send frag skb decreases ttl */ 341 /* send frag skb decreases ttl */
346 unicast_packet->header.ttl++; 342 unicast_packet->header.ttl++;
347 ret = frag_send_skb(skb, bat_priv, 343 ret = batadv_frag_send_skb(skb, bat_priv,
348 neigh_node->if_incoming, neigh_node->addr); 344 neigh_node->if_incoming,
345 neigh_node->addr);
349 goto out; 346 goto out;
350 } 347 }
351 348
352 send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); 349 batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
353 ret = 0; 350 ret = 0;
354 goto out; 351 goto out;
355 352
356out: 353out:
357 if (neigh_node) 354 if (neigh_node)
358 neigh_node_free_ref(neigh_node); 355 batadv_neigh_node_free_ref(neigh_node);
359 if (orig_node) 356 if (orig_node)
360 orig_node_free_ref(orig_node); 357 batadv_orig_node_free_ref(orig_node);
361 if (ret == 1) 358 if (ret == 1)
362 kfree_skb(skb); 359 kfree_skb(skb);
363 return ret; 360 return ret;
diff --git a/net/batman-adv/unicast.h b/net/batman-adv/unicast.h
index a9faf6b1db19..87f8f89d1440 100644
--- a/net/batman-adv/unicast.h
+++ b/net/batman-adv/unicast.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Andreas Langer 3 * Andreas Langer
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_UNICAST_H_ 20#ifndef _NET_BATMAN_ADV_UNICAST_H_
@@ -27,12 +25,13 @@
27#define FRAG_TIMEOUT 10000 /* purge frag list entries after time in ms */ 25#define FRAG_TIMEOUT 10000 /* purge frag list entries after time in ms */
28#define FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */ 26#define FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */
29 27
30int 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,
31 struct sk_buff **new_skb); 29 struct sk_buff **new_skb);
32void frag_list_free(struct list_head *head); 30void batadv_frag_list_free(struct list_head *head);
33int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv); 31int batadv_unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv);
34int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, 32int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
35 struct hard_iface *hard_iface, const uint8_t dstaddr[]); 33 struct hard_iface *hard_iface,
34 const uint8_t dstaddr[]);
36 35
37static inline int frag_can_reassemble(const struct sk_buff *skb, int mtu) 36static inline int frag_can_reassemble(const struct sk_buff *skb, int mtu)
38{ 37{
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c
index 01d5da54143e..20eef04645bd 100644
--- a/net/batman-adv/vis.c
+++ b/net/batman-adv/vis.c
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2008-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2008-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Simon Wunderlich 3 * Simon Wunderlich
5 * 4 *
@@ -16,7 +15,6 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#include "main.h" 20#include "main.h"
@@ -64,8 +62,9 @@ static int vis_info_cmp(const struct hlist_node *node, const void *data2)
64 return compare_eth(p1->vis_orig, p2->vis_orig); 62 return compare_eth(p1->vis_orig, p2->vis_orig);
65} 63}
66 64
67/* 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
68/* hash algorithm from http://en.wikipedia.org/wiki/Hash_table */ 66 * hash algorithm from http://en.wikipedia.org/wiki/Hash_table
67 */
69static uint32_t vis_info_choose(const void *data, uint32_t size) 68static uint32_t vis_info_choose(const void *data, uint32_t size)
70{ 69{
71 const struct vis_info *vis_info = data; 70 const struct vis_info *vis_info = data;
@@ -118,7 +117,8 @@ static struct vis_info *vis_hash_find(struct bat_priv *bat_priv,
118} 117}
119 118
120/* 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
121 * does not already exist in the list */ 120 * does not already exist in the list
121 */
122static void vis_data_insert_interface(const uint8_t *interface, 122static void 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)
@@ -188,7 +188,7 @@ static ssize_t vis_data_read_entry(char *buff,
188 return 0; 188 return 0;
189} 189}
190 190
191int vis_seq_print_text(struct seq_file *seq, void *offset) 191int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
192{ 192{
193 struct hard_iface *primary_if; 193 struct hard_iface *primary_if;
194 struct hlist_node *node; 194 struct hlist_node *node;
@@ -334,7 +334,8 @@ out:
334} 334}
335 335
336/* add the info packet to the send list, if it was not 336/* add the info packet to the send list, if it was not
337 * already linked in. */ 337 * already linked in.
338 */
338static void send_list_add(struct bat_priv *bat_priv, struct vis_info *info) 339static void send_list_add(struct bat_priv *bat_priv, struct vis_info *info)
339{ 340{
340 if (list_empty(&info->send_list)) { 341 if (list_empty(&info->send_list)) {
@@ -344,7 +345,8 @@ static void send_list_add(struct bat_priv *bat_priv, struct vis_info *info)
344} 345}
345 346
346/* delete the info packet from the send list, if it was 347/* delete the info packet from the send list, if it was
347 * linked in. */ 348 * linked in.
349 */
348static void send_list_del(struct vis_info *info) 350static void send_list_del(struct vis_info *info)
349{ 351{
350 if (!list_empty(&info->send_list)) { 352 if (!list_empty(&info->send_list)) {
@@ -388,7 +390,8 @@ static int recv_list_is_in(struct bat_priv *bat_priv,
388 390
389/* try to add the packet to the vis_hash. return NULL if invalid (e.g. too old, 391/* try to add the packet to the vis_hash. return NULL if invalid (e.g. too old,
390 * broken.. ). vis hash must be locked outside. is_new is set when the packet 392 * broken.. ). vis hash must be locked outside. is_new is set when the packet
391 * is newer than old entries in the hash. */ 393 * is newer than old entries in the hash.
394 */
392static struct vis_info *add_packet(struct bat_priv *bat_priv, 395static struct vis_info *add_packet(struct bat_priv *bat_priv,
393 struct vis_packet *vis_packet, 396 struct vis_packet *vis_packet,
394 int vis_info_len, int *is_new, 397 int vis_info_len, int *is_new,
@@ -462,7 +465,7 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv,
462 465
463 /* Make it a broadcast packet, if required */ 466 /* Make it a broadcast packet, if required */
464 if (make_broadcast) 467 if (make_broadcast)
465 memcpy(packet->target_orig, broadcast_addr, ETH_ALEN); 468 memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN);
466 469
467 /* repair if entries is longer than packet. */ 470 /* repair if entries is longer than packet. */
468 if (packet->entries * sizeof(struct vis_info_entry) > vis_info_len) 471 if (packet->entries * sizeof(struct vis_info_entry) > vis_info_len)
@@ -483,9 +486,9 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv,
483} 486}
484 487
485/* handle the server sync packet, forward if needed. */ 488/* handle the server sync packet, forward if needed. */
486void receive_server_sync_packet(struct bat_priv *bat_priv, 489void batadv_receive_server_sync_packet(struct bat_priv *bat_priv,
487 struct vis_packet *vis_packet, 490 struct vis_packet *vis_packet,
488 int vis_info_len) 491 int vis_info_len)
489{ 492{
490 struct vis_info *info; 493 struct vis_info *info;
491 int is_new, make_broadcast; 494 int is_new, make_broadcast;
@@ -500,7 +503,8 @@ void receive_server_sync_packet(struct bat_priv *bat_priv,
500 goto end; 503 goto end;
501 504
502 /* only if we are server ourselves and packet is newer than the one in 505 /* only if we are server ourselves and packet is newer than the one in
503 * hash.*/ 506 * hash.
507 */
504 if (vis_server == VIS_TYPE_SERVER_SYNC && is_new) 508 if (vis_server == VIS_TYPE_SERVER_SYNC && is_new)
505 send_list_add(bat_priv, info); 509 send_list_add(bat_priv, info);
506end: 510end:
@@ -508,9 +512,9 @@ end:
508} 512}
509 513
510/* handle an incoming client update packet and schedule forward if needed. */ 514/* handle an incoming client update packet and schedule forward if needed. */
511void receive_client_update_packet(struct bat_priv *bat_priv, 515void batadv_receive_client_update_packet(struct bat_priv *bat_priv,
512 struct vis_packet *vis_packet, 516 struct vis_packet *vis_packet,
513 int vis_info_len) 517 int vis_info_len)
514{ 518{
515 struct vis_info *info; 519 struct vis_info *info;
516 struct vis_packet *packet; 520 struct vis_packet *packet;
@@ -524,7 +528,7 @@ void receive_client_update_packet(struct bat_priv *bat_priv,
524 528
525 /* Are we the target for this VIS packet? */ 529 /* Are we the target for this VIS packet? */
526 if (vis_server == VIS_TYPE_SERVER_SYNC && 530 if (vis_server == VIS_TYPE_SERVER_SYNC &&
527 is_my_mac(vis_packet->target_orig)) 531 batadv_is_my_mac(vis_packet->target_orig))
528 are_target = 1; 532 are_target = 1;
529 533
530 spin_lock_bh(&bat_priv->vis_hash_lock); 534 spin_lock_bh(&bat_priv->vis_hash_lock);
@@ -543,7 +547,7 @@ void receive_client_update_packet(struct bat_priv *bat_priv,
543 send_list_add(bat_priv, info); 547 send_list_add(bat_priv, info);
544 548
545 /* ... we're not the recipient (and thus need to forward). */ 549 /* ... we're not the recipient (and thus need to forward). */
546 } else if (!is_my_mac(packet->target_orig)) { 550 } else if (!batadv_is_my_mac(packet->target_orig)) {
547 send_list_add(bat_priv, info); 551 send_list_add(bat_priv, info);
548 } 552 }
549 553
@@ -554,7 +558,8 @@ end:
554/* Walk the originators and find the VIS server with the best tq. Set the packet 558/* Walk the originators and find the VIS server with the best tq. Set the packet
555 * address to its address and return the best_tq. 559 * address to its address and return the best_tq.
556 * 560 *
557 * Must be called with the originator hash locked */ 561 * Must be called with the originator hash locked
562 */
558static int find_best_vis_server(struct bat_priv *bat_priv, 563static int find_best_vis_server(struct bat_priv *bat_priv,
559 struct vis_info *info) 564 struct vis_info *info)
560{ 565{
@@ -574,7 +579,7 @@ static int find_best_vis_server(struct bat_priv *bat_priv,
574 579
575 rcu_read_lock(); 580 rcu_read_lock();
576 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { 581 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
577 router = orig_node_get_router(orig_node); 582 router = batadv_orig_node_get_router(orig_node);
578 if (!router) 583 if (!router)
579 continue; 584 continue;
580 585
@@ -584,7 +589,7 @@ static int find_best_vis_server(struct bat_priv *bat_priv,
584 memcpy(packet->target_orig, orig_node->orig, 589 memcpy(packet->target_orig, orig_node->orig,
585 ETH_ALEN); 590 ETH_ALEN);
586 } 591 }
587 neigh_node_free_ref(router); 592 batadv_neigh_node_free_ref(router);
588 } 593 }
589 rcu_read_unlock(); 594 rcu_read_unlock();
590 } 595 }
@@ -605,7 +610,8 @@ static bool vis_packet_full(const struct vis_info *info)
605} 610}
606 611
607/* generates a packet of own vis data, 612/* generates a packet of own vis data,
608 * returns 0 on success, -1 if no packet could be generated */ 613 * returns 0 on success, -1 if no packet could be generated
614 */
609static int generate_vis_packet(struct bat_priv *bat_priv) 615static int generate_vis_packet(struct bat_priv *bat_priv)
610{ 616{
611 struct hashtable_t *hash = bat_priv->orig_hash; 617 struct hashtable_t *hash = bat_priv->orig_hash;
@@ -623,7 +629,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
623 info->first_seen = jiffies; 629 info->first_seen = jiffies;
624 packet->vis_type = atomic_read(&bat_priv->vis_mode); 630 packet->vis_type = atomic_read(&bat_priv->vis_mode);
625 631
626 memcpy(packet->target_orig, broadcast_addr, ETH_ALEN); 632 memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN);
627 packet->header.ttl = TTL; 633 packet->header.ttl = TTL;
628 packet->seqno = htonl(ntohl(packet->seqno) + 1); 634 packet->seqno = htonl(ntohl(packet->seqno) + 1);
629 packet->entries = 0; 635 packet->entries = 0;
@@ -641,7 +647,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
641 647
642 rcu_read_lock(); 648 rcu_read_lock();
643 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { 649 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
644 router = orig_node_get_router(orig_node); 650 router = batadv_orig_node_get_router(orig_node);
645 if (!router) 651 if (!router)
646 continue; 652 continue;
647 653
@@ -665,7 +671,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
665 packet->entries++; 671 packet->entries++;
666 672
667next: 673next:
668 neigh_node_free_ref(router); 674 batadv_neigh_node_free_ref(router);
669 675
670 if (vis_packet_full(info)) 676 if (vis_packet_full(info))
671 goto unlock; 677 goto unlock;
@@ -703,7 +709,8 @@ unlock:
703} 709}
704 710
705/* free old vis packets. Must be called with this vis_hash_lock 711/* free old vis packets. Must be called with this vis_hash_lock
706 * held */ 712 * held
713 */
707static void purge_vis_packets(struct bat_priv *bat_priv) 714static void purge_vis_packets(struct bat_priv *bat_priv)
708{ 715{
709 uint32_t i; 716 uint32_t i;
@@ -757,15 +764,16 @@ static void broadcast_vis_packet(struct bat_priv *bat_priv,
757 if (!(orig_node->flags & VIS_SERVER)) 764 if (!(orig_node->flags & VIS_SERVER))
758 continue; 765 continue;
759 766
760 router = orig_node_get_router(orig_node); 767 router = batadv_orig_node_get_router(orig_node);
761 if (!router) 768 if (!router)
762 continue; 769 continue;
763 770
764 /* don't send it if we already received the packet from 771 /* don't send it if we already received the packet from
765 * this node. */ 772 * this node.
773 */
766 if (recv_list_is_in(bat_priv, &info->recv_list, 774 if (recv_list_is_in(bat_priv, &info->recv_list,
767 orig_node->orig)) { 775 orig_node->orig)) {
768 neigh_node_free_ref(router); 776 batadv_neigh_node_free_ref(router);
769 continue; 777 continue;
770 } 778 }
771 779
@@ -773,11 +781,12 @@ static void broadcast_vis_packet(struct bat_priv *bat_priv,
773 hard_iface = router->if_incoming; 781 hard_iface = router->if_incoming;
774 memcpy(dstaddr, router->addr, ETH_ALEN); 782 memcpy(dstaddr, router->addr, ETH_ALEN);
775 783
776 neigh_node_free_ref(router); 784 batadv_neigh_node_free_ref(router);
777 785
778 skb = skb_clone(info->skb_packet, GFP_ATOMIC); 786 skb = skb_clone(info->skb_packet, GFP_ATOMIC);
779 if (skb) 787 if (skb)
780 send_skb_packet(skb, hard_iface, dstaddr); 788 batadv_send_skb_packet(skb, hard_iface,
789 dstaddr);
781 790
782 } 791 }
783 rcu_read_unlock(); 792 rcu_read_unlock();
@@ -798,19 +807,19 @@ static void unicast_vis_packet(struct bat_priv *bat_priv,
798 if (!orig_node) 807 if (!orig_node)
799 goto out; 808 goto out;
800 809
801 router = orig_node_get_router(orig_node); 810 router = batadv_orig_node_get_router(orig_node);
802 if (!router) 811 if (!router)
803 goto out; 812 goto out;
804 813
805 skb = skb_clone(info->skb_packet, GFP_ATOMIC); 814 skb = skb_clone(info->skb_packet, GFP_ATOMIC);
806 if (skb) 815 if (skb)
807 send_skb_packet(skb, router->if_incoming, router->addr); 816 batadv_send_skb_packet(skb, router->if_incoming, router->addr);
808 817
809out: 818out:
810 if (router) 819 if (router)
811 neigh_node_free_ref(router); 820 batadv_neigh_node_free_ref(router);
812 if (orig_node) 821 if (orig_node)
813 orig_node_free_ref(orig_node); 822 batadv_orig_node_free_ref(orig_node);
814} 823}
815 824
816/* only send one vis packet. called from send_vis_packets() */ 825/* only send one vis packet. called from send_vis_packets() */
@@ -878,8 +887,9 @@ static void send_vis_packets(struct work_struct *work)
878} 887}
879 888
880/* init the vis server. this may only be called when if_list is already 889/* init the vis server. this may only be called when if_list is already
881 * initialized (e.g. bat0 is initialized, interfaces have been added) */ 890 * initialized (e.g. bat0 is initialized, interfaces have been added)
882int vis_init(struct bat_priv *bat_priv) 891 */
892int batadv_vis_init(struct bat_priv *bat_priv)
883{ 893{
884 struct vis_packet *packet; 894 struct vis_packet *packet;
885 int hash_added; 895 int hash_added;
@@ -889,7 +899,7 @@ int vis_init(struct bat_priv *bat_priv)
889 899
890 spin_lock_bh(&bat_priv->vis_hash_lock); 900 spin_lock_bh(&bat_priv->vis_hash_lock);
891 901
892 bat_priv->vis_hash = hash_new(256); 902 bat_priv->vis_hash = batadv_hash_new(256);
893 if (!bat_priv->vis_hash) { 903 if (!bat_priv->vis_hash) {
894 pr_err("Can't initialize vis_hash\n"); 904 pr_err("Can't initialize vis_hash\n");
895 goto err; 905 goto err;
@@ -943,7 +953,7 @@ free_info:
943 bat_priv->my_vis_info = NULL; 953 bat_priv->my_vis_info = NULL;
944err: 954err:
945 spin_unlock_bh(&bat_priv->vis_hash_lock); 955 spin_unlock_bh(&bat_priv->vis_hash_lock);
946 vis_quit(bat_priv); 956 batadv_vis_quit(bat_priv);
947 return -ENOMEM; 957 return -ENOMEM;
948} 958}
949 959
@@ -958,7 +968,7 @@ static void free_info_ref(struct hlist_node *node, void *arg)
958} 968}
959 969
960/* shutdown vis-server */ 970/* shutdown vis-server */
961void vis_quit(struct bat_priv *bat_priv) 971void batadv_vis_quit(struct bat_priv *bat_priv)
962{ 972{
963 if (!bat_priv->vis_hash) 973 if (!bat_priv->vis_hash)
964 return; 974 return;
@@ -977,6 +987,6 @@ void vis_quit(struct bat_priv *bat_priv)
977static void start_vis_timer(struct bat_priv *bat_priv) 987static void start_vis_timer(struct bat_priv *bat_priv)
978{ 988{
979 INIT_DELAYED_WORK(&bat_priv->vis_work, send_vis_packets); 989 INIT_DELAYED_WORK(&bat_priv->vis_work, send_vis_packets);
980 queue_delayed_work(bat_event_workqueue, &bat_priv->vis_work, 990 queue_delayed_work(batadv_event_workqueue, &bat_priv->vis_work,
981 msecs_to_jiffies(VIS_INTERVAL)); 991 msecs_to_jiffies(VIS_INTERVAL));
982} 992}
diff --git a/net/batman-adv/vis.h b/net/batman-adv/vis.h
index ee2e46e5347b..dad595870f8f 100644
--- a/net/batman-adv/vis.h
+++ b/net/batman-adv/vis.h
@@ -1,5 +1,4 @@
1/* 1/* Copyright (C) 2008-2012 B.A.T.M.A.N. contributors:
2 * Copyright (C) 2008-2012 B.A.T.M.A.N. contributors:
3 * 2 *
4 * Simon Wunderlich, Marek Lindner 3 * Simon Wunderlich, Marek Lindner
5 * 4 *
@@ -16,23 +15,22 @@
16 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA 17 * 02110-1301, USA
19 *
20 */ 18 */
21 19
22#ifndef _NET_BATMAN_ADV_VIS_H_ 20#ifndef _NET_BATMAN_ADV_VIS_H_
23#define _NET_BATMAN_ADV_VIS_H_ 21#define _NET_BATMAN_ADV_VIS_H_
24 22
25#define VIS_TIMEOUT 200000 /* timeout of vis packets 23/* timeout of vis packets in miliseconds */
26 * in miliseconds */ 24#define VIS_TIMEOUT 200000
27 25
28int vis_seq_print_text(struct seq_file *seq, void *offset); 26int batadv_vis_seq_print_text(struct seq_file *seq, void *offset);
29void receive_server_sync_packet(struct bat_priv *bat_priv, 27void batadv_receive_server_sync_packet(struct bat_priv *bat_priv,
30 struct vis_packet *vis_packet, 28 struct vis_packet *vis_packet,
31 int vis_info_len); 29 int vis_info_len);
32void receive_client_update_packet(struct bat_priv *bat_priv, 30void batadv_receive_client_update_packet(struct bat_priv *bat_priv,
33 struct vis_packet *vis_packet, 31 struct vis_packet *vis_packet,
34 int vis_info_len); 32 int vis_info_len);
35int vis_init(struct bat_priv *bat_priv); 33int batadv_vis_init(struct bat_priv *bat_priv);
36void vis_quit(struct bat_priv *bat_priv); 34void batadv_vis_quit(struct bat_priv *bat_priv);
37 35
38#endif /* _NET_BATMAN_ADV_VIS_H_ */ 36#endif /* _NET_BATMAN_ADV_VIS_H_ */