aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-06-25 19:15:58 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-25 19:18:10 -0400
commit1d5873e9d75bb72012a6c1327a368d0d2b13581f (patch)
tree20f4d5b75bdffbf1945008aabec946b8ff3f5053
parent7665de15642dfb1709177517aa0488162727342c (diff)
parenta513088d022c8f59cebe17c567797c220563b517 (diff)
Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge
Included changes: - yet another batch of 'namespace cleaning' patches Conflicts: net/batman-adv/translation-table.c Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/batman-adv/bat_debugfs.c143
-rw-r--r--net/batman-adv/bat_iv_ogm.c490
-rw-r--r--net/batman-adv/bat_sysfs.c277
-rw-r--r--net/batman-adv/bitarray.c18
-rw-r--r--net/batman-adv/bitarray.h6
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c518
-rw-r--r--net/batman-adv/gateway_client.c125
-rw-r--r--net/batman-adv/gateway_common.c10
-rw-r--r--net/batman-adv/hard-interface.c96
-rw-r--r--net/batman-adv/hard-interface.h7
-rw-r--r--net/batman-adv/hash.c4
-rw-r--r--net/batman-adv/hash.h19
-rw-r--r--net/batman-adv/icmp_socket.c84
-rw-r--r--net/batman-adv/main.c8
-rw-r--r--net/batman-adv/main.h17
-rw-r--r--net/batman-adv/originator.c128
-rw-r--r--net/batman-adv/originator.h10
-rw-r--r--net/batman-adv/routing.c174
-rw-r--r--net/batman-adv/send.c48
-rw-r--r--net/batman-adv/soft-interface.c86
-rw-r--r--net/batman-adv/translation-table.c744
-rw-r--r--net/batman-adv/unicast.c6
-rw-r--r--net/batman-adv/unicast.h2
-rw-r--r--net/batman-adv/vis.c53
24 files changed, 1591 insertions, 1482 deletions
diff --git a/net/batman-adv/bat_debugfs.c b/net/batman-adv/bat_debugfs.c
index 4001c57a25e4..03f09f0f6d98 100644
--- a/net/batman-adv/bat_debugfs.c
+++ b/net/batman-adv/bat_debugfs.c
@@ -32,25 +32,25 @@
32#include "icmp_socket.h" 32#include "icmp_socket.h"
33#include "bridge_loop_avoidance.h" 33#include "bridge_loop_avoidance.h"
34 34
35static struct dentry *bat_debugfs; 35static struct dentry *batadv_debugfs;
36 36
37#ifdef CONFIG_BATMAN_ADV_DEBUG 37#ifdef CONFIG_BATMAN_ADV_DEBUG
38#define LOG_BUFF_MASK (log_buff_len-1) 38#define LOG_BUFF_MASK (batadv_log_buff_len - 1)
39#define LOG_BUFF(idx) (debug_log->log_buff[(idx) & LOG_BUFF_MASK]) 39#define LOG_BUFF(idx) (debug_log->log_buff[(idx) & LOG_BUFF_MASK])
40 40
41static int log_buff_len = LOG_BUF_LEN; 41static int batadv_log_buff_len = LOG_BUF_LEN;
42 42
43static void emit_log_char(struct debug_log *debug_log, char c) 43static void batadv_emit_log_char(struct debug_log *debug_log, char c)
44{ 44{
45 LOG_BUFF(debug_log->log_end) = c; 45 LOG_BUFF(debug_log->log_end) = c;
46 debug_log->log_end++; 46 debug_log->log_end++;
47 47
48 if (debug_log->log_end - debug_log->log_start > log_buff_len) 48 if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len)
49 debug_log->log_start = debug_log->log_end - log_buff_len; 49 debug_log->log_start = debug_log->log_end - batadv_log_buff_len;
50} 50}
51 51
52__printf(2, 3) 52__printf(2, 3)
53static int fdebug_log(struct debug_log *debug_log, const char *fmt, ...) 53static int batadv_fdebug_log(struct debug_log *debug_log, const char *fmt, ...)
54{ 54{
55 va_list args; 55 va_list args;
56 static char debug_log_buf[256]; 56 static char debug_log_buf[256];
@@ -65,7 +65,7 @@ static int fdebug_log(struct debug_log *debug_log, const char *fmt, ...)
65 va_end(args); 65 va_end(args);
66 66
67 for (p = debug_log_buf; *p != 0; p++) 67 for (p = debug_log_buf; *p != 0; p++)
68 emit_log_char(debug_log, *p); 68 batadv_emit_log_char(debug_log, *p);
69 69
70 spin_unlock_bh(&debug_log->lock); 70 spin_unlock_bh(&debug_log->lock);
71 71
@@ -81,14 +81,14 @@ int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...)
81 81
82 va_start(args, fmt); 82 va_start(args, fmt);
83 vscnprintf(tmp_log_buf, sizeof(tmp_log_buf), fmt, args); 83 vscnprintf(tmp_log_buf, sizeof(tmp_log_buf), fmt, args);
84 fdebug_log(bat_priv->debug_log, "[%10u] %s", 84 batadv_fdebug_log(bat_priv->debug_log, "[%10u] %s",
85 jiffies_to_msecs(jiffies), tmp_log_buf); 85 jiffies_to_msecs(jiffies), tmp_log_buf);
86 va_end(args); 86 va_end(args);
87 87
88 return 0; 88 return 0;
89} 89}
90 90
91static int log_open(struct inode *inode, struct file *file) 91static int batadv_log_open(struct inode *inode, struct file *file)
92{ 92{
93 nonseekable_open(inode, file); 93 nonseekable_open(inode, file);
94 file->private_data = inode->i_private; 94 file->private_data = inode->i_private;
@@ -96,14 +96,14 @@ static int log_open(struct inode *inode, struct file *file)
96 return 0; 96 return 0;
97} 97}
98 98
99static int log_release(struct inode *inode, struct file *file) 99static int batadv_log_release(struct inode *inode, struct file *file)
100{ 100{
101 batadv_dec_module_count(); 101 batadv_dec_module_count();
102 return 0; 102 return 0;
103} 103}
104 104
105static ssize_t log_read(struct file *file, char __user *buf, 105static ssize_t batadv_log_read(struct file *file, char __user *buf,
106 size_t count, loff_t *ppos) 106 size_t count, loff_t *ppos)
107{ 107{
108 struct bat_priv *bat_priv = file->private_data; 108 struct bat_priv *bat_priv = file->private_data;
109 struct debug_log *debug_log = bat_priv->debug_log; 109 struct debug_log *debug_log = bat_priv->debug_log;
@@ -156,7 +156,7 @@ static ssize_t log_read(struct file *file, char __user *buf,
156 return error; 156 return error;
157} 157}
158 158
159static unsigned int log_poll(struct file *file, poll_table *wait) 159static unsigned int batadv_log_poll(struct file *file, poll_table *wait)
160{ 160{
161 struct bat_priv *bat_priv = file->private_data; 161 struct bat_priv *bat_priv = file->private_data;
162 struct debug_log *debug_log = bat_priv->debug_log; 162 struct debug_log *debug_log = bat_priv->debug_log;
@@ -169,15 +169,15 @@ static unsigned int log_poll(struct file *file, poll_table *wait)
169 return 0; 169 return 0;
170} 170}
171 171
172static const struct file_operations log_fops = { 172static const struct file_operations batadv_log_fops = {
173 .open = log_open, 173 .open = batadv_log_open,
174 .release = log_release, 174 .release = batadv_log_release,
175 .read = log_read, 175 .read = batadv_log_read,
176 .poll = log_poll, 176 .poll = batadv_log_poll,
177 .llseek = no_llseek, 177 .llseek = no_llseek,
178}; 178};
179 179
180static int debug_log_setup(struct bat_priv *bat_priv) 180static int batadv_debug_log_setup(struct bat_priv *bat_priv)
181{ 181{
182 struct dentry *d; 182 struct dentry *d;
183 183
@@ -192,7 +192,8 @@ static int debug_log_setup(struct bat_priv *bat_priv)
192 init_waitqueue_head(&bat_priv->debug_log->queue_wait); 192 init_waitqueue_head(&bat_priv->debug_log->queue_wait);
193 193
194 d = debugfs_create_file("log", S_IFREG | S_IRUSR, 194 d = debugfs_create_file("log", S_IFREG | S_IRUSR,
195 bat_priv->debug_dir, bat_priv, &log_fops); 195 bat_priv->debug_dir, bat_priv,
196 &batadv_log_fops);
196 if (!d) 197 if (!d)
197 goto err; 198 goto err;
198 199
@@ -202,49 +203,49 @@ err:
202 return -ENOMEM; 203 return -ENOMEM;
203} 204}
204 205
205static void debug_log_cleanup(struct bat_priv *bat_priv) 206static void batadv_debug_log_cleanup(struct bat_priv *bat_priv)
206{ 207{
207 kfree(bat_priv->debug_log); 208 kfree(bat_priv->debug_log);
208 bat_priv->debug_log = NULL; 209 bat_priv->debug_log = NULL;
209} 210}
210#else /* CONFIG_BATMAN_ADV_DEBUG */ 211#else /* CONFIG_BATMAN_ADV_DEBUG */
211static int debug_log_setup(struct bat_priv *bat_priv) 212static int batadv_debug_log_setup(struct bat_priv *bat_priv)
212{ 213{
213 bat_priv->debug_log = NULL; 214 bat_priv->debug_log = NULL;
214 return 0; 215 return 0;
215} 216}
216 217
217static void debug_log_cleanup(struct bat_priv *bat_priv) 218static void batadv_debug_log_cleanup(struct bat_priv *bat_priv)
218{ 219{
219 return; 220 return;
220} 221}
221#endif 222#endif
222 223
223static int bat_algorithms_open(struct inode *inode, struct file *file) 224static int batadv_algorithms_open(struct inode *inode, struct file *file)
224{ 225{
225 return single_open(file, batadv_algo_seq_print_text, NULL); 226 return single_open(file, batadv_algo_seq_print_text, NULL);
226} 227}
227 228
228static int originators_open(struct inode *inode, struct file *file) 229static int batadv_originators_open(struct inode *inode, struct file *file)
229{ 230{
230 struct net_device *net_dev = (struct net_device *)inode->i_private; 231 struct net_device *net_dev = (struct net_device *)inode->i_private;
231 return single_open(file, batadv_orig_seq_print_text, net_dev); 232 return single_open(file, batadv_orig_seq_print_text, net_dev);
232} 233}
233 234
234static int gateways_open(struct inode *inode, struct file *file) 235static int batadv_gateways_open(struct inode *inode, struct file *file)
235{ 236{
236 struct net_device *net_dev = (struct net_device *)inode->i_private; 237 struct net_device *net_dev = (struct net_device *)inode->i_private;
237 return single_open(file, batadv_gw_client_seq_print_text, net_dev); 238 return single_open(file, batadv_gw_client_seq_print_text, net_dev);
238} 239}
239 240
240static int transtable_global_open(struct inode *inode, struct file *file) 241static int batadv_transtable_global_open(struct inode *inode, struct file *file)
241{ 242{
242 struct net_device *net_dev = (struct net_device *)inode->i_private; 243 struct net_device *net_dev = (struct net_device *)inode->i_private;
243 return single_open(file, batadv_tt_global_seq_print_text, net_dev); 244 return single_open(file, batadv_tt_global_seq_print_text, net_dev);
244} 245}
245 246
246#ifdef CONFIG_BATMAN_ADV_BLA 247#ifdef CONFIG_BATMAN_ADV_BLA
247static int bla_claim_table_open(struct inode *inode, struct file *file) 248static int batadv_bla_claim_table_open(struct inode *inode, struct file *file)
248{ 249{
249 struct net_device *net_dev = (struct net_device *)inode->i_private; 250 struct net_device *net_dev = (struct net_device *)inode->i_private;
250 return single_open(file, batadv_bla_claim_table_seq_print_text, 251 return single_open(file, batadv_bla_claim_table_seq_print_text,
@@ -252,13 +253,13 @@ static int bla_claim_table_open(struct inode *inode, struct file *file)
252} 253}
253#endif 254#endif
254 255
255static int transtable_local_open(struct inode *inode, struct file *file) 256static int batadv_transtable_local_open(struct inode *inode, struct file *file)
256{ 257{
257 struct net_device *net_dev = (struct net_device *)inode->i_private; 258 struct net_device *net_dev = (struct net_device *)inode->i_private;
258 return single_open(file, batadv_tt_local_seq_print_text, net_dev); 259 return single_open(file, batadv_tt_local_seq_print_text, net_dev);
259} 260}
260 261
261static int vis_data_open(struct inode *inode, struct file *file) 262static int batadv_vis_data_open(struct inode *inode, struct file *file)
262{ 263{
263 struct net_device *net_dev = (struct net_device *)inode->i_private; 264 struct net_device *net_dev = (struct net_device *)inode->i_private;
264 return single_open(file, batadv_vis_seq_print_text, net_dev); 265 return single_open(file, batadv_vis_seq_print_text, net_dev);
@@ -269,37 +270,37 @@ struct bat_debuginfo {
269 const struct file_operations fops; 270 const struct file_operations fops;
270}; 271};
271 272
272#define BAT_DEBUGINFO(_name, _mode, _open) \ 273#define BAT_DEBUGINFO(_name, _mode, _open) \
273struct bat_debuginfo bat_debuginfo_##_name = { \ 274struct bat_debuginfo batadv_debuginfo_##_name = { \
274 .attr = { .name = __stringify(_name), \ 275 .attr = { .name = __stringify(_name), \
275 .mode = _mode, }, \ 276 .mode = _mode, }, \
276 .fops = { .owner = THIS_MODULE, \ 277 .fops = { .owner = THIS_MODULE, \
277 .open = _open, \ 278 .open = _open, \
278 .read = seq_read, \ 279 .read = seq_read, \
279 .llseek = seq_lseek, \ 280 .llseek = seq_lseek, \
280 .release = single_release, \ 281 .release = single_release, \
281 } \ 282 } \
282}; 283};
283 284
284static BAT_DEBUGINFO(routing_algos, S_IRUGO, bat_algorithms_open); 285static BAT_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open);
285static BAT_DEBUGINFO(originators, S_IRUGO, originators_open); 286static BAT_DEBUGINFO(originators, S_IRUGO, batadv_originators_open);
286static BAT_DEBUGINFO(gateways, S_IRUGO, gateways_open); 287static BAT_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open);
287static BAT_DEBUGINFO(transtable_global, S_IRUGO, transtable_global_open); 288static BAT_DEBUGINFO(transtable_global, S_IRUGO, batadv_transtable_global_open);
288#ifdef CONFIG_BATMAN_ADV_BLA 289#ifdef CONFIG_BATMAN_ADV_BLA
289static BAT_DEBUGINFO(bla_claim_table, S_IRUGO, bla_claim_table_open); 290static BAT_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open);
290#endif 291#endif
291static BAT_DEBUGINFO(transtable_local, S_IRUGO, transtable_local_open); 292static BAT_DEBUGINFO(transtable_local, S_IRUGO, batadv_transtable_local_open);
292static BAT_DEBUGINFO(vis_data, S_IRUGO, vis_data_open); 293static BAT_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open);
293 294
294static struct bat_debuginfo *mesh_debuginfos[] = { 295static struct bat_debuginfo *batadv_mesh_debuginfos[] = {
295 &bat_debuginfo_originators, 296 &batadv_debuginfo_originators,
296 &bat_debuginfo_gateways, 297 &batadv_debuginfo_gateways,
297 &bat_debuginfo_transtable_global, 298 &batadv_debuginfo_transtable_global,
298#ifdef CONFIG_BATMAN_ADV_BLA 299#ifdef CONFIG_BATMAN_ADV_BLA
299 &bat_debuginfo_bla_claim_table, 300 &batadv_debuginfo_bla_claim_table,
300#endif 301#endif
301 &bat_debuginfo_transtable_local, 302 &batadv_debuginfo_transtable_local,
302 &bat_debuginfo_vis_data, 303 &batadv_debuginfo_vis_data,
303 NULL, 304 NULL,
304}; 305};
305 306
@@ -308,17 +309,17 @@ void batadv_debugfs_init(void)
308 struct bat_debuginfo *bat_debug; 309 struct bat_debuginfo *bat_debug;
309 struct dentry *file; 310 struct dentry *file;
310 311
311 bat_debugfs = debugfs_create_dir(DEBUGFS_BAT_SUBDIR, NULL); 312 batadv_debugfs = debugfs_create_dir(DEBUGFS_BAT_SUBDIR, NULL);
312 if (bat_debugfs == ERR_PTR(-ENODEV)) 313 if (batadv_debugfs == ERR_PTR(-ENODEV))
313 bat_debugfs = NULL; 314 batadv_debugfs = NULL;
314 315
315 if (!bat_debugfs) 316 if (!batadv_debugfs)
316 goto out; 317 goto out;
317 318
318 bat_debug = &bat_debuginfo_routing_algos; 319 bat_debug = &batadv_debuginfo_routing_algos;
319 file = debugfs_create_file(bat_debug->attr.name, 320 file = debugfs_create_file(bat_debug->attr.name,
320 S_IFREG | bat_debug->attr.mode, 321 S_IFREG | bat_debug->attr.mode,
321 bat_debugfs, NULL, &bat_debug->fops); 322 batadv_debugfs, NULL, &bat_debug->fops);
322 if (!file) 323 if (!file)
323 pr_err("Can't add debugfs file: %s\n", bat_debug->attr.name); 324 pr_err("Can't add debugfs file: %s\n", bat_debug->attr.name);
324 325
@@ -328,9 +329,9 @@ out:
328 329
329void batadv_debugfs_destroy(void) 330void batadv_debugfs_destroy(void)
330{ 331{
331 if (bat_debugfs) { 332 if (batadv_debugfs) {
332 debugfs_remove_recursive(bat_debugfs); 333 debugfs_remove_recursive(batadv_debugfs);
333 bat_debugfs = NULL; 334 batadv_debugfs = NULL;
334 } 335 }
335} 336}
336 337
@@ -340,20 +341,20 @@ int batadv_debugfs_add_meshif(struct net_device *dev)
340 struct bat_debuginfo **bat_debug; 341 struct bat_debuginfo **bat_debug;
341 struct dentry *file; 342 struct dentry *file;
342 343
343 if (!bat_debugfs) 344 if (!batadv_debugfs)
344 goto out; 345 goto out;
345 346
346 bat_priv->debug_dir = debugfs_create_dir(dev->name, bat_debugfs); 347 bat_priv->debug_dir = debugfs_create_dir(dev->name, batadv_debugfs);
347 if (!bat_priv->debug_dir) 348 if (!bat_priv->debug_dir)
348 goto out; 349 goto out;
349 350
350 if (batadv_socket_setup(bat_priv) < 0) 351 if (batadv_socket_setup(bat_priv) < 0)
351 goto rem_attr; 352 goto rem_attr;
352 353
353 if (debug_log_setup(bat_priv) < 0) 354 if (batadv_debug_log_setup(bat_priv) < 0)
354 goto rem_attr; 355 goto rem_attr;
355 356
356 for (bat_debug = mesh_debuginfos; *bat_debug; ++bat_debug) { 357 for (bat_debug = batadv_mesh_debuginfos; *bat_debug; ++bat_debug) {
357 file = debugfs_create_file(((*bat_debug)->attr).name, 358 file = debugfs_create_file(((*bat_debug)->attr).name,
358 S_IFREG | ((*bat_debug)->attr).mode, 359 S_IFREG | ((*bat_debug)->attr).mode,
359 bat_priv->debug_dir, 360 bat_priv->debug_dir,
@@ -381,9 +382,9 @@ void batadv_debugfs_del_meshif(struct net_device *dev)
381{ 382{
382 struct bat_priv *bat_priv = netdev_priv(dev); 383 struct bat_priv *bat_priv = netdev_priv(dev);
383 384
384 debug_log_cleanup(bat_priv); 385 batadv_debug_log_cleanup(bat_priv);
385 386
386 if (bat_debugfs) { 387 if (batadv_debugfs) {
387 debugfs_remove_recursive(bat_priv->debug_dir); 388 debugfs_remove_recursive(bat_priv->debug_dir);
388 bat_priv->debug_dir = NULL; 389 bat_priv->debug_dir = NULL;
389 } 390 }
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 94859d45ed6e..ca6466574c46 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -28,11 +28,11 @@
28#include "send.h" 28#include "send.h"
29#include "bat_algo.h" 29#include "bat_algo.h"
30 30
31static struct neigh_node *bat_iv_ogm_neigh_new(struct hard_iface *hard_iface, 31static struct neigh_node *batadv_iv_ogm_neigh_new(struct hard_iface *hard_iface,
32 const uint8_t *neigh_addr, 32 const uint8_t *neigh_addr,
33 struct orig_node *orig_node, 33 struct orig_node *orig_node,
34 struct orig_node *orig_neigh, 34 struct orig_node *orig_neigh,
35 __be32 seqno) 35 __be32 seqno)
36{ 36{
37 struct neigh_node *neigh_node; 37 struct neigh_node *neigh_node;
38 38
@@ -54,7 +54,7 @@ out:
54 return neigh_node; 54 return neigh_node;
55} 55}
56 56
57static int bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) 57static int batadv_iv_ogm_iface_enable(struct hard_iface *hard_iface)
58{ 58{
59 struct batman_ogm_packet *batman_ogm_packet; 59 struct batman_ogm_packet *batman_ogm_packet;
60 uint32_t random_seqno; 60 uint32_t random_seqno;
@@ -85,13 +85,13 @@ out:
85 return res; 85 return res;
86} 86}
87 87
88static void bat_iv_ogm_iface_disable(struct hard_iface *hard_iface) 88static void batadv_iv_ogm_iface_disable(struct hard_iface *hard_iface)
89{ 89{
90 kfree(hard_iface->packet_buff); 90 kfree(hard_iface->packet_buff);
91 hard_iface->packet_buff = NULL; 91 hard_iface->packet_buff = NULL;
92} 92}
93 93
94static void bat_iv_ogm_iface_update_mac(struct hard_iface *hard_iface) 94static void batadv_iv_ogm_iface_update_mac(struct hard_iface *hard_iface)
95{ 95{
96 struct batman_ogm_packet *batman_ogm_packet; 96 struct batman_ogm_packet *batman_ogm_packet;
97 97
@@ -102,7 +102,7 @@ static void bat_iv_ogm_iface_update_mac(struct hard_iface *hard_iface)
102 hard_iface->net_dev->dev_addr, ETH_ALEN); 102 hard_iface->net_dev->dev_addr, ETH_ALEN);
103} 103}
104 104
105static void bat_iv_ogm_primary_iface_set(struct hard_iface *hard_iface) 105static void batadv_iv_ogm_primary_iface_set(struct hard_iface *hard_iface)
106{ 106{
107 struct batman_ogm_packet *batman_ogm_packet; 107 struct batman_ogm_packet *batman_ogm_packet;
108 108
@@ -112,7 +112,8 @@ static void bat_iv_ogm_primary_iface_set(struct hard_iface *hard_iface)
112} 112}
113 113
114/* when do we schedule our own ogm to be sent */ 114/* when do we schedule our own ogm to be sent */
115static unsigned long bat_iv_ogm_emit_send_time(const struct bat_priv *bat_priv) 115static unsigned long
116batadv_iv_ogm_emit_send_time(const struct bat_priv *bat_priv)
116{ 117{
117 return jiffies + msecs_to_jiffies( 118 return jiffies + msecs_to_jiffies(
118 atomic_read(&bat_priv->orig_interval) - 119 atomic_read(&bat_priv->orig_interval) -
@@ -120,21 +121,21 @@ static unsigned long bat_iv_ogm_emit_send_time(const struct bat_priv *bat_priv)
120} 121}
121 122
122/* when do we schedule a ogm packet to be sent */ 123/* when do we schedule a ogm packet to be sent */
123static unsigned long bat_iv_ogm_fwd_send_time(void) 124static unsigned long batadv_iv_ogm_fwd_send_time(void)
124{ 125{
125 return jiffies + msecs_to_jiffies(random32() % (JITTER/2)); 126 return jiffies + msecs_to_jiffies(random32() % (JITTER/2));
126} 127}
127 128
128/* apply hop penalty for a normal link */ 129/* apply hop penalty for a normal link */
129static uint8_t hop_penalty(uint8_t tq, const struct bat_priv *bat_priv) 130static uint8_t batadv_hop_penalty(uint8_t tq, const struct bat_priv *bat_priv)
130{ 131{
131 int hop_penalty = atomic_read(&bat_priv->hop_penalty); 132 int hop_penalty = atomic_read(&bat_priv->hop_penalty);
132 return (tq * (TQ_MAX_VALUE - hop_penalty)) / (TQ_MAX_VALUE); 133 return (tq * (TQ_MAX_VALUE - hop_penalty)) / (TQ_MAX_VALUE);
133} 134}
134 135
135/* is there another aggregated packet here? */ 136/* is there another aggregated packet here? */
136static int bat_iv_ogm_aggr_packet(int buff_pos, int packet_len, 137static int batadv_iv_ogm_aggr_packet(int buff_pos, int packet_len,
137 int tt_num_changes) 138 int tt_num_changes)
138{ 139{
139 int next_buff_pos = 0; 140 int next_buff_pos = 0;
140 141
@@ -146,7 +147,7 @@ static int bat_iv_ogm_aggr_packet(int buff_pos, int packet_len,
146} 147}
147 148
148/* send a batman ogm to a given interface */ 149/* send a batman ogm to a given interface */
149static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet, 150static void batadv_iv_ogm_send_to_if(struct forw_packet *forw_packet,
150 struct hard_iface *hard_iface) 151 struct hard_iface *hard_iface)
151{ 152{
152 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 153 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
@@ -164,8 +165,8 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
164 batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data; 165 batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data;
165 166
166 /* adjust all flags and log packets */ 167 /* adjust all flags and log packets */
167 while (bat_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len, 168 while (batadv_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len,
168 batman_ogm_packet->tt_num_changes)) { 169 batman_ogm_packet->tt_num_changes)) {
169 170
170 /* we might have aggregated direct link packets with an 171 /* we might have aggregated direct link packets with an
171 * ordinary base packet 172 * ordinary base packet
@@ -179,16 +180,16 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
179 fwd_str = (packet_num > 0 ? "Forwarding" : (forw_packet->own ? 180 fwd_str = (packet_num > 0 ? "Forwarding" : (forw_packet->own ?
180 "Sending own" : 181 "Sending own" :
181 "Forwarding")); 182 "Forwarding"));
182 bat_dbg(DBG_BATMAN, bat_priv, 183 batadv_dbg(DBG_BATMAN, bat_priv,
183 "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n", 184 "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n",
184 fwd_str, (packet_num > 0 ? "aggregated " : ""), 185 fwd_str, (packet_num > 0 ? "aggregated " : ""),
185 batman_ogm_packet->orig, 186 batman_ogm_packet->orig,
186 ntohl(batman_ogm_packet->seqno), 187 ntohl(batman_ogm_packet->seqno),
187 batman_ogm_packet->tq, batman_ogm_packet->header.ttl, 188 batman_ogm_packet->tq, batman_ogm_packet->header.ttl,
188 (batman_ogm_packet->flags & DIRECTLINK ? 189 (batman_ogm_packet->flags & DIRECTLINK ?
189 "on" : "off"), 190 "on" : "off"),
190 batman_ogm_packet->ttvn, hard_iface->net_dev->name, 191 batman_ogm_packet->ttvn, hard_iface->net_dev->name,
191 hard_iface->net_dev->dev_addr); 192 hard_iface->net_dev->dev_addr);
192 193
193 buff_pos += BATMAN_OGM_HLEN; 194 buff_pos += BATMAN_OGM_HLEN;
194 buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes); 195 buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes);
@@ -208,7 +209,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
208} 209}
209 210
210/* send a batman ogm packet */ 211/* send a batman ogm packet */
211static void bat_iv_ogm_emit(struct forw_packet *forw_packet) 212static void batadv_iv_ogm_emit(struct forw_packet *forw_packet)
212{ 213{
213 struct hard_iface *hard_iface; 214 struct hard_iface *hard_iface;
214 struct net_device *soft_iface; 215 struct net_device *soft_iface;
@@ -232,7 +233,7 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
232 if (forw_packet->if_incoming->if_status != IF_ACTIVE) 233 if (forw_packet->if_incoming->if_status != IF_ACTIVE)
233 goto out; 234 goto out;
234 235
235 primary_if = primary_if_get_selected(bat_priv); 236 primary_if = batadv_primary_if_get_selected(bat_priv);
236 if (!primary_if) 237 if (!primary_if)
237 goto out; 238 goto out;
238 239
@@ -243,14 +244,14 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
243 (forw_packet->own && (forw_packet->if_incoming != primary_if))) { 244 (forw_packet->own && (forw_packet->if_incoming != primary_if))) {
244 245
245 /* FIXME: what about aggregated packets ? */ 246 /* FIXME: what about aggregated packets ? */
246 bat_dbg(DBG_BATMAN, bat_priv, 247 batadv_dbg(DBG_BATMAN, bat_priv,
247 "%s packet (originator %pM, seqno %u, TTL %d) on interface %s [%pM]\n", 248 "%s packet (originator %pM, seqno %u, TTL %d) on interface %s [%pM]\n",
248 (forw_packet->own ? "Sending own" : "Forwarding"), 249 (forw_packet->own ? "Sending own" : "Forwarding"),
249 batman_ogm_packet->orig, 250 batman_ogm_packet->orig,
250 ntohl(batman_ogm_packet->seqno), 251 ntohl(batman_ogm_packet->seqno),
251 batman_ogm_packet->header.ttl, 252 batman_ogm_packet->header.ttl,
252 forw_packet->if_incoming->net_dev->name, 253 forw_packet->if_incoming->net_dev->name,
253 forw_packet->if_incoming->net_dev->dev_addr); 254 forw_packet->if_incoming->net_dev->dev_addr);
254 255
255 /* skb is only used once and than forw_packet is free'd */ 256 /* skb is only used once and than forw_packet is free'd */
256 batadv_send_skb_packet(forw_packet->skb, 257 batadv_send_skb_packet(forw_packet->skb,
@@ -267,23 +268,23 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
267 if (hard_iface->soft_iface != soft_iface) 268 if (hard_iface->soft_iface != soft_iface)
268 continue; 269 continue;
269 270
270 bat_iv_ogm_send_to_if(forw_packet, hard_iface); 271 batadv_iv_ogm_send_to_if(forw_packet, hard_iface);
271 } 272 }
272 rcu_read_unlock(); 273 rcu_read_unlock();
273 274
274out: 275out:
275 if (primary_if) 276 if (primary_if)
276 hardif_free_ref(primary_if); 277 batadv_hardif_free_ref(primary_if);
277} 278}
278 279
279/* return true if new_packet can be aggregated with forw_packet */ 280/* return true if new_packet can be aggregated with forw_packet */
280static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet 281static bool
281 *new_batman_ogm_packet, 282batadv_iv_ogm_can_aggregate(const struct batman_ogm_packet *new_bat_ogm_packet,
282 struct bat_priv *bat_priv, 283 struct bat_priv *bat_priv,
283 int packet_len, unsigned long send_time, 284 int packet_len, unsigned long send_time,
284 bool directlink, 285 bool directlink,
285 const struct hard_iface *if_incoming, 286 const struct hard_iface *if_incoming,
286 const struct forw_packet *forw_packet) 287 const struct forw_packet *forw_packet)
287{ 288{
288 struct batman_ogm_packet *batman_ogm_packet; 289 struct batman_ogm_packet *batman_ogm_packet;
289 int aggregated_bytes = forw_packet->packet_len + packet_len; 290 int aggregated_bytes = forw_packet->packet_len + packet_len;
@@ -311,7 +312,7 @@ static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet
311 * a "global" packet as well as the base 312 * a "global" packet as well as the base
312 * packet 313 * packet
313 */ 314 */
314 primary_if = primary_if_get_selected(bat_priv); 315 primary_if = batadv_primary_if_get_selected(bat_priv);
315 if (!primary_if) 316 if (!primary_if)
316 goto out; 317 goto out;
317 318
@@ -335,7 +336,7 @@ static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet
335 * interface only - we still can aggregate 336 * interface only - we still can aggregate
336 */ 337 */
337 if ((directlink) && 338 if ((directlink) &&
338 (new_batman_ogm_packet->header.ttl == 1) && 339 (new_bat_ogm_packet->header.ttl == 1) &&
339 (forw_packet->if_incoming == if_incoming) && 340 (forw_packet->if_incoming == if_incoming) &&
340 341
341 /* packets from direct neighbors or 342 /* packets from direct neighbors or
@@ -352,16 +353,16 @@ static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet
352 353
353out: 354out:
354 if (primary_if) 355 if (primary_if)
355 hardif_free_ref(primary_if); 356 batadv_hardif_free_ref(primary_if);
356 return res; 357 return res;
357} 358}
358 359
359/* create a new aggregated packet and add this packet to it */ 360/* create a new aggregated packet and add this packet to it */
360static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff, 361static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
361 int packet_len, unsigned long send_time, 362 int packet_len, unsigned long send_time,
362 bool direct_link, 363 bool direct_link,
363 struct hard_iface *if_incoming, 364 struct hard_iface *if_incoming,
364 int own_packet) 365 int own_packet)
365{ 366{
366 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 367 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
367 struct forw_packet *forw_packet_aggr; 368 struct forw_packet *forw_packet_aggr;
@@ -373,8 +374,8 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
373 /* own packet should always be scheduled */ 374 /* own packet should always be scheduled */
374 if (!own_packet) { 375 if (!own_packet) {
375 if (!atomic_dec_not_zero(&bat_priv->batman_queue_left)) { 376 if (!atomic_dec_not_zero(&bat_priv->batman_queue_left)) {
376 bat_dbg(DBG_BATMAN, bat_priv, 377 batadv_dbg(DBG_BATMAN, bat_priv,
377 "batman packet queue full\n"); 378 "batman packet queue full\n");
378 goto out; 379 goto out;
379 } 380 }
380 } 381 }
@@ -431,13 +432,13 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
431 432
432 return; 433 return;
433out: 434out:
434 hardif_free_ref(if_incoming); 435 batadv_hardif_free_ref(if_incoming);
435} 436}
436 437
437/* aggregate a new packet into the existing ogm packet */ 438/* aggregate a new packet into the existing ogm packet */
438static void bat_iv_ogm_aggregate(struct forw_packet *forw_packet_aggr, 439static void batadv_iv_ogm_aggregate(struct forw_packet *forw_packet_aggr,
439 const unsigned char *packet_buff, 440 const unsigned char *packet_buff,
440 int packet_len, bool direct_link) 441 int packet_len, bool direct_link)
441{ 442{
442 unsigned char *skb_buff; 443 unsigned char *skb_buff;
443 444
@@ -452,10 +453,11 @@ static void bat_iv_ogm_aggregate(struct forw_packet *forw_packet_aggr,
452 (1 << forw_packet_aggr->num_packets); 453 (1 << forw_packet_aggr->num_packets);
453} 454}
454 455
455static void bat_iv_ogm_queue_add(struct bat_priv *bat_priv, 456static void batadv_iv_ogm_queue_add(struct bat_priv *bat_priv,
456 unsigned char *packet_buff, 457 unsigned char *packet_buff,
457 int packet_len, struct hard_iface *if_incoming, 458 int packet_len,
458 int own_packet, unsigned long send_time) 459 struct hard_iface *if_incoming,
460 int own_packet, unsigned long send_time)
459{ 461{
460 /* _aggr -> pointer to the packet we want to aggregate with 462 /* _aggr -> pointer to the packet we want to aggregate with
461 * _pos -> pointer to the position in the queue 463 * _pos -> pointer to the position in the queue
@@ -474,11 +476,11 @@ static void bat_iv_ogm_queue_add(struct bat_priv *bat_priv,
474 if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) { 476 if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) {
475 hlist_for_each_entry(forw_packet_pos, tmp_node, 477 hlist_for_each_entry(forw_packet_pos, tmp_node,
476 &bat_priv->forw_bat_list, list) { 478 &bat_priv->forw_bat_list, list) {
477 if (bat_iv_ogm_can_aggregate(batman_ogm_packet, 479 if (batadv_iv_ogm_can_aggregate(batman_ogm_packet,
478 bat_priv, packet_len, 480 bat_priv, packet_len,
479 send_time, direct_link, 481 send_time, direct_link,
480 if_incoming, 482 if_incoming,
481 forw_packet_pos)) { 483 forw_packet_pos)) {
482 forw_packet_aggr = forw_packet_pos; 484 forw_packet_aggr = forw_packet_pos;
483 break; 485 break;
484 } 486 }
@@ -500,28 +502,28 @@ static void bat_iv_ogm_queue_add(struct bat_priv *bat_priv,
500 (atomic_read(&bat_priv->aggregated_ogms))) 502 (atomic_read(&bat_priv->aggregated_ogms)))
501 send_time += msecs_to_jiffies(MAX_AGGREGATION_MS); 503 send_time += msecs_to_jiffies(MAX_AGGREGATION_MS);
502 504
503 bat_iv_ogm_aggregate_new(packet_buff, packet_len, 505 batadv_iv_ogm_aggregate_new(packet_buff, packet_len,
504 send_time, direct_link, 506 send_time, direct_link,
505 if_incoming, own_packet); 507 if_incoming, own_packet);
506 } else { 508 } else {
507 bat_iv_ogm_aggregate(forw_packet_aggr, packet_buff, 509 batadv_iv_ogm_aggregate(forw_packet_aggr, packet_buff,
508 packet_len, direct_link); 510 packet_len, direct_link);
509 spin_unlock_bh(&bat_priv->forw_bat_list_lock); 511 spin_unlock_bh(&bat_priv->forw_bat_list_lock);
510 } 512 }
511} 513}
512 514
513static void bat_iv_ogm_forward(struct orig_node *orig_node, 515static void batadv_iv_ogm_forward(struct orig_node *orig_node,
514 const struct ethhdr *ethhdr, 516 const struct ethhdr *ethhdr,
515 struct batman_ogm_packet *batman_ogm_packet, 517 struct batman_ogm_packet *batman_ogm_packet,
516 bool is_single_hop_neigh, 518 bool is_single_hop_neigh,
517 bool is_from_best_next_hop, 519 bool is_from_best_next_hop,
518 struct hard_iface *if_incoming) 520 struct hard_iface *if_incoming)
519{ 521{
520 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 522 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
521 uint8_t tt_num_changes; 523 uint8_t tt_num_changes;
522 524
523 if (batman_ogm_packet->header.ttl <= 1) { 525 if (batman_ogm_packet->header.ttl <= 1) {
524 bat_dbg(DBG_BATMAN, bat_priv, "ttl exceeded\n"); 526 batadv_dbg(DBG_BATMAN, bat_priv, "ttl exceeded\n");
525 return; 527 return;
526 } 528 }
527 529
@@ -544,11 +546,12 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node,
544 memcpy(batman_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN); 546 memcpy(batman_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN);
545 547
546 /* apply hop penalty */ 548 /* apply hop penalty */
547 batman_ogm_packet->tq = hop_penalty(batman_ogm_packet->tq, bat_priv); 549 batman_ogm_packet->tq = batadv_hop_penalty(batman_ogm_packet->tq,
550 bat_priv);
548 551
549 bat_dbg(DBG_BATMAN, bat_priv, 552 batadv_dbg(DBG_BATMAN, bat_priv,
550 "Forwarding packet: tq: %i, ttl: %i\n", 553 "Forwarding packet: tq: %i, ttl: %i\n",
551 batman_ogm_packet->tq, batman_ogm_packet->header.ttl); 554 batman_ogm_packet->tq, batman_ogm_packet->header.ttl);
552 555
553 /* switch of primaries first hop flag when forwarding */ 556 /* switch of primaries first hop flag when forwarding */
554 batman_ogm_packet->flags &= ~PRIMARIES_FIRST_HOP; 557 batman_ogm_packet->flags &= ~PRIMARIES_FIRST_HOP;
@@ -557,12 +560,12 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node,
557 else 560 else
558 batman_ogm_packet->flags &= ~DIRECTLINK; 561 batman_ogm_packet->flags &= ~DIRECTLINK;
559 562
560 bat_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet, 563 batadv_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet,
561 BATMAN_OGM_HLEN + batadv_tt_len(tt_num_changes), 564 BATMAN_OGM_HLEN + batadv_tt_len(tt_num_changes),
562 if_incoming, 0, bat_iv_ogm_fwd_send_time()); 565 if_incoming, 0, batadv_iv_ogm_fwd_send_time());
563} 566}
564 567
565static void bat_iv_ogm_schedule(struct hard_iface *hard_iface) 568static void batadv_iv_ogm_schedule(struct hard_iface *hard_iface)
566{ 569{
567 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 570 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
568 struct batman_ogm_packet *batman_ogm_packet; 571 struct batman_ogm_packet *batman_ogm_packet;
@@ -570,7 +573,7 @@ static void bat_iv_ogm_schedule(struct hard_iface *hard_iface)
570 int vis_server, tt_num_changes = 0; 573 int vis_server, tt_num_changes = 0;
571 574
572 vis_server = atomic_read(&bat_priv->vis_mode); 575 vis_server = atomic_read(&bat_priv->vis_mode);
573 primary_if = primary_if_get_selected(bat_priv); 576 primary_if = batadv_primary_if_get_selected(bat_priv);
574 577
575 if (hard_iface == primary_if) 578 if (hard_iface == primary_if)
576 tt_num_changes = batadv_tt_append_diff(bat_priv, 579 tt_num_changes = batadv_tt_append_diff(bat_priv,
@@ -603,38 +606,40 @@ static void bat_iv_ogm_schedule(struct hard_iface *hard_iface)
603 batman_ogm_packet->gw_flags = NO_FLAGS; 606 batman_ogm_packet->gw_flags = NO_FLAGS;
604 607
605 batadv_slide_own_bcast_window(hard_iface); 608 batadv_slide_own_bcast_window(hard_iface);
606 bat_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff, 609 batadv_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff,
607 hard_iface->packet_len, hard_iface, 1, 610 hard_iface->packet_len, hard_iface, 1,
608 bat_iv_ogm_emit_send_time(bat_priv)); 611 batadv_iv_ogm_emit_send_time(bat_priv));
609 612
610 if (primary_if) 613 if (primary_if)
611 hardif_free_ref(primary_if); 614 batadv_hardif_free_ref(primary_if);
612} 615}
613 616
614static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv, 617static void
615 struct orig_node *orig_node, 618batadv_iv_ogm_orig_update(struct bat_priv *bat_priv,
616 const struct ethhdr *ethhdr, 619 struct orig_node *orig_node,
617 const struct batman_ogm_packet 620 const struct ethhdr *ethhdr,
618 *batman_ogm_packet, 621 const struct batman_ogm_packet *batman_ogm_packet,
619 struct hard_iface *if_incoming, 622 struct hard_iface *if_incoming,
620 const unsigned char *tt_buff, 623 const unsigned char *tt_buff,
621 int is_duplicate) 624 int is_duplicate)
622{ 625{
623 struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; 626 struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
624 struct neigh_node *router = NULL; 627 struct neigh_node *router = NULL;
625 struct orig_node *orig_node_tmp; 628 struct orig_node *orig_node_tmp;
626 struct hlist_node *node; 629 struct hlist_node *node;
627 uint8_t bcast_own_sum_orig, bcast_own_sum_neigh; 630 uint8_t bcast_own_sum_orig, bcast_own_sum_neigh;
631 uint8_t *neigh_addr;
628 632
629 bat_dbg(DBG_BATMAN, bat_priv, 633 batadv_dbg(DBG_BATMAN, bat_priv,
630 "update_originator(): Searching and updating originator entry of received packet\n"); 634 "update_originator(): Searching and updating originator entry of received packet\n");
631 635
632 rcu_read_lock(); 636 rcu_read_lock();
633 hlist_for_each_entry_rcu(tmp_neigh_node, node, 637 hlist_for_each_entry_rcu(tmp_neigh_node, node,
634 &orig_node->neigh_list, list) { 638 &orig_node->neigh_list, list) {
635 if (compare_eth(tmp_neigh_node->addr, ethhdr->h_source) && 639 neigh_addr = tmp_neigh_node->addr;
636 (tmp_neigh_node->if_incoming == if_incoming) && 640 if (batadv_compare_eth(neigh_addr, ethhdr->h_source) &&
637 atomic_inc_not_zero(&tmp_neigh_node->refcount)) { 641 tmp_neigh_node->if_incoming == if_incoming &&
642 atomic_inc_not_zero(&tmp_neigh_node->refcount)) {
638 if (neigh_node) 643 if (neigh_node)
639 batadv_neigh_node_free_ref(neigh_node); 644 batadv_neigh_node_free_ref(neigh_node);
640 neigh_node = tmp_neigh_node; 645 neigh_node = tmp_neigh_node;
@@ -659,16 +664,17 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv,
659 if (!orig_tmp) 664 if (!orig_tmp)
660 goto unlock; 665 goto unlock;
661 666
662 neigh_node = bat_iv_ogm_neigh_new(if_incoming, ethhdr->h_source, 667 neigh_node = batadv_iv_ogm_neigh_new(if_incoming,
663 orig_node, orig_tmp, 668 ethhdr->h_source,
664 batman_ogm_packet->seqno); 669 orig_node, orig_tmp,
670 batman_ogm_packet->seqno);
665 671
666 batadv_orig_node_free_ref(orig_tmp); 672 batadv_orig_node_free_ref(orig_tmp);
667 if (!neigh_node) 673 if (!neigh_node)
668 goto unlock; 674 goto unlock;
669 } else 675 } else
670 bat_dbg(DBG_BATMAN, bat_priv, 676 batadv_dbg(DBG_BATMAN, bat_priv,
671 "Updating existing last-hop neighbor of originator\n"); 677 "Updating existing last-hop neighbor of originator\n");
672 678
673 rcu_read_unlock(); 679 rcu_read_unlock();
674 680
@@ -757,10 +763,10 @@ out:
757 batadv_neigh_node_free_ref(router); 763 batadv_neigh_node_free_ref(router);
758} 764}
759 765
760static int bat_iv_ogm_calc_tq(struct orig_node *orig_node, 766static int batadv_iv_ogm_calc_tq(struct orig_node *orig_node,
761 struct orig_node *orig_neigh_node, 767 struct orig_node *orig_neigh_node,
762 struct batman_ogm_packet *batman_ogm_packet, 768 struct batman_ogm_packet *batman_ogm_packet,
763 struct hard_iface *if_incoming) 769 struct hard_iface *if_incoming)
764{ 770{
765 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 771 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
766 struct neigh_node *neigh_node = NULL, *tmp_neigh_node; 772 struct neigh_node *neigh_node = NULL, *tmp_neigh_node;
@@ -774,7 +780,8 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node,
774 hlist_for_each_entry_rcu(tmp_neigh_node, node, 780 hlist_for_each_entry_rcu(tmp_neigh_node, node,
775 &orig_neigh_node->neigh_list, list) { 781 &orig_neigh_node->neigh_list, list) {
776 782
777 if (!compare_eth(tmp_neigh_node->addr, orig_neigh_node->orig)) 783 if (!batadv_compare_eth(tmp_neigh_node->addr,
784 orig_neigh_node->orig))
778 continue; 785 continue;
779 786
780 if (tmp_neigh_node->if_incoming != if_incoming) 787 if (tmp_neigh_node->if_incoming != if_incoming)
@@ -789,11 +796,11 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node,
789 rcu_read_unlock(); 796 rcu_read_unlock();
790 797
791 if (!neigh_node) 798 if (!neigh_node)
792 neigh_node = bat_iv_ogm_neigh_new(if_incoming, 799 neigh_node = batadv_iv_ogm_neigh_new(if_incoming,
793 orig_neigh_node->orig, 800 orig_neigh_node->orig,
794 orig_neigh_node, 801 orig_neigh_node,
795 orig_neigh_node, 802 orig_neigh_node,
796 batman_ogm_packet->seqno); 803 batman_ogm_packet->seqno);
797 804
798 if (!neigh_node) 805 if (!neigh_node)
799 goto out; 806 goto out;
@@ -844,10 +851,11 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node,
844 * tq_asym_penalty) / 851 * tq_asym_penalty) /
845 (TQ_MAX_VALUE * TQ_MAX_VALUE)); 852 (TQ_MAX_VALUE * TQ_MAX_VALUE));
846 853
847 bat_dbg(DBG_BATMAN, bat_priv, 854 batadv_dbg(DBG_BATMAN, bat_priv,
848 "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n", 855 "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n",
849 orig_node->orig, orig_neigh_node->orig, total_count, 856 orig_node->orig, orig_neigh_node->orig, total_count,
850 neigh_rq_count, tq_own, tq_asym_penalty, batman_ogm_packet->tq); 857 neigh_rq_count, tq_own,
858 tq_asym_penalty, batman_ogm_packet->tq);
851 859
852 /* if link has the minimum required transmission quality 860 /* if link has the minimum required transmission quality
853 * consider it bidirectional 861 * consider it bidirectional
@@ -869,10 +877,10 @@ out:
869 * -1 the packet is old and has been received while the seqno window 877 * -1 the packet is old and has been received while the seqno window
870 * was protected. Caller should drop it. 878 * was protected. Caller should drop it.
871 */ 879 */
872static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, 880static int
873 const struct batman_ogm_packet 881batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
874 *batman_ogm_packet, 882 const struct batman_ogm_packet *batman_ogm_packet,
875 const struct hard_iface *if_incoming) 883 const struct hard_iface *if_incoming)
876{ 884{
877 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 885 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
878 struct orig_node *orig_node; 886 struct orig_node *orig_node;
@@ -883,6 +891,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
883 int need_update = 0; 891 int need_update = 0;
884 int set_mark, ret = -1; 892 int set_mark, ret = -1;
885 uint32_t seqno = ntohl(batman_ogm_packet->seqno); 893 uint32_t seqno = ntohl(batman_ogm_packet->seqno);
894 uint8_t *neigh_addr;
886 895
887 orig_node = batadv_get_orig_node(bat_priv, batman_ogm_packet->orig); 896 orig_node = batadv_get_orig_node(bat_priv, batman_ogm_packet->orig);
888 if (!orig_node) 897 if (!orig_node)
@@ -901,12 +910,13 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
901 hlist_for_each_entry_rcu(tmp_neigh_node, node, 910 hlist_for_each_entry_rcu(tmp_neigh_node, node,
902 &orig_node->neigh_list, list) { 911 &orig_node->neigh_list, list) {
903 912
904 is_duplicate |= bat_test_bit(tmp_neigh_node->real_bits, 913 is_duplicate |= batadv_test_bit(tmp_neigh_node->real_bits,
905 orig_node->last_real_seqno, 914 orig_node->last_real_seqno,
906 seqno); 915 seqno);
907 916
908 if (compare_eth(tmp_neigh_node->addr, ethhdr->h_source) && 917 neigh_addr = tmp_neigh_node->addr;
909 (tmp_neigh_node->if_incoming == if_incoming)) 918 if (batadv_compare_eth(neigh_addr, ethhdr->h_source) &&
919 tmp_neigh_node->if_incoming == if_incoming)
910 set_mark = 1; 920 set_mark = 1;
911 else 921 else
912 set_mark = 0; 922 set_mark = 0;
@@ -923,9 +933,9 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
923 rcu_read_unlock(); 933 rcu_read_unlock();
924 934
925 if (need_update) { 935 if (need_update) {
926 bat_dbg(DBG_BATMAN, bat_priv, 936 batadv_dbg(DBG_BATMAN, bat_priv,
927 "updating last_seqno: old %u, new %u\n", 937 "updating last_seqno: old %u, new %u\n",
928 orig_node->last_real_seqno, seqno); 938 orig_node->last_real_seqno, seqno);
929 orig_node->last_real_seqno = seqno; 939 orig_node->last_real_seqno = seqno;
930 } 940 }
931 941
@@ -937,10 +947,10 @@ out:
937 return ret; 947 return ret;
938} 948}
939 949
940static void bat_iv_ogm_process(const struct ethhdr *ethhdr, 950static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
941 struct batman_ogm_packet *batman_ogm_packet, 951 struct batman_ogm_packet *batman_ogm_packet,
942 const unsigned char *tt_buff, 952 const unsigned char *tt_buff,
943 struct hard_iface *if_incoming) 953 struct hard_iface *if_incoming)
944{ 954{
945 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 955 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
946 struct hard_iface *hard_iface; 956 struct hard_iface *hard_iface;
@@ -949,11 +959,12 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
949 struct neigh_node *orig_neigh_router = NULL; 959 struct neigh_node *orig_neigh_router = NULL;
950 int has_directlink_flag; 960 int has_directlink_flag;
951 int is_my_addr = 0, is_my_orig = 0, is_my_oldorig = 0; 961 int is_my_addr = 0, is_my_orig = 0, is_my_oldorig = 0;
952 int is_broadcast = 0, is_bidirectional; 962 int is_broadcast = 0, is_bidirect;
953 bool is_single_hop_neigh = false; 963 bool is_single_hop_neigh = false;
954 bool is_from_best_next_hop = false; 964 bool is_from_best_next_hop = false;
955 int is_duplicate; 965 int is_duplicate, sameseq, simlar_ttl;
956 uint32_t if_incoming_seqno; 966 uint32_t if_incoming_seqno;
967 uint8_t *prev_sender;
957 968
958 /* Silently drop when the batman packet is actually not a 969 /* Silently drop when the batman packet is actually not a
959 * correct packet. 970 * correct packet.
@@ -975,18 +986,19 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
975 986
976 has_directlink_flag = (batman_ogm_packet->flags & DIRECTLINK ? 1 : 0); 987 has_directlink_flag = (batman_ogm_packet->flags & DIRECTLINK ? 1 : 0);
977 988
978 if (compare_eth(ethhdr->h_source, batman_ogm_packet->orig)) 989 if (batadv_compare_eth(ethhdr->h_source, batman_ogm_packet->orig))
979 is_single_hop_neigh = true; 990 is_single_hop_neigh = true;
980 991
981 bat_dbg(DBG_BATMAN, bat_priv, 992 batadv_dbg(DBG_BATMAN, bat_priv,
982 "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n", 993 "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n",
983 ethhdr->h_source, if_incoming->net_dev->name, 994 ethhdr->h_source, if_incoming->net_dev->name,
984 if_incoming->net_dev->dev_addr, batman_ogm_packet->orig, 995 if_incoming->net_dev->dev_addr, batman_ogm_packet->orig,
985 batman_ogm_packet->prev_sender, ntohl(batman_ogm_packet->seqno), 996 batman_ogm_packet->prev_sender,
986 batman_ogm_packet->ttvn, ntohs(batman_ogm_packet->tt_crc), 997 ntohl(batman_ogm_packet->seqno), batman_ogm_packet->ttvn,
987 batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq, 998 ntohs(batman_ogm_packet->tt_crc),
988 batman_ogm_packet->header.ttl, 999 batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq,
989 batman_ogm_packet->header.version, has_directlink_flag); 1000 batman_ogm_packet->header.ttl,
1001 batman_ogm_packet->header.version, has_directlink_flag);
990 1002
991 rcu_read_lock(); 1003 rcu_read_lock();
992 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { 1004 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
@@ -996,16 +1008,16 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
996 if (hard_iface->soft_iface != if_incoming->soft_iface) 1008 if (hard_iface->soft_iface != if_incoming->soft_iface)
997 continue; 1009 continue;
998 1010
999 if (compare_eth(ethhdr->h_source, 1011 if (batadv_compare_eth(ethhdr->h_source,
1000 hard_iface->net_dev->dev_addr)) 1012 hard_iface->net_dev->dev_addr))
1001 is_my_addr = 1; 1013 is_my_addr = 1;
1002 1014
1003 if (compare_eth(batman_ogm_packet->orig, 1015 if (batadv_compare_eth(batman_ogm_packet->orig,
1004 hard_iface->net_dev->dev_addr)) 1016 hard_iface->net_dev->dev_addr))
1005 is_my_orig = 1; 1017 is_my_orig = 1;
1006 1018
1007 if (compare_eth(batman_ogm_packet->prev_sender, 1019 if (batadv_compare_eth(batman_ogm_packet->prev_sender,
1008 hard_iface->net_dev->dev_addr)) 1020 hard_iface->net_dev->dev_addr))
1009 is_my_oldorig = 1; 1021 is_my_oldorig = 1;
1010 1022
1011 if (is_broadcast_ether_addr(ethhdr->h_source)) 1023 if (is_broadcast_ether_addr(ethhdr->h_source))
@@ -1014,29 +1026,30 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1014 rcu_read_unlock(); 1026 rcu_read_unlock();
1015 1027
1016 if (batman_ogm_packet->header.version != COMPAT_VERSION) { 1028 if (batman_ogm_packet->header.version != COMPAT_VERSION) {
1017 bat_dbg(DBG_BATMAN, bat_priv, 1029 batadv_dbg(DBG_BATMAN, bat_priv,
1018 "Drop packet: incompatible batman version (%i)\n", 1030 "Drop packet: incompatible batman version (%i)\n",
1019 batman_ogm_packet->header.version); 1031 batman_ogm_packet->header.version);
1020 return; 1032 return;
1021 } 1033 }
1022 1034
1023 if (is_my_addr) { 1035 if (is_my_addr) {
1024 bat_dbg(DBG_BATMAN, bat_priv, 1036 batadv_dbg(DBG_BATMAN, bat_priv,
1025 "Drop packet: received my own broadcast (sender: %pM)\n", 1037 "Drop packet: received my own broadcast (sender: %pM)\n",
1026 ethhdr->h_source); 1038 ethhdr->h_source);
1027 return; 1039 return;
1028 } 1040 }
1029 1041
1030 if (is_broadcast) { 1042 if (is_broadcast) {
1031 bat_dbg(DBG_BATMAN, bat_priv, 1043 batadv_dbg(DBG_BATMAN, bat_priv,
1032 "Drop packet: ignoring all packets with broadcast source addr (sender: %pM)\n", 1044 "Drop packet: ignoring all packets with broadcast source addr (sender: %pM)\n",
1033 ethhdr->h_source); 1045 ethhdr->h_source);
1034 return; 1046 return;
1035 } 1047 }
1036 1048
1037 if (is_my_orig) { 1049 if (is_my_orig) {
1038 unsigned long *word; 1050 unsigned long *word;
1039 int offset; 1051 int offset;
1052 int32_t bit_pos;
1040 1053
1041 orig_neigh_node = batadv_get_orig_node(bat_priv, 1054 orig_neigh_node = batadv_get_orig_node(bat_priv,
1042 ethhdr->h_source); 1055 ethhdr->h_source);
@@ -1048,37 +1061,37 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1048 * save packet seqno for bidirectional check 1061 * save packet seqno for bidirectional check
1049 */ 1062 */
1050 if (has_directlink_flag && 1063 if (has_directlink_flag &&
1051 compare_eth(if_incoming->net_dev->dev_addr, 1064 batadv_compare_eth(if_incoming->net_dev->dev_addr,
1052 batman_ogm_packet->orig)) { 1065 batman_ogm_packet->orig)) {
1053 offset = if_incoming->if_num * NUM_WORDS; 1066 offset = if_incoming->if_num * NUM_WORDS;
1054 1067
1055 spin_lock_bh(&orig_neigh_node->ogm_cnt_lock); 1068 spin_lock_bh(&orig_neigh_node->ogm_cnt_lock);
1056 word = &(orig_neigh_node->bcast_own[offset]); 1069 word = &(orig_neigh_node->bcast_own[offset]);
1057 bat_set_bit(word, 1070 bit_pos = if_incoming_seqno - 2;
1058 if_incoming_seqno - 1071 bit_pos -= ntohl(batman_ogm_packet->seqno);
1059 ntohl(batman_ogm_packet->seqno) - 2); 1072 batadv_set_bit(word, bit_pos);
1060 orig_neigh_node->bcast_own_sum[if_incoming->if_num] = 1073 orig_neigh_node->bcast_own_sum[if_incoming->if_num] =
1061 bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE); 1074 bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE);
1062 spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock); 1075 spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock);
1063 } 1076 }
1064 1077
1065 bat_dbg(DBG_BATMAN, bat_priv, 1078 batadv_dbg(DBG_BATMAN, bat_priv,
1066 "Drop packet: originator packet from myself (via neighbor)\n"); 1079 "Drop packet: originator packet from myself (via neighbor)\n");
1067 batadv_orig_node_free_ref(orig_neigh_node); 1080 batadv_orig_node_free_ref(orig_neigh_node);
1068 return; 1081 return;
1069 } 1082 }
1070 1083
1071 if (is_my_oldorig) { 1084 if (is_my_oldorig) {
1072 bat_dbg(DBG_BATMAN, bat_priv, 1085 batadv_dbg(DBG_BATMAN, bat_priv,
1073 "Drop packet: ignoring all rebroadcast echos (sender: %pM)\n", 1086 "Drop packet: ignoring all rebroadcast echos (sender: %pM)\n",
1074 ethhdr->h_source); 1087 ethhdr->h_source);
1075 return; 1088 return;
1076 } 1089 }
1077 1090
1078 if (batman_ogm_packet->flags & NOT_BEST_NEXT_HOP) { 1091 if (batman_ogm_packet->flags & NOT_BEST_NEXT_HOP) {
1079 bat_dbg(DBG_BATMAN, bat_priv, 1092 batadv_dbg(DBG_BATMAN, bat_priv,
1080 "Drop packet: ignoring all packets not forwarded from the best next hop (sender: %pM)\n", 1093 "Drop packet: ignoring all packets not forwarded from the best next hop (sender: %pM)\n",
1081 ethhdr->h_source); 1094 ethhdr->h_source);
1082 return; 1095 return;
1083 } 1096 }
1084 1097
@@ -1086,19 +1099,19 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1086 if (!orig_node) 1099 if (!orig_node)
1087 return; 1100 return;
1088 1101
1089 is_duplicate = bat_iv_ogm_update_seqnos(ethhdr, batman_ogm_packet, 1102 is_duplicate = batadv_iv_ogm_update_seqnos(ethhdr, batman_ogm_packet,
1090 if_incoming); 1103 if_incoming);
1091 1104
1092 if (is_duplicate == -1) { 1105 if (is_duplicate == -1) {
1093 bat_dbg(DBG_BATMAN, bat_priv, 1106 batadv_dbg(DBG_BATMAN, bat_priv,
1094 "Drop packet: packet within seqno protection time (sender: %pM)\n", 1107 "Drop packet: packet within seqno protection time (sender: %pM)\n",
1095 ethhdr->h_source); 1108 ethhdr->h_source);
1096 goto out; 1109 goto out;
1097 } 1110 }
1098 1111
1099 if (batman_ogm_packet->tq == 0) { 1112 if (batman_ogm_packet->tq == 0) {
1100 bat_dbg(DBG_BATMAN, bat_priv, 1113 batadv_dbg(DBG_BATMAN, bat_priv,
1101 "Drop packet: originator packet with tq equal 0\n"); 1114 "Drop packet: originator packet with tq equal 0\n");
1102 goto out; 1115 goto out;
1103 } 1116 }
1104 1117
@@ -1107,18 +1120,18 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1107 router_router = batadv_orig_node_get_router(router->orig_node); 1120 router_router = batadv_orig_node_get_router(router->orig_node);
1108 1121
1109 if ((router && router->tq_avg != 0) && 1122 if ((router && router->tq_avg != 0) &&
1110 (compare_eth(router->addr, ethhdr->h_source))) 1123 (batadv_compare_eth(router->addr, ethhdr->h_source)))
1111 is_from_best_next_hop = true; 1124 is_from_best_next_hop = true;
1112 1125
1126 prev_sender = batman_ogm_packet->prev_sender;
1113 /* avoid temporary routing loops */ 1127 /* avoid temporary routing loops */
1114 if (router && router_router && 1128 if (router && router_router &&
1115 (compare_eth(router->addr, batman_ogm_packet->prev_sender)) && 1129 (batadv_compare_eth(router->addr, prev_sender)) &&
1116 !(compare_eth(batman_ogm_packet->orig, 1130 !(batadv_compare_eth(batman_ogm_packet->orig, prev_sender)) &&
1117 batman_ogm_packet->prev_sender)) && 1131 (batadv_compare_eth(router->addr, router_router->addr))) {
1118 (compare_eth(router->addr, router_router->addr))) { 1132 batadv_dbg(DBG_BATMAN, bat_priv,
1119 bat_dbg(DBG_BATMAN, bat_priv, 1133 "Drop packet: ignoring all rebroadcast packets that may make me loop (sender: %pM)\n",
1120 "Drop packet: ignoring all rebroadcast packets that may make me loop (sender: %pM)\n", 1134 ethhdr->h_source);
1121 ethhdr->h_source);
1122 goto out; 1135 goto out;
1123 } 1136 }
1124 1137
@@ -1137,13 +1150,13 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1137 * don't route towards it 1150 * don't route towards it
1138 */ 1151 */
1139 if (!is_single_hop_neigh && (!orig_neigh_router)) { 1152 if (!is_single_hop_neigh && (!orig_neigh_router)) {
1140 bat_dbg(DBG_BATMAN, bat_priv, 1153 batadv_dbg(DBG_BATMAN, bat_priv,
1141 "Drop packet: OGM via unknown neighbor!\n"); 1154 "Drop packet: OGM via unknown neighbor!\n");
1142 goto out_neigh; 1155 goto out_neigh;
1143 } 1156 }
1144 1157
1145 is_bidirectional = bat_iv_ogm_calc_tq(orig_node, orig_neigh_node, 1158 is_bidirect = batadv_iv_ogm_calc_tq(orig_node, orig_neigh_node,
1146 batman_ogm_packet, if_incoming); 1159 batman_ogm_packet, if_incoming);
1147 1160
1148 batadv_bonding_save_primary(orig_node, orig_neigh_node, 1161 batadv_bonding_save_primary(orig_node, orig_neigh_node,
1149 batman_ogm_packet); 1162 batman_ogm_packet);
@@ -1151,45 +1164,44 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
1151 /* update ranking if it is not a duplicate or has the same 1164 /* update ranking if it is not a duplicate or has the same
1152 * seqno and similar ttl as the non-duplicate 1165 * seqno and similar ttl as the non-duplicate
1153 */ 1166 */
1154 if (is_bidirectional && 1167 sameseq = orig_node->last_real_seqno == ntohl(batman_ogm_packet->seqno);
1155 (!is_duplicate || 1168 simlar_ttl = orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl;
1156 ((orig_node->last_real_seqno == ntohl(batman_ogm_packet->seqno)) && 1169 if (is_bidirect && (!is_duplicate || (sameseq && simlar_ttl)))
1157 (orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl)))) 1170 batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr,
1158 bat_iv_ogm_orig_update(bat_priv, orig_node, ethhdr, 1171 batman_ogm_packet, if_incoming,
1159 batman_ogm_packet, if_incoming, 1172 tt_buff, is_duplicate);
1160 tt_buff, is_duplicate);
1161 1173
1162 /* is single hop (direct) neighbor */ 1174 /* is single hop (direct) neighbor */
1163 if (is_single_hop_neigh) { 1175 if (is_single_hop_neigh) {
1164 1176
1165 /* mark direct link on incoming interface */ 1177 /* mark direct link on incoming interface */
1166 bat_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet, 1178 batadv_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet,
1167 is_single_hop_neigh, is_from_best_next_hop, 1179 is_single_hop_neigh,
1168 if_incoming); 1180 is_from_best_next_hop, if_incoming);
1169 1181
1170 bat_dbg(DBG_BATMAN, bat_priv, 1182 batadv_dbg(DBG_BATMAN, bat_priv,
1171 "Forwarding packet: rebroadcast neighbor packet with direct link flag\n"); 1183 "Forwarding packet: rebroadcast neighbor packet with direct link flag\n");
1172 goto out_neigh; 1184 goto out_neigh;
1173 } 1185 }
1174 1186
1175 /* multihop originator */ 1187 /* multihop originator */
1176 if (!is_bidirectional) { 1188 if (!is_bidirect) {
1177 bat_dbg(DBG_BATMAN, bat_priv, 1189 batadv_dbg(DBG_BATMAN, bat_priv,
1178 "Drop packet: not received via bidirectional link\n"); 1190 "Drop packet: not received via bidirectional link\n");
1179 goto out_neigh; 1191 goto out_neigh;
1180 } 1192 }
1181 1193
1182 if (is_duplicate) { 1194 if (is_duplicate) {
1183 bat_dbg(DBG_BATMAN, bat_priv, 1195 batadv_dbg(DBG_BATMAN, bat_priv,
1184 "Drop packet: duplicate packet received\n"); 1196 "Drop packet: duplicate packet received\n");
1185 goto out_neigh; 1197 goto out_neigh;
1186 } 1198 }
1187 1199
1188 bat_dbg(DBG_BATMAN, bat_priv, 1200 batadv_dbg(DBG_BATMAN, bat_priv,
1189 "Forwarding packet: rebroadcast originator packet\n"); 1201 "Forwarding packet: rebroadcast originator packet\n");
1190 bat_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet, 1202 batadv_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet,
1191 is_single_hop_neigh, is_from_best_next_hop, 1203 is_single_hop_neigh, is_from_best_next_hop,
1192 if_incoming); 1204 if_incoming);
1193 1205
1194out_neigh: 1206out_neigh:
1195 if ((orig_neigh_node) && (!is_single_hop_neigh)) 1207 if ((orig_neigh_node) && (!is_single_hop_neigh))
@@ -1205,8 +1217,8 @@ out:
1205 batadv_orig_node_free_ref(orig_node); 1217 batadv_orig_node_free_ref(orig_node);
1206} 1218}
1207 1219
1208static int bat_iv_ogm_receive(struct sk_buff *skb, 1220static int batadv_iv_ogm_receive(struct sk_buff *skb,
1209 struct hard_iface *if_incoming) 1221 struct hard_iface *if_incoming)
1210{ 1222{
1211 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 1223 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
1212 struct batman_ogm_packet *batman_ogm_packet; 1224 struct batman_ogm_packet *batman_ogm_packet;
@@ -1222,7 +1234,7 @@ static int bat_iv_ogm_receive(struct sk_buff *skb,
1222 /* did we receive a B.A.T.M.A.N. IV OGM packet on an interface 1234 /* did we receive a B.A.T.M.A.N. IV OGM packet on an interface
1223 * that does not have B.A.T.M.A.N. IV enabled ? 1235 * that does not have B.A.T.M.A.N. IV enabled ?
1224 */ 1236 */
1225 if (bat_priv->bat_algo_ops->bat_ogm_emit != bat_iv_ogm_emit) 1237 if (bat_priv->bat_algo_ops->bat_ogm_emit != batadv_iv_ogm_emit)
1226 return NET_RX_DROP; 1238 return NET_RX_DROP;
1227 1239
1228 batadv_inc_counter(bat_priv, BAT_CNT_MGMT_RX); 1240 batadv_inc_counter(bat_priv, BAT_CNT_MGMT_RX);
@@ -1238,29 +1250,29 @@ static int bat_iv_ogm_receive(struct sk_buff *skb,
1238 do { 1250 do {
1239 tt_buff = packet_buff + buff_pos + BATMAN_OGM_HLEN; 1251 tt_buff = packet_buff + buff_pos + BATMAN_OGM_HLEN;
1240 1252
1241 bat_iv_ogm_process(ethhdr, batman_ogm_packet, 1253 batadv_iv_ogm_process(ethhdr, batman_ogm_packet, tt_buff,
1242 tt_buff, if_incoming); 1254 if_incoming);
1243 1255
1244 buff_pos += BATMAN_OGM_HLEN; 1256 buff_pos += BATMAN_OGM_HLEN;
1245 buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes); 1257 buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes);
1246 1258
1247 batman_ogm_packet = (struct batman_ogm_packet *) 1259 batman_ogm_packet = (struct batman_ogm_packet *)
1248 (packet_buff + buff_pos); 1260 (packet_buff + buff_pos);
1249 } while (bat_iv_ogm_aggr_packet(buff_pos, packet_len, 1261 } while (batadv_iv_ogm_aggr_packet(buff_pos, packet_len,
1250 batman_ogm_packet->tt_num_changes)); 1262 batman_ogm_packet->tt_num_changes));
1251 1263
1252 kfree_skb(skb); 1264 kfree_skb(skb);
1253 return NET_RX_SUCCESS; 1265 return NET_RX_SUCCESS;
1254} 1266}
1255 1267
1256static struct bat_algo_ops batman_iv __read_mostly = { 1268static struct bat_algo_ops batadv_batman_iv __read_mostly = {
1257 .name = "BATMAN_IV", 1269 .name = "BATMAN_IV",
1258 .bat_iface_enable = bat_iv_ogm_iface_enable, 1270 .bat_iface_enable = batadv_iv_ogm_iface_enable,
1259 .bat_iface_disable = bat_iv_ogm_iface_disable, 1271 .bat_iface_disable = batadv_iv_ogm_iface_disable,
1260 .bat_iface_update_mac = bat_iv_ogm_iface_update_mac, 1272 .bat_iface_update_mac = batadv_iv_ogm_iface_update_mac,
1261 .bat_primary_iface_set = bat_iv_ogm_primary_iface_set, 1273 .bat_primary_iface_set = batadv_iv_ogm_primary_iface_set,
1262 .bat_ogm_schedule = bat_iv_ogm_schedule, 1274 .bat_ogm_schedule = batadv_iv_ogm_schedule,
1263 .bat_ogm_emit = bat_iv_ogm_emit, 1275 .bat_ogm_emit = batadv_iv_ogm_emit,
1264}; 1276};
1265 1277
1266int __init batadv_iv_init(void) 1278int __init batadv_iv_init(void)
@@ -1268,11 +1280,11 @@ int __init batadv_iv_init(void)
1268 int ret; 1280 int ret;
1269 1281
1270 /* batman originator packet */ 1282 /* batman originator packet */
1271 ret = batadv_recv_handler_register(BAT_IV_OGM, bat_iv_ogm_receive); 1283 ret = batadv_recv_handler_register(BAT_IV_OGM, batadv_iv_ogm_receive);
1272 if (ret < 0) 1284 if (ret < 0)
1273 goto out; 1285 goto out;
1274 1286
1275 ret = batadv_algo_register(&batman_iv); 1287 ret = batadv_algo_register(&batadv_batman_iv);
1276 if (ret < 0) 1288 if (ret < 0)
1277 goto handler_unregister; 1289 goto handler_unregister;
1278 1290
diff --git a/net/batman-adv/bat_sysfs.c b/net/batman-adv/bat_sysfs.c
index 8196fa6ff22e..03b76a41ac4e 100644
--- a/net/batman-adv/bat_sysfs.c
+++ b/net/batman-adv/bat_sysfs.c
@@ -26,15 +26,15 @@
26#include "gateway_client.h" 26#include "gateway_client.h"
27#include "vis.h" 27#include "vis.h"
28 28
29static struct net_device *kobj_to_netdev(struct kobject *obj) 29static struct net_device *batadv_kobj_to_netdev(struct kobject *obj)
30{ 30{
31 struct device *dev = container_of(obj->parent, struct device, kobj); 31 struct device *dev = container_of(obj->parent, struct device, kobj);
32 return to_net_dev(dev); 32 return to_net_dev(dev);
33} 33}
34 34
35static struct bat_priv *kobj_to_batpriv(struct kobject *obj) 35static struct bat_priv *batadv_kobj_to_batpriv(struct kobject *obj)
36{ 36{
37 struct net_device *net_dev = kobj_to_netdev(obj); 37 struct net_device *net_dev = batadv_kobj_to_netdev(obj);
38 return netdev_priv(net_dev); 38 return netdev_priv(net_dev);
39} 39}
40 40
@@ -42,19 +42,19 @@ static struct bat_priv *kobj_to_batpriv(struct kobject *obj)
42#define UEV_ACTION_VAR "BATACTION=" 42#define UEV_ACTION_VAR "BATACTION="
43#define UEV_DATA_VAR "BATDATA=" 43#define UEV_DATA_VAR "BATDATA="
44 44
45static char *uev_action_str[] = { 45static char *batadv_uev_action_str[] = {
46 "add", 46 "add",
47 "del", 47 "del",
48 "change" 48 "change"
49}; 49};
50 50
51static char *uev_type_str[] = { 51static char *batadv_uev_type_str[] = {
52 "gw" 52 "gw"
53}; 53};
54 54
55/* Use this, if you have customized show and store functions */ 55/* Use this, if you have customized show and store functions */
56#define BAT_ATTR(_name, _mode, _show, _store) \ 56#define BAT_ATTR(_name, _mode, _show, _store) \
57struct bat_attribute bat_attr_##_name = { \ 57struct bat_attribute batadv_attr_##_name = { \
58 .attr = {.name = __stringify(_name), \ 58 .attr = {.name = __stringify(_name), \
59 .mode = _mode }, \ 59 .mode = _mode }, \
60 .show = _show, \ 60 .show = _show, \
@@ -62,20 +62,21 @@ struct bat_attribute bat_attr_##_name = { \
62}; 62};
63 63
64#define BAT_ATTR_SIF_STORE_BOOL(_name, _post_func) \ 64#define BAT_ATTR_SIF_STORE_BOOL(_name, _post_func) \
65ssize_t store_##_name(struct kobject *kobj, struct attribute *attr, \ 65ssize_t batadv_store_##_name(struct kobject *kobj, \
66 char *buff, size_t count) \ 66 struct attribute *attr, char *buff, \
67 size_t count) \
67{ \ 68{ \
68 struct net_device *net_dev = kobj_to_netdev(kobj); \ 69 struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
69 struct bat_priv *bat_priv = netdev_priv(net_dev); \ 70 struct bat_priv *bat_priv = netdev_priv(net_dev); \
70 return __store_bool_attr(buff, count, _post_func, attr, \ 71 return __batadv_store_bool_attr(buff, count, _post_func, attr, \
71 &bat_priv->_name, net_dev); \ 72 &bat_priv->_name, net_dev); \
72} 73}
73 74
74#define BAT_ATTR_SIF_SHOW_BOOL(_name) \ 75#define BAT_ATTR_SIF_SHOW_BOOL(_name) \
75ssize_t show_##_name(struct kobject *kobj, \ 76ssize_t batadv_show_##_name(struct kobject *kobj, \
76 struct attribute *attr, char *buff) \ 77 struct attribute *attr, char *buff) \
77{ \ 78{ \
78 struct bat_priv *bat_priv = kobj_to_batpriv(kobj); \ 79 struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj); \
79 return sprintf(buff, "%s\n", \ 80 return sprintf(buff, "%s\n", \
80 atomic_read(&bat_priv->_name) == 0 ? \ 81 atomic_read(&bat_priv->_name) == 0 ? \
81 "disabled" : "enabled"); \ 82 "disabled" : "enabled"); \
@@ -87,24 +88,27 @@ ssize_t show_##_name(struct kobject *kobj, \
87#define BAT_ATTR_SIF_BOOL(_name, _mode, _post_func) \ 88#define BAT_ATTR_SIF_BOOL(_name, _mode, _post_func) \
88 static BAT_ATTR_SIF_STORE_BOOL(_name, _post_func) \ 89 static BAT_ATTR_SIF_STORE_BOOL(_name, _post_func) \
89 static BAT_ATTR_SIF_SHOW_BOOL(_name) \ 90 static BAT_ATTR_SIF_SHOW_BOOL(_name) \
90 static BAT_ATTR(_name, _mode, show_##_name, store_##_name) 91 static BAT_ATTR(_name, _mode, batadv_show_##_name, \
92 batadv_store_##_name)
91 93
92 94
93#define BAT_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \ 95#define BAT_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \
94ssize_t store_##_name(struct kobject *kobj, struct attribute *attr, \ 96ssize_t batadv_store_##_name(struct kobject *kobj, \
95 char *buff, size_t count) \ 97 struct attribute *attr, char *buff, \
98 size_t count) \
96{ \ 99{ \
97 struct net_device *net_dev = kobj_to_netdev(kobj); \ 100 struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
98 struct bat_priv *bat_priv = netdev_priv(net_dev); \ 101 struct bat_priv *bat_priv = netdev_priv(net_dev); \
99 return __store_uint_attr(buff, count, _min, _max, _post_func, \ 102 return __batadv_store_uint_attr(buff, count, _min, _max, \
100 attr, &bat_priv->_name, net_dev); \ 103 _post_func, attr, \
104 &bat_priv->_name, net_dev); \
101} 105}
102 106
103#define BAT_ATTR_SIF_SHOW_UINT(_name) \ 107#define BAT_ATTR_SIF_SHOW_UINT(_name) \
104ssize_t show_##_name(struct kobject *kobj, \ 108ssize_t batadv_show_##_name(struct kobject *kobj, \
105 struct attribute *attr, char *buff) \ 109 struct attribute *attr, char *buff) \
106{ \ 110{ \
107 struct bat_priv *bat_priv = kobj_to_batpriv(kobj); \ 111 struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj); \
108 return sprintf(buff, "%i\n", atomic_read(&bat_priv->_name)); \ 112 return sprintf(buff, "%i\n", atomic_read(&bat_priv->_name)); \
109} \ 113} \
110 114
@@ -114,14 +118,16 @@ ssize_t show_##_name(struct kobject *kobj, \
114#define BAT_ATTR_SIF_UINT(_name, _mode, _min, _max, _post_func) \ 118#define BAT_ATTR_SIF_UINT(_name, _mode, _min, _max, _post_func) \
115 static BAT_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \ 119 static BAT_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \
116 static BAT_ATTR_SIF_SHOW_UINT(_name) \ 120 static BAT_ATTR_SIF_SHOW_UINT(_name) \
117 static BAT_ATTR(_name, _mode, show_##_name, store_##_name) 121 static BAT_ATTR(_name, _mode, batadv_show_##_name, \
122 batadv_store_##_name)
118 123
119 124
120#define BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \ 125#define BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \
121ssize_t store_##_name(struct kobject *kobj, struct attribute *attr, \ 126ssize_t batadv_store_##_name(struct kobject *kobj, \
122 char *buff, size_t count) \ 127 struct attribute *attr, char *buff, \
128 size_t count) \
123{ \ 129{ \
124 struct net_device *net_dev = kobj_to_netdev(kobj); \ 130 struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
125 struct hard_iface *hard_iface; \ 131 struct hard_iface *hard_iface; \
126 ssize_t length; \ 132 ssize_t length; \
127 \ 133 \
@@ -129,18 +135,19 @@ ssize_t store_##_name(struct kobject *kobj, struct attribute *attr, \
129 if (!hard_iface) \ 135 if (!hard_iface) \
130 return 0; \ 136 return 0; \
131 \ 137 \
132 length = __store_uint_attr(buff, count, _min, _max, _post_func, \ 138 length = __batadv_store_uint_attr(buff, count, _min, _max, \
133 attr, &hard_iface->_name, net_dev); \ 139 _post_func, attr, \
140 &hard_iface->_name, net_dev); \
134 \ 141 \
135 hardif_free_ref(hard_iface); \ 142 batadv_hardif_free_ref(hard_iface); \
136 return length; \ 143 return length; \
137} 144}
138 145
139#define BAT_ATTR_HIF_SHOW_UINT(_name) \ 146#define BAT_ATTR_HIF_SHOW_UINT(_name) \
140ssize_t show_##_name(struct kobject *kobj, \ 147ssize_t batadv_show_##_name(struct kobject *kobj, \
141 struct attribute *attr, char *buff) \ 148 struct attribute *attr, char *buff) \
142{ \ 149{ \
143 struct net_device *net_dev = kobj_to_netdev(kobj); \ 150 struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
144 struct hard_iface *hard_iface; \ 151 struct hard_iface *hard_iface; \
145 ssize_t length; \ 152 ssize_t length; \
146 \ 153 \
@@ -150,7 +157,7 @@ ssize_t show_##_name(struct kobject *kobj, \
150 \ 157 \
151 length = sprintf(buff, "%i\n", atomic_read(&hard_iface->_name));\ 158 length = sprintf(buff, "%i\n", atomic_read(&hard_iface->_name));\
152 \ 159 \
153 hardif_free_ref(hard_iface); \ 160 batadv_hardif_free_ref(hard_iface); \
154 return length; \ 161 return length; \
155} 162}
156 163
@@ -160,12 +167,13 @@ ssize_t show_##_name(struct kobject *kobj, \
160#define BAT_ATTR_HIF_UINT(_name, _mode, _min, _max, _post_func) \ 167#define BAT_ATTR_HIF_UINT(_name, _mode, _min, _max, _post_func) \
161 static BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \ 168 static BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \
162 static BAT_ATTR_HIF_SHOW_UINT(_name) \ 169 static BAT_ATTR_HIF_SHOW_UINT(_name) \
163 static BAT_ATTR(_name, _mode, show_##_name, store_##_name) 170 static BAT_ATTR(_name, _mode, batadv_show_##_name, \
171 batadv_store_##_name)
164 172
165 173
166static int store_bool_attr(char *buff, size_t count, 174static int batadv_store_bool_attr(char *buff, size_t count,
167 struct net_device *net_dev, 175 struct net_device *net_dev,
168 const char *attr_name, atomic_t *attr) 176 const char *attr_name, atomic_t *attr)
169{ 177{
170 int enabled = -1; 178 int enabled = -1;
171 179
@@ -200,23 +208,27 @@ static int store_bool_attr(char *buff, size_t count,
200 return count; 208 return count;
201} 209}
202 210
203static inline ssize_t __store_bool_attr(char *buff, size_t count, 211static inline ssize_t
204 void (*post_func)(struct net_device *), 212__batadv_store_bool_attr(char *buff, size_t count,
205 struct attribute *attr, 213 void (*post_func)(struct net_device *),
206 atomic_t *attr_store, struct net_device *net_dev) 214 struct attribute *attr,
215 atomic_t *attr_store, struct net_device *net_dev)
207{ 216{
208 int ret; 217 int ret;
209 218
210 ret = store_bool_attr(buff, count, net_dev, attr->name, attr_store); 219 ret = batadv_store_bool_attr(buff, count, net_dev, attr->name,
220 attr_store);
211 if (post_func && ret) 221 if (post_func && ret)
212 post_func(net_dev); 222 post_func(net_dev);
213 223
214 return ret; 224 return ret;
215} 225}
216 226
217static int store_uint_attr(const char *buff, size_t count, 227static int batadv_store_uint_attr(const char *buff, size_t count,
218 struct net_device *net_dev, const char *attr_name, 228 struct net_device *net_dev,
219 unsigned int min, unsigned int max, atomic_t *attr) 229 const char *attr_name,
230 unsigned int min, unsigned int max,
231 atomic_t *attr)
220{ 232{
221 unsigned long uint_val; 233 unsigned long uint_val;
222 int ret; 234 int ret;
@@ -251,26 +263,27 @@ static int store_uint_attr(const char *buff, size_t count,
251 return count; 263 return count;
252} 264}
253 265
254static inline ssize_t __store_uint_attr(const char *buff, size_t count, 266static inline ssize_t
255 int min, int max, 267__batadv_store_uint_attr(const char *buff, size_t count,
256 void (*post_func)(struct net_device *), 268 int min, int max,
257 const struct attribute *attr, 269 void (*post_func)(struct net_device *),
258 atomic_t *attr_store, struct net_device *net_dev) 270 const struct attribute *attr,
271 atomic_t *attr_store, struct net_device *net_dev)
259{ 272{
260 int ret; 273 int ret;
261 274
262 ret = store_uint_attr(buff, count, net_dev, attr->name, 275 ret = batadv_store_uint_attr(buff, count, net_dev, attr->name, min, max,
263 min, max, attr_store); 276 attr_store);
264 if (post_func && ret) 277 if (post_func && ret)
265 post_func(net_dev); 278 post_func(net_dev);
266 279
267 return ret; 280 return ret;
268} 281}
269 282
270static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr, 283static ssize_t batadv_show_vis_mode(struct kobject *kobj,
271 char *buff) 284 struct attribute *attr, char *buff)
272{ 285{
273 struct bat_priv *bat_priv = kobj_to_batpriv(kobj); 286 struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
274 int vis_mode = atomic_read(&bat_priv->vis_mode); 287 int vis_mode = atomic_read(&bat_priv->vis_mode);
275 288
276 return sprintf(buff, "%s\n", 289 return sprintf(buff, "%s\n",
@@ -278,10 +291,11 @@ static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr,
278 "client" : "server"); 291 "client" : "server");
279} 292}
280 293
281static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, 294static ssize_t batadv_store_vis_mode(struct kobject *kobj,
282 char *buff, size_t count) 295 struct attribute *attr, char *buff,
296 size_t count)
283{ 297{
284 struct net_device *net_dev = kobj_to_netdev(kobj); 298 struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
285 struct bat_priv *bat_priv = netdev_priv(net_dev); 299 struct bat_priv *bat_priv = netdev_priv(net_dev);
286 unsigned long val; 300 unsigned long val;
287 int ret, vis_mode_tmp = -1; 301 int ret, vis_mode_tmp = -1;
@@ -319,23 +333,23 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
319 return count; 333 return count;
320} 334}
321 335
322static ssize_t show_bat_algo(struct kobject *kobj, struct attribute *attr, 336static ssize_t batadv_show_bat_algo(struct kobject *kobj,
323 char *buff) 337 struct attribute *attr, char *buff)
324{ 338{
325 struct bat_priv *bat_priv = kobj_to_batpriv(kobj); 339 struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
326 return sprintf(buff, "%s\n", bat_priv->bat_algo_ops->name); 340 return sprintf(buff, "%s\n", bat_priv->bat_algo_ops->name);
327} 341}
328 342
329static void post_gw_deselect(struct net_device *net_dev) 343static void batadv_post_gw_deselect(struct net_device *net_dev)
330{ 344{
331 struct bat_priv *bat_priv = netdev_priv(net_dev); 345 struct bat_priv *bat_priv = netdev_priv(net_dev);
332 batadv_gw_deselect(bat_priv); 346 batadv_gw_deselect(bat_priv);
333} 347}
334 348
335static ssize_t show_gw_mode(struct kobject *kobj, struct attribute *attr, 349static ssize_t batadv_show_gw_mode(struct kobject *kobj, struct attribute *attr,
336 char *buff) 350 char *buff)
337{ 351{
338 struct bat_priv *bat_priv = kobj_to_batpriv(kobj); 352 struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
339 int bytes_written; 353 int bytes_written;
340 354
341 switch (atomic_read(&bat_priv->gw_mode)) { 355 switch (atomic_read(&bat_priv->gw_mode)) {
@@ -353,10 +367,11 @@ static ssize_t show_gw_mode(struct kobject *kobj, struct attribute *attr,
353 return bytes_written; 367 return bytes_written;
354} 368}
355 369
356static ssize_t store_gw_mode(struct kobject *kobj, struct attribute *attr, 370static ssize_t batadv_store_gw_mode(struct kobject *kobj,
357 char *buff, size_t count) 371 struct attribute *attr, char *buff,
372 size_t count)
358{ 373{
359 struct net_device *net_dev = kobj_to_netdev(kobj); 374 struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
360 struct bat_priv *bat_priv = netdev_priv(net_dev); 375 struct bat_priv *bat_priv = netdev_priv(net_dev);
361 char *curr_gw_mode_str; 376 char *curr_gw_mode_str;
362 int gw_mode_tmp = -1; 377 int gw_mode_tmp = -1;
@@ -405,10 +420,10 @@ static ssize_t store_gw_mode(struct kobject *kobj, struct attribute *attr,
405 return count; 420 return count;
406} 421}
407 422
408static ssize_t show_gw_bwidth(struct kobject *kobj, struct attribute *attr, 423static ssize_t batadv_show_gw_bwidth(struct kobject *kobj,
409 char *buff) 424 struct attribute *attr, char *buff)
410{ 425{
411 struct bat_priv *bat_priv = kobj_to_batpriv(kobj); 426 struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
412 int down, up; 427 int down, up;
413 int gw_bandwidth = atomic_read(&bat_priv->gw_bandwidth); 428 int gw_bandwidth = atomic_read(&bat_priv->gw_bandwidth);
414 429
@@ -420,10 +435,11 @@ static ssize_t show_gw_bwidth(struct kobject *kobj, struct attribute *attr,
420 (up > 2048 ? "MBit" : "KBit")); 435 (up > 2048 ? "MBit" : "KBit"));
421} 436}
422 437
423static ssize_t store_gw_bwidth(struct kobject *kobj, struct attribute *attr, 438static ssize_t batadv_store_gw_bwidth(struct kobject *kobj,
424 char *buff, size_t count) 439 struct attribute *attr, char *buff,
440 size_t count)
425{ 441{
426 struct net_device *net_dev = kobj_to_netdev(kobj); 442 struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
427 443
428 if (buff[count - 1] == '\n') 444 if (buff[count - 1] == '\n')
429 buff[count - 1] = '\0'; 445 buff[count - 1] = '\0';
@@ -438,36 +454,38 @@ BAT_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL);
438#endif 454#endif
439BAT_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu); 455BAT_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu);
440BAT_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL); 456BAT_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL);
441static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode); 457static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, batadv_show_vis_mode,
442static BAT_ATTR(routing_algo, S_IRUGO, show_bat_algo, NULL); 458 batadv_store_vis_mode);
443static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, show_gw_mode, store_gw_mode); 459static BAT_ATTR(routing_algo, S_IRUGO, batadv_show_bat_algo, NULL);
460static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, batadv_show_gw_mode,
461 batadv_store_gw_mode);
444BAT_ATTR_SIF_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, NULL); 462BAT_ATTR_SIF_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, NULL);
445BAT_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, TQ_MAX_VALUE, NULL); 463BAT_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, TQ_MAX_VALUE, NULL);
446BAT_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, TQ_MAX_VALUE, 464BAT_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, TQ_MAX_VALUE,
447 post_gw_deselect); 465 batadv_post_gw_deselect);
448static BAT_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, show_gw_bwidth, 466static BAT_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth,
449 store_gw_bwidth); 467 batadv_store_gw_bwidth);
450#ifdef CONFIG_BATMAN_ADV_DEBUG 468#ifdef CONFIG_BATMAN_ADV_DEBUG
451BAT_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, DBG_ALL, NULL); 469BAT_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, DBG_ALL, NULL);
452#endif 470#endif
453 471
454static struct bat_attribute *mesh_attrs[] = { 472static struct bat_attribute *batadv_mesh_attrs[] = {
455 &bat_attr_aggregated_ogms, 473 &batadv_attr_aggregated_ogms,
456 &bat_attr_bonding, 474 &batadv_attr_bonding,
457#ifdef CONFIG_BATMAN_ADV_BLA 475#ifdef CONFIG_BATMAN_ADV_BLA
458 &bat_attr_bridge_loop_avoidance, 476 &batadv_attr_bridge_loop_avoidance,
459#endif 477#endif
460 &bat_attr_fragmentation, 478 &batadv_attr_fragmentation,
461 &bat_attr_ap_isolation, 479 &batadv_attr_ap_isolation,
462 &bat_attr_vis_mode, 480 &batadv_attr_vis_mode,
463 &bat_attr_routing_algo, 481 &batadv_attr_routing_algo,
464 &bat_attr_gw_mode, 482 &batadv_attr_gw_mode,
465 &bat_attr_orig_interval, 483 &batadv_attr_orig_interval,
466 &bat_attr_hop_penalty, 484 &batadv_attr_hop_penalty,
467 &bat_attr_gw_sel_class, 485 &batadv_attr_gw_sel_class,
468 &bat_attr_gw_bandwidth, 486 &batadv_attr_gw_bandwidth,
469#ifdef CONFIG_BATMAN_ADV_DEBUG 487#ifdef CONFIG_BATMAN_ADV_DEBUG
470 &bat_attr_log_level, 488 &batadv_attr_log_level,
471#endif 489#endif
472 NULL, 490 NULL,
473}; 491};
@@ -487,7 +505,7 @@ int batadv_sysfs_add_meshif(struct net_device *dev)
487 goto out; 505 goto out;
488 } 506 }
489 507
490 for (bat_attr = mesh_attrs; *bat_attr; ++bat_attr) { 508 for (bat_attr = batadv_mesh_attrs; *bat_attr; ++bat_attr) {
491 err = sysfs_create_file(bat_priv->mesh_obj, 509 err = sysfs_create_file(bat_priv->mesh_obj,
492 &((*bat_attr)->attr)); 510 &((*bat_attr)->attr));
493 if (err) { 511 if (err) {
@@ -501,7 +519,7 @@ int batadv_sysfs_add_meshif(struct net_device *dev)
501 return 0; 519 return 0;
502 520
503rem_attr: 521rem_attr:
504 for (bat_attr = mesh_attrs; *bat_attr; ++bat_attr) 522 for (bat_attr = batadv_mesh_attrs; *bat_attr; ++bat_attr)
505 sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr)); 523 sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr));
506 524
507 kobject_put(bat_priv->mesh_obj); 525 kobject_put(bat_priv->mesh_obj);
@@ -515,17 +533,17 @@ void batadv_sysfs_del_meshif(struct net_device *dev)
515 struct bat_priv *bat_priv = netdev_priv(dev); 533 struct bat_priv *bat_priv = netdev_priv(dev);
516 struct bat_attribute **bat_attr; 534 struct bat_attribute **bat_attr;
517 535
518 for (bat_attr = mesh_attrs; *bat_attr; ++bat_attr) 536 for (bat_attr = batadv_mesh_attrs; *bat_attr; ++bat_attr)
519 sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr)); 537 sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr));
520 538
521 kobject_put(bat_priv->mesh_obj); 539 kobject_put(bat_priv->mesh_obj);
522 bat_priv->mesh_obj = NULL; 540 bat_priv->mesh_obj = NULL;
523} 541}
524 542
525static ssize_t show_mesh_iface(struct kobject *kobj, struct attribute *attr, 543static ssize_t batadv_show_mesh_iface(struct kobject *kobj,
526 char *buff) 544 struct attribute *attr, char *buff)
527{ 545{
528 struct net_device *net_dev = kobj_to_netdev(kobj); 546 struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
529 struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev); 547 struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
530 ssize_t length; 548 ssize_t length;
531 549
@@ -535,15 +553,16 @@ static ssize_t show_mesh_iface(struct kobject *kobj, struct attribute *attr,
535 length = sprintf(buff, "%s\n", hard_iface->if_status == IF_NOT_IN_USE ? 553 length = sprintf(buff, "%s\n", hard_iface->if_status == IF_NOT_IN_USE ?
536 "none" : hard_iface->soft_iface->name); 554 "none" : hard_iface->soft_iface->name);
537 555
538 hardif_free_ref(hard_iface); 556 batadv_hardif_free_ref(hard_iface);
539 557
540 return length; 558 return length;
541} 559}
542 560
543static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr, 561static ssize_t batadv_store_mesh_iface(struct kobject *kobj,
544 char *buff, size_t count) 562 struct attribute *attr, char *buff,
563 size_t count)
545{ 564{
546 struct net_device *net_dev = kobj_to_netdev(kobj); 565 struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
547 struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev); 566 struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
548 int status_tmp = -1; 567 int status_tmp = -1;
549 int ret = count; 568 int ret = count;
@@ -557,7 +576,7 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
557 if (strlen(buff) >= IFNAMSIZ) { 576 if (strlen(buff) >= IFNAMSIZ) {
558 pr_err("Invalid parameter for 'mesh_iface' setting received: interface name too long '%s'\n", 577 pr_err("Invalid parameter for 'mesh_iface' setting received: interface name too long '%s'\n",
559 buff); 578 buff);
560 hardif_free_ref(hard_iface); 579 batadv_hardif_free_ref(hard_iface);
561 return -EINVAL; 580 return -EINVAL;
562 } 581 }
563 582
@@ -592,14 +611,14 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
592unlock: 611unlock:
593 rtnl_unlock(); 612 rtnl_unlock();
594out: 613out:
595 hardif_free_ref(hard_iface); 614 batadv_hardif_free_ref(hard_iface);
596 return ret; 615 return ret;
597} 616}
598 617
599static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr, 618static ssize_t batadv_show_iface_status(struct kobject *kobj,
600 char *buff) 619 struct attribute *attr, char *buff)
601{ 620{
602 struct net_device *net_dev = kobj_to_netdev(kobj); 621 struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
603 struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev); 622 struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
604 ssize_t length; 623 ssize_t length;
605 624
@@ -625,18 +644,18 @@ static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr,
625 break; 644 break;
626 } 645 }
627 646
628 hardif_free_ref(hard_iface); 647 batadv_hardif_free_ref(hard_iface);
629 648
630 return length; 649 return length;
631} 650}
632 651
633static BAT_ATTR(mesh_iface, S_IRUGO | S_IWUSR, 652static BAT_ATTR(mesh_iface, S_IRUGO | S_IWUSR,
634 show_mesh_iface, store_mesh_iface); 653 batadv_show_mesh_iface, batadv_store_mesh_iface);
635static BAT_ATTR(iface_status, S_IRUGO, show_iface_status, NULL); 654static BAT_ATTR(iface_status, S_IRUGO, batadv_show_iface_status, NULL);
636 655
637static struct bat_attribute *batman_attrs[] = { 656static struct bat_attribute *batadv_batman_attrs[] = {
638 &bat_attr_mesh_iface, 657 &batadv_attr_mesh_iface,
639 &bat_attr_iface_status, 658 &batadv_attr_iface_status,
640 NULL, 659 NULL,
641}; 660};
642 661
@@ -655,7 +674,7 @@ int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
655 goto out; 674 goto out;
656 } 675 }
657 676
658 for (bat_attr = batman_attrs; *bat_attr; ++bat_attr) { 677 for (bat_attr = batadv_batman_attrs; *bat_attr; ++bat_attr) {
659 err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr)); 678 err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr));
660 if (err) { 679 if (err) {
661 bat_err(dev, "Can't add sysfs file: %s/%s/%s\n", 680 bat_err(dev, "Can't add sysfs file: %s/%s/%s\n",
@@ -668,7 +687,7 @@ int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
668 return 0; 687 return 0;
669 688
670rem_attr: 689rem_attr:
671 for (bat_attr = batman_attrs; *bat_attr; ++bat_attr) 690 for (bat_attr = batadv_batman_attrs; *bat_attr; ++bat_attr)
672 sysfs_remove_file(*hardif_obj, &((*bat_attr)->attr)); 691 sysfs_remove_file(*hardif_obj, &((*bat_attr)->attr));
673out: 692out:
674 return -ENOMEM; 693 return -ENOMEM;
@@ -688,27 +707,28 @@ int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
688 struct kobject *bat_kobj; 707 struct kobject *bat_kobj;
689 char *uevent_env[4] = { NULL, NULL, NULL, NULL }; 708 char *uevent_env[4] = { NULL, NULL, NULL, NULL };
690 709
691 primary_if = primary_if_get_selected(bat_priv); 710 primary_if = batadv_primary_if_get_selected(bat_priv);
692 if (!primary_if) 711 if (!primary_if)
693 goto out; 712 goto out;
694 713
695 bat_kobj = &primary_if->soft_iface->dev.kobj; 714 bat_kobj = &primary_if->soft_iface->dev.kobj;
696 715
697 uevent_env[0] = kmalloc(strlen(UEV_TYPE_VAR) + 716 uevent_env[0] = kmalloc(strlen(UEV_TYPE_VAR) +
698 strlen(uev_type_str[type]) + 1, 717 strlen(batadv_uev_type_str[type]) + 1,
699 GFP_ATOMIC); 718 GFP_ATOMIC);
700 if (!uevent_env[0]) 719 if (!uevent_env[0])
701 goto out; 720 goto out;
702 721
703 sprintf(uevent_env[0], "%s%s", UEV_TYPE_VAR, uev_type_str[type]); 722 sprintf(uevent_env[0], "%s%s", UEV_TYPE_VAR, batadv_uev_type_str[type]);
704 723
705 uevent_env[1] = kmalloc(strlen(UEV_ACTION_VAR) + 724 uevent_env[1] = kmalloc(strlen(UEV_ACTION_VAR) +
706 strlen(uev_action_str[action]) + 1, 725 strlen(batadv_uev_action_str[action]) + 1,
707 GFP_ATOMIC); 726 GFP_ATOMIC);
708 if (!uevent_env[1]) 727 if (!uevent_env[1])
709 goto out; 728 goto out;
710 729
711 sprintf(uevent_env[1], "%s%s", UEV_ACTION_VAR, uev_action_str[action]); 730 sprintf(uevent_env[1], "%s%s", UEV_ACTION_VAR,
731 batadv_uev_action_str[action]);
712 732
713 /* If the event is DEL, ignore the data field */ 733 /* If the event is DEL, ignore the data field */
714 if (action != UEV_DEL) { 734 if (action != UEV_DEL) {
@@ -727,12 +747,13 @@ out:
727 kfree(uevent_env[2]); 747 kfree(uevent_env[2]);
728 748
729 if (primary_if) 749 if (primary_if)
730 hardif_free_ref(primary_if); 750 batadv_hardif_free_ref(primary_if);
731 751
732 if (ret) 752 if (ret)
733 bat_dbg(DBG_BATMAN, bat_priv, 753 batadv_dbg(DBG_BATMAN, bat_priv,
734 "Impossible to send uevent for (%s,%s,%s) event (err: %d)\n", 754 "Impossible to send uevent for (%s,%s,%s) event (err: %d)\n",
735 uev_type_str[type], uev_action_str[action], 755 batadv_uev_type_str[type],
736 (action == UEV_DEL ? "NULL" : data), ret); 756 batadv_uev_action_str[action],
757 (action == UEV_DEL ? "NULL" : data), ret);
737 return ret; 758 return ret;
738} 759}
diff --git a/net/batman-adv/bitarray.c b/net/batman-adv/bitarray.c
index 838abbc73c6c..e195b9eed7ee 100644
--- a/net/batman-adv/bitarray.c
+++ b/net/batman-adv/bitarray.c
@@ -48,7 +48,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
48 */ 48 */
49 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)) {
50 if (set_mark) 50 if (set_mark)
51 bat_set_bit(seq_bits, -seq_num_diff); 51 batadv_set_bit(seq_bits, -seq_num_diff);
52 return 0; 52 return 0;
53 } 53 }
54 54
@@ -59,19 +59,19 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
59 batadv_bitmap_shift_left(seq_bits, seq_num_diff); 59 batadv_bitmap_shift_left(seq_bits, seq_num_diff);
60 60
61 if (set_mark) 61 if (set_mark)
62 bat_set_bit(seq_bits, 0); 62 batadv_set_bit(seq_bits, 0);
63 return 1; 63 return 1;
64 } 64 }
65 65
66 /* sequence number is much newer, probably missed a lot of packets */ 66 /* sequence number is much newer, probably missed a lot of packets */
67 if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) && 67 if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) &&
68 (seq_num_diff < EXPECTED_SEQNO_RANGE)) { 68 (seq_num_diff < EXPECTED_SEQNO_RANGE)) {
69 bat_dbg(DBG_BATMAN, bat_priv, 69 batadv_dbg(DBG_BATMAN, bat_priv,
70 "We missed a lot of packets (%i) !\n", 70 "We missed a lot of packets (%i) !\n",
71 seq_num_diff - 1); 71 seq_num_diff - 1);
72 bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE); 72 bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE);
73 if (set_mark) 73 if (set_mark)
74 bat_set_bit(seq_bits, 0); 74 batadv_set_bit(seq_bits, 0);
75 return 1; 75 return 1;
76 } 76 }
77 77
@@ -83,12 +83,12 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
83 if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || 83 if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) ||
84 (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { 84 (seq_num_diff >= EXPECTED_SEQNO_RANGE)) {
85 85
86 bat_dbg(DBG_BATMAN, bat_priv, 86 batadv_dbg(DBG_BATMAN, bat_priv,
87 "Other host probably restarted!\n"); 87 "Other host probably restarted!\n");
88 88
89 bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE); 89 bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE);
90 if (set_mark) 90 if (set_mark)
91 bat_set_bit(seq_bits, 0); 91 batadv_set_bit(seq_bits, 0);
92 92
93 return 1; 93 return 1;
94 } 94 }
diff --git a/net/batman-adv/bitarray.h b/net/batman-adv/bitarray.h
index 8ab542632343..7954ba81cece 100644
--- a/net/batman-adv/bitarray.h
+++ b/net/batman-adv/bitarray.h
@@ -23,8 +23,8 @@
23/* 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
24 * and curr_seqno is within range of last_seqno 24 * and curr_seqno is within range of last_seqno
25 */ 25 */
26static inline int bat_test_bit(const unsigned long *seq_bits, 26static inline int batadv_test_bit(const unsigned long *seq_bits,
27 uint32_t last_seqno, uint32_t curr_seqno) 27 uint32_t last_seqno, uint32_t curr_seqno)
28{ 28{
29 int32_t diff; 29 int32_t diff;
30 30
@@ -36,7 +36,7 @@ static inline int bat_test_bit(const unsigned long *seq_bits,
36} 36}
37 37
38/* turn corresponding bit on, so we can remember that we got the packet */ 38/* turn corresponding bit on, so we can remember that we got the packet */
39static inline void bat_set_bit(unsigned long *seq_bits, int32_t n) 39static inline void batadv_set_bit(unsigned long *seq_bits, int32_t n)
40{ 40{
41 /* if too old, just drop it */ 41 /* if too old, just drop it */
42 if (n < 0 || n >= TQ_LOCAL_WINDOW_SIZE) 42 if (n < 0 || n >= TQ_LOCAL_WINDOW_SIZE)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 52c0d637d581..0592d2bcb9b5 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -31,14 +31,14 @@
31#include <net/arp.h> 31#include <net/arp.h>
32#include <linux/if_vlan.h> 32#include <linux/if_vlan.h>
33 33
34static const uint8_t announce_mac[4] = {0x43, 0x05, 0x43, 0x05}; 34static const uint8_t batadv_announce_mac[4] = {0x43, 0x05, 0x43, 0x05};
35 35
36static void bla_periodic_work(struct work_struct *work); 36static void batadv_bla_periodic_work(struct work_struct *work);
37static void bla_send_announce(struct bat_priv *bat_priv, 37static void batadv_bla_send_announce(struct bat_priv *bat_priv,
38 struct backbone_gw *backbone_gw); 38 struct backbone_gw *backbone_gw);
39 39
40/* return the index of the claim */ 40/* return the index of the claim */
41static inline uint32_t choose_claim(const void *data, uint32_t size) 41static inline uint32_t batadv_choose_claim(const void *data, uint32_t size)
42{ 42{
43 const unsigned char *key = data; 43 const unsigned char *key = data;
44 uint32_t hash = 0; 44 uint32_t hash = 0;
@@ -58,7 +58,8 @@ static inline uint32_t choose_claim(const void *data, uint32_t size)
58} 58}
59 59
60/* return the index of the backbone gateway */ 60/* return the index of the backbone gateway */
61static inline uint32_t choose_backbone_gw(const void *data, uint32_t size) 61static inline uint32_t batadv_choose_backbone_gw(const void *data,
62 uint32_t size)
62{ 63{
63 const unsigned char *key = data; 64 const unsigned char *key = data;
64 uint32_t hash = 0; 65 uint32_t hash = 0;
@@ -79,7 +80,8 @@ static inline uint32_t choose_backbone_gw(const void *data, uint32_t size)
79 80
80 81
81/* compares address and vid of two backbone gws */ 82/* compares address and vid of two backbone gws */
82static int compare_backbone_gw(const struct hlist_node *node, const void *data2) 83static int batadv_compare_backbone_gw(const struct hlist_node *node,
84 const void *data2)
83{ 85{
84 const void *data1 = container_of(node, struct backbone_gw, 86 const void *data1 = container_of(node, struct backbone_gw,
85 hash_entry); 87 hash_entry);
@@ -88,7 +90,8 @@ static int compare_backbone_gw(const struct hlist_node *node, const void *data2)
88} 90}
89 91
90/* compares address and vid of two claims */ 92/* compares address and vid of two claims */
91static int compare_claim(const struct hlist_node *node, const void *data2) 93static int batadv_compare_claim(const struct hlist_node *node,
94 const void *data2)
92{ 95{
93 const void *data1 = container_of(node, struct claim, 96 const void *data1 = container_of(node, struct claim,
94 hash_entry); 97 hash_entry);
@@ -97,28 +100,28 @@ static int compare_claim(const struct hlist_node *node, const void *data2)
97} 100}
98 101
99/* free a backbone gw */ 102/* free a backbone gw */
100static void backbone_gw_free_ref(struct backbone_gw *backbone_gw) 103static void batadv_backbone_gw_free_ref(struct backbone_gw *backbone_gw)
101{ 104{
102 if (atomic_dec_and_test(&backbone_gw->refcount)) 105 if (atomic_dec_and_test(&backbone_gw->refcount))
103 kfree_rcu(backbone_gw, rcu); 106 kfree_rcu(backbone_gw, rcu);
104} 107}
105 108
106/* finally deinitialize the claim */ 109/* finally deinitialize the claim */
107static void claim_free_rcu(struct rcu_head *rcu) 110static void batadv_claim_free_rcu(struct rcu_head *rcu)
108{ 111{
109 struct claim *claim; 112 struct claim *claim;
110 113
111 claim = container_of(rcu, struct claim, rcu); 114 claim = container_of(rcu, struct claim, rcu);
112 115
113 backbone_gw_free_ref(claim->backbone_gw); 116 batadv_backbone_gw_free_ref(claim->backbone_gw);
114 kfree(claim); 117 kfree(claim);
115} 118}
116 119
117/* free a claim, call claim_free_rcu if its the last reference */ 120/* free a claim, call claim_free_rcu if its the last reference */
118static void claim_free_ref(struct claim *claim) 121static void batadv_claim_free_ref(struct claim *claim)
119{ 122{
120 if (atomic_dec_and_test(&claim->refcount)) 123 if (atomic_dec_and_test(&claim->refcount))
121 call_rcu(&claim->rcu, claim_free_rcu); 124 call_rcu(&claim->rcu, batadv_claim_free_rcu);
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
@@ -127,8 +130,8 @@ static void claim_free_ref(struct claim *claim)
127 * looks for a claim in the hash, and returns it if found 130 * looks for a claim in the hash, and returns it if found
128 * or NULL otherwise. 131 * or NULL otherwise.
129 */ 132 */
130static struct claim *claim_hash_find(struct bat_priv *bat_priv, 133static struct claim *batadv_claim_hash_find(struct bat_priv *bat_priv,
131 struct claim *data) 134 struct claim *data)
132{ 135{
133 struct hashtable_t *hash = bat_priv->claim_hash; 136 struct hashtable_t *hash = bat_priv->claim_hash;
134 struct hlist_head *head; 137 struct hlist_head *head;
@@ -140,12 +143,12 @@ static struct claim *claim_hash_find(struct bat_priv *bat_priv,
140 if (!hash) 143 if (!hash)
141 return NULL; 144 return NULL;
142 145
143 index = choose_claim(data, hash->size); 146 index = batadv_choose_claim(data, hash->size);
144 head = &hash->table[index]; 147 head = &hash->table[index];
145 148
146 rcu_read_lock(); 149 rcu_read_lock();
147 hlist_for_each_entry_rcu(claim, node, head, hash_entry) { 150 hlist_for_each_entry_rcu(claim, node, head, hash_entry) {
148 if (!compare_claim(&claim->hash_entry, data)) 151 if (!batadv_compare_claim(&claim->hash_entry, data))
149 continue; 152 continue;
150 153
151 if (!atomic_inc_not_zero(&claim->refcount)) 154 if (!atomic_inc_not_zero(&claim->refcount))
@@ -166,8 +169,8 @@ static struct claim *claim_hash_find(struct bat_priv *bat_priv,
166 * looks for a claim in the hash, and returns it if found 169 * looks for a claim in the hash, and returns it if found
167 * or NULL otherwise. 170 * or NULL otherwise.
168 */ 171 */
169static struct backbone_gw *backbone_hash_find(struct bat_priv *bat_priv, 172static struct backbone_gw *batadv_backbone_hash_find(struct bat_priv *bat_priv,
170 uint8_t *addr, short vid) 173 uint8_t *addr, short vid)
171{ 174{
172 struct hashtable_t *hash = bat_priv->backbone_hash; 175 struct hashtable_t *hash = bat_priv->backbone_hash;
173 struct hlist_head *head; 176 struct hlist_head *head;
@@ -182,13 +185,13 @@ static struct backbone_gw *backbone_hash_find(struct bat_priv *bat_priv,
182 memcpy(search_entry.orig, addr, ETH_ALEN); 185 memcpy(search_entry.orig, addr, ETH_ALEN);
183 search_entry.vid = vid; 186 search_entry.vid = vid;
184 187
185 index = choose_backbone_gw(&search_entry, hash->size); 188 index = batadv_choose_backbone_gw(&search_entry, hash->size);
186 head = &hash->table[index]; 189 head = &hash->table[index];
187 190
188 rcu_read_lock(); 191 rcu_read_lock();
189 hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { 192 hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) {
190 if (!compare_backbone_gw(&backbone_gw->hash_entry, 193 if (!batadv_compare_backbone_gw(&backbone_gw->hash_entry,
191 &search_entry)) 194 &search_entry))
192 continue; 195 continue;
193 196
194 if (!atomic_inc_not_zero(&backbone_gw->refcount)) 197 if (!atomic_inc_not_zero(&backbone_gw->refcount))
@@ -203,7 +206,7 @@ static struct backbone_gw *backbone_hash_find(struct bat_priv *bat_priv,
203} 206}
204 207
205/* delete all claims for a backbone */ 208/* delete all claims for a backbone */
206static void bla_del_backbone_claims(struct backbone_gw *backbone_gw) 209static void batadv_bla_del_backbone_claims(struct backbone_gw *backbone_gw)
207{ 210{
208 struct hashtable_t *hash; 211 struct hashtable_t *hash;
209 struct hlist_node *node, *node_tmp; 212 struct hlist_node *node, *node_tmp;
@@ -227,7 +230,7 @@ static void bla_del_backbone_claims(struct backbone_gw *backbone_gw)
227 if (claim->backbone_gw != backbone_gw) 230 if (claim->backbone_gw != backbone_gw)
228 continue; 231 continue;
229 232
230 claim_free_ref(claim); 233 batadv_claim_free_ref(claim);
231 hlist_del_rcu(node); 234 hlist_del_rcu(node);
232 } 235 }
233 spin_unlock_bh(list_lock); 236 spin_unlock_bh(list_lock);
@@ -244,8 +247,8 @@ static void bla_del_backbone_claims(struct backbone_gw *backbone_gw)
244 * 247 *
245 * sends a claim frame according to the provided info. 248 * sends a claim frame according to the provided info.
246 */ 249 */
247static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, 250static void batadv_bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
248 short vid, int claimtype) 251 short vid, int claimtype)
249{ 252{
250 struct sk_buff *skb; 253 struct sk_buff *skb;
251 struct ethhdr *ethhdr; 254 struct ethhdr *ethhdr;
@@ -255,7 +258,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
255 struct bla_claim_dst local_claim_dest; 258 struct bla_claim_dst local_claim_dest;
256 __be32 zeroip = 0; 259 __be32 zeroip = 0;
257 260
258 primary_if = primary_if_get_selected(bat_priv); 261 primary_if = batadv_primary_if_get_selected(bat_priv);
259 if (!primary_if) 262 if (!primary_if)
260 return; 263 return;
261 264
@@ -294,25 +297,26 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
294 * set Ethernet SRC to the clients mac 297 * set Ethernet SRC to the clients mac
295 */ 298 */
296 memcpy(ethhdr->h_source, mac, ETH_ALEN); 299 memcpy(ethhdr->h_source, mac, ETH_ALEN);
297 bat_dbg(DBG_BLA, bat_priv, 300 batadv_dbg(DBG_BLA, bat_priv,
298 "bla_send_claim(): CLAIM %pM on vid %d\n", mac, vid); 301 "bla_send_claim(): CLAIM %pM on vid %d\n", mac, vid);
299 break; 302 break;
300 case CLAIM_TYPE_DEL: 303 case CLAIM_TYPE_DEL:
301 /* unclaim frame 304 /* unclaim frame
302 * set HW SRC to the clients mac 305 * set HW SRC to the clients mac
303 */ 306 */
304 memcpy(hw_src, mac, ETH_ALEN); 307 memcpy(hw_src, mac, ETH_ALEN);
305 bat_dbg(DBG_BLA, bat_priv, 308 batadv_dbg(DBG_BLA, bat_priv,
306 "bla_send_claim(): UNCLAIM %pM on vid %d\n", mac, vid); 309 "bla_send_claim(): UNCLAIM %pM on vid %d\n", mac,
310 vid);
307 break; 311 break;
308 case CLAIM_TYPE_ANNOUNCE: 312 case CLAIM_TYPE_ANNOUNCE:
309 /* announcement frame 313 /* announcement frame
310 * set HW SRC to the special mac containg the crc 314 * set HW SRC to the special mac containg the crc
311 */ 315 */
312 memcpy(hw_src, mac, ETH_ALEN); 316 memcpy(hw_src, mac, ETH_ALEN);
313 bat_dbg(DBG_BLA, bat_priv, 317 batadv_dbg(DBG_BLA, bat_priv,
314 "bla_send_claim(): ANNOUNCE of %pM on vid %d\n", 318 "bla_send_claim(): ANNOUNCE of %pM on vid %d\n",
315 ethhdr->h_source, vid); 319 ethhdr->h_source, vid);
316 break; 320 break;
317 case CLAIM_TYPE_REQUEST: 321 case CLAIM_TYPE_REQUEST:
318 /* request frame 322 /* request frame
@@ -320,9 +324,9 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
320 */ 324 */
321 memcpy(hw_src, mac, ETH_ALEN); 325 memcpy(hw_src, mac, ETH_ALEN);
322 memcpy(ethhdr->h_dest, mac, ETH_ALEN); 326 memcpy(ethhdr->h_dest, mac, ETH_ALEN);
323 bat_dbg(DBG_BLA, bat_priv, 327 batadv_dbg(DBG_BLA, bat_priv,
324 "bla_send_claim(): REQUEST of %pM to %pMon vid %d\n", 328 "bla_send_claim(): REQUEST of %pM to %pMon vid %d\n",
325 ethhdr->h_source, ethhdr->h_dest, vid); 329 ethhdr->h_source, ethhdr->h_dest, vid);
326 break; 330 break;
327 331
328 } 332 }
@@ -339,7 +343,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
339 netif_rx(skb); 343 netif_rx(skb);
340out: 344out:
341 if (primary_if) 345 if (primary_if)
342 hardif_free_ref(primary_if); 346 batadv_hardif_free_ref(primary_if);
343} 347}
344 348
345/* @bat_priv: the bat priv with all the soft interface information 349/* @bat_priv: the bat priv with all the soft interface information
@@ -349,21 +353,21 @@ out:
349 * searches for the backbone gw or creates a new one if it could not 353 * searches for the backbone gw or creates a new one if it could not
350 * be found. 354 * be found.
351 */ 355 */
352static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv, 356static struct backbone_gw *batadv_bla_get_backbone_gw(struct bat_priv *bat_priv,
353 uint8_t *orig, short vid) 357 uint8_t *orig, short vid)
354{ 358{
355 struct backbone_gw *entry; 359 struct backbone_gw *entry;
356 struct orig_node *orig_node; 360 struct orig_node *orig_node;
357 int hash_added; 361 int hash_added;
358 362
359 entry = backbone_hash_find(bat_priv, orig, vid); 363 entry = batadv_backbone_hash_find(bat_priv, orig, vid);
360 364
361 if (entry) 365 if (entry)
362 return entry; 366 return entry;
363 367
364 bat_dbg(DBG_BLA, bat_priv, 368 batadv_dbg(DBG_BLA, bat_priv,
365 "bla_get_backbone_gw(): not found (%pM, %d), creating new entry\n", 369 "bla_get_backbone_gw(): not found (%pM, %d), creating new entry\n",
366 orig, vid); 370 orig, vid);
367 371
368 entry = kzalloc(sizeof(*entry), GFP_ATOMIC); 372 entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
369 if (!entry) 373 if (!entry)
@@ -379,8 +383,10 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv,
379 /* one for the hash, one for returning */ 383 /* one for the hash, one for returning */
380 atomic_set(&entry->refcount, 2); 384 atomic_set(&entry->refcount, 2);
381 385
382 hash_added = hash_add(bat_priv->backbone_hash, compare_backbone_gw, 386 hash_added = batadv_hash_add(bat_priv->backbone_hash,
383 choose_backbone_gw, entry, &entry->hash_entry); 387 batadv_compare_backbone_gw,
388 batadv_choose_backbone_gw, entry,
389 &entry->hash_entry);
384 390
385 if (unlikely(hash_added != 0)) { 391 if (unlikely(hash_added != 0)) {
386 /* hash failed, free the structure */ 392 /* hash failed, free the structure */
@@ -389,7 +395,7 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv,
389 } 395 }
390 396
391 /* this is a gateway now, remove any tt entries */ 397 /* this is a gateway now, remove any tt entries */
392 orig_node = orig_hash_find(bat_priv, orig); 398 orig_node = batadv_orig_hash_find(bat_priv, orig);
393 if (orig_node) { 399 if (orig_node) {
394 batadv_tt_global_del_orig(bat_priv, orig_node, 400 batadv_tt_global_del_orig(bat_priv, orig_node,
395 "became a backbone gateway"); 401 "became a backbone gateway");
@@ -401,19 +407,20 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv,
401/* update or add the own backbone gw to make sure we announce 407/* update or add the own backbone gw to make sure we announce
402 * where we receive other backbone gws 408 * where we receive other backbone gws
403 */ 409 */
404static void bla_update_own_backbone_gw(struct bat_priv *bat_priv, 410static void batadv_bla_update_own_backbone_gw(struct bat_priv *bat_priv,
405 struct hard_iface *primary_if, 411 struct hard_iface *primary_if,
406 short vid) 412 short vid)
407{ 413{
408 struct backbone_gw *backbone_gw; 414 struct backbone_gw *backbone_gw;
409 415
410 backbone_gw = bla_get_backbone_gw(bat_priv, 416 backbone_gw = batadv_bla_get_backbone_gw(bat_priv,
411 primary_if->net_dev->dev_addr, vid); 417 primary_if->net_dev->dev_addr,
418 vid);
412 if (unlikely(!backbone_gw)) 419 if (unlikely(!backbone_gw))
413 return; 420 return;
414 421
415 backbone_gw->lasttime = jiffies; 422 backbone_gw->lasttime = jiffies;
416 backbone_gw_free_ref(backbone_gw); 423 batadv_backbone_gw_free_ref(backbone_gw);
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
@@ -422,8 +429,8 @@ static void bla_update_own_backbone_gw(struct bat_priv *bat_priv,
422 * Repeat all of our own claims, and finally send an ANNOUNCE frame 429 * Repeat all of our own claims, and finally send an ANNOUNCE frame
423 * to allow the requester another check if the CRC is correct now. 430 * to allow the requester another check if the CRC is correct now.
424 */ 431 */
425static void bla_answer_request(struct bat_priv *bat_priv, 432static void batadv_bla_answer_request(struct bat_priv *bat_priv,
426 struct hard_iface *primary_if, short vid) 433 struct hard_iface *primary_if, short vid)
427{ 434{
428 struct hlist_node *node; 435 struct hlist_node *node;
429 struct hlist_head *head; 436 struct hlist_head *head;
@@ -432,11 +439,12 @@ static void bla_answer_request(struct bat_priv *bat_priv,
432 struct backbone_gw *backbone_gw; 439 struct backbone_gw *backbone_gw;
433 int i; 440 int i;
434 441
435 bat_dbg(DBG_BLA, bat_priv, 442 batadv_dbg(DBG_BLA, bat_priv,
436 "bla_answer_request(): received a claim request, send all of our own claims again\n"); 443 "bla_answer_request(): received a claim request, send all of our own claims again\n");
437 444
438 backbone_gw = backbone_hash_find(bat_priv, 445 backbone_gw = batadv_backbone_hash_find(bat_priv,
439 primary_if->net_dev->dev_addr, vid); 446 primary_if->net_dev->dev_addr,
447 vid);
440 if (!backbone_gw) 448 if (!backbone_gw)
441 return; 449 return;
442 450
@@ -450,15 +458,15 @@ static void bla_answer_request(struct bat_priv *bat_priv,
450 if (claim->backbone_gw != backbone_gw) 458 if (claim->backbone_gw != backbone_gw)
451 continue; 459 continue;
452 460
453 bla_send_claim(bat_priv, claim->addr, claim->vid, 461 batadv_bla_send_claim(bat_priv, claim->addr, claim->vid,
454 CLAIM_TYPE_ADD); 462 CLAIM_TYPE_ADD);
455 } 463 }
456 rcu_read_unlock(); 464 rcu_read_unlock();
457 } 465 }
458 466
459 /* finally, send an announcement frame */ 467 /* finally, send an announcement frame */
460 bla_send_announce(bat_priv, backbone_gw); 468 batadv_bla_send_announce(bat_priv, backbone_gw);
461 backbone_gw_free_ref(backbone_gw); 469 batadv_backbone_gw_free_ref(backbone_gw);
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
@@ -467,18 +475,17 @@ static void bla_answer_request(struct bat_priv *bat_priv,
467 * After the request, it will repeat all of his own claims and finally 475 * After the request, it will repeat all of his own claims and finally
468 * send an announcement claim with which we can check again. 476 * send an announcement claim with which we can check again.
469 */ 477 */
470static void bla_send_request(struct backbone_gw *backbone_gw) 478static void batadv_bla_send_request(struct backbone_gw *backbone_gw)
471{ 479{
472 /* first, remove all old entries */ 480 /* first, remove all old entries */
473 bla_del_backbone_claims(backbone_gw); 481 batadv_bla_del_backbone_claims(backbone_gw);
474 482
475 bat_dbg(DBG_BLA, backbone_gw->bat_priv, 483 batadv_dbg(DBG_BLA, backbone_gw->bat_priv, "Sending REQUEST to %pM\n",
476 "Sending REQUEST to %pM\n", 484 backbone_gw->orig);
477 backbone_gw->orig);
478 485
479 /* send request */ 486 /* send request */
480 bla_send_claim(backbone_gw->bat_priv, backbone_gw->orig, 487 batadv_bla_send_claim(backbone_gw->bat_priv, backbone_gw->orig,
481 backbone_gw->vid, CLAIM_TYPE_REQUEST); 488 backbone_gw->vid, CLAIM_TYPE_REQUEST);
482 489
483 /* no local broadcasts should be sent or received, for now. */ 490 /* no local broadcasts should be sent or received, for now. */
484 if (!atomic_read(&backbone_gw->request_sent)) { 491 if (!atomic_read(&backbone_gw->request_sent)) {
@@ -493,17 +500,18 @@ static void bla_send_request(struct backbone_gw *backbone_gw)
493 * This function sends an announcement. It is called from multiple 500 * This function sends an announcement. It is called from multiple
494 * places. 501 * places.
495 */ 502 */
496static void bla_send_announce(struct bat_priv *bat_priv, 503static void batadv_bla_send_announce(struct bat_priv *bat_priv,
497 struct backbone_gw *backbone_gw) 504 struct backbone_gw *backbone_gw)
498{ 505{
499 uint8_t mac[ETH_ALEN]; 506 uint8_t mac[ETH_ALEN];
500 __be16 crc; 507 __be16 crc;
501 508
502 memcpy(mac, announce_mac, 4); 509 memcpy(mac, batadv_announce_mac, 4);
503 crc = htons(backbone_gw->crc); 510 crc = htons(backbone_gw->crc);
504 memcpy(&mac[4], &crc, 2); 511 memcpy(&mac[4], &crc, 2);
505 512
506 bla_send_claim(bat_priv, mac, backbone_gw->vid, CLAIM_TYPE_ANNOUNCE); 513 batadv_bla_send_claim(bat_priv, mac, backbone_gw->vid,
514 CLAIM_TYPE_ANNOUNCE);
507 515
508} 516}
509 517
@@ -514,8 +522,9 @@ static void bla_send_announce(struct bat_priv *bat_priv,
514 * 522 *
515 * Adds a claim in the claim hash. 523 * Adds a claim in the claim hash.
516 */ 524 */
517static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac, 525static void batadv_bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
518 const short vid, struct backbone_gw *backbone_gw) 526 const short vid,
527 struct backbone_gw *backbone_gw)
519{ 528{
520 struct claim *claim; 529 struct claim *claim;
521 struct claim search_claim; 530 struct claim search_claim;
@@ -523,7 +532,7 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
523 532
524 memcpy(search_claim.addr, mac, ETH_ALEN); 533 memcpy(search_claim.addr, mac, ETH_ALEN);
525 search_claim.vid = vid; 534 search_claim.vid = vid;
526 claim = claim_hash_find(bat_priv, &search_claim); 535 claim = batadv_claim_hash_find(bat_priv, &search_claim);
527 536
528 /* create a new claim entry if it does not exist yet. */ 537 /* create a new claim entry if it does not exist yet. */
529 if (!claim) { 538 if (!claim) {
@@ -537,11 +546,13 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
537 claim->backbone_gw = backbone_gw; 546 claim->backbone_gw = backbone_gw;
538 547
539 atomic_set(&claim->refcount, 2); 548 atomic_set(&claim->refcount, 2);
540 bat_dbg(DBG_BLA, bat_priv, 549 batadv_dbg(DBG_BLA, bat_priv,
541 "bla_add_claim(): adding new entry %pM, vid %d to hash ...\n", 550 "bla_add_claim(): adding new entry %pM, vid %d to hash ...\n",
542 mac, vid); 551 mac, vid);
543 hash_added = hash_add(bat_priv->claim_hash, compare_claim, 552 hash_added = batadv_hash_add(bat_priv->claim_hash,
544 choose_claim, claim, &claim->hash_entry); 553 batadv_compare_claim,
554 batadv_choose_claim, claim,
555 &claim->hash_entry);
545 556
546 if (unlikely(hash_added != 0)) { 557 if (unlikely(hash_added != 0)) {
547 /* only local changes happened. */ 558 /* only local changes happened. */
@@ -554,13 +565,13 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
554 /* no need to register a new backbone */ 565 /* no need to register a new backbone */
555 goto claim_free_ref; 566 goto claim_free_ref;
556 567
557 bat_dbg(DBG_BLA, bat_priv, 568 batadv_dbg(DBG_BLA, bat_priv,
558 "bla_add_claim(): changing ownership for %pM, vid %d\n", 569 "bla_add_claim(): changing ownership for %pM, vid %d\n",
559 mac, vid); 570 mac, vid);
560 571
561 claim->backbone_gw->crc ^= 572 claim->backbone_gw->crc ^=
562 crc16(0, claim->addr, ETH_ALEN); 573 crc16(0, claim->addr, ETH_ALEN);
563 backbone_gw_free_ref(claim->backbone_gw); 574 batadv_backbone_gw_free_ref(claim->backbone_gw);
564 575
565 } 576 }
566 /* set (new) backbone gw */ 577 /* set (new) backbone gw */
@@ -571,45 +582,48 @@ static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac,
571 backbone_gw->lasttime = jiffies; 582 backbone_gw->lasttime = jiffies;
572 583
573claim_free_ref: 584claim_free_ref:
574 claim_free_ref(claim); 585 batadv_claim_free_ref(claim);
575} 586}
576 587
577/* Delete a claim from the claim hash which has the 588/* Delete a claim from the claim hash which has the
578 * given mac address and vid. 589 * given mac address and vid.
579 */ 590 */
580static void bla_del_claim(struct bat_priv *bat_priv, const uint8_t *mac, 591static void batadv_bla_del_claim(struct bat_priv *bat_priv, const uint8_t *mac,
581 const short vid) 592 const short vid)
582{ 593{
583 struct claim search_claim, *claim; 594 struct claim search_claim, *claim;
584 595
585 memcpy(search_claim.addr, mac, ETH_ALEN); 596 memcpy(search_claim.addr, mac, ETH_ALEN);
586 search_claim.vid = vid; 597 search_claim.vid = vid;
587 claim = claim_hash_find(bat_priv, &search_claim); 598 claim = batadv_claim_hash_find(bat_priv, &search_claim);
588 if (!claim) 599 if (!claim)
589 return; 600 return;
590 601
591 bat_dbg(DBG_BLA, bat_priv, "bla_del_claim(): %pM, vid %d\n", mac, vid); 602 batadv_dbg(DBG_BLA, bat_priv, "bla_del_claim(): %pM, vid %d\n", mac,
603 vid);
592 604
593 hash_remove(bat_priv->claim_hash, compare_claim, choose_claim, claim); 605 batadv_hash_remove(bat_priv->claim_hash, batadv_compare_claim,
594 claim_free_ref(claim); /* reference from the hash is gone */ 606 batadv_choose_claim, claim);
607 batadv_claim_free_ref(claim); /* reference from the hash is gone */
595 608
596 claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN); 609 claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
597 610
598 /* don't need the reference from hash_find() anymore */ 611 /* don't need the reference from hash_find() anymore */
599 claim_free_ref(claim); 612 batadv_claim_free_ref(claim);
600} 613}
601 614
602/* check for ANNOUNCE frame, return 1 if handled */ 615/* check for ANNOUNCE frame, return 1 if handled */
603static int handle_announce(struct bat_priv *bat_priv, 616static int batadv_handle_announce(struct bat_priv *bat_priv,
604 uint8_t *an_addr, uint8_t *backbone_addr, short vid) 617 uint8_t *an_addr, uint8_t *backbone_addr,
618 short vid)
605{ 619{
606 struct backbone_gw *backbone_gw; 620 struct backbone_gw *backbone_gw;
607 uint16_t crc; 621 uint16_t crc;
608 622
609 if (memcmp(an_addr, announce_mac, 4) != 0) 623 if (memcmp(an_addr, batadv_announce_mac, 4) != 0)
610 return 0; 624 return 0;
611 625
612 backbone_gw = bla_get_backbone_gw(bat_priv, backbone_addr, vid); 626 backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid);
613 627
614 if (unlikely(!backbone_gw)) 628 if (unlikely(!backbone_gw))
615 return 1; 629 return 1;
@@ -619,17 +633,17 @@ static int handle_announce(struct bat_priv *bat_priv,
619 backbone_gw->lasttime = jiffies; 633 backbone_gw->lasttime = jiffies;
620 crc = ntohs(*((__be16 *)(&an_addr[4]))); 634 crc = ntohs(*((__be16 *)(&an_addr[4])));
621 635
622 bat_dbg(DBG_BLA, bat_priv, 636 batadv_dbg(DBG_BLA, bat_priv,
623 "handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = %04x\n", 637 "handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = %04x\n",
624 vid, backbone_gw->orig, crc); 638 vid, backbone_gw->orig, crc);
625 639
626 if (backbone_gw->crc != crc) { 640 if (backbone_gw->crc != crc) {
627 bat_dbg(DBG_BLA, backbone_gw->bat_priv, 641 batadv_dbg(DBG_BLA, backbone_gw->bat_priv,
628 "handle_announce(): CRC FAILED for %pM/%d (my = %04x, sent = %04x)\n", 642 "handle_announce(): CRC FAILED for %pM/%d (my = %04x, sent = %04x)\n",
629 backbone_gw->orig, backbone_gw->vid, backbone_gw->crc, 643 backbone_gw->orig, backbone_gw->vid,
630 crc); 644 backbone_gw->crc, crc);
631 645
632 bla_send_request(backbone_gw); 646 batadv_bla_send_request(backbone_gw);
633 } else { 647 } else {
634 /* if we have sent a request and the crc was OK, 648 /* if we have sent a request and the crc was OK,
635 * we can allow traffic again. 649 * we can allow traffic again.
@@ -640,84 +654,87 @@ static int handle_announce(struct bat_priv *bat_priv,
640 } 654 }
641 } 655 }
642 656
643 backbone_gw_free_ref(backbone_gw); 657 batadv_backbone_gw_free_ref(backbone_gw);
644 return 1; 658 return 1;
645} 659}
646 660
647/* check for REQUEST frame, return 1 if handled */ 661/* check for REQUEST frame, return 1 if handled */
648static int handle_request(struct bat_priv *bat_priv, 662static int batadv_handle_request(struct bat_priv *bat_priv,
649 struct hard_iface *primary_if, 663 struct hard_iface *primary_if,
650 uint8_t *backbone_addr, 664 uint8_t *backbone_addr,
651 struct ethhdr *ethhdr, short vid) 665 struct ethhdr *ethhdr, short vid)
652{ 666{
653 /* check for REQUEST frame */ 667 /* check for REQUEST frame */
654 if (!compare_eth(backbone_addr, ethhdr->h_dest)) 668 if (!batadv_compare_eth(backbone_addr, ethhdr->h_dest))
655 return 0; 669 return 0;
656 670
657 /* sanity check, this should not happen on a normal switch, 671 /* sanity check, this should not happen on a normal switch,
658 * we ignore it in this case. 672 * we ignore it in this case.
659 */ 673 */
660 if (!compare_eth(ethhdr->h_dest, primary_if->net_dev->dev_addr)) 674 if (!batadv_compare_eth(ethhdr->h_dest, primary_if->net_dev->dev_addr))
661 return 1; 675 return 1;
662 676
663 bat_dbg(DBG_BLA, bat_priv, 677 batadv_dbg(DBG_BLA, bat_priv,
664 "handle_request(): REQUEST vid %d (sent by %pM)...\n", 678 "handle_request(): REQUEST vid %d (sent by %pM)...\n",
665 vid, ethhdr->h_source); 679 vid, ethhdr->h_source);
666 680
667 bla_answer_request(bat_priv, primary_if, vid); 681 batadv_bla_answer_request(bat_priv, primary_if, vid);
668 return 1; 682 return 1;
669} 683}
670 684
671/* check for UNCLAIM frame, return 1 if handled */ 685/* check for UNCLAIM frame, return 1 if handled */
672static int handle_unclaim(struct bat_priv *bat_priv, 686static int batadv_handle_unclaim(struct bat_priv *bat_priv,
673 struct hard_iface *primary_if, 687 struct hard_iface *primary_if,
674 uint8_t *backbone_addr, 688 uint8_t *backbone_addr,
675 uint8_t *claim_addr, short vid) 689 uint8_t *claim_addr, short vid)
676{ 690{
677 struct backbone_gw *backbone_gw; 691 struct backbone_gw *backbone_gw;
678 692
679 /* unclaim in any case if it is our own */ 693 /* unclaim in any case if it is our own */
680 if (primary_if && compare_eth(backbone_addr, 694 if (primary_if && batadv_compare_eth(backbone_addr,
681 primary_if->net_dev->dev_addr)) 695 primary_if->net_dev->dev_addr))
682 bla_send_claim(bat_priv, claim_addr, vid, CLAIM_TYPE_DEL); 696 batadv_bla_send_claim(bat_priv, claim_addr, vid,
697 CLAIM_TYPE_DEL);
683 698
684 backbone_gw = backbone_hash_find(bat_priv, backbone_addr, vid); 699 backbone_gw = batadv_backbone_hash_find(bat_priv, backbone_addr, vid);
685 700
686 if (!backbone_gw) 701 if (!backbone_gw)
687 return 1; 702 return 1;
688 703
689 /* this must be an UNCLAIM frame */ 704 /* this must be an UNCLAIM frame */
690 bat_dbg(DBG_BLA, bat_priv, 705 batadv_dbg(DBG_BLA, bat_priv,
691 "handle_unclaim(): UNCLAIM %pM on vid %d (sent by %pM)...\n", 706 "handle_unclaim(): UNCLAIM %pM on vid %d (sent by %pM)...\n",
692 claim_addr, vid, backbone_gw->orig); 707 claim_addr, vid, backbone_gw->orig);
693 708
694 bla_del_claim(bat_priv, claim_addr, vid); 709 batadv_bla_del_claim(bat_priv, claim_addr, vid);
695 backbone_gw_free_ref(backbone_gw); 710 batadv_backbone_gw_free_ref(backbone_gw);
696 return 1; 711 return 1;
697} 712}
698 713
699/* check for CLAIM frame, return 1 if handled */ 714/* check for CLAIM frame, return 1 if handled */
700static int handle_claim(struct bat_priv *bat_priv, 715static int batadv_handle_claim(struct bat_priv *bat_priv,
701 struct hard_iface *primary_if, uint8_t *backbone_addr, 716 struct hard_iface *primary_if,
702 uint8_t *claim_addr, short vid) 717 uint8_t *backbone_addr, uint8_t *claim_addr,
718 short vid)
703{ 719{
704 struct backbone_gw *backbone_gw; 720 struct backbone_gw *backbone_gw;
705 721
706 /* register the gateway if not yet available, and add the claim. */ 722 /* register the gateway if not yet available, and add the claim. */
707 723
708 backbone_gw = bla_get_backbone_gw(bat_priv, backbone_addr, vid); 724 backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid);
709 725
710 if (unlikely(!backbone_gw)) 726 if (unlikely(!backbone_gw))
711 return 1; 727 return 1;
712 728
713 /* this must be a CLAIM frame */ 729 /* this must be a CLAIM frame */
714 bla_add_claim(bat_priv, claim_addr, vid, backbone_gw); 730 batadv_bla_add_claim(bat_priv, claim_addr, vid, backbone_gw);
715 if (compare_eth(backbone_addr, primary_if->net_dev->dev_addr)) 731 if (batadv_compare_eth(backbone_addr, primary_if->net_dev->dev_addr))
716 bla_send_claim(bat_priv, claim_addr, vid, CLAIM_TYPE_ADD); 732 batadv_bla_send_claim(bat_priv, claim_addr, vid,
733 CLAIM_TYPE_ADD);
717 734
718 /* TODO: we could call something like tt_local_del() here. */ 735 /* TODO: we could call something like tt_local_del() here. */
719 736
720 backbone_gw_free_ref(backbone_gw); 737 batadv_backbone_gw_free_ref(backbone_gw);
721 return 1; 738 return 1;
722} 739}
723 740
@@ -735,10 +752,10 @@ static int handle_claim(struct bat_priv *bat_priv,
735 * 1 - if is a claim packet from another group 752 * 1 - if is a claim packet from another group
736 * 0 - if it is not a claim packet 753 * 0 - if it is not a claim packet
737 */ 754 */
738static int check_claim_group(struct bat_priv *bat_priv, 755static int batadv_check_claim_group(struct bat_priv *bat_priv,
739 struct hard_iface *primary_if, 756 struct hard_iface *primary_if,
740 uint8_t *hw_src, uint8_t *hw_dst, 757 uint8_t *hw_src, uint8_t *hw_dst,
741 struct ethhdr *ethhdr) 758 struct ethhdr *ethhdr)
742{ 759{
743 uint8_t *backbone_addr; 760 uint8_t *backbone_addr;
744 struct orig_node *orig_node; 761 struct orig_node *orig_node;
@@ -769,7 +786,7 @@ static int check_claim_group(struct bat_priv *bat_priv,
769 } 786 }
770 787
771 /* don't accept claim frames from ourselves */ 788 /* don't accept claim frames from ourselves */
772 if (compare_eth(backbone_addr, primary_if->net_dev->dev_addr)) 789 if (batadv_compare_eth(backbone_addr, primary_if->net_dev->dev_addr))
773 return 0; 790 return 0;
774 791
775 /* if its already the same group, it is fine. */ 792 /* if its already the same group, it is fine. */
@@ -777,7 +794,7 @@ static int check_claim_group(struct bat_priv *bat_priv,
777 return 2; 794 return 2;
778 795
779 /* lets see if this originator is in our mesh */ 796 /* lets see if this originator is in our mesh */
780 orig_node = orig_hash_find(bat_priv, backbone_addr); 797 orig_node = batadv_orig_hash_find(bat_priv, backbone_addr);
781 798
782 /* dont accept claims from gateways which are not in 799 /* dont accept claims from gateways which are not in
783 * the same mesh or group. 800 * the same mesh or group.
@@ -787,9 +804,9 @@ static int check_claim_group(struct bat_priv *bat_priv,
787 804
788 /* if our mesh friends mac is bigger, use it for ourselves. */ 805 /* if our mesh friends mac is bigger, use it for ourselves. */
789 if (ntohs(bla_dst->group) > ntohs(bla_dst_own->group)) { 806 if (ntohs(bla_dst->group) > ntohs(bla_dst_own->group)) {
790 bat_dbg(DBG_BLA, bat_priv, 807 batadv_dbg(DBG_BLA, bat_priv,
791 "taking other backbones claim group: %04x\n", 808 "taking other backbones claim group: %04x\n",
792 ntohs(bla_dst->group)); 809 ntohs(bla_dst->group));
793 bla_dst_own->group = bla_dst->group; 810 bla_dst_own->group = bla_dst->group;
794 } 811 }
795 812
@@ -807,9 +824,9 @@ static int check_claim_group(struct bat_priv *bat_priv,
807 * returns 1 if it was a claim frame, otherwise return 0 to 824 * returns 1 if it was a claim frame, otherwise return 0 to
808 * tell the callee that it can use the frame on its own. 825 * tell the callee that it can use the frame on its own.
809 */ 826 */
810static int bla_process_claim(struct bat_priv *bat_priv, 827static int batadv_bla_process_claim(struct bat_priv *bat_priv,
811 struct hard_iface *primary_if, 828 struct hard_iface *primary_if,
812 struct sk_buff *skb) 829 struct sk_buff *skb)
813{ 830{
814 struct ethhdr *ethhdr; 831 struct ethhdr *ethhdr;
815 struct vlan_ethhdr *vhdr; 832 struct vlan_ethhdr *vhdr;
@@ -862,51 +879,54 @@ static int bla_process_claim(struct bat_priv *bat_priv,
862 bla_dst = (struct bla_claim_dst *)hw_dst; 879 bla_dst = (struct bla_claim_dst *)hw_dst;
863 880
864 /* check if it is a claim frame. */ 881 /* check if it is a claim frame. */
865 ret = check_claim_group(bat_priv, primary_if, hw_src, hw_dst, ethhdr); 882 ret = batadv_check_claim_group(bat_priv, primary_if, hw_src, hw_dst,
883 ethhdr);
866 if (ret == 1) 884 if (ret == 1)
867 bat_dbg(DBG_BLA, bat_priv, 885 batadv_dbg(DBG_BLA, bat_priv,
868 "bla_process_claim(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n", 886 "bla_process_claim(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
869 ethhdr->h_source, vid, hw_src, hw_dst); 887 ethhdr->h_source, vid, hw_src, hw_dst);
870 888
871 if (ret < 2) 889 if (ret < 2)
872 return ret; 890 return ret;
873 891
874 /* become a backbone gw ourselves on this vlan if not happened yet */ 892 /* become a backbone gw ourselves on this vlan if not happened yet */
875 bla_update_own_backbone_gw(bat_priv, primary_if, vid); 893 batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
876 894
877 /* check for the different types of claim frames ... */ 895 /* check for the different types of claim frames ... */
878 switch (bla_dst->type) { 896 switch (bla_dst->type) {
879 case CLAIM_TYPE_ADD: 897 case CLAIM_TYPE_ADD:
880 if (handle_claim(bat_priv, primary_if, hw_src, 898 if (batadv_handle_claim(bat_priv, primary_if, hw_src,
881 ethhdr->h_source, vid)) 899 ethhdr->h_source, vid))
882 return 1; 900 return 1;
883 break; 901 break;
884 case CLAIM_TYPE_DEL: 902 case CLAIM_TYPE_DEL:
885 if (handle_unclaim(bat_priv, primary_if, 903 if (batadv_handle_unclaim(bat_priv, primary_if,
886 ethhdr->h_source, hw_src, vid)) 904 ethhdr->h_source, hw_src, vid))
887 return 1; 905 return 1;
888 break; 906 break;
889 907
890 case CLAIM_TYPE_ANNOUNCE: 908 case CLAIM_TYPE_ANNOUNCE:
891 if (handle_announce(bat_priv, hw_src, ethhdr->h_source, vid)) 909 if (batadv_handle_announce(bat_priv, hw_src, ethhdr->h_source,
910 vid))
892 return 1; 911 return 1;
893 break; 912 break;
894 case CLAIM_TYPE_REQUEST: 913 case CLAIM_TYPE_REQUEST:
895 if (handle_request(bat_priv, primary_if, hw_src, ethhdr, vid)) 914 if (batadv_handle_request(bat_priv, primary_if, hw_src, ethhdr,
915 vid))
896 return 1; 916 return 1;
897 break; 917 break;
898 } 918 }
899 919
900 bat_dbg(DBG_BLA, bat_priv, 920 batadv_dbg(DBG_BLA, bat_priv,
901 "bla_process_claim(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n", 921 "bla_process_claim(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
902 ethhdr->h_source, vid, hw_src, hw_dst); 922 ethhdr->h_source, vid, hw_src, hw_dst);
903 return 1; 923 return 1;
904} 924}
905 925
906/* Check when we last heard from other nodes, and remove them in case of 926/* Check when we last heard from other nodes, and remove them in case of
907 * a time out, or clean all backbone gws if now is set. 927 * a time out, or clean all backbone gws if now is set.
908 */ 928 */
909static void bla_purge_backbone_gw(struct bat_priv *bat_priv, int now) 929static void batadv_bla_purge_backbone_gw(struct bat_priv *bat_priv, int now)
910{ 930{
911 struct backbone_gw *backbone_gw; 931 struct backbone_gw *backbone_gw;
912 struct hlist_node *node, *node_tmp; 932 struct hlist_node *node, *node_tmp;
@@ -928,23 +948,23 @@ static void bla_purge_backbone_gw(struct bat_priv *bat_priv, int now)
928 head, hash_entry) { 948 head, hash_entry) {
929 if (now) 949 if (now)
930 goto purge_now; 950 goto purge_now;
931 if (!has_timed_out(backbone_gw->lasttime, 951 if (!batadv_has_timed_out(backbone_gw->lasttime,
932 BLA_BACKBONE_TIMEOUT)) 952 BLA_BACKBONE_TIMEOUT))
933 continue; 953 continue;
934 954
935 bat_dbg(DBG_BLA, backbone_gw->bat_priv, 955 batadv_dbg(DBG_BLA, backbone_gw->bat_priv,
936 "bla_purge_backbone_gw(): backbone gw %pM timed out\n", 956 "bla_purge_backbone_gw(): backbone gw %pM timed out\n",
937 backbone_gw->orig); 957 backbone_gw->orig);
938 958
939purge_now: 959purge_now:
940 /* don't wait for the pending request anymore */ 960 /* don't wait for the pending request anymore */
941 if (atomic_read(&backbone_gw->request_sent)) 961 if (atomic_read(&backbone_gw->request_sent))
942 atomic_dec(&bat_priv->bla_num_requests); 962 atomic_dec(&bat_priv->bla_num_requests);
943 963
944 bla_del_backbone_claims(backbone_gw); 964 batadv_bla_del_backbone_claims(backbone_gw);
945 965
946 hlist_del_rcu(node); 966 hlist_del_rcu(node);
947 backbone_gw_free_ref(backbone_gw); 967 batadv_backbone_gw_free_ref(backbone_gw);
948 } 968 }
949 spin_unlock_bh(list_lock); 969 spin_unlock_bh(list_lock);
950 } 970 }
@@ -957,8 +977,8 @@ purge_now:
957 * Check when we heard last time from our own claims, and remove them in case of 977 * Check when we heard last time from our own claims, and remove them in case of
958 * a time out, or clean all claims if now is set 978 * a time out, or clean all claims if now is set
959 */ 979 */
960static void bla_purge_claims(struct bat_priv *bat_priv, 980static void batadv_bla_purge_claims(struct bat_priv *bat_priv,
961 struct hard_iface *primary_if, int now) 981 struct hard_iface *primary_if, int now)
962{ 982{
963 struct claim *claim; 983 struct claim *claim;
964 struct hlist_node *node; 984 struct hlist_node *node;
@@ -977,21 +997,21 @@ static void bla_purge_claims(struct bat_priv *bat_priv,
977 hlist_for_each_entry_rcu(claim, node, head, hash_entry) { 997 hlist_for_each_entry_rcu(claim, node, head, hash_entry) {
978 if (now) 998 if (now)
979 goto purge_now; 999 goto purge_now;
980 if (!compare_eth(claim->backbone_gw->orig, 1000 if (!batadv_compare_eth(claim->backbone_gw->orig,
981 primary_if->net_dev->dev_addr)) 1001 primary_if->net_dev->dev_addr))
982 continue; 1002 continue;
983 if (!has_timed_out(claim->lasttime, 1003 if (!batadv_has_timed_out(claim->lasttime,
984 BLA_CLAIM_TIMEOUT)) 1004 BLA_CLAIM_TIMEOUT))
985 continue; 1005 continue;
986 1006
987 bat_dbg(DBG_BLA, bat_priv, 1007 batadv_dbg(DBG_BLA, bat_priv,
988 "bla_purge_claims(): %pM, vid %d, time out\n", 1008 "bla_purge_claims(): %pM, vid %d, time out\n",
989 claim->addr, claim->vid); 1009 claim->addr, claim->vid);
990 1010
991purge_now: 1011purge_now:
992 handle_unclaim(bat_priv, primary_if, 1012 batadv_handle_unclaim(bat_priv, primary_if,
993 claim->backbone_gw->orig, 1013 claim->backbone_gw->orig,
994 claim->addr, claim->vid); 1014 claim->addr, claim->vid);
995 } 1015 }
996 rcu_read_unlock(); 1016 rcu_read_unlock();
997 } 1017 }
@@ -1018,8 +1038,8 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
1018 htons(crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN)); 1038 htons(crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN));
1019 1039
1020 if (!oldif) { 1040 if (!oldif) {
1021 bla_purge_claims(bat_priv, NULL, 1); 1041 batadv_bla_purge_claims(bat_priv, NULL, 1);
1022 bla_purge_backbone_gw(bat_priv, 1); 1042 batadv_bla_purge_backbone_gw(bat_priv, 1);
1023 return; 1043 return;
1024 } 1044 }
1025 1045
@@ -1033,8 +1053,8 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
1033 rcu_read_lock(); 1053 rcu_read_lock();
1034 hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { 1054 hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) {
1035 /* own orig still holds the old value. */ 1055 /* own orig still holds the old value. */
1036 if (!compare_eth(backbone_gw->orig, 1056 if (!batadv_compare_eth(backbone_gw->orig,
1037 oldif->net_dev->dev_addr)) 1057 oldif->net_dev->dev_addr))
1038 continue; 1058 continue;
1039 1059
1040 memcpy(backbone_gw->orig, 1060 memcpy(backbone_gw->orig,
@@ -1042,7 +1062,7 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
1042 /* send an announce frame so others will ask for our 1062 /* send an announce frame so others will ask for our
1043 * claims and update their tables. 1063 * claims and update their tables.
1044 */ 1064 */
1045 bla_send_announce(bat_priv, backbone_gw); 1065 batadv_bla_send_announce(bat_priv, backbone_gw);
1046 } 1066 }
1047 rcu_read_unlock(); 1067 rcu_read_unlock();
1048 } 1068 }
@@ -1051,9 +1071,9 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
1051 1071
1052 1072
1053/* (re)start the timer */ 1073/* (re)start the timer */
1054static void bla_start_timer(struct bat_priv *bat_priv) 1074static void batadv_bla_start_timer(struct bat_priv *bat_priv)
1055{ 1075{
1056 INIT_DELAYED_WORK(&bat_priv->bla_work, bla_periodic_work); 1076 INIT_DELAYED_WORK(&bat_priv->bla_work, batadv_bla_periodic_work);
1057 queue_delayed_work(batadv_event_workqueue, &bat_priv->bla_work, 1077 queue_delayed_work(batadv_event_workqueue, &bat_priv->bla_work,
1058 msecs_to_jiffies(BLA_PERIOD_LENGTH)); 1078 msecs_to_jiffies(BLA_PERIOD_LENGTH));
1059} 1079}
@@ -1062,7 +1082,7 @@ static void bla_start_timer(struct bat_priv *bat_priv)
1062 * * purge structures when they are too old 1082 * * purge structures when they are too old
1063 * * send announcements 1083 * * send announcements
1064 */ 1084 */
1065static void bla_periodic_work(struct work_struct *work) 1085static void batadv_bla_periodic_work(struct work_struct *work)
1066{ 1086{
1067 struct delayed_work *delayed_work = 1087 struct delayed_work *delayed_work =
1068 container_of(work, struct delayed_work, work); 1088 container_of(work, struct delayed_work, work);
@@ -1075,12 +1095,12 @@ static void bla_periodic_work(struct work_struct *work)
1075 struct hard_iface *primary_if; 1095 struct hard_iface *primary_if;
1076 int i; 1096 int i;
1077 1097
1078 primary_if = primary_if_get_selected(bat_priv); 1098 primary_if = batadv_primary_if_get_selected(bat_priv);
1079 if (!primary_if) 1099 if (!primary_if)
1080 goto out; 1100 goto out;
1081 1101
1082 bla_purge_claims(bat_priv, primary_if, 0); 1102 batadv_bla_purge_claims(bat_priv, primary_if, 0);
1083 bla_purge_backbone_gw(bat_priv, 0); 1103 batadv_bla_purge_backbone_gw(bat_priv, 0);
1084 1104
1085 if (!atomic_read(&bat_priv->bridge_loop_avoidance)) 1105 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
1086 goto out; 1106 goto out;
@@ -1094,21 +1114,21 @@ static void bla_periodic_work(struct work_struct *work)
1094 1114
1095 rcu_read_lock(); 1115 rcu_read_lock();
1096 hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { 1116 hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) {
1097 if (!compare_eth(backbone_gw->orig, 1117 if (!batadv_compare_eth(backbone_gw->orig,
1098 primary_if->net_dev->dev_addr)) 1118 primary_if->net_dev->dev_addr))
1099 continue; 1119 continue;
1100 1120
1101 backbone_gw->lasttime = jiffies; 1121 backbone_gw->lasttime = jiffies;
1102 1122
1103 bla_send_announce(bat_priv, backbone_gw); 1123 batadv_bla_send_announce(bat_priv, backbone_gw);
1104 } 1124 }
1105 rcu_read_unlock(); 1125 rcu_read_unlock();
1106 } 1126 }
1107out: 1127out:
1108 if (primary_if) 1128 if (primary_if)
1109 hardif_free_ref(primary_if); 1129 batadv_hardif_free_ref(primary_if);
1110 1130
1111 bla_start_timer(bat_priv); 1131 batadv_bla_start_timer(bat_priv);
1112} 1132}
1113 1133
1114/* The hash for claim and backbone hash receive the same key because they 1134/* The hash for claim and backbone hash receive the same key because they
@@ -1116,8 +1136,8 @@ out:
1116 * them with to different keys to allow nested locking without generating 1136 * them with to different keys to allow nested locking without generating
1117 * lockdep warnings 1137 * lockdep warnings
1118 */ 1138 */
1119static struct lock_class_key claim_hash_lock_class_key; 1139static struct lock_class_key batadv_claim_hash_lock_class_key;
1120static struct lock_class_key backbone_hash_lock_class_key; 1140static struct lock_class_key batadv_backbone_hash_lock_class_key;
1121 1141
1122/* initialize all bla structures */ 1142/* initialize all bla structures */
1123int batadv_bla_init(struct bat_priv *bat_priv) 1143int batadv_bla_init(struct bat_priv *bat_priv)
@@ -1126,17 +1146,17 @@ int batadv_bla_init(struct bat_priv *bat_priv)
1126 uint8_t claim_dest[ETH_ALEN] = {0xff, 0x43, 0x05, 0x00, 0x00, 0x00}; 1146 uint8_t claim_dest[ETH_ALEN] = {0xff, 0x43, 0x05, 0x00, 0x00, 0x00};
1127 struct hard_iface *primary_if; 1147 struct hard_iface *primary_if;
1128 1148
1129 bat_dbg(DBG_BLA, bat_priv, "bla hash registering\n"); 1149 batadv_dbg(DBG_BLA, bat_priv, "bla hash registering\n");
1130 1150
1131 /* setting claim destination address */ 1151 /* setting claim destination address */
1132 memcpy(&bat_priv->claim_dest.magic, claim_dest, 3); 1152 memcpy(&bat_priv->claim_dest.magic, claim_dest, 3);
1133 bat_priv->claim_dest.type = 0; 1153 bat_priv->claim_dest.type = 0;
1134 primary_if = primary_if_get_selected(bat_priv); 1154 primary_if = batadv_primary_if_get_selected(bat_priv);
1135 if (primary_if) { 1155 if (primary_if) {
1136 bat_priv->claim_dest.group = 1156 bat_priv->claim_dest.group =
1137 htons(crc16(0, primary_if->net_dev->dev_addr, 1157 htons(crc16(0, primary_if->net_dev->dev_addr,
1138 ETH_ALEN)); 1158 ETH_ALEN));
1139 hardif_free_ref(primary_if); 1159 batadv_hardif_free_ref(primary_if);
1140 } else { 1160 } else {
1141 bat_priv->claim_dest.group = 0; /* will be set later */ 1161 bat_priv->claim_dest.group = 0; /* will be set later */
1142 } 1162 }
@@ -1157,13 +1177,13 @@ int batadv_bla_init(struct bat_priv *bat_priv)
1157 return -ENOMEM; 1177 return -ENOMEM;
1158 1178
1159 batadv_hash_set_lock_class(bat_priv->claim_hash, 1179 batadv_hash_set_lock_class(bat_priv->claim_hash,
1160 &claim_hash_lock_class_key); 1180 &batadv_claim_hash_lock_class_key);
1161 batadv_hash_set_lock_class(bat_priv->backbone_hash, 1181 batadv_hash_set_lock_class(bat_priv->backbone_hash,
1162 &backbone_hash_lock_class_key); 1182 &batadv_backbone_hash_lock_class_key);
1163 1183
1164 bat_dbg(DBG_BLA, bat_priv, "bla hashes initialized\n"); 1184 batadv_dbg(DBG_BLA, bat_priv, "bla hashes initialized\n");
1165 1185
1166 bla_start_timer(bat_priv); 1186 batadv_bla_start_timer(bat_priv);
1167 return 0; 1187 return 0;
1168} 1188}
1169 1189
@@ -1203,13 +1223,13 @@ int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
1203 /* we can stop searching if the entry is too old ; 1223 /* we can stop searching if the entry is too old ;
1204 * later entries will be even older 1224 * later entries will be even older
1205 */ 1225 */
1206 if (has_timed_out(entry->entrytime, DUPLIST_TIMEOUT)) 1226 if (batadv_has_timed_out(entry->entrytime, DUPLIST_TIMEOUT))
1207 break; 1227 break;
1208 1228
1209 if (entry->crc != crc) 1229 if (entry->crc != crc)
1210 continue; 1230 continue;
1211 1231
1212 if (compare_eth(entry->orig, bcast_packet->orig)) 1232 if (batadv_compare_eth(entry->orig, bcast_packet->orig))
1213 continue; 1233 continue;
1214 1234
1215 /* this entry seems to match: same crc, not too old, 1235 /* this entry seems to match: same crc, not too old,
@@ -1257,7 +1277,7 @@ int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig)
1257 1277
1258 rcu_read_lock(); 1278 rcu_read_lock();
1259 hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { 1279 hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) {
1260 if (compare_eth(backbone_gw->orig, orig)) { 1280 if (batadv_compare_eth(backbone_gw->orig, orig)) {
1261 rcu_read_unlock(); 1281 rcu_read_unlock();
1262 return 1; 1282 return 1;
1263 } 1283 }
@@ -1304,12 +1324,12 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb,
1304 } 1324 }
1305 1325
1306 /* see if this originator is a backbone gw for this VLAN */ 1326 /* see if this originator is a backbone gw for this VLAN */
1307 backbone_gw = backbone_hash_find(orig_node->bat_priv, 1327 backbone_gw = batadv_backbone_hash_find(orig_node->bat_priv,
1308 orig_node->orig, vid); 1328 orig_node->orig, vid);
1309 if (!backbone_gw) 1329 if (!backbone_gw)
1310 return 0; 1330 return 0;
1311 1331
1312 backbone_gw_free_ref(backbone_gw); 1332 batadv_backbone_gw_free_ref(backbone_gw);
1313 return 1; 1333 return 1;
1314} 1334}
1315 1335
@@ -1319,20 +1339,20 @@ void batadv_bla_free(struct bat_priv *bat_priv)
1319 struct hard_iface *primary_if; 1339 struct hard_iface *primary_if;
1320 1340
1321 cancel_delayed_work_sync(&bat_priv->bla_work); 1341 cancel_delayed_work_sync(&bat_priv->bla_work);
1322 primary_if = primary_if_get_selected(bat_priv); 1342 primary_if = batadv_primary_if_get_selected(bat_priv);
1323 1343
1324 if (bat_priv->claim_hash) { 1344 if (bat_priv->claim_hash) {
1325 bla_purge_claims(bat_priv, primary_if, 1); 1345 batadv_bla_purge_claims(bat_priv, primary_if, 1);
1326 batadv_hash_destroy(bat_priv->claim_hash); 1346 batadv_hash_destroy(bat_priv->claim_hash);
1327 bat_priv->claim_hash = NULL; 1347 bat_priv->claim_hash = NULL;
1328 } 1348 }
1329 if (bat_priv->backbone_hash) { 1349 if (bat_priv->backbone_hash) {
1330 bla_purge_backbone_gw(bat_priv, 1); 1350 batadv_bla_purge_backbone_gw(bat_priv, 1);
1331 batadv_hash_destroy(bat_priv->backbone_hash); 1351 batadv_hash_destroy(bat_priv->backbone_hash);
1332 bat_priv->backbone_hash = NULL; 1352 bat_priv->backbone_hash = NULL;
1333 } 1353 }
1334 if (primary_if) 1354 if (primary_if)
1335 hardif_free_ref(primary_if); 1355 batadv_hardif_free_ref(primary_if);
1336} 1356}
1337 1357
1338/* @bat_priv: the bat priv with all the soft interface information 1358/* @bat_priv: the bat priv with all the soft interface information
@@ -1356,7 +1376,7 @@ int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
1356 1376
1357 ethhdr = (struct ethhdr *)skb_mac_header(skb); 1377 ethhdr = (struct ethhdr *)skb_mac_header(skb);
1358 1378
1359 primary_if = primary_if_get_selected(bat_priv); 1379 primary_if = batadv_primary_if_get_selected(bat_priv);
1360 if (!primary_if) 1380 if (!primary_if)
1361 goto handled; 1381 goto handled;
1362 1382
@@ -1371,21 +1391,21 @@ int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
1371 1391
1372 memcpy(search_claim.addr, ethhdr->h_source, ETH_ALEN); 1392 memcpy(search_claim.addr, ethhdr->h_source, ETH_ALEN);
1373 search_claim.vid = vid; 1393 search_claim.vid = vid;
1374 claim = claim_hash_find(bat_priv, &search_claim); 1394 claim = batadv_claim_hash_find(bat_priv, &search_claim);
1375 1395
1376 if (!claim) { 1396 if (!claim) {
1377 /* possible optimization: race for a claim */ 1397 /* possible optimization: race for a claim */
1378 /* No claim exists yet, claim it for us! 1398 /* No claim exists yet, claim it for us!
1379 */ 1399 */
1380 handle_claim(bat_priv, primary_if, 1400 batadv_handle_claim(bat_priv, primary_if,
1381 primary_if->net_dev->dev_addr, 1401 primary_if->net_dev->dev_addr,
1382 ethhdr->h_source, vid); 1402 ethhdr->h_source, vid);
1383 goto allow; 1403 goto allow;
1384 } 1404 }
1385 1405
1386 /* if it is our own claim ... */ 1406 /* if it is our own claim ... */
1387 if (compare_eth(claim->backbone_gw->orig, 1407 if (batadv_compare_eth(claim->backbone_gw->orig,
1388 primary_if->net_dev->dev_addr)) { 1408 primary_if->net_dev->dev_addr)) {
1389 /* ... allow it in any case */ 1409 /* ... allow it in any case */
1390 claim->lasttime = jiffies; 1410 claim->lasttime = jiffies;
1391 goto allow; 1411 goto allow;
@@ -1400,13 +1420,13 @@ int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
1400 * send a claim and update the claim table 1420 * send a claim and update the claim table
1401 * immediately. 1421 * immediately.
1402 */ 1422 */
1403 handle_claim(bat_priv, primary_if, 1423 batadv_handle_claim(bat_priv, primary_if,
1404 primary_if->net_dev->dev_addr, 1424 primary_if->net_dev->dev_addr,
1405 ethhdr->h_source, vid); 1425 ethhdr->h_source, vid);
1406 goto allow; 1426 goto allow;
1407 } 1427 }
1408allow: 1428allow:
1409 bla_update_own_backbone_gw(bat_priv, primary_if, vid); 1429 batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
1410 ret = 0; 1430 ret = 0;
1411 goto out; 1431 goto out;
1412 1432
@@ -1416,9 +1436,9 @@ handled:
1416 1436
1417out: 1437out:
1418 if (primary_if) 1438 if (primary_if)
1419 hardif_free_ref(primary_if); 1439 batadv_hardif_free_ref(primary_if);
1420 if (claim) 1440 if (claim)
1421 claim_free_ref(claim); 1441 batadv_claim_free_ref(claim);
1422 return ret; 1442 return ret;
1423} 1443}
1424 1444
@@ -1441,7 +1461,7 @@ int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
1441 struct hard_iface *primary_if; 1461 struct hard_iface *primary_if;
1442 int ret = 0; 1462 int ret = 0;
1443 1463
1444 primary_if = primary_if_get_selected(bat_priv); 1464 primary_if = batadv_primary_if_get_selected(bat_priv);
1445 if (!primary_if) 1465 if (!primary_if)
1446 goto out; 1466 goto out;
1447 1467
@@ -1451,7 +1471,7 @@ int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
1451 /* in VLAN case, the mac header might not be set. */ 1471 /* in VLAN case, the mac header might not be set. */
1452 skb_reset_mac_header(skb); 1472 skb_reset_mac_header(skb);
1453 1473
1454 if (bla_process_claim(bat_priv, primary_if, skb)) 1474 if (batadv_bla_process_claim(bat_priv, primary_if, skb))
1455 goto handled; 1475 goto handled;
1456 1476
1457 ethhdr = (struct ethhdr *)skb_mac_header(skb); 1477 ethhdr = (struct ethhdr *)skb_mac_header(skb);
@@ -1464,21 +1484,21 @@ int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
1464 memcpy(search_claim.addr, ethhdr->h_source, ETH_ALEN); 1484 memcpy(search_claim.addr, ethhdr->h_source, ETH_ALEN);
1465 search_claim.vid = vid; 1485 search_claim.vid = vid;
1466 1486
1467 claim = claim_hash_find(bat_priv, &search_claim); 1487 claim = batadv_claim_hash_find(bat_priv, &search_claim);
1468 1488
1469 /* if no claim exists, allow it. */ 1489 /* if no claim exists, allow it. */
1470 if (!claim) 1490 if (!claim)
1471 goto allow; 1491 goto allow;
1472 1492
1473 /* check if we are responsible. */ 1493 /* check if we are responsible. */
1474 if (compare_eth(claim->backbone_gw->orig, 1494 if (batadv_compare_eth(claim->backbone_gw->orig,
1475 primary_if->net_dev->dev_addr)) { 1495 primary_if->net_dev->dev_addr)) {
1476 /* if yes, the client has roamed and we have 1496 /* if yes, the client has roamed and we have
1477 * to unclaim it. 1497 * to unclaim it.
1478 */ 1498 */
1479 handle_unclaim(bat_priv, primary_if, 1499 batadv_handle_unclaim(bat_priv, primary_if,
1480 primary_if->net_dev->dev_addr, 1500 primary_if->net_dev->dev_addr,
1481 ethhdr->h_source, vid); 1501 ethhdr->h_source, vid);
1482 goto allow; 1502 goto allow;
1483 } 1503 }
1484 1504
@@ -1495,16 +1515,16 @@ int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
1495 goto allow; 1515 goto allow;
1496 } 1516 }
1497allow: 1517allow:
1498 bla_update_own_backbone_gw(bat_priv, primary_if, vid); 1518 batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
1499 ret = 0; 1519 ret = 0;
1500 goto out; 1520 goto out;
1501handled: 1521handled:
1502 ret = 1; 1522 ret = 1;
1503out: 1523out:
1504 if (primary_if) 1524 if (primary_if)
1505 hardif_free_ref(primary_if); 1525 batadv_hardif_free_ref(primary_if);
1506 if (claim) 1526 if (claim)
1507 claim_free_ref(claim); 1527 batadv_claim_free_ref(claim);
1508 return ret; 1528 return ret;
1509} 1529}
1510 1530
@@ -1520,8 +1540,9 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
1520 uint32_t i; 1540 uint32_t i;
1521 bool is_own; 1541 bool is_own;
1522 int ret = 0; 1542 int ret = 0;
1543 uint8_t *primary_addr;
1523 1544
1524 primary_if = primary_if_get_selected(bat_priv); 1545 primary_if = batadv_primary_if_get_selected(bat_priv);
1525 if (!primary_if) { 1546 if (!primary_if) {
1526 ret = seq_printf(seq, 1547 ret = seq_printf(seq,
1527 "BATMAN mesh %s disabled - please specify interfaces to enable it\n", 1548 "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
@@ -1536,9 +1557,10 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
1536 goto out; 1557 goto out;
1537 } 1558 }
1538 1559
1560 primary_addr = primary_if->net_dev->dev_addr;
1539 seq_printf(seq, 1561 seq_printf(seq,
1540 "Claims announced for the mesh %s (orig %pM, group id %04x)\n", 1562 "Claims announced for the mesh %s (orig %pM, group id %04x)\n",
1541 net_dev->name, primary_if->net_dev->dev_addr, 1563 net_dev->name, primary_addr,
1542 ntohs(bat_priv->claim_dest.group)); 1564 ntohs(bat_priv->claim_dest.group));
1543 seq_printf(seq, " %-17s %-5s %-17s [o] (%-4s)\n", 1565 seq_printf(seq, " %-17s %-5s %-17s [o] (%-4s)\n",
1544 "Client", "VID", "Originator", "CRC"); 1566 "Client", "VID", "Originator", "CRC");
@@ -1547,8 +1569,8 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
1547 1569
1548 rcu_read_lock(); 1570 rcu_read_lock();
1549 hlist_for_each_entry_rcu(claim, node, head, hash_entry) { 1571 hlist_for_each_entry_rcu(claim, node, head, hash_entry) {
1550 is_own = compare_eth(claim->backbone_gw->orig, 1572 is_own = batadv_compare_eth(claim->backbone_gw->orig,
1551 primary_if->net_dev->dev_addr); 1573 primary_addr);
1552 seq_printf(seq, " * %pM on % 5d by %pM [%c] (%04x)\n", 1574 seq_printf(seq, " * %pM on % 5d by %pM [%c] (%04x)\n",
1553 claim->addr, claim->vid, 1575 claim->addr, claim->vid,
1554 claim->backbone_gw->orig, 1576 claim->backbone_gw->orig,
@@ -1559,6 +1581,6 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
1559 } 1581 }
1560out: 1582out:
1561 if (primary_if) 1583 if (primary_if)
1562 hardif_free_ref(primary_if); 1584 batadv_hardif_free_ref(primary_if);
1563 return ret; 1585 return ret;
1564} 1586}
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 0d90fffd9efb..efe7519f1491 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -36,13 +36,13 @@
36#define DHCP_OPTIONS_OFFSET 240 36#define DHCP_OPTIONS_OFFSET 240
37#define DHCP_REQUEST 3 37#define DHCP_REQUEST 3
38 38
39static void gw_node_free_ref(struct gw_node *gw_node) 39static void batadv_gw_node_free_ref(struct gw_node *gw_node)
40{ 40{
41 if (atomic_dec_and_test(&gw_node->refcount)) 41 if (atomic_dec_and_test(&gw_node->refcount))
42 kfree_rcu(gw_node, rcu); 42 kfree_rcu(gw_node, rcu);
43} 43}
44 44
45static struct gw_node *gw_get_selected_gw_node(struct bat_priv *bat_priv) 45static struct gw_node *batadv_gw_get_selected_gw_node(struct bat_priv *bat_priv)
46{ 46{
47 struct gw_node *gw_node; 47 struct gw_node *gw_node;
48 48
@@ -64,7 +64,7 @@ struct orig_node *batadv_gw_get_selected_orig(struct bat_priv *bat_priv)
64 struct gw_node *gw_node; 64 struct gw_node *gw_node;
65 struct orig_node *orig_node = NULL; 65 struct orig_node *orig_node = NULL;
66 66
67 gw_node = gw_get_selected_gw_node(bat_priv); 67 gw_node = batadv_gw_get_selected_gw_node(bat_priv);
68 if (!gw_node) 68 if (!gw_node)
69 goto out; 69 goto out;
70 70
@@ -80,11 +80,12 @@ unlock:
80 rcu_read_unlock(); 80 rcu_read_unlock();
81out: 81out:
82 if (gw_node) 82 if (gw_node)
83 gw_node_free_ref(gw_node); 83 batadv_gw_node_free_ref(gw_node);
84 return orig_node; 84 return orig_node;
85} 85}
86 86
87static void gw_select(struct bat_priv *bat_priv, struct gw_node *new_gw_node) 87static void batadv_gw_select(struct bat_priv *bat_priv,
88 struct gw_node *new_gw_node)
88{ 89{
89 struct gw_node *curr_gw_node; 90 struct gw_node *curr_gw_node;
90 91
@@ -97,7 +98,7 @@ static void gw_select(struct bat_priv *bat_priv, struct gw_node *new_gw_node)
97 rcu_assign_pointer(bat_priv->curr_gw, new_gw_node); 98 rcu_assign_pointer(bat_priv->curr_gw, new_gw_node);
98 99
99 if (curr_gw_node) 100 if (curr_gw_node)
100 gw_node_free_ref(curr_gw_node); 101 batadv_gw_node_free_ref(curr_gw_node);
101 102
102 spin_unlock_bh(&bat_priv->gw_list_lock); 103 spin_unlock_bh(&bat_priv->gw_list_lock);
103} 104}
@@ -107,7 +108,7 @@ void batadv_gw_deselect(struct bat_priv *bat_priv)
107 atomic_set(&bat_priv->gw_reselect, 1); 108 atomic_set(&bat_priv->gw_reselect, 1);
108} 109}
109 110
110static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv) 111static struct gw_node *batadv_gw_get_best_gw_node(struct bat_priv *bat_priv)
111{ 112{
112 struct neigh_node *router; 113 struct neigh_node *router;
113 struct hlist_node *node; 114 struct hlist_node *node;
@@ -144,7 +145,7 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv)
144 ((tmp_gw_factor == max_gw_factor) && 145 ((tmp_gw_factor == max_gw_factor) &&
145 (router->tq_avg > max_tq))) { 146 (router->tq_avg > max_tq))) {
146 if (curr_gw) 147 if (curr_gw)
147 gw_node_free_ref(curr_gw); 148 batadv_gw_node_free_ref(curr_gw);
148 curr_gw = gw_node; 149 curr_gw = gw_node;
149 atomic_inc(&curr_gw->refcount); 150 atomic_inc(&curr_gw->refcount);
150 } 151 }
@@ -159,7 +160,7 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv)
159 */ 160 */
160 if (router->tq_avg > max_tq) { 161 if (router->tq_avg > max_tq) {
161 if (curr_gw) 162 if (curr_gw)
162 gw_node_free_ref(curr_gw); 163 batadv_gw_node_free_ref(curr_gw);
163 curr_gw = gw_node; 164 curr_gw = gw_node;
164 atomic_inc(&curr_gw->refcount); 165 atomic_inc(&curr_gw->refcount);
165 } 166 }
@@ -172,7 +173,7 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv)
172 if (tmp_gw_factor > max_gw_factor) 173 if (tmp_gw_factor > max_gw_factor)
173 max_gw_factor = tmp_gw_factor; 174 max_gw_factor = tmp_gw_factor;
174 175
175 gw_node_free_ref(gw_node); 176 batadv_gw_node_free_ref(gw_node);
176 177
177next: 178next:
178 batadv_neigh_node_free_ref(router); 179 batadv_neigh_node_free_ref(router);
@@ -199,9 +200,9 @@ void batadv_gw_election(struct bat_priv *bat_priv)
199 if (!atomic_dec_not_zero(&bat_priv->gw_reselect)) 200 if (!atomic_dec_not_zero(&bat_priv->gw_reselect))
200 goto out; 201 goto out;
201 202
202 curr_gw = gw_get_selected_gw_node(bat_priv); 203 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
203 204
204 next_gw = gw_get_best_gw_node(bat_priv); 205 next_gw = batadv_gw_get_best_gw_node(bat_priv);
205 206
206 if (curr_gw == next_gw) 207 if (curr_gw == next_gw)
207 goto out; 208 goto out;
@@ -217,30 +218,30 @@ void batadv_gw_election(struct bat_priv *bat_priv)
217 } 218 }
218 219
219 if ((curr_gw) && (!next_gw)) { 220 if ((curr_gw) && (!next_gw)) {
220 bat_dbg(DBG_BATMAN, bat_priv, 221 batadv_dbg(DBG_BATMAN, bat_priv,
221 "Removing selected gateway - no gateway in range\n"); 222 "Removing selected gateway - no gateway in range\n");
222 batadv_throw_uevent(bat_priv, UEV_GW, UEV_DEL, NULL); 223 batadv_throw_uevent(bat_priv, UEV_GW, UEV_DEL, NULL);
223 } else if ((!curr_gw) && (next_gw)) { 224 } else if ((!curr_gw) && (next_gw)) {
224 bat_dbg(DBG_BATMAN, bat_priv, 225 batadv_dbg(DBG_BATMAN, bat_priv,
225 "Adding route to gateway %pM (gw_flags: %i, tq: %i)\n", 226 "Adding route to gateway %pM (gw_flags: %i, tq: %i)\n",
226 next_gw->orig_node->orig, next_gw->orig_node->gw_flags, 227 next_gw->orig_node->orig,
227 router->tq_avg); 228 next_gw->orig_node->gw_flags, router->tq_avg);
228 batadv_throw_uevent(bat_priv, UEV_GW, UEV_ADD, gw_addr); 229 batadv_throw_uevent(bat_priv, UEV_GW, UEV_ADD, gw_addr);
229 } else { 230 } else {
230 bat_dbg(DBG_BATMAN, bat_priv, 231 batadv_dbg(DBG_BATMAN, bat_priv,
231 "Changing route to gateway %pM (gw_flags: %i, tq: %i)\n", 232 "Changing route to gateway %pM (gw_flags: %i, tq: %i)\n",
232 next_gw->orig_node->orig, next_gw->orig_node->gw_flags, 233 next_gw->orig_node->orig,
233 router->tq_avg); 234 next_gw->orig_node->gw_flags, router->tq_avg);
234 batadv_throw_uevent(bat_priv, UEV_GW, UEV_CHANGE, gw_addr); 235 batadv_throw_uevent(bat_priv, UEV_GW, UEV_CHANGE, gw_addr);
235 } 236 }
236 237
237 gw_select(bat_priv, next_gw); 238 batadv_gw_select(bat_priv, next_gw);
238 239
239out: 240out:
240 if (curr_gw) 241 if (curr_gw)
241 gw_node_free_ref(curr_gw); 242 batadv_gw_node_free_ref(curr_gw);
242 if (next_gw) 243 if (next_gw)
243 gw_node_free_ref(next_gw); 244 batadv_gw_node_free_ref(next_gw);
244 if (router) 245 if (router)
245 batadv_neigh_node_free_ref(router); 246 batadv_neigh_node_free_ref(router);
246} 247}
@@ -282,9 +283,9 @@ void batadv_gw_check_election(struct bat_priv *bat_priv,
282 (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_sel_class))) 283 (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_sel_class)))
283 goto out; 284 goto out;
284 285
285 bat_dbg(DBG_BATMAN, bat_priv, 286 batadv_dbg(DBG_BATMAN, bat_priv,
286 "Restarting gateway selection: better gateway found (tq curr: %i, tq new: %i)\n", 287 "Restarting gateway selection: better gateway found (tq curr: %i, tq new: %i)\n",
287 gw_tq_avg, orig_tq_avg); 288 gw_tq_avg, orig_tq_avg);
288 289
289deselect: 290deselect:
290 batadv_gw_deselect(bat_priv); 291 batadv_gw_deselect(bat_priv);
@@ -299,8 +300,9 @@ out:
299 return; 300 return;
300} 301}
301 302
302static void gw_node_add(struct bat_priv *bat_priv, 303static void batadv_gw_node_add(struct bat_priv *bat_priv,
303 struct orig_node *orig_node, uint8_t new_gwflags) 304 struct orig_node *orig_node,
305 uint8_t new_gwflags)
304{ 306{
305 struct gw_node *gw_node; 307 struct gw_node *gw_node;
306 int down, up; 308 int down, up;
@@ -318,13 +320,13 @@ static void gw_node_add(struct bat_priv *bat_priv,
318 spin_unlock_bh(&bat_priv->gw_list_lock); 320 spin_unlock_bh(&bat_priv->gw_list_lock);
319 321
320 batadv_gw_bandwidth_to_kbit(new_gwflags, &down, &up); 322 batadv_gw_bandwidth_to_kbit(new_gwflags, &down, &up);
321 bat_dbg(DBG_BATMAN, bat_priv, 323 batadv_dbg(DBG_BATMAN, bat_priv,
322 "Found new gateway %pM -> gw_class: %i - %i%s/%i%s\n", 324 "Found new gateway %pM -> gw_class: %i - %i%s/%i%s\n",
323 orig_node->orig, new_gwflags, 325 orig_node->orig, new_gwflags,
324 (down > 2048 ? down / 1024 : down), 326 (down > 2048 ? down / 1024 : down),
325 (down > 2048 ? "MBit" : "KBit"), 327 (down > 2048 ? "MBit" : "KBit"),
326 (up > 2048 ? up / 1024 : up), 328 (up > 2048 ? up / 1024 : up),
327 (up > 2048 ? "MBit" : "KBit")); 329 (up > 2048 ? "MBit" : "KBit"));
328} 330}
329 331
330void batadv_gw_node_update(struct bat_priv *bat_priv, 332void batadv_gw_node_update(struct bat_priv *bat_priv,
@@ -338,25 +340,25 @@ void batadv_gw_node_update(struct bat_priv *bat_priv,
338 * have this gateway in our list (duplication check!) even though we 340 * have this gateway in our list (duplication check!) even though we
339 * have no currently selected gateway. 341 * have no currently selected gateway.
340 */ 342 */
341 curr_gw = gw_get_selected_gw_node(bat_priv); 343 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
342 344
343 rcu_read_lock(); 345 rcu_read_lock();
344 hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) { 346 hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) {
345 if (gw_node->orig_node != orig_node) 347 if (gw_node->orig_node != orig_node)
346 continue; 348 continue;
347 349
348 bat_dbg(DBG_BATMAN, bat_priv, 350 batadv_dbg(DBG_BATMAN, bat_priv,
349 "Gateway class of originator %pM changed from %i to %i\n", 351 "Gateway class of originator %pM changed from %i to %i\n",
350 orig_node->orig, gw_node->orig_node->gw_flags, 352 orig_node->orig, gw_node->orig_node->gw_flags,
351 new_gwflags); 353 new_gwflags);
352 354
353 gw_node->deleted = 0; 355 gw_node->deleted = 0;
354 356
355 if (new_gwflags == NO_FLAGS) { 357 if (new_gwflags == NO_FLAGS) {
356 gw_node->deleted = jiffies; 358 gw_node->deleted = jiffies;
357 bat_dbg(DBG_BATMAN, bat_priv, 359 batadv_dbg(DBG_BATMAN, bat_priv,
358 "Gateway %pM removed from gateway list\n", 360 "Gateway %pM removed from gateway list\n",
359 orig_node->orig); 361 orig_node->orig);
360 362
361 if (gw_node == curr_gw) 363 if (gw_node == curr_gw)
362 goto deselect; 364 goto deselect;
@@ -368,7 +370,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv,
368 if (new_gwflags == NO_FLAGS) 370 if (new_gwflags == NO_FLAGS)
369 goto unlock; 371 goto unlock;
370 372
371 gw_node_add(bat_priv, orig_node, new_gwflags); 373 batadv_gw_node_add(bat_priv, orig_node, new_gwflags);
372 goto unlock; 374 goto unlock;
373 375
374deselect: 376deselect:
@@ -377,7 +379,7 @@ unlock:
377 rcu_read_unlock(); 379 rcu_read_unlock();
378 380
379 if (curr_gw) 381 if (curr_gw)
380 gw_node_free_ref(curr_gw); 382 batadv_gw_node_free_ref(curr_gw);
381} 383}
382 384
383void batadv_gw_node_delete(struct bat_priv *bat_priv, 385void batadv_gw_node_delete(struct bat_priv *bat_priv,
@@ -393,7 +395,7 @@ void batadv_gw_node_purge(struct bat_priv *bat_priv)
393 unsigned long timeout = msecs_to_jiffies(2 * PURGE_TIMEOUT); 395 unsigned long timeout = msecs_to_jiffies(2 * PURGE_TIMEOUT);
394 int do_deselect = 0; 396 int do_deselect = 0;
395 397
396 curr_gw = gw_get_selected_gw_node(bat_priv); 398 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
397 399
398 spin_lock_bh(&bat_priv->gw_list_lock); 400 spin_lock_bh(&bat_priv->gw_list_lock);
399 401
@@ -408,7 +410,7 @@ void batadv_gw_node_purge(struct bat_priv *bat_priv)
408 do_deselect = 1; 410 do_deselect = 1;
409 411
410 hlist_del_rcu(&gw_node->list); 412 hlist_del_rcu(&gw_node->list);
411 gw_node_free_ref(gw_node); 413 batadv_gw_node_free_ref(gw_node);
412 } 414 }
413 415
414 spin_unlock_bh(&bat_priv->gw_list_lock); 416 spin_unlock_bh(&bat_priv->gw_list_lock);
@@ -418,12 +420,13 @@ void batadv_gw_node_purge(struct bat_priv *bat_priv)
418 batadv_gw_deselect(bat_priv); 420 batadv_gw_deselect(bat_priv);
419 421
420 if (curr_gw) 422 if (curr_gw)
421 gw_node_free_ref(curr_gw); 423 batadv_gw_node_free_ref(curr_gw);
422} 424}
423 425
424/* fails if orig_node has no router */ 426/* fails if orig_node has no router */
425static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq, 427static int batadv_write_buffer_text(struct bat_priv *bat_priv,
426 const struct gw_node *gw_node) 428 struct seq_file *seq,
429 const struct gw_node *gw_node)
427{ 430{
428 struct gw_node *curr_gw; 431 struct gw_node *curr_gw;
429 struct neigh_node *router; 432 struct neigh_node *router;
@@ -435,7 +438,7 @@ static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq,
435 if (!router) 438 if (!router)
436 goto out; 439 goto out;
437 440
438 curr_gw = gw_get_selected_gw_node(bat_priv); 441 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
439 442
440 ret = seq_printf(seq, "%s %pM (%3i) %pM [%10s]: %3i - %i%s/%i%s\n", 443 ret = seq_printf(seq, "%s %pM (%3i) %pM [%10s]: %3i - %i%s/%i%s\n",
441 (curr_gw == gw_node ? "=>" : " "), 444 (curr_gw == gw_node ? "=>" : " "),
@@ -450,7 +453,7 @@ static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq,
450 453
451 batadv_neigh_node_free_ref(router); 454 batadv_neigh_node_free_ref(router);
452 if (curr_gw) 455 if (curr_gw)
453 gw_node_free_ref(curr_gw); 456 batadv_gw_node_free_ref(curr_gw);
454out: 457out:
455 return ret; 458 return ret;
456} 459}
@@ -464,7 +467,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
464 struct hlist_node *node; 467 struct hlist_node *node;
465 int gw_count = 0, ret = 0; 468 int gw_count = 0, ret = 0;
466 469
467 primary_if = primary_if_get_selected(bat_priv); 470 primary_if = batadv_primary_if_get_selected(bat_priv);
468 if (!primary_if) { 471 if (!primary_if) {
469 ret = seq_printf(seq, 472 ret = seq_printf(seq,
470 "BATMAN mesh %s disabled - please specify interfaces to enable it\n", 473 "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
@@ -491,7 +494,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
491 continue; 494 continue;
492 495
493 /* fails if orig_node has no router */ 496 /* fails if orig_node has no router */
494 if (_write_buffer_text(bat_priv, seq, gw_node) < 0) 497 if (batadv_write_buffer_text(bat_priv, seq, gw_node) < 0)
495 continue; 498 continue;
496 499
497 gw_count++; 500 gw_count++;
@@ -503,11 +506,11 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
503 506
504out: 507out:
505 if (primary_if) 508 if (primary_if)
506 hardif_free_ref(primary_if); 509 batadv_hardif_free_ref(primary_if);
507 return ret; 510 return ret;
508} 511}
509 512
510static bool is_type_dhcprequest(struct sk_buff *skb, int header_len) 513static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len)
511{ 514{
512 int ret = false; 515 int ret = false;
513 unsigned char *p; 516 unsigned char *p;
@@ -655,7 +658,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
655 if (!orig_dst_node->gw_flags) 658 if (!orig_dst_node->gw_flags)
656 goto out; 659 goto out;
657 660
658 ret = is_type_dhcprequest(skb, header_len); 661 ret = batadv_is_type_dhcprequest(skb, header_len);
659 if (!ret) 662 if (!ret)
660 goto out; 663 goto out;
661 664
@@ -667,7 +670,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
667 curr_tq_avg = TQ_MAX_VALUE; 670 curr_tq_avg = TQ_MAX_VALUE;
668 break; 671 break;
669 case GW_MODE_CLIENT: 672 case GW_MODE_CLIENT:
670 curr_gw = gw_get_selected_gw_node(bat_priv); 673 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
671 if (!curr_gw) 674 if (!curr_gw)
672 goto out; 675 goto out;
673 676
@@ -702,7 +705,7 @@ out:
702 if (orig_dst_node) 705 if (orig_dst_node)
703 batadv_orig_node_free_ref(orig_dst_node); 706 batadv_orig_node_free_ref(orig_dst_node);
704 if (curr_gw) 707 if (curr_gw)
705 gw_node_free_ref(curr_gw); 708 batadv_gw_node_free_ref(curr_gw);
706 if (neigh_old) 709 if (neigh_old)
707 batadv_neigh_node_free_ref(neigh_old); 710 batadv_neigh_node_free_ref(neigh_old);
708 if (neigh_curr) 711 if (neigh_curr)
diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c
index 3700562cf276..6edf37f9a15c 100644
--- a/net/batman-adv/gateway_common.c
+++ b/net/batman-adv/gateway_common.c
@@ -22,7 +22,7 @@
22#include "gateway_client.h" 22#include "gateway_client.h"
23 23
24/* calculates the gateway class from kbit */ 24/* calculates the gateway class from kbit */
25static void kbit_to_gw_bandwidth(int down, int up, long *gw_srv_class) 25static void batadv_kbit_to_gw_bandwidth(int down, int up, long *gw_srv_class)
26{ 26{
27 int mdown = 0, tdown, tup, difference; 27 int mdown = 0, tdown, tup, difference;
28 uint8_t sbit, part; 28 uint8_t sbit, part;
@@ -73,8 +73,8 @@ void batadv_gw_bandwidth_to_kbit(uint8_t gw_srv_class, int *down, int *up)
73 *up = ((upart + 1) * (*down)) / 8; 73 *up = ((upart + 1) * (*down)) / 8;
74} 74}
75 75
76static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff, 76static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
77 int *up, int *down) 77 int *up, int *down)
78{ 78{
79 int ret, multi = 1; 79 int ret, multi = 1;
80 char *slash_ptr, *tmp_ptr; 80 char *slash_ptr, *tmp_ptr;
@@ -142,7 +142,7 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
142 int up = 0, down = 0; 142 int up = 0, down = 0;
143 bool ret; 143 bool ret;
144 144
145 ret = parse_gw_bandwidth(net_dev, buff, &up, &down); 145 ret = batadv_parse_gw_bandwidth(net_dev, buff, &up, &down);
146 if (!ret) 146 if (!ret)
147 goto end; 147 goto end;
148 148
@@ -152,7 +152,7 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
152 if (!up) 152 if (!up)
153 up = down / 5; 153 up = down / 5;
154 154
155 kbit_to_gw_bandwidth(down, up, &gw_bandwidth_tmp); 155 batadv_kbit_to_gw_bandwidth(down, up, &gw_bandwidth_tmp);
156 156
157 /* the gw bandwidth we guessed above might not match the given 157 /* the gw bandwidth we guessed above might not match the given
158 * 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
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 2a4d394771b8..c22c145d8224 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -57,7 +57,7 @@ out:
57 return hard_iface; 57 return hard_iface;
58} 58}
59 59
60static int is_valid_iface(const struct net_device *net_dev) 60static int batadv_is_valid_iface(const struct net_device *net_dev)
61{ 61{
62 if (net_dev->flags & IFF_LOOPBACK) 62 if (net_dev->flags & IFF_LOOPBACK)
63 return 0; 63 return 0;
@@ -75,7 +75,8 @@ static int is_valid_iface(const struct net_device *net_dev)
75 return 1; 75 return 1;
76} 76}
77 77
78static struct hard_iface *hardif_get_active(const struct net_device *soft_iface) 78static struct hard_iface *
79batadv_hardif_get_active(const struct net_device *soft_iface)
79{ 80{
80 struct hard_iface *hard_iface; 81 struct hard_iface *hard_iface;
81 82
@@ -96,13 +97,13 @@ out:
96 return hard_iface; 97 return hard_iface;
97} 98}
98 99
99static void primary_if_update_addr(struct bat_priv *bat_priv, 100static void batadv_primary_if_update_addr(struct bat_priv *bat_priv,
100 struct hard_iface *oldif) 101 struct hard_iface *oldif)
101{ 102{
102 struct vis_packet *vis_packet; 103 struct vis_packet *vis_packet;
103 struct hard_iface *primary_if; 104 struct hard_iface *primary_if;
104 105
105 primary_if = primary_if_get_selected(bat_priv); 106 primary_if = batadv_primary_if_get_selected(bat_priv);
106 if (!primary_if) 107 if (!primary_if)
107 goto out; 108 goto out;
108 109
@@ -115,11 +116,11 @@ static void primary_if_update_addr(struct bat_priv *bat_priv,
115 batadv_bla_update_orig_address(bat_priv, primary_if, oldif); 116 batadv_bla_update_orig_address(bat_priv, primary_if, oldif);
116out: 117out:
117 if (primary_if) 118 if (primary_if)
118 hardif_free_ref(primary_if); 119 batadv_hardif_free_ref(primary_if);
119} 120}
120 121
121static void primary_if_select(struct bat_priv *bat_priv, 122static void batadv_primary_if_select(struct bat_priv *bat_priv,
122 struct hard_iface *new_hard_iface) 123 struct hard_iface *new_hard_iface)
123{ 124{
124 struct hard_iface *curr_hard_iface; 125 struct hard_iface *curr_hard_iface;
125 126
@@ -135,14 +136,14 @@ static void primary_if_select(struct bat_priv *bat_priv,
135 goto out; 136 goto out;
136 137
137 bat_priv->bat_algo_ops->bat_primary_iface_set(new_hard_iface); 138 bat_priv->bat_algo_ops->bat_primary_iface_set(new_hard_iface);
138 primary_if_update_addr(bat_priv, curr_hard_iface); 139 batadv_primary_if_update_addr(bat_priv, curr_hard_iface);
139 140
140out: 141out:
141 if (curr_hard_iface) 142 if (curr_hard_iface)
142 hardif_free_ref(curr_hard_iface); 143 batadv_hardif_free_ref(curr_hard_iface);
143} 144}
144 145
145static bool hardif_is_iface_up(const struct hard_iface *hard_iface) 146static bool batadv_hardif_is_iface_up(const struct hard_iface *hard_iface)
146{ 147{
147 if (hard_iface->net_dev->flags & IFF_UP) 148 if (hard_iface->net_dev->flags & IFF_UP)
148 return true; 149 return true;
@@ -150,7 +151,7 @@ static bool hardif_is_iface_up(const struct hard_iface *hard_iface)
150 return false; 151 return false;
151} 152}
152 153
153static void check_known_mac_addr(const struct net_device *net_dev) 154static void batadv_check_known_mac_addr(const struct net_device *net_dev)
154{ 155{
155 const struct hard_iface *hard_iface; 156 const struct hard_iface *hard_iface;
156 157
@@ -163,8 +164,8 @@ static void check_known_mac_addr(const struct net_device *net_dev)
163 if (hard_iface->net_dev == net_dev) 164 if (hard_iface->net_dev == net_dev)
164 continue; 165 continue;
165 166
166 if (!compare_eth(hard_iface->net_dev->dev_addr, 167 if (!batadv_compare_eth(hard_iface->net_dev->dev_addr,
167 net_dev->dev_addr)) 168 net_dev->dev_addr))
168 continue; 169 continue;
169 170
170 pr_warn("The newly added mac address (%pM) already exists on: %s\n", 171 pr_warn("The newly added mac address (%pM) already exists on: %s\n",
@@ -213,7 +214,7 @@ void batadv_update_min_mtu(struct net_device *soft_iface)
213 soft_iface->mtu = min_mtu; 214 soft_iface->mtu = min_mtu;
214} 215}
215 216
216static void hardif_activate_interface(struct hard_iface *hard_iface) 217static void batadv_hardif_activate_interface(struct hard_iface *hard_iface)
217{ 218{
218 struct bat_priv *bat_priv; 219 struct bat_priv *bat_priv;
219 struct hard_iface *primary_if = NULL; 220 struct hard_iface *primary_if = NULL;
@@ -229,9 +230,9 @@ static void hardif_activate_interface(struct hard_iface *hard_iface)
229 /* the first active interface becomes our primary interface or 230 /* the first active interface becomes our primary interface or
230 * the next active interface after the old primary interface was removed 231 * the next active interface after the old primary interface was removed
231 */ 232 */
232 primary_if = primary_if_get_selected(bat_priv); 233 primary_if = batadv_primary_if_get_selected(bat_priv);
233 if (!primary_if) 234 if (!primary_if)
234 primary_if_select(bat_priv, hard_iface); 235 batadv_primary_if_select(bat_priv, hard_iface);
235 236
236 bat_info(hard_iface->soft_iface, "Interface activated: %s\n", 237 bat_info(hard_iface->soft_iface, "Interface activated: %s\n",
237 hard_iface->net_dev->name); 238 hard_iface->net_dev->name);
@@ -240,10 +241,10 @@ static void hardif_activate_interface(struct hard_iface *hard_iface)
240 241
241out: 242out:
242 if (primary_if) 243 if (primary_if)
243 hardif_free_ref(primary_if); 244 batadv_hardif_free_ref(primary_if);
244} 245}
245 246
246static void hardif_deactivate_interface(struct hard_iface *hard_iface) 247static void batadv_hardif_deactivate_interface(struct hard_iface *hard_iface)
247{ 248{
248 if ((hard_iface->if_status != IF_ACTIVE) && 249 if ((hard_iface->if_status != IF_ACTIVE) &&
249 (hard_iface->if_status != IF_TO_BE_ACTIVATED)) 250 (hard_iface->if_status != IF_TO_BE_ACTIVATED))
@@ -331,8 +332,8 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
331 hard_iface->net_dev->name, hard_iface->net_dev->mtu, 332 hard_iface->net_dev->name, hard_iface->net_dev->mtu,
332 ETH_DATA_LEN + BAT_HEADER_LEN); 333 ETH_DATA_LEN + BAT_HEADER_LEN);
333 334
334 if (hardif_is_iface_up(hard_iface)) 335 if (batadv_hardif_is_iface_up(hard_iface))
335 hardif_activate_interface(hard_iface); 336 batadv_hardif_activate_interface(hard_iface);
336 else 337 else
337 bat_err(hard_iface->soft_iface, 338 bat_err(hard_iface->soft_iface,
338 "Not using interface %s (retrying later): interface not active\n", 339 "Not using interface %s (retrying later): interface not active\n",
@@ -347,7 +348,7 @@ out:
347err_dev: 348err_dev:
348 dev_put(soft_iface); 349 dev_put(soft_iface);
349err: 350err:
350 hardif_free_ref(hard_iface); 351 batadv_hardif_free_ref(hard_iface);
351 return ret; 352 return ret;
352} 353}
353 354
@@ -357,7 +358,7 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface)
357 struct hard_iface *primary_if = NULL; 358 struct hard_iface *primary_if = NULL;
358 359
359 if (hard_iface->if_status == IF_ACTIVE) 360 if (hard_iface->if_status == IF_ACTIVE)
360 hardif_deactivate_interface(hard_iface); 361 batadv_hardif_deactivate_interface(hard_iface);
361 362
362 if (hard_iface->if_status != IF_INACTIVE) 363 if (hard_iface->if_status != IF_INACTIVE)
363 goto out; 364 goto out;
@@ -369,15 +370,15 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface)
369 bat_priv->num_ifaces--; 370 bat_priv->num_ifaces--;
370 batadv_orig_hash_del_if(hard_iface, bat_priv->num_ifaces); 371 batadv_orig_hash_del_if(hard_iface, bat_priv->num_ifaces);
371 372
372 primary_if = primary_if_get_selected(bat_priv); 373 primary_if = batadv_primary_if_get_selected(bat_priv);
373 if (hard_iface == primary_if) { 374 if (hard_iface == primary_if) {
374 struct hard_iface *new_if; 375 struct hard_iface *new_if;
375 376
376 new_if = hardif_get_active(hard_iface->soft_iface); 377 new_if = batadv_hardif_get_active(hard_iface->soft_iface);
377 primary_if_select(bat_priv, new_if); 378 batadv_primary_if_select(bat_priv, new_if);
378 379
379 if (new_if) 380 if (new_if)
380 hardif_free_ref(new_if); 381 batadv_hardif_free_ref(new_if);
381 } 382 }
382 383
383 bat_priv->bat_algo_ops->bat_iface_disable(hard_iface); 384 bat_priv->bat_algo_ops->bat_iface_disable(hard_iface);
@@ -393,21 +394,22 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface)
393 batadv_softif_destroy(hard_iface->soft_iface); 394 batadv_softif_destroy(hard_iface->soft_iface);
394 395
395 hard_iface->soft_iface = NULL; 396 hard_iface->soft_iface = NULL;
396 hardif_free_ref(hard_iface); 397 batadv_hardif_free_ref(hard_iface);
397 398
398out: 399out:
399 if (primary_if) 400 if (primary_if)
400 hardif_free_ref(primary_if); 401 batadv_hardif_free_ref(primary_if);
401} 402}
402 403
403static struct hard_iface *hardif_add_interface(struct net_device *net_dev) 404static struct hard_iface *
405batadv_hardif_add_interface(struct net_device *net_dev)
404{ 406{
405 struct hard_iface *hard_iface; 407 struct hard_iface *hard_iface;
406 int ret; 408 int ret;
407 409
408 ASSERT_RTNL(); 410 ASSERT_RTNL();
409 411
410 ret = is_valid_iface(net_dev); 412 ret = batadv_is_valid_iface(net_dev);
411 if (ret != 1) 413 if (ret != 1)
412 goto out; 414 goto out;
413 415
@@ -429,7 +431,7 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
429 /* extra reference for return */ 431 /* extra reference for return */
430 atomic_set(&hard_iface->refcount, 2); 432 atomic_set(&hard_iface->refcount, 2);
431 433
432 check_known_mac_addr(hard_iface->net_dev); 434 batadv_check_known_mac_addr(hard_iface->net_dev);
433 list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list); 435 list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list);
434 436
435 /* This can't be called via a bat_priv callback because 437 /* This can't be called via a bat_priv callback because
@@ -448,7 +450,7 @@ out:
448 return NULL; 450 return NULL;
449} 451}
450 452
451static void hardif_remove_interface(struct hard_iface *hard_iface) 453static void batadv_hardif_remove_interface(struct hard_iface *hard_iface)
452{ 454{
453 ASSERT_RTNL(); 455 ASSERT_RTNL();
454 456
@@ -461,7 +463,7 @@ static void hardif_remove_interface(struct hard_iface *hard_iface)
461 463
462 hard_iface->if_status = IF_TO_BE_REMOVED; 464 hard_iface->if_status = IF_TO_BE_REMOVED;
463 batadv_sysfs_del_hardif(&hard_iface->hardif_obj); 465 batadv_sysfs_del_hardif(&hard_iface->hardif_obj);
464 hardif_free_ref(hard_iface); 466 batadv_hardif_free_ref(hard_iface);
465} 467}
466 468
467void batadv_hardif_remove_interfaces(void) 469void batadv_hardif_remove_interfaces(void)
@@ -472,13 +474,13 @@ void batadv_hardif_remove_interfaces(void)
472 list_for_each_entry_safe(hard_iface, hard_iface_tmp, 474 list_for_each_entry_safe(hard_iface, hard_iface_tmp,
473 &batadv_hardif_list, list) { 475 &batadv_hardif_list, list) {
474 list_del_rcu(&hard_iface->list); 476 list_del_rcu(&hard_iface->list);
475 hardif_remove_interface(hard_iface); 477 batadv_hardif_remove_interface(hard_iface);
476 } 478 }
477 rtnl_unlock(); 479 rtnl_unlock();
478} 480}
479 481
480static int hard_if_event(struct notifier_block *this, 482static int batadv_hard_if_event(struct notifier_block *this,
481 unsigned long event, void *ptr) 483 unsigned long event, void *ptr)
482{ 484{
483 struct net_device *net_dev = ptr; 485 struct net_device *net_dev = ptr;
484 struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev); 486 struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev);
@@ -486,23 +488,23 @@ static int hard_if_event(struct notifier_block *this,
486 struct bat_priv *bat_priv; 488 struct bat_priv *bat_priv;
487 489
488 if (!hard_iface && event == NETDEV_REGISTER) 490 if (!hard_iface && event == NETDEV_REGISTER)
489 hard_iface = hardif_add_interface(net_dev); 491 hard_iface = batadv_hardif_add_interface(net_dev);
490 492
491 if (!hard_iface) 493 if (!hard_iface)
492 goto out; 494 goto out;
493 495
494 switch (event) { 496 switch (event) {
495 case NETDEV_UP: 497 case NETDEV_UP:
496 hardif_activate_interface(hard_iface); 498 batadv_hardif_activate_interface(hard_iface);
497 break; 499 break;
498 case NETDEV_GOING_DOWN: 500 case NETDEV_GOING_DOWN:
499 case NETDEV_DOWN: 501 case NETDEV_DOWN:
500 hardif_deactivate_interface(hard_iface); 502 batadv_hardif_deactivate_interface(hard_iface);
501 break; 503 break;
502 case NETDEV_UNREGISTER: 504 case NETDEV_UNREGISTER:
503 list_del_rcu(&hard_iface->list); 505 list_del_rcu(&hard_iface->list);
504 506
505 hardif_remove_interface(hard_iface); 507 batadv_hardif_remove_interface(hard_iface);
506 break; 508 break;
507 case NETDEV_CHANGEMTU: 509 case NETDEV_CHANGEMTU:
508 if (hard_iface->soft_iface) 510 if (hard_iface->soft_iface)
@@ -512,27 +514,27 @@ static int hard_if_event(struct notifier_block *this,
512 if (hard_iface->if_status == IF_NOT_IN_USE) 514 if (hard_iface->if_status == IF_NOT_IN_USE)
513 goto hardif_put; 515 goto hardif_put;
514 516
515 check_known_mac_addr(hard_iface->net_dev); 517 batadv_check_known_mac_addr(hard_iface->net_dev);
516 518
517 bat_priv = netdev_priv(hard_iface->soft_iface); 519 bat_priv = netdev_priv(hard_iface->soft_iface);
518 bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface); 520 bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface);
519 521
520 primary_if = primary_if_get_selected(bat_priv); 522 primary_if = batadv_primary_if_get_selected(bat_priv);
521 if (!primary_if) 523 if (!primary_if)
522 goto hardif_put; 524 goto hardif_put;
523 525
524 if (hard_iface == primary_if) 526 if (hard_iface == primary_if)
525 primary_if_update_addr(bat_priv, NULL); 527 batadv_primary_if_update_addr(bat_priv, NULL);
526 break; 528 break;
527 default: 529 default:
528 break; 530 break;
529 } 531 }
530 532
531hardif_put: 533hardif_put:
532 hardif_free_ref(hard_iface); 534 batadv_hardif_free_ref(hard_iface);
533out: 535out:
534 if (primary_if) 536 if (primary_if)
535 hardif_free_ref(primary_if); 537 batadv_hardif_free_ref(primary_if);
536 return NOTIFY_DONE; 538 return NOTIFY_DONE;
537} 539}
538 540
@@ -569,5 +571,5 @@ out:
569} 571}
570 572
571struct notifier_block batadv_hard_if_notifier = { 573struct notifier_block batadv_hard_if_notifier = {
572 .notifier_call = hard_if_event, 574 .notifier_call = batadv_hard_if_event,
573}; 575};
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index 6bc12c0eb2f0..d66dabd620b7 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -42,14 +42,15 @@ void batadv_update_min_mtu(struct net_device *soft_iface);
42void batadv_hardif_free_rcu(struct rcu_head *rcu); 42void batadv_hardif_free_rcu(struct rcu_head *rcu);
43bool batadv_is_wifi_iface(int ifindex); 43bool batadv_is_wifi_iface(int ifindex);
44 44
45static inline void hardif_free_ref(struct hard_iface *hard_iface) 45static inline void
46batadv_hardif_free_ref(struct hard_iface *hard_iface)
46{ 47{
47 if (atomic_dec_and_test(&hard_iface->refcount)) 48 if (atomic_dec_and_test(&hard_iface->refcount))
48 call_rcu(&hard_iface->rcu, batadv_hardif_free_rcu); 49 call_rcu(&hard_iface->rcu, batadv_hardif_free_rcu);
49} 50}
50 51
51static inline struct hard_iface *primary_if_get_selected( 52static inline struct hard_iface *
52 struct bat_priv *bat_priv) 53batadv_primary_if_get_selected(struct bat_priv *bat_priv)
53{ 54{
54 struct hard_iface *hard_iface; 55 struct hard_iface *hard_iface;
55 56
diff --git a/net/batman-adv/hash.c b/net/batman-adv/hash.c
index e39f8f4bb165..1fb961c8d9a0 100644
--- a/net/batman-adv/hash.c
+++ b/net/batman-adv/hash.c
@@ -21,7 +21,7 @@
21#include "hash.h" 21#include "hash.h"
22 22
23/* clears the hash */ 23/* clears the hash */
24static void hash_init(struct hashtable_t *hash) 24static void batadv_hash_init(struct hashtable_t *hash)
25{ 25{
26 uint32_t i; 26 uint32_t i;
27 27
@@ -58,7 +58,7 @@ struct hashtable_t *batadv_hash_new(uint32_t size)
58 goto free_table; 58 goto free_table;
59 59
60 hash->size = size; 60 hash->size = size;
61 hash_init(hash); 61 batadv_hash_init(hash);
62 return hash; 62 return hash;
63 63
64free_table: 64free_table:
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h
index eba8f2a55ccc..7ec4e5b0bd41 100644
--- a/net/batman-adv/hash.h
+++ b/net/batman-adv/hash.h
@@ -54,8 +54,8 @@ void batadv_hash_destroy(struct hashtable_t *hash);
54 * 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
55 * elements, memory might be leaked. 55 * elements, memory might be leaked.
56 */ 56 */
57static inline void hash_delete(struct hashtable_t *hash, 57static inline void batadv_hash_delete(struct hashtable_t *hash,
58 hashdata_free_cb free_cb, void *arg) 58 hashdata_free_cb free_cb, void *arg)
59{ 59{
60 struct hlist_head *head; 60 struct hlist_head *head;
61 struct hlist_node *node, *node_tmp; 61 struct hlist_node *node, *node_tmp;
@@ -89,10 +89,11 @@ static inline void hash_delete(struct hashtable_t *hash,
89 * 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
90 * and -1 on error. 90 * and -1 on error.
91 */ 91 */
92static inline int hash_add(struct hashtable_t *hash, 92static inline int batadv_hash_add(struct hashtable_t *hash,
93 hashdata_compare_cb compare, 93 hashdata_compare_cb compare,
94 hashdata_choose_cb choose, 94 hashdata_choose_cb choose,
95 const void *data, struct hlist_node *data_node) 95 const void *data,
96 struct hlist_node *data_node)
96{ 97{
97 uint32_t index; 98 uint32_t index;
98 int ret = -1; 99 int ret = -1;
@@ -133,9 +134,9 @@ out:
133 * structure you use with just the key filled, we just need the key for 134 * structure you use with just the key filled, we just need the key for
134 * comparing. 135 * comparing.
135 */ 136 */
136static inline void *hash_remove(struct hashtable_t *hash, 137static inline void *batadv_hash_remove(struct hashtable_t *hash,
137 hashdata_compare_cb compare, 138 hashdata_compare_cb compare,
138 hashdata_choose_cb choose, void *data) 139 hashdata_choose_cb choose, void *data)
139{ 140{
140 uint32_t index; 141 uint32_t index;
141 struct hlist_node *node; 142 struct hlist_node *node;
diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c
index 40c5e189e6fd..b285c31bfa9e 100644
--- a/net/batman-adv/icmp_socket.c
+++ b/net/batman-adv/icmp_socket.c
@@ -26,18 +26,18 @@
26#include "originator.h" 26#include "originator.h"
27#include "hard-interface.h" 27#include "hard-interface.h"
28 28
29static struct socket_client *socket_client_hash[256]; 29static struct socket_client *batadv_socket_client_hash[256];
30 30
31static void bat_socket_add_packet(struct socket_client *socket_client, 31static void batadv_socket_add_packet(struct socket_client *socket_client,
32 struct icmp_packet_rr *icmp_packet, 32 struct icmp_packet_rr *icmp_packet,
33 size_t icmp_len); 33 size_t icmp_len);
34 34
35void batadv_socket_init(void) 35void batadv_socket_init(void)
36{ 36{
37 memset(socket_client_hash, 0, sizeof(socket_client_hash)); 37 memset(batadv_socket_client_hash, 0, sizeof(batadv_socket_client_hash));
38} 38}
39 39
40static int bat_socket_open(struct inode *inode, struct file *file) 40static int batadv_socket_open(struct inode *inode, struct file *file)
41{ 41{
42 unsigned int i; 42 unsigned int i;
43 struct socket_client *socket_client; 43 struct socket_client *socket_client;
@@ -49,14 +49,14 @@ static int bat_socket_open(struct inode *inode, struct file *file)
49 if (!socket_client) 49 if (!socket_client)
50 return -ENOMEM; 50 return -ENOMEM;
51 51
52 for (i = 0; i < ARRAY_SIZE(socket_client_hash); i++) { 52 for (i = 0; i < ARRAY_SIZE(batadv_socket_client_hash); i++) {
53 if (!socket_client_hash[i]) { 53 if (!batadv_socket_client_hash[i]) {
54 socket_client_hash[i] = socket_client; 54 batadv_socket_client_hash[i] = socket_client;
55 break; 55 break;
56 } 56 }
57 } 57 }
58 58
59 if (i == ARRAY_SIZE(socket_client_hash)) { 59 if (i == ARRAY_SIZE(batadv_socket_client_hash)) {
60 pr_err("Error - can't add another packet client: maximum number of clients reached\n"); 60 pr_err("Error - can't add another packet client: maximum number of clients reached\n");
61 kfree(socket_client); 61 kfree(socket_client);
62 return -EXFULL; 62 return -EXFULL;
@@ -75,7 +75,7 @@ static int bat_socket_open(struct inode *inode, struct file *file)
75 return 0; 75 return 0;
76} 76}
77 77
78static int bat_socket_release(struct inode *inode, struct file *file) 78static int batadv_socket_release(struct inode *inode, struct file *file)
79{ 79{
80 struct socket_client *socket_client = file->private_data; 80 struct socket_client *socket_client = file->private_data;
81 struct socket_packet *socket_packet; 81 struct socket_packet *socket_packet;
@@ -92,7 +92,7 @@ static int bat_socket_release(struct inode *inode, struct file *file)
92 kfree(socket_packet); 92 kfree(socket_packet);
93 } 93 }
94 94
95 socket_client_hash[socket_client->index] = NULL; 95 batadv_socket_client_hash[socket_client->index] = NULL;
96 spin_unlock_bh(&socket_client->lock); 96 spin_unlock_bh(&socket_client->lock);
97 97
98 kfree(socket_client); 98 kfree(socket_client);
@@ -101,8 +101,8 @@ static int bat_socket_release(struct inode *inode, struct file *file)
101 return 0; 101 return 0;
102} 102}
103 103
104static ssize_t bat_socket_read(struct file *file, char __user *buf, 104static ssize_t batadv_socket_read(struct file *file, char __user *buf,
105 size_t count, loff_t *ppos) 105 size_t count, loff_t *ppos)
106{ 106{
107 struct socket_client *socket_client = file->private_data; 107 struct socket_client *socket_client = file->private_data;
108 struct socket_packet *socket_packet; 108 struct socket_packet *socket_packet;
@@ -144,8 +144,8 @@ static ssize_t bat_socket_read(struct file *file, char __user *buf,
144 return packet_len; 144 return packet_len;
145} 145}
146 146
147static ssize_t bat_socket_write(struct file *file, const char __user *buff, 147static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
148 size_t len, loff_t *off) 148 size_t len, loff_t *off)
149{ 149{
150 struct socket_client *socket_client = file->private_data; 150 struct socket_client *socket_client = file->private_data;
151 struct bat_priv *bat_priv = socket_client->bat_priv; 151 struct bat_priv *bat_priv = socket_client->bat_priv;
@@ -158,12 +158,12 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
158 size_t packet_len = sizeof(struct icmp_packet); 158 size_t packet_len = sizeof(struct icmp_packet);
159 159
160 if (len < sizeof(struct icmp_packet)) { 160 if (len < sizeof(struct icmp_packet)) {
161 bat_dbg(DBG_BATMAN, bat_priv, 161 batadv_dbg(DBG_BATMAN, bat_priv,
162 "Error - can't send packet from char device: invalid packet size\n"); 162 "Error - can't send packet from char device: invalid packet size\n");
163 return -EINVAL; 163 return -EINVAL;
164 } 164 }
165 165
166 primary_if = primary_if_get_selected(bat_priv); 166 primary_if = batadv_primary_if_get_selected(bat_priv);
167 167
168 if (!primary_if) { 168 if (!primary_if) {
169 len = -EFAULT; 169 len = -EFAULT;
@@ -188,15 +188,15 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
188 } 188 }
189 189
190 if (icmp_packet->header.packet_type != BAT_ICMP) { 190 if (icmp_packet->header.packet_type != BAT_ICMP) {
191 bat_dbg(DBG_BATMAN, bat_priv, 191 batadv_dbg(DBG_BATMAN, bat_priv,
192 "Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n"); 192 "Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n");
193 len = -EINVAL; 193 len = -EINVAL;
194 goto free_skb; 194 goto free_skb;
195 } 195 }
196 196
197 if (icmp_packet->msg_type != ECHO_REQUEST) { 197 if (icmp_packet->msg_type != ECHO_REQUEST) {
198 bat_dbg(DBG_BATMAN, bat_priv, 198 batadv_dbg(DBG_BATMAN, bat_priv,
199 "Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n"); 199 "Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n");
200 len = -EINVAL; 200 len = -EINVAL;
201 goto free_skb; 201 goto free_skb;
202 } 202 }
@@ -206,14 +206,15 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
206 if (icmp_packet->header.version != COMPAT_VERSION) { 206 if (icmp_packet->header.version != COMPAT_VERSION) {
207 icmp_packet->msg_type = PARAMETER_PROBLEM; 207 icmp_packet->msg_type = PARAMETER_PROBLEM;
208 icmp_packet->header.version = COMPAT_VERSION; 208 icmp_packet->header.version = COMPAT_VERSION;
209 bat_socket_add_packet(socket_client, icmp_packet, packet_len); 209 batadv_socket_add_packet(socket_client, icmp_packet,
210 packet_len);
210 goto free_skb; 211 goto free_skb;
211 } 212 }
212 213
213 if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE) 214 if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE)
214 goto dst_unreach; 215 goto dst_unreach;
215 216
216 orig_node = orig_hash_find(bat_priv, icmp_packet->dst); 217 orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->dst);
217 if (!orig_node) 218 if (!orig_node)
218 goto dst_unreach; 219 goto dst_unreach;
219 220
@@ -239,12 +240,12 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
239 240
240dst_unreach: 241dst_unreach:
241 icmp_packet->msg_type = DESTINATION_UNREACHABLE; 242 icmp_packet->msg_type = DESTINATION_UNREACHABLE;
242 bat_socket_add_packet(socket_client, icmp_packet, packet_len); 243 batadv_socket_add_packet(socket_client, icmp_packet, packet_len);
243free_skb: 244free_skb:
244 kfree_skb(skb); 245 kfree_skb(skb);
245out: 246out:
246 if (primary_if) 247 if (primary_if)
247 hardif_free_ref(primary_if); 248 batadv_hardif_free_ref(primary_if);
248 if (neigh_node) 249 if (neigh_node)
249 batadv_neigh_node_free_ref(neigh_node); 250 batadv_neigh_node_free_ref(neigh_node);
250 if (orig_node) 251 if (orig_node)
@@ -252,7 +253,7 @@ out:
252 return len; 253 return len;
253} 254}
254 255
255static unsigned int bat_socket_poll(struct file *file, poll_table *wait) 256static unsigned int batadv_socket_poll(struct file *file, poll_table *wait)
256{ 257{
257 struct socket_client *socket_client = file->private_data; 258 struct socket_client *socket_client = file->private_data;
258 259
@@ -264,13 +265,13 @@ static unsigned int bat_socket_poll(struct file *file, poll_table *wait)
264 return 0; 265 return 0;
265} 266}
266 267
267static const struct file_operations fops = { 268static const struct file_operations batadv_fops = {
268 .owner = THIS_MODULE, 269 .owner = THIS_MODULE,
269 .open = bat_socket_open, 270 .open = batadv_socket_open,
270 .release = bat_socket_release, 271 .release = batadv_socket_release,
271 .read = bat_socket_read, 272 .read = batadv_socket_read,
272 .write = bat_socket_write, 273 .write = batadv_socket_write,
273 .poll = bat_socket_poll, 274 .poll = batadv_socket_poll,
274 .llseek = no_llseek, 275 .llseek = no_llseek,
275}; 276};
276 277
@@ -282,7 +283,7 @@ int batadv_socket_setup(struct bat_priv *bat_priv)
282 goto err; 283 goto err;
283 284
284 d = debugfs_create_file(ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR, 285 d = debugfs_create_file(ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR,
285 bat_priv->debug_dir, bat_priv, &fops); 286 bat_priv->debug_dir, bat_priv, &batadv_fops);
286 if (!d) 287 if (!d)
287 goto err; 288 goto err;
288 289
@@ -292,9 +293,9 @@ err:
292 return -ENOMEM; 293 return -ENOMEM;
293} 294}
294 295
295static void bat_socket_add_packet(struct socket_client *socket_client, 296static void batadv_socket_add_packet(struct socket_client *socket_client,
296 struct icmp_packet_rr *icmp_packet, 297 struct icmp_packet_rr *icmp_packet,
297 size_t icmp_len) 298 size_t icmp_len)
298{ 299{
299 struct socket_packet *socket_packet; 300 struct socket_packet *socket_packet;
300 301
@@ -312,7 +313,7 @@ static void bat_socket_add_packet(struct socket_client *socket_client,
312 /* while waiting for the lock the socket_client could have been 313 /* while waiting for the lock the socket_client could have been
313 * deleted 314 * deleted
314 */ 315 */
315 if (!socket_client_hash[icmp_packet->uid]) { 316 if (!batadv_socket_client_hash[icmp_packet->uid]) {
316 spin_unlock_bh(&socket_client->lock); 317 spin_unlock_bh(&socket_client->lock);
317 kfree(socket_packet); 318 kfree(socket_packet);
318 return; 319 return;
@@ -338,8 +339,9 @@ static void bat_socket_add_packet(struct socket_client *socket_client,
338void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet, 339void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet,
339 size_t icmp_len) 340 size_t icmp_len)
340{ 341{
341 struct socket_client *hash = socket_client_hash[icmp_packet->uid]; 342 struct socket_client *hash;
342 343
344 hash = batadv_socket_client_hash[icmp_packet->uid];
343 if (hash) 345 if (hash)
344 bat_socket_add_packet(hash, icmp_packet, icmp_len); 346 batadv_socket_add_packet(hash, icmp_packet, icmp_len);
345} 347}
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index d56d6b2e1924..e4564306453c 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -180,7 +180,7 @@ int batadv_is_my_mac(const uint8_t *addr)
180 if (hard_iface->if_status != IF_ACTIVE) 180 if (hard_iface->if_status != IF_ACTIVE)
181 continue; 181 continue;
182 182
183 if (compare_eth(hard_iface->net_dev->dev_addr, addr)) { 183 if (batadv_compare_eth(hard_iface->net_dev->dev_addr, addr)) {
184 rcu_read_unlock(); 184 rcu_read_unlock();
185 return 1; 185 return 1;
186 } 186 }
@@ -238,9 +238,9 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
238 batman_ogm_packet = (struct batman_ogm_packet *)skb->data; 238 batman_ogm_packet = (struct batman_ogm_packet *)skb->data;
239 239
240 if (batman_ogm_packet->header.version != COMPAT_VERSION) { 240 if (batman_ogm_packet->header.version != COMPAT_VERSION) {
241 bat_dbg(DBG_BATMAN, bat_priv, 241 batadv_dbg(DBG_BATMAN, bat_priv,
242 "Drop packet: incompatible batman version (%i)\n", 242 "Drop packet: incompatible batman version (%i)\n",
243 batman_ogm_packet->header.version); 243 batman_ogm_packet->header.version);
244 goto err_free; 244 goto err_free;
245 } 245 }
246 246
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 4b06b7621e7a..28242642c3f1 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -175,7 +175,7 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset);
175int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...) 175int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...)
176__printf(2, 3); 176__printf(2, 3);
177 177
178#define bat_dbg(type, bat_priv, fmt, arg...) \ 178#define batadv_dbg(type, bat_priv, fmt, arg...) \
179 do { \ 179 do { \
180 if (atomic_read(&bat_priv->log_level) & type) \ 180 if (atomic_read(&bat_priv->log_level) & type) \
181 batadv_debug_log(bat_priv, fmt, ## arg);\ 181 batadv_debug_log(bat_priv, fmt, ## arg);\
@@ -183,9 +183,9 @@ __printf(2, 3);
183 while (0) 183 while (0)
184#else /* !CONFIG_BATMAN_ADV_DEBUG */ 184#else /* !CONFIG_BATMAN_ADV_DEBUG */
185__printf(3, 4) 185__printf(3, 4)
186static inline void bat_dbg(int type __always_unused, 186static inline void batadv_dbg(int type __always_unused,
187 struct bat_priv *bat_priv __always_unused, 187 struct bat_priv *bat_priv __always_unused,
188 const char *fmt __always_unused, ...) 188 const char *fmt __always_unused, ...)
189{ 189{
190} 190}
191#endif 191#endif
@@ -194,14 +194,14 @@ static inline void bat_dbg(int type __always_unused,
194 do { \ 194 do { \
195 struct net_device *_netdev = (net_dev); \ 195 struct net_device *_netdev = (net_dev); \
196 struct bat_priv *_batpriv = netdev_priv(_netdev); \ 196 struct bat_priv *_batpriv = netdev_priv(_netdev); \
197 bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ 197 batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
198 pr_info("%s: " fmt, _netdev->name, ## arg); \ 198 pr_info("%s: " fmt, _netdev->name, ## arg); \
199 } while (0) 199 } while (0)
200#define bat_err(net_dev, fmt, arg...) \ 200#define bat_err(net_dev, fmt, arg...) \
201 do { \ 201 do { \
202 struct net_device *_netdev = (net_dev); \ 202 struct net_device *_netdev = (net_dev); \
203 struct bat_priv *_batpriv = netdev_priv(_netdev); \ 203 struct bat_priv *_batpriv = netdev_priv(_netdev); \
204 bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ 204 batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
205 pr_err("%s: " fmt, _netdev->name, ## arg); \ 205 pr_err("%s: " fmt, _netdev->name, ## arg); \
206 } while (0) 206 } while (0)
207 207
@@ -209,7 +209,7 @@ static inline void bat_dbg(int type __always_unused,
209 * 209 *
210 * 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
211 */ 211 */
212static inline int compare_eth(const void *data1, const void *data2) 212static inline int batadv_compare_eth(const void *data1, const void *data2)
213{ 213{
214 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); 214 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
215} 215}
@@ -220,7 +220,8 @@ static inline int compare_eth(const void *data1, const void *data2)
220 * 220 *
221 * Returns true if current time is after timestamp + timeout 221 * Returns true if current time is after timestamp + timeout
222 */ 222 */
223static inline bool has_timed_out(unsigned long timestamp, unsigned int timeout) 223static inline bool batadv_has_timed_out(unsigned long timestamp,
224 unsigned int timeout)
224{ 225{
225 return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout)); 226 return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout));
226} 227}
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 86e7e082c2bc..bf9ec39a8349 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -28,17 +28,17 @@
28#include "soft-interface.h" 28#include "soft-interface.h"
29#include "bridge_loop_avoidance.h" 29#include "bridge_loop_avoidance.h"
30 30
31static void purge_orig(struct work_struct *work); 31static void batadv_purge_orig(struct work_struct *work);
32 32
33static void start_purge_timer(struct bat_priv *bat_priv) 33static void batadv_start_purge_timer(struct bat_priv *bat_priv)
34{ 34{
35 INIT_DELAYED_WORK(&bat_priv->orig_work, purge_orig); 35 INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig);
36 queue_delayed_work(batadv_event_workqueue, 36 queue_delayed_work(batadv_event_workqueue,
37 &bat_priv->orig_work, msecs_to_jiffies(1000)); 37 &bat_priv->orig_work, msecs_to_jiffies(1000));
38} 38}
39 39
40/* returns 1 if they are the same originator */ 40/* returns 1 if they are the same originator */
41static int compare_orig(const struct hlist_node *node, const void *data2) 41static int batadv_compare_orig(const struct hlist_node *node, const void *data2)
42{ 42{
43 const void *data1 = container_of(node, struct orig_node, hash_entry); 43 const void *data1 = container_of(node, struct orig_node, hash_entry);
44 44
@@ -55,7 +55,7 @@ int batadv_originator_init(struct bat_priv *bat_priv)
55 if (!bat_priv->orig_hash) 55 if (!bat_priv->orig_hash)
56 goto err; 56 goto err;
57 57
58 start_purge_timer(bat_priv); 58 batadv_start_purge_timer(bat_priv);
59 return 0; 59 return 0;
60 60
61err: 61err:
@@ -102,15 +102,15 @@ struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface,
102 /* extra reference for return */ 102 /* extra reference for return */
103 atomic_set(&neigh_node->refcount, 2); 103 atomic_set(&neigh_node->refcount, 2);
104 104
105 bat_dbg(DBG_BATMAN, bat_priv, 105 batadv_dbg(DBG_BATMAN, bat_priv,
106 "Creating new neighbor %pM, initial seqno %d\n", 106 "Creating new neighbor %pM, initial seqno %d\n",
107 neigh_addr, seqno); 107 neigh_addr, seqno);
108 108
109out: 109out:
110 return neigh_node; 110 return neigh_node;
111} 111}
112 112
113static void orig_node_free_rcu(struct rcu_head *rcu) 113static void batadv_orig_node_free_rcu(struct rcu_head *rcu)
114{ 114{
115 struct hlist_node *node, *node_tmp; 115 struct hlist_node *node, *node_tmp;
116 struct neigh_node *neigh_node, *tmp_neigh_node; 116 struct neigh_node *neigh_node, *tmp_neigh_node;
@@ -149,7 +149,7 @@ static void orig_node_free_rcu(struct rcu_head *rcu)
149void batadv_orig_node_free_ref(struct orig_node *orig_node) 149void batadv_orig_node_free_ref(struct orig_node *orig_node)
150{ 150{
151 if (atomic_dec_and_test(&orig_node->refcount)) 151 if (atomic_dec_and_test(&orig_node->refcount))
152 call_rcu(&orig_node->rcu, orig_node_free_rcu); 152 call_rcu(&orig_node->rcu, batadv_orig_node_free_rcu);
153} 153}
154 154
155void batadv_originator_free(struct bat_priv *bat_priv) 155void batadv_originator_free(struct bat_priv *bat_priv)
@@ -195,12 +195,12 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
195 int size; 195 int size;
196 int hash_added; 196 int hash_added;
197 197
198 orig_node = orig_hash_find(bat_priv, addr); 198 orig_node = batadv_orig_hash_find(bat_priv, addr);
199 if (orig_node) 199 if (orig_node)
200 return orig_node; 200 return orig_node;
201 201
202 bat_dbg(DBG_BATMAN, bat_priv, 202 batadv_dbg(DBG_BATMAN, bat_priv, "Creating new originator: %pM\n",
203 "Creating new originator: %pM\n", addr); 203 addr);
204 204
205 orig_node = kzalloc(sizeof(*orig_node), GFP_ATOMIC); 205 orig_node = kzalloc(sizeof(*orig_node), GFP_ATOMIC);
206 if (!orig_node) 206 if (!orig_node)
@@ -248,8 +248,9 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv,
248 if (!orig_node->bcast_own_sum) 248 if (!orig_node->bcast_own_sum)
249 goto free_bcast_own; 249 goto free_bcast_own;
250 250
251 hash_added = hash_add(bat_priv->orig_hash, compare_orig, 251 hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig,
252 choose_orig, orig_node, &orig_node->hash_entry); 252 batadv_choose_orig, orig_node,
253 &orig_node->hash_entry);
253 if (hash_added != 0) 254 if (hash_added != 0)
254 goto free_bcast_own_sum; 255 goto free_bcast_own_sum;
255 256
@@ -263,14 +264,15 @@ free_orig_node:
263 return NULL; 264 return NULL;
264} 265}
265 266
266static bool purge_orig_neighbors(struct bat_priv *bat_priv, 267static bool batadv_purge_orig_neighbors(struct bat_priv *bat_priv,
267 struct orig_node *orig_node, 268 struct orig_node *orig_node,
268 struct neigh_node **best_neigh_node) 269 struct neigh_node **best_neigh_node)
269{ 270{
270 struct hlist_node *node, *node_tmp; 271 struct hlist_node *node, *node_tmp;
271 struct neigh_node *neigh_node; 272 struct neigh_node *neigh_node;
272 bool neigh_purged = false; 273 bool neigh_purged = false;
273 unsigned long last_seen; 274 unsigned long last_seen;
275 struct hard_iface *if_incoming;
274 276
275 *best_neigh_node = NULL; 277 *best_neigh_node = NULL;
276 278
@@ -280,28 +282,26 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv,
280 hlist_for_each_entry_safe(neigh_node, node, node_tmp, 282 hlist_for_each_entry_safe(neigh_node, node, node_tmp,
281 &orig_node->neigh_list, list) { 283 &orig_node->neigh_list, list) {
282 284
283 if ((has_timed_out(neigh_node->last_seen, PURGE_TIMEOUT)) || 285 last_seen = neigh_node->last_seen;
284 (neigh_node->if_incoming->if_status == IF_INACTIVE) || 286 if_incoming = neigh_node->if_incoming;
285 (neigh_node->if_incoming->if_status == IF_NOT_IN_USE) || 287
286 (neigh_node->if_incoming->if_status == IF_TO_BE_REMOVED)) { 288 if ((batadv_has_timed_out(last_seen, PURGE_TIMEOUT)) ||
287 289 (if_incoming->if_status == IF_INACTIVE) ||
288 last_seen = neigh_node->last_seen; 290 (if_incoming->if_status == IF_NOT_IN_USE) ||
289 291 (if_incoming->if_status == IF_TO_BE_REMOVED)) {
290 if ((neigh_node->if_incoming->if_status == 292
291 IF_INACTIVE) || 293 if ((if_incoming->if_status == IF_INACTIVE) ||
292 (neigh_node->if_incoming->if_status == 294 (if_incoming->if_status == IF_NOT_IN_USE) ||
293 IF_NOT_IN_USE) || 295 (if_incoming->if_status == IF_TO_BE_REMOVED))
294 (neigh_node->if_incoming->if_status == 296 batadv_dbg(DBG_BATMAN, bat_priv,
295 IF_TO_BE_REMOVED)) 297 "neighbor purge: originator %pM, neighbor: %pM, iface: %s\n",
296 bat_dbg(DBG_BATMAN, bat_priv, 298 orig_node->orig, neigh_node->addr,
297 "neighbor purge: originator %pM, neighbor: %pM, iface: %s\n", 299 if_incoming->net_dev->name);
298 orig_node->orig, neigh_node->addr,
299 neigh_node->if_incoming->net_dev->name);
300 else 300 else
301 bat_dbg(DBG_BATMAN, bat_priv, 301 batadv_dbg(DBG_BATMAN, bat_priv,
302 "neighbor timeout: originator %pM, neighbor: %pM, last_seen: %u\n", 302 "neighbor timeout: originator %pM, neighbor: %pM, last_seen: %u\n",
303 orig_node->orig, neigh_node->addr, 303 orig_node->orig, neigh_node->addr,
304 jiffies_to_msecs(last_seen)); 304 jiffies_to_msecs(last_seen));
305 305
306 neigh_purged = true; 306 neigh_purged = true;
307 307
@@ -319,20 +319,20 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv,
319 return neigh_purged; 319 return neigh_purged;
320} 320}
321 321
322static bool purge_orig_node(struct bat_priv *bat_priv, 322static bool batadv_purge_orig_node(struct bat_priv *bat_priv,
323 struct orig_node *orig_node) 323 struct orig_node *orig_node)
324{ 324{
325 struct neigh_node *best_neigh_node; 325 struct neigh_node *best_neigh_node;
326 326
327 if (has_timed_out(orig_node->last_seen, 2 * PURGE_TIMEOUT)) { 327 if (batadv_has_timed_out(orig_node->last_seen, 2 * PURGE_TIMEOUT)) {
328 bat_dbg(DBG_BATMAN, bat_priv, 328 batadv_dbg(DBG_BATMAN, bat_priv,
329 "Originator timeout: originator %pM, last_seen %u\n", 329 "Originator timeout: originator %pM, last_seen %u\n",
330 orig_node->orig, 330 orig_node->orig,
331 jiffies_to_msecs(orig_node->last_seen)); 331 jiffies_to_msecs(orig_node->last_seen));
332 return true; 332 return true;
333 } else { 333 } else {
334 if (purge_orig_neighbors(bat_priv, orig_node, 334 if (batadv_purge_orig_neighbors(bat_priv, orig_node,
335 &best_neigh_node)) 335 &best_neigh_node))
336 batadv_update_route(bat_priv, orig_node, 336 batadv_update_route(bat_priv, orig_node,
337 best_neigh_node); 337 best_neigh_node);
338 } 338 }
@@ -340,7 +340,7 @@ static bool purge_orig_node(struct bat_priv *bat_priv,
340 return false; 340 return false;
341} 341}
342 342
343static void _purge_orig(struct bat_priv *bat_priv) 343static void _batadv_purge_orig(struct bat_priv *bat_priv)
344{ 344{
345 struct hashtable_t *hash = bat_priv->orig_hash; 345 struct hashtable_t *hash = bat_priv->orig_hash;
346 struct hlist_node *node, *node_tmp; 346 struct hlist_node *node, *node_tmp;
@@ -360,7 +360,7 @@ static void _purge_orig(struct bat_priv *bat_priv)
360 spin_lock_bh(list_lock); 360 spin_lock_bh(list_lock);
361 hlist_for_each_entry_safe(orig_node, node, node_tmp, 361 hlist_for_each_entry_safe(orig_node, node, node_tmp,
362 head, hash_entry) { 362 head, hash_entry) {
363 if (purge_orig_node(bat_priv, orig_node)) { 363 if (batadv_purge_orig_node(bat_priv, orig_node)) {
364 if (orig_node->gw_flags) 364 if (orig_node->gw_flags)
365 batadv_gw_node_delete(bat_priv, 365 batadv_gw_node_delete(bat_priv,
366 orig_node); 366 orig_node);
@@ -369,8 +369,8 @@ static void _purge_orig(struct bat_priv *bat_priv)
369 continue; 369 continue;
370 } 370 }
371 371
372 if (has_timed_out(orig_node->last_frag_packet, 372 if (batadv_has_timed_out(orig_node->last_frag_packet,
373 FRAG_TIMEOUT)) 373 FRAG_TIMEOUT))
374 batadv_frag_list_free(&orig_node->frag_list); 374 batadv_frag_list_free(&orig_node->frag_list);
375 } 375 }
376 spin_unlock_bh(list_lock); 376 spin_unlock_bh(list_lock);
@@ -380,20 +380,20 @@ static void _purge_orig(struct bat_priv *bat_priv)
380 batadv_gw_election(bat_priv); 380 batadv_gw_election(bat_priv);
381} 381}
382 382
383static void purge_orig(struct work_struct *work) 383static void batadv_purge_orig(struct work_struct *work)
384{ 384{
385 struct delayed_work *delayed_work = 385 struct delayed_work *delayed_work =
386 container_of(work, struct delayed_work, work); 386 container_of(work, struct delayed_work, work);
387 struct bat_priv *bat_priv = 387 struct bat_priv *bat_priv =
388 container_of(delayed_work, struct bat_priv, orig_work); 388 container_of(delayed_work, struct bat_priv, orig_work);
389 389
390 _purge_orig(bat_priv); 390 _batadv_purge_orig(bat_priv);
391 start_purge_timer(bat_priv); 391 batadv_start_purge_timer(bat_priv);
392} 392}
393 393
394void batadv_purge_orig_ref(struct bat_priv *bat_priv) 394void batadv_purge_orig_ref(struct bat_priv *bat_priv)
395{ 395{
396 _purge_orig(bat_priv); 396 _batadv_purge_orig(bat_priv);
397} 397}
398 398
399int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) 399int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
@@ -412,7 +412,7 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
412 uint32_t i; 412 uint32_t i;
413 int ret = 0; 413 int ret = 0;
414 414
415 primary_if = primary_if_get_selected(bat_priv); 415 primary_if = batadv_primary_if_get_selected(bat_priv);
416 416
417 if (!primary_if) { 417 if (!primary_if) {
418 ret = seq_printf(seq, 418 ret = seq_printf(seq,
@@ -479,11 +479,11 @@ next:
479 479
480out: 480out:
481 if (primary_if) 481 if (primary_if)
482 hardif_free_ref(primary_if); 482 batadv_hardif_free_ref(primary_if);
483 return ret; 483 return ret;
484} 484}
485 485
486static int orig_node_add_if(struct orig_node *orig_node, int max_if_num) 486static int batadv_orig_node_add_if(struct orig_node *orig_node, int max_if_num)
487{ 487{
488 void *data_ptr; 488 void *data_ptr;
489 489
@@ -528,7 +528,7 @@ int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num)
528 rcu_read_lock(); 528 rcu_read_lock();
529 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { 529 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
530 spin_lock_bh(&orig_node->ogm_cnt_lock); 530 spin_lock_bh(&orig_node->ogm_cnt_lock);
531 ret = orig_node_add_if(orig_node, max_if_num); 531 ret = batadv_orig_node_add_if(orig_node, max_if_num);
532 spin_unlock_bh(&orig_node->ogm_cnt_lock); 532 spin_unlock_bh(&orig_node->ogm_cnt_lock);
533 533
534 if (ret == -ENOMEM) 534 if (ret == -ENOMEM)
@@ -544,8 +544,8 @@ err:
544 return -ENOMEM; 544 return -ENOMEM;
545} 545}
546 546
547static int orig_node_del_if(struct orig_node *orig_node, 547static int batadv_orig_node_del_if(struct orig_node *orig_node,
548 int max_if_num, int del_if_num) 548 int max_if_num, int del_if_num)
549{ 549{
550 void *data_ptr = NULL; 550 void *data_ptr = NULL;
551 int chunk_size; 551 int chunk_size;
@@ -612,8 +612,8 @@ int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num)
612 rcu_read_lock(); 612 rcu_read_lock();
613 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { 613 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
614 spin_lock_bh(&orig_node->ogm_cnt_lock); 614 spin_lock_bh(&orig_node->ogm_cnt_lock);
615 ret = orig_node_del_if(orig_node, max_if_num, 615 ret = batadv_orig_node_del_if(orig_node, max_if_num,
616 hard_iface->if_num); 616 hard_iface->if_num);
617 spin_unlock_bh(&orig_node->ogm_cnt_lock); 617 spin_unlock_bh(&orig_node->ogm_cnt_lock);
618 618
619 if (ret == -ENOMEM) 619 if (ret == -ENOMEM)
diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h
index a72171997056..35f67eb4073f 100644
--- a/net/batman-adv/originator.h
+++ b/net/batman-adv/originator.h
@@ -41,7 +41,7 @@ int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num);
41/* 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
42 * hash algorithm from http://en.wikipedia.org/wiki/Hash_table 42 * hash algorithm from http://en.wikipedia.org/wiki/Hash_table
43 */ 43 */
44static inline uint32_t choose_orig(const void *data, uint32_t size) 44static inline uint32_t batadv_choose_orig(const void *data, uint32_t size)
45{ 45{
46 const unsigned char *key = data; 46 const unsigned char *key = data;
47 uint32_t hash = 0; 47 uint32_t hash = 0;
@@ -60,8 +60,8 @@ static inline uint32_t choose_orig(const void *data, uint32_t size)
60 return hash % size; 60 return hash % size;
61} 61}
62 62
63static inline struct orig_node *orig_hash_find(struct bat_priv *bat_priv, 63static inline struct orig_node *batadv_orig_hash_find(struct bat_priv *bat_priv,
64 const void *data) 64 const void *data)
65{ 65{
66 struct hashtable_t *hash = bat_priv->orig_hash; 66 struct hashtable_t *hash = bat_priv->orig_hash;
67 struct hlist_head *head; 67 struct hlist_head *head;
@@ -72,12 +72,12 @@ static inline struct orig_node *orig_hash_find(struct bat_priv *bat_priv,
72 if (!hash) 72 if (!hash)
73 return NULL; 73 return NULL;
74 74
75 index = choose_orig(data, hash->size); 75 index = batadv_choose_orig(data, hash->size);
76 head = &hash->table[index]; 76 head = &hash->table[index];
77 77
78 rcu_read_lock(); 78 rcu_read_lock();
79 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { 79 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
80 if (!compare_eth(orig_node, data)) 80 if (!batadv_compare_eth(orig_node, data))
81 continue; 81 continue;
82 82
83 if (!atomic_inc_not_zero(&orig_node->refcount)) 83 if (!atomic_inc_not_zero(&orig_node->refcount))
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 79f63cf11be4..e7ee40d6d609 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -29,8 +29,8 @@
29#include "unicast.h" 29#include "unicast.h"
30#include "bridge_loop_avoidance.h" 30#include "bridge_loop_avoidance.h"
31 31
32static int route_unicast_packet(struct sk_buff *skb, 32static int batadv_route_unicast_packet(struct sk_buff *skb,
33 struct hard_iface *recv_if); 33 struct hard_iface *recv_if);
34 34
35void batadv_slide_own_bcast_window(struct hard_iface *hard_iface) 35void batadv_slide_own_bcast_window(struct hard_iface *hard_iface)
36{ 36{
@@ -61,9 +61,9 @@ void batadv_slide_own_bcast_window(struct hard_iface *hard_iface)
61 } 61 }
62} 62}
63 63
64static void _update_route(struct bat_priv *bat_priv, 64static void _batadv_update_route(struct bat_priv *bat_priv,
65 struct orig_node *orig_node, 65 struct orig_node *orig_node,
66 struct neigh_node *neigh_node) 66 struct neigh_node *neigh_node)
67{ 67{
68 struct neigh_node *curr_router; 68 struct neigh_node *curr_router;
69 69
@@ -71,23 +71,23 @@ static void _update_route(struct bat_priv *bat_priv,
71 71
72 /* route deleted */ 72 /* route deleted */
73 if ((curr_router) && (!neigh_node)) { 73 if ((curr_router) && (!neigh_node)) {
74 bat_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n", 74 batadv_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n",
75 orig_node->orig); 75 orig_node->orig);
76 batadv_tt_global_del_orig(bat_priv, orig_node, 76 batadv_tt_global_del_orig(bat_priv, orig_node,
77 "Deleted route towards originator"); 77 "Deleted route towards originator");
78 78
79 /* route added */ 79 /* route added */
80 } else if ((!curr_router) && (neigh_node)) { 80 } else if ((!curr_router) && (neigh_node)) {
81 81
82 bat_dbg(DBG_ROUTES, bat_priv, 82 batadv_dbg(DBG_ROUTES, bat_priv,
83 "Adding route towards: %pM (via %pM)\n", 83 "Adding route towards: %pM (via %pM)\n",
84 orig_node->orig, neigh_node->addr); 84 orig_node->orig, neigh_node->addr);
85 /* route changed */ 85 /* route changed */
86 } else if (neigh_node && curr_router) { 86 } else if (neigh_node && curr_router) {
87 bat_dbg(DBG_ROUTES, bat_priv, 87 batadv_dbg(DBG_ROUTES, bat_priv,
88 "Changing route towards: %pM (now via %pM - was via %pM)\n", 88 "Changing route towards: %pM (now via %pM - was via %pM)\n",
89 orig_node->orig, neigh_node->addr, 89 orig_node->orig, neigh_node->addr,
90 curr_router->addr); 90 curr_router->addr);
91 } 91 }
92 92
93 if (curr_router) 93 if (curr_router)
@@ -117,7 +117,7 @@ void batadv_update_route(struct bat_priv *bat_priv, struct orig_node *orig_node,
117 router = batadv_orig_node_get_router(orig_node); 117 router = batadv_orig_node_get_router(orig_node);
118 118
119 if (router != neigh_node) 119 if (router != neigh_node)
120 _update_route(bat_priv, orig_node, neigh_node); 120 _batadv_update_route(bat_priv, orig_node, neigh_node);
121 121
122out: 122out:
123 if (router) 123 if (router)
@@ -151,8 +151,8 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node,
151 spin_lock_bh(&orig_node->neigh_list_lock); 151 spin_lock_bh(&orig_node->neigh_list_lock);
152 152
153 /* only consider if it has the same primary address ... */ 153 /* only consider if it has the same primary address ... */
154 if (!compare_eth(orig_node->orig, 154 if (!batadv_compare_eth(orig_node->orig,
155 neigh_node->orig_node->primary_addr)) 155 neigh_node->orig_node->primary_addr))
156 goto candidate_del; 156 goto candidate_del;
157 157
158 router = batadv_orig_node_get_router(orig_node); 158 router = batadv_orig_node_get_router(orig_node);
@@ -180,7 +180,8 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node,
180 continue; 180 continue;
181 181
182 if ((neigh_node->if_incoming == tmp_neigh_node->if_incoming) || 182 if ((neigh_node->if_incoming == tmp_neigh_node->if_incoming) ||
183 (compare_eth(neigh_node->addr, tmp_neigh_node->addr))) { 183 (batadv_compare_eth(neigh_node->addr,
184 tmp_neigh_node->addr))) {
184 interference_candidate = 1; 185 interference_candidate = 1;
185 break; 186 break;
186 } 187 }
@@ -233,12 +234,12 @@ int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
233{ 234{
234 if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || 235 if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) ||
235 (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { 236 (seq_num_diff >= EXPECTED_SEQNO_RANGE)) {
236 if (!has_timed_out(*last_reset, RESET_PROTECTION_MS)) 237 if (!batadv_has_timed_out(*last_reset, RESET_PROTECTION_MS))
237 return 1; 238 return 1;
238 239
239 *last_reset = jiffies; 240 *last_reset = jiffies;
240 bat_dbg(DBG_BATMAN, bat_priv, 241 batadv_dbg(DBG_BATMAN, bat_priv,
241 "old packet received, start protection\n"); 242 "old packet received, start protection\n");
242 } 243 }
243 244
244 return 0; 245 return 0;
@@ -275,8 +276,8 @@ bool batadv_check_management_packet(struct sk_buff *skb,
275 return true; 276 return true;
276} 277}
277 278
278static int recv_my_icmp_packet(struct bat_priv *bat_priv, 279static int batadv_recv_my_icmp_packet(struct bat_priv *bat_priv,
279 struct sk_buff *skb, size_t icmp_len) 280 struct sk_buff *skb, size_t icmp_len)
280{ 281{
281 struct hard_iface *primary_if = NULL; 282 struct hard_iface *primary_if = NULL;
282 struct orig_node *orig_node = NULL; 283 struct orig_node *orig_node = NULL;
@@ -292,13 +293,13 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
292 goto out; 293 goto out;
293 } 294 }
294 295
295 primary_if = primary_if_get_selected(bat_priv); 296 primary_if = batadv_primary_if_get_selected(bat_priv);
296 if (!primary_if) 297 if (!primary_if)
297 goto out; 298 goto out;
298 299
299 /* answer echo request (ping) */ 300 /* answer echo request (ping) */
300 /* get routing information */ 301 /* get routing information */
301 orig_node = orig_hash_find(bat_priv, icmp_packet->orig); 302 orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->orig);
302 if (!orig_node) 303 if (!orig_node)
303 goto out; 304 goto out;
304 305
@@ -322,7 +323,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
322 323
323out: 324out:
324 if (primary_if) 325 if (primary_if)
325 hardif_free_ref(primary_if); 326 batadv_hardif_free_ref(primary_if);
326 if (router) 327 if (router)
327 batadv_neigh_node_free_ref(router); 328 batadv_neigh_node_free_ref(router);
328 if (orig_node) 329 if (orig_node)
@@ -330,8 +331,8 @@ out:
330 return ret; 331 return ret;
331} 332}
332 333
333static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, 334static int batadv_recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
334 struct sk_buff *skb) 335 struct sk_buff *skb)
335{ 336{
336 struct hard_iface *primary_if = NULL; 337 struct hard_iface *primary_if = NULL;
337 struct orig_node *orig_node = NULL; 338 struct orig_node *orig_node = NULL;
@@ -348,12 +349,12 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
348 goto out; 349 goto out;
349 } 350 }
350 351
351 primary_if = primary_if_get_selected(bat_priv); 352 primary_if = batadv_primary_if_get_selected(bat_priv);
352 if (!primary_if) 353 if (!primary_if)
353 goto out; 354 goto out;
354 355
355 /* get routing information */ 356 /* get routing information */
356 orig_node = orig_hash_find(bat_priv, icmp_packet->orig); 357 orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->orig);
357 if (!orig_node) 358 if (!orig_node)
358 goto out; 359 goto out;
359 360
@@ -377,7 +378,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
377 378
378out: 379out:
379 if (primary_if) 380 if (primary_if)
380 hardif_free_ref(primary_if); 381 batadv_hardif_free_ref(primary_if);
381 if (router) 382 if (router)
382 batadv_neigh_node_free_ref(router); 383 batadv_neigh_node_free_ref(router);
383 if (orig_node) 384 if (orig_node)
@@ -430,14 +431,14 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
430 431
431 /* packet for me */ 432 /* packet for me */
432 if (batadv_is_my_mac(icmp_packet->dst)) 433 if (batadv_is_my_mac(icmp_packet->dst))
433 return recv_my_icmp_packet(bat_priv, skb, hdr_size); 434 return batadv_recv_my_icmp_packet(bat_priv, skb, hdr_size);
434 435
435 /* TTL exceeded */ 436 /* TTL exceeded */
436 if (icmp_packet->header.ttl < 2) 437 if (icmp_packet->header.ttl < 2)
437 return recv_icmp_ttl_exceeded(bat_priv, skb); 438 return batadv_recv_icmp_ttl_exceeded(bat_priv, skb);
438 439
439 /* get routing information */ 440 /* get routing information */
440 orig_node = orig_hash_find(bat_priv, icmp_packet->dst); 441 orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->dst);
441 if (!orig_node) 442 if (!orig_node)
442 goto out; 443 goto out;
443 444
@@ -472,8 +473,9 @@ out:
472 * This method rotates the bonding list and increases the 473 * This method rotates the bonding list and increases the
473 * returned router's refcount. 474 * returned router's refcount.
474 */ 475 */
475static struct neigh_node *find_bond_router(struct orig_node *primary_orig, 476static struct neigh_node *
476 const struct hard_iface *recv_if) 477batadv_find_bond_router(struct orig_node *primary_orig,
478 const struct hard_iface *recv_if)
477{ 479{
478 struct neigh_node *tmp_neigh_node; 480 struct neigh_node *tmp_neigh_node;
479 struct neigh_node *router = NULL, *first_candidate = NULL; 481 struct neigh_node *router = NULL, *first_candidate = NULL;
@@ -526,8 +528,9 @@ out:
526 * 528 *
527 * Increases the returned router's refcount 529 * Increases the returned router's refcount
528 */ 530 */
529static struct neigh_node *find_ifalter_router(struct orig_node *primary_orig, 531static struct neigh_node *
530 const struct hard_iface *recv_if) 532batadv_find_ifalter_router(struct orig_node *primary_orig,
533 const struct hard_iface *recv_if)
531{ 534{
532 struct neigh_node *tmp_neigh_node; 535 struct neigh_node *tmp_neigh_node;
533 struct neigh_node *router = NULL, *first_candidate = NULL; 536 struct neigh_node *router = NULL, *first_candidate = NULL;
@@ -578,6 +581,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
578 struct tt_query_packet *tt_query; 581 struct tt_query_packet *tt_query;
579 uint16_t tt_size; 582 uint16_t tt_size;
580 struct ethhdr *ethhdr; 583 struct ethhdr *ethhdr;
584 char tt_flag;
581 585
582 /* drop packet if it has not necessary minimum size */ 586 /* drop packet if it has not necessary minimum size */
583 if (unlikely(!pskb_may_pull(skb, sizeof(struct tt_query_packet)))) 587 if (unlikely(!pskb_may_pull(skb, sizeof(struct tt_query_packet))))
@@ -607,11 +611,12 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
607 * forwarded 611 * forwarded
608 */ 612 */
609 if (!batadv_send_tt_response(bat_priv, tt_query)) { 613 if (!batadv_send_tt_response(bat_priv, tt_query)) {
610 bat_dbg(DBG_TT, bat_priv, 614 tt_flag = tt_query->flags & TT_FULL_TABLE ? 'F' : '.';
611 "Routing TT_REQUEST to %pM [%c]\n", 615 batadv_dbg(DBG_TT, bat_priv,
612 tt_query->dst, 616 "Routing TT_REQUEST to %pM [%c]\n",
613 (tt_query->flags & TT_FULL_TABLE ? 'F' : '.')); 617 tt_query->dst,
614 return route_unicast_packet(skb, recv_if); 618 tt_flag);
619 return batadv_route_unicast_packet(skb, recv_if);
615 } 620 }
616 break; 621 break;
617 case TT_RESPONSE: 622 case TT_RESPONSE:
@@ -635,11 +640,12 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
635 640
636 batadv_handle_tt_response(bat_priv, tt_query); 641 batadv_handle_tt_response(bat_priv, tt_query);
637 } else { 642 } else {
638 bat_dbg(DBG_TT, bat_priv, 643 tt_flag = tt_query->flags & TT_FULL_TABLE ? 'F' : '.';
639 "Routing TT_RESPONSE to %pM [%c]\n", 644 batadv_dbg(DBG_TT, bat_priv,
640 tt_query->dst, 645 "Routing TT_RESPONSE to %pM [%c]\n",
641 (tt_query->flags & TT_FULL_TABLE ? 'F' : '.')); 646 tt_query->dst,
642 return route_unicast_packet(skb, recv_if); 647 tt_flag);
648 return batadv_route_unicast_packet(skb, recv_if);
643 } 649 }
644 break; 650 break;
645 } 651 }
@@ -675,7 +681,7 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
675 roam_adv_packet = (struct roam_adv_packet *)skb->data; 681 roam_adv_packet = (struct roam_adv_packet *)skb->data;
676 682
677 if (!batadv_is_my_mac(roam_adv_packet->dst)) 683 if (!batadv_is_my_mac(roam_adv_packet->dst))
678 return route_unicast_packet(skb, recv_if); 684 return batadv_route_unicast_packet(skb, recv_if);
679 685
680 /* check if it is a backbone gateway. we don't accept 686 /* check if it is a backbone gateway. we don't accept
681 * roaming advertisement from it, as it has the same 687 * roaming advertisement from it, as it has the same
@@ -684,13 +690,13 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
684 if (batadv_bla_is_backbone_gw_orig(bat_priv, roam_adv_packet->src)) 690 if (batadv_bla_is_backbone_gw_orig(bat_priv, roam_adv_packet->src))
685 goto out; 691 goto out;
686 692
687 orig_node = orig_hash_find(bat_priv, roam_adv_packet->src); 693 orig_node = batadv_orig_hash_find(bat_priv, roam_adv_packet->src);
688 if (!orig_node) 694 if (!orig_node)
689 goto out; 695 goto out;
690 696
691 bat_dbg(DBG_TT, bat_priv, 697 batadv_dbg(DBG_TT, bat_priv,
692 "Received ROAMING_ADV from %pM (client %pM)\n", 698 "Received ROAMING_ADV from %pM (client %pM)\n",
693 roam_adv_packet->src, roam_adv_packet->client); 699 roam_adv_packet->src, roam_adv_packet->client);
694 700
695 batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client, 701 batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client,
696 atomic_read(&orig_node->last_ttvn) + 1, true, 702 atomic_read(&orig_node->last_ttvn) + 1, true,
@@ -721,6 +727,7 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv,
721 struct neigh_node *router; 727 struct neigh_node *router;
722 static uint8_t zero_mac[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; 728 static uint8_t zero_mac[ETH_ALEN] = {0, 0, 0, 0, 0, 0};
723 int bonding_enabled; 729 int bonding_enabled;
730 uint8_t *primary_addr;
724 731
725 if (!orig_node) 732 if (!orig_node)
726 return NULL; 733 return NULL;
@@ -743,20 +750,22 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv,
743 if ((!recv_if) && (!bonding_enabled)) 750 if ((!recv_if) && (!bonding_enabled))
744 goto return_router; 751 goto return_router;
745 752
753 primary_addr = router_orig->primary_addr;
754
746 /* if we have something in the primary_addr, we can search 755 /* if we have something in the primary_addr, we can search
747 * for a potential bonding candidate. 756 * for a potential bonding candidate.
748 */ 757 */
749 if (compare_eth(router_orig->primary_addr, zero_mac)) 758 if (batadv_compare_eth(primary_addr, zero_mac))
750 goto return_router; 759 goto return_router;
751 760
752 /* find the orig_node which has the primary interface. might 761 /* find the orig_node which has the primary interface. might
753 * even be the same as our router_orig in many cases 762 * even be the same as our router_orig in many cases
754 */ 763 */
755 if (compare_eth(router_orig->primary_addr, router_orig->orig)) { 764 if (batadv_compare_eth(primary_addr, router_orig->orig)) {
756 primary_orig_node = router_orig; 765 primary_orig_node = router_orig;
757 } else { 766 } else {
758 primary_orig_node = orig_hash_find(bat_priv, 767 primary_orig_node = batadv_orig_hash_find(bat_priv,
759 router_orig->primary_addr); 768 primary_addr);
760 if (!primary_orig_node) 769 if (!primary_orig_node)
761 goto return_router; 770 goto return_router;
762 771
@@ -776,9 +785,9 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv,
776 batadv_neigh_node_free_ref(router); 785 batadv_neigh_node_free_ref(router);
777 786
778 if (bonding_enabled) 787 if (bonding_enabled)
779 router = find_bond_router(primary_orig_node, recv_if); 788 router = batadv_find_bond_router(primary_orig_node, recv_if);
780 else 789 else
781 router = find_ifalter_router(primary_orig_node, recv_if); 790 router = batadv_find_ifalter_router(primary_orig_node, recv_if);
782 791
783return_router: 792return_router:
784 if (router && router->if_incoming->if_status != IF_ACTIVE) 793 if (router && router->if_incoming->if_status != IF_ACTIVE)
@@ -794,7 +803,7 @@ err:
794 return NULL; 803 return NULL;
795} 804}
796 805
797static int check_unicast_packet(struct sk_buff *skb, int hdr_size) 806static int batadv_check_unicast_packet(struct sk_buff *skb, int hdr_size)
798{ 807{
799 struct ethhdr *ethhdr; 808 struct ethhdr *ethhdr;
800 809
@@ -819,7 +828,8 @@ static int check_unicast_packet(struct sk_buff *skb, int hdr_size)
819 return 0; 828 return 0;
820} 829}
821 830
822static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) 831static int batadv_route_unicast_packet(struct sk_buff *skb,
832 struct hard_iface *recv_if)
823{ 833{
824 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 834 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
825 struct orig_node *orig_node = NULL; 835 struct orig_node *orig_node = NULL;
@@ -839,7 +849,7 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
839 } 849 }
840 850
841 /* get routing information */ 851 /* get routing information */
842 orig_node = orig_hash_find(bat_priv, unicast_packet->dest); 852 orig_node = batadv_orig_hash_find(bat_priv, unicast_packet->dest);
843 853
844 if (!orig_node) 854 if (!orig_node)
845 goto out; 855 goto out;
@@ -866,7 +876,8 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
866 } 876 }
867 877
868 if (unicast_packet->header.packet_type == BAT_UNICAST_FRAG && 878 if (unicast_packet->header.packet_type == BAT_UNICAST_FRAG &&
869 frag_can_reassemble(skb, neigh_node->if_incoming->net_dev->mtu)) { 879 batadv_frag_can_reassemble(skb,
880 neigh_node->if_incoming->net_dev->mtu)) {
870 881
871 ret = batadv_frag_reassemble_skb(skb, bat_priv, &new_skb); 882 ret = batadv_frag_reassemble_skb(skb, bat_priv, &new_skb);
872 883
@@ -903,8 +914,8 @@ out:
903 return ret; 914 return ret;
904} 915}
905 916
906static int check_unicast_ttvn(struct bat_priv *bat_priv, 917static int batadv_check_unicast_ttvn(struct bat_priv *bat_priv,
907 struct sk_buff *skb) { 918 struct sk_buff *skb) {
908 uint8_t curr_ttvn; 919 uint8_t curr_ttvn;
909 struct orig_node *orig_node; 920 struct orig_node *orig_node;
910 struct ethhdr *ethhdr; 921 struct ethhdr *ethhdr;
@@ -922,7 +933,8 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
922 tt_poss_change = bat_priv->tt_poss_change; 933 tt_poss_change = bat_priv->tt_poss_change;
923 curr_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); 934 curr_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn);
924 } else { 935 } else {
925 orig_node = orig_hash_find(bat_priv, unicast_packet->dest); 936 orig_node = batadv_orig_hash_find(bat_priv,
937 unicast_packet->dest);
926 938
927 if (!orig_node) 939 if (!orig_node)
928 return 0; 940 return 0;
@@ -955,12 +967,12 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
955 if (!orig_node) { 967 if (!orig_node) {
956 if (!batadv_is_my_client(bat_priv, ethhdr->h_dest)) 968 if (!batadv_is_my_client(bat_priv, ethhdr->h_dest))
957 return 0; 969 return 0;
958 primary_if = primary_if_get_selected(bat_priv); 970 primary_if = batadv_primary_if_get_selected(bat_priv);
959 if (!primary_if) 971 if (!primary_if)
960 return 0; 972 return 0;
961 memcpy(unicast_packet->dest, 973 memcpy(unicast_packet->dest,
962 primary_if->net_dev->dev_addr, ETH_ALEN); 974 primary_if->net_dev->dev_addr, ETH_ALEN);
963 hardif_free_ref(primary_if); 975 batadv_hardif_free_ref(primary_if);
964 } else { 976 } else {
965 memcpy(unicast_packet->dest, orig_node->orig, 977 memcpy(unicast_packet->dest, orig_node->orig,
966 ETH_ALEN); 978 ETH_ALEN);
@@ -969,10 +981,10 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,
969 batadv_orig_node_free_ref(orig_node); 981 batadv_orig_node_free_ref(orig_node);
970 } 982 }
971 983
972 bat_dbg(DBG_ROUTES, bat_priv, 984 batadv_dbg(DBG_ROUTES, bat_priv,
973 "TTVN mismatch (old_ttvn %u new_ttvn %u)! Rerouting unicast packet (for %pM) to %pM\n", 985 "TTVN mismatch (old_ttvn %u new_ttvn %u)! Rerouting unicast packet (for %pM) to %pM\n",
974 unicast_packet->ttvn, curr_ttvn, ethhdr->h_dest, 986 unicast_packet->ttvn, curr_ttvn, ethhdr->h_dest,
975 unicast_packet->dest); 987 unicast_packet->dest);
976 988
977 unicast_packet->ttvn = curr_ttvn; 989 unicast_packet->ttvn = curr_ttvn;
978 } 990 }
@@ -985,10 +997,10 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
985 struct unicast_packet *unicast_packet; 997 struct unicast_packet *unicast_packet;
986 int hdr_size = sizeof(*unicast_packet); 998 int hdr_size = sizeof(*unicast_packet);
987 999
988 if (check_unicast_packet(skb, hdr_size) < 0) 1000 if (batadv_check_unicast_packet(skb, hdr_size) < 0)
989 return NET_RX_DROP; 1001 return NET_RX_DROP;
990 1002
991 if (!check_unicast_ttvn(bat_priv, skb)) 1003 if (!batadv_check_unicast_ttvn(bat_priv, skb))
992 return NET_RX_DROP; 1004 return NET_RX_DROP;
993 1005
994 unicast_packet = (struct unicast_packet *)skb->data; 1006 unicast_packet = (struct unicast_packet *)skb->data;
@@ -1000,7 +1012,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1000 return NET_RX_SUCCESS; 1012 return NET_RX_SUCCESS;
1001 } 1013 }
1002 1014
1003 return route_unicast_packet(skb, recv_if); 1015 return batadv_route_unicast_packet(skb, recv_if);
1004} 1016}
1005 1017
1006int batadv_recv_ucast_frag_packet(struct sk_buff *skb, 1018int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
@@ -1012,10 +1024,10 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
1012 struct sk_buff *new_skb = NULL; 1024 struct sk_buff *new_skb = NULL;
1013 int ret; 1025 int ret;
1014 1026
1015 if (check_unicast_packet(skb, hdr_size) < 0) 1027 if (batadv_check_unicast_packet(skb, hdr_size) < 0)
1016 return NET_RX_DROP; 1028 return NET_RX_DROP;
1017 1029
1018 if (!check_unicast_ttvn(bat_priv, skb)) 1030 if (!batadv_check_unicast_ttvn(bat_priv, skb))
1019 return NET_RX_DROP; 1031 return NET_RX_DROP;
1020 1032
1021 unicast_packet = (struct unicast_frag_packet *)skb->data; 1033 unicast_packet = (struct unicast_frag_packet *)skb->data;
@@ -1037,7 +1049,7 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
1037 return NET_RX_SUCCESS; 1049 return NET_RX_SUCCESS;
1038 } 1050 }
1039 1051
1040 return route_unicast_packet(skb, recv_if); 1052 return batadv_route_unicast_packet(skb, recv_if);
1041} 1053}
1042 1054
1043 1055
@@ -1078,7 +1090,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1078 if (bcast_packet->header.ttl < 2) 1090 if (bcast_packet->header.ttl < 2)
1079 goto out; 1091 goto out;
1080 1092
1081 orig_node = orig_hash_find(bat_priv, bcast_packet->orig); 1093 orig_node = batadv_orig_hash_find(bat_priv, bcast_packet->orig);
1082 1094
1083 if (!orig_node) 1095 if (!orig_node)
1084 goto out; 1096 goto out;
@@ -1086,8 +1098,8 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1086 spin_lock_bh(&orig_node->bcast_seqno_lock); 1098 spin_lock_bh(&orig_node->bcast_seqno_lock);
1087 1099
1088 /* check whether the packet is a duplicate */ 1100 /* check whether the packet is a duplicate */
1089 if (bat_test_bit(orig_node->bcast_bits, orig_node->last_bcast_seqno, 1101 if (batadv_test_bit(orig_node->bcast_bits, orig_node->last_bcast_seqno,
1090 ntohl(bcast_packet->seqno))) 1102 ntohl(bcast_packet->seqno)))
1091 goto spin_unlock; 1103 goto spin_unlock;
1092 1104
1093 seq_diff = ntohl(bcast_packet->seqno) - orig_node->last_bcast_seqno; 1105 seq_diff = ntohl(bcast_packet->seqno) - orig_node->last_bcast_seqno;
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 2c92a32ec6c6..1842cbc280c7 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -27,7 +27,7 @@
27#include "gateway_common.h" 27#include "gateway_common.h"
28#include "originator.h" 28#include "originator.h"
29 29
30static void send_outstanding_bcast_packet(struct work_struct *work); 30static void batadv_send_outstanding_bcast_packet(struct work_struct *work);
31 31
32/* 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
33 * specified batman interface 33 * specified batman interface
@@ -96,18 +96,18 @@ void batadv_schedule_bat_ogm(struct hard_iface *hard_iface)
96 bat_priv->bat_algo_ops->bat_ogm_schedule(hard_iface); 96 bat_priv->bat_algo_ops->bat_ogm_schedule(hard_iface);
97} 97}
98 98
99static void forw_packet_free(struct forw_packet *forw_packet) 99static void batadv_forw_packet_free(struct forw_packet *forw_packet)
100{ 100{
101 if (forw_packet->skb) 101 if (forw_packet->skb)
102 kfree_skb(forw_packet->skb); 102 kfree_skb(forw_packet->skb);
103 if (forw_packet->if_incoming) 103 if (forw_packet->if_incoming)
104 hardif_free_ref(forw_packet->if_incoming); 104 batadv_hardif_free_ref(forw_packet->if_incoming);
105 kfree(forw_packet); 105 kfree(forw_packet);
106} 106}
107 107
108static void _add_bcast_packet_to_list(struct bat_priv *bat_priv, 108static void _batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
109 struct forw_packet *forw_packet, 109 struct forw_packet *forw_packet,
110 unsigned long send_time) 110 unsigned long send_time)
111{ 111{
112 INIT_HLIST_NODE(&forw_packet->list); 112 INIT_HLIST_NODE(&forw_packet->list);
113 113
@@ -118,7 +118,7 @@ static void _add_bcast_packet_to_list(struct bat_priv *bat_priv,
118 118
119 /* start timer for this packet */ 119 /* start timer for this packet */
120 INIT_DELAYED_WORK(&forw_packet->delayed_work, 120 INIT_DELAYED_WORK(&forw_packet->delayed_work,
121 send_outstanding_bcast_packet); 121 batadv_send_outstanding_bcast_packet);
122 queue_delayed_work(batadv_event_workqueue, &forw_packet->delayed_work, 122 queue_delayed_work(batadv_event_workqueue, &forw_packet->delayed_work,
123 send_time); 123 send_time);
124} 124}
@@ -142,11 +142,11 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
142 struct sk_buff *newskb; 142 struct sk_buff *newskb;
143 143
144 if (!atomic_dec_not_zero(&bat_priv->bcast_queue_left)) { 144 if (!atomic_dec_not_zero(&bat_priv->bcast_queue_left)) {
145 bat_dbg(DBG_BATMAN, bat_priv, "bcast packet queue full\n"); 145 batadv_dbg(DBG_BATMAN, bat_priv, "bcast packet queue full\n");
146 goto out; 146 goto out;
147 } 147 }
148 148
149 primary_if = primary_if_get_selected(bat_priv); 149 primary_if = batadv_primary_if_get_selected(bat_priv);
150 if (!primary_if) 150 if (!primary_if)
151 goto out_and_inc; 151 goto out_and_inc;
152 152
@@ -171,7 +171,7 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
171 /* how often did we send the bcast packet ? */ 171 /* how often did we send the bcast packet ? */
172 forw_packet->num_packets = 0; 172 forw_packet->num_packets = 0;
173 173
174 _add_bcast_packet_to_list(bat_priv, forw_packet, delay); 174 _batadv_add_bcast_packet_to_list(bat_priv, forw_packet, delay);
175 return NETDEV_TX_OK; 175 return NETDEV_TX_OK;
176 176
177packet_free: 177packet_free:
@@ -180,11 +180,11 @@ out_and_inc:
180 atomic_inc(&bat_priv->bcast_queue_left); 180 atomic_inc(&bat_priv->bcast_queue_left);
181out: 181out:
182 if (primary_if) 182 if (primary_if)
183 hardif_free_ref(primary_if); 183 batadv_hardif_free_ref(primary_if);
184 return NETDEV_TX_BUSY; 184 return NETDEV_TX_BUSY;
185} 185}
186 186
187static void send_outstanding_bcast_packet(struct work_struct *work) 187static void batadv_send_outstanding_bcast_packet(struct work_struct *work)
188{ 188{
189 struct hard_iface *hard_iface; 189 struct hard_iface *hard_iface;
190 struct delayed_work *delayed_work = 190 struct delayed_work *delayed_work =
@@ -220,13 +220,13 @@ static void send_outstanding_bcast_packet(struct work_struct *work)
220 220
221 /* if we still have some more bcasts to send */ 221 /* if we still have some more bcasts to send */
222 if (forw_packet->num_packets < 3) { 222 if (forw_packet->num_packets < 3) {
223 _add_bcast_packet_to_list(bat_priv, forw_packet, 223 _batadv_add_bcast_packet_to_list(bat_priv, forw_packet,
224 msecs_to_jiffies(5)); 224 msecs_to_jiffies(5));
225 return; 225 return;
226 } 226 }
227 227
228out: 228out:
229 forw_packet_free(forw_packet); 229 batadv_forw_packet_free(forw_packet);
230 atomic_inc(&bat_priv->bcast_queue_left); 230 atomic_inc(&bat_priv->bcast_queue_left);
231} 231}
232 232
@@ -260,7 +260,7 @@ out:
260 if (!forw_packet->own) 260 if (!forw_packet->own)
261 atomic_inc(&bat_priv->batman_queue_left); 261 atomic_inc(&bat_priv->batman_queue_left);
262 262
263 forw_packet_free(forw_packet); 263 batadv_forw_packet_free(forw_packet);
264} 264}
265 265
266void batadv_purge_outstanding_packets(struct bat_priv *bat_priv, 266void batadv_purge_outstanding_packets(struct bat_priv *bat_priv,
@@ -271,12 +271,12 @@ void batadv_purge_outstanding_packets(struct bat_priv *bat_priv,
271 bool pending; 271 bool pending;
272 272
273 if (hard_iface) 273 if (hard_iface)
274 bat_dbg(DBG_BATMAN, bat_priv, 274 batadv_dbg(DBG_BATMAN, bat_priv,
275 "purge_outstanding_packets(): %s\n", 275 "purge_outstanding_packets(): %s\n",
276 hard_iface->net_dev->name); 276 hard_iface->net_dev->name);
277 else 277 else
278 bat_dbg(DBG_BATMAN, bat_priv, 278 batadv_dbg(DBG_BATMAN, bat_priv,
279 "purge_outstanding_packets()\n"); 279 "purge_outstanding_packets()\n");
280 280
281 /* free bcast list */ 281 /* free bcast list */
282 spin_lock_bh(&bat_priv->forw_bcast_list_lock); 282 spin_lock_bh(&bat_priv->forw_bcast_list_lock);
@@ -292,7 +292,7 @@ void batadv_purge_outstanding_packets(struct bat_priv *bat_priv,
292 292
293 spin_unlock_bh(&bat_priv->forw_bcast_list_lock); 293 spin_unlock_bh(&bat_priv->forw_bcast_list_lock);
294 294
295 /* send_outstanding_bcast_packet() will lock the list to 295 /* batadv_send_outstanding_bcast_packet() will lock the list to
296 * delete the item from the list 296 * delete the item from the list
297 */ 297 */
298 pending = cancel_delayed_work_sync(&forw_packet->delayed_work); 298 pending = cancel_delayed_work_sync(&forw_packet->delayed_work);
@@ -300,7 +300,7 @@ void batadv_purge_outstanding_packets(struct bat_priv *bat_priv,
300 300
301 if (pending) { 301 if (pending) {
302 hlist_del(&forw_packet->list); 302 hlist_del(&forw_packet->list);
303 forw_packet_free(forw_packet); 303 batadv_forw_packet_free(forw_packet);
304 } 304 }
305 } 305 }
306 spin_unlock_bh(&bat_priv->forw_bcast_list_lock); 306 spin_unlock_bh(&bat_priv->forw_bcast_list_lock);
@@ -327,7 +327,7 @@ void batadv_purge_outstanding_packets(struct bat_priv *bat_priv,
327 327
328 if (pending) { 328 if (pending) {
329 hlist_del(&forw_packet->list); 329 hlist_del(&forw_packet->list);
330 forw_packet_free(forw_packet); 330 batadv_forw_packet_free(forw_packet);
331 } 331 }
332 } 332 }
333 spin_unlock_bh(&bat_priv->forw_bat_list_lock); 333 spin_unlock_bh(&bat_priv->forw_bat_list_lock);
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 0658781febde..2de1d742119f 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -37,23 +37,23 @@
37#include "bridge_loop_avoidance.h" 37#include "bridge_loop_avoidance.h"
38 38
39 39
40static int bat_get_settings(struct net_device *dev, struct ethtool_cmd *cmd); 40static int batadv_get_settings(struct net_device *dev, struct ethtool_cmd *cmd);
41static void bat_get_drvinfo(struct net_device *dev, 41static void batadv_get_drvinfo(struct net_device *dev,
42 struct ethtool_drvinfo *info); 42 struct ethtool_drvinfo *info);
43static u32 bat_get_msglevel(struct net_device *dev); 43static u32 batadv_get_msglevel(struct net_device *dev);
44static void bat_set_msglevel(struct net_device *dev, u32 value); 44static void batadv_set_msglevel(struct net_device *dev, u32 value);
45static u32 bat_get_link(struct net_device *dev); 45static u32 batadv_get_link(struct net_device *dev);
46static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data); 46static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data);
47static void batadv_get_ethtool_stats(struct net_device *dev, 47static void batadv_get_ethtool_stats(struct net_device *dev,
48 struct ethtool_stats *stats, u64 *data); 48 struct ethtool_stats *stats, u64 *data);
49static int batadv_get_sset_count(struct net_device *dev, int stringset); 49static int batadv_get_sset_count(struct net_device *dev, int stringset);
50 50
51static const struct ethtool_ops bat_ethtool_ops = { 51static const struct ethtool_ops batadv_ethtool_ops = {
52 .get_settings = bat_get_settings, 52 .get_settings = batadv_get_settings,
53 .get_drvinfo = bat_get_drvinfo, 53 .get_drvinfo = batadv_get_drvinfo,
54 .get_msglevel = bat_get_msglevel, 54 .get_msglevel = batadv_get_msglevel,
55 .set_msglevel = bat_set_msglevel, 55 .set_msglevel = batadv_set_msglevel,
56 .get_link = bat_get_link, 56 .get_link = batadv_get_link,
57 .get_strings = batadv_get_strings, 57 .get_strings = batadv_get_strings,
58 .get_ethtool_stats = batadv_get_ethtool_stats, 58 .get_ethtool_stats = batadv_get_ethtool_stats,
59 .get_sset_count = batadv_get_sset_count, 59 .get_sset_count = batadv_get_sset_count,
@@ -78,25 +78,25 @@ int batadv_skb_head_push(struct sk_buff *skb, unsigned int len)
78 return 0; 78 return 0;
79} 79}
80 80
81static int interface_open(struct net_device *dev) 81static int batadv_interface_open(struct net_device *dev)
82{ 82{
83 netif_start_queue(dev); 83 netif_start_queue(dev);
84 return 0; 84 return 0;
85} 85}
86 86
87static int interface_release(struct net_device *dev) 87static int batadv_interface_release(struct net_device *dev)
88{ 88{
89 netif_stop_queue(dev); 89 netif_stop_queue(dev);
90 return 0; 90 return 0;
91} 91}
92 92
93static struct net_device_stats *interface_stats(struct net_device *dev) 93static struct net_device_stats *batadv_interface_stats(struct net_device *dev)
94{ 94{
95 struct bat_priv *bat_priv = netdev_priv(dev); 95 struct bat_priv *bat_priv = netdev_priv(dev);
96 return &bat_priv->stats; 96 return &bat_priv->stats;
97} 97}
98 98
99static int interface_set_mac_addr(struct net_device *dev, void *p) 99static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)
100{ 100{
101 struct bat_priv *bat_priv = netdev_priv(dev); 101 struct bat_priv *bat_priv = netdev_priv(dev);
102 struct sockaddr *addr = p; 102 struct sockaddr *addr = p;
@@ -116,7 +116,7 @@ static int interface_set_mac_addr(struct net_device *dev, void *p)
116 return 0; 116 return 0;
117} 117}
118 118
119static int interface_change_mtu(struct net_device *dev, int new_mtu) 119static int batadv_interface_change_mtu(struct net_device *dev, int new_mtu)
120{ 120{
121 /* check ranges */ 121 /* check ranges */
122 if ((new_mtu < 68) || (new_mtu > batadv_hardif_min_mtu(dev))) 122 if ((new_mtu < 68) || (new_mtu > batadv_hardif_min_mtu(dev)))
@@ -127,7 +127,8 @@ static int interface_change_mtu(struct net_device *dev, int new_mtu)
127 return 0; 127 return 0;
128} 128}
129 129
130static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) 130static int batadv_interface_tx(struct sk_buff *skb,
131 struct net_device *soft_iface)
131{ 132{
132 struct ethhdr *ethhdr = (struct ethhdr *)skb->data; 133 struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
133 struct bat_priv *bat_priv = netdev_priv(soft_iface); 134 struct bat_priv *bat_priv = netdev_priv(soft_iface);
@@ -168,7 +169,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
168 /* don't accept stp packets. STP does not help in meshes. 169 /* don't accept stp packets. STP does not help in meshes.
169 * better use the bridge loop avoidance ... 170 * better use the bridge loop avoidance ...
170 */ 171 */
171 if (compare_eth(ethhdr->h_dest, stp_addr)) 172 if (batadv_compare_eth(ethhdr->h_dest, stp_addr))
172 goto dropped; 173 goto dropped;
173 174
174 if (is_multicast_ether_addr(ethhdr->h_dest)) { 175 if (is_multicast_ether_addr(ethhdr->h_dest)) {
@@ -199,7 +200,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
199 200
200 /* ethernet packet should be broadcasted */ 201 /* ethernet packet should be broadcasted */
201 if (do_bcast) { 202 if (do_bcast) {
202 primary_if = primary_if_get_selected(bat_priv); 203 primary_if = batadv_primary_if_get_selected(bat_priv);
203 if (!primary_if) 204 if (!primary_if)
204 goto dropped; 205 goto dropped;
205 206
@@ -253,7 +254,7 @@ dropped_freed:
253 bat_priv->stats.tx_dropped++; 254 bat_priv->stats.tx_dropped++;
254end: 255end:
255 if (primary_if) 256 if (primary_if)
256 hardif_free_ref(primary_if); 257 batadv_hardif_free_ref(primary_if);
257 return NETDEV_TX_OK; 258 return NETDEV_TX_OK;
258} 259}
259 260
@@ -323,23 +324,23 @@ out:
323 return; 324 return;
324} 325}
325 326
326static const struct net_device_ops bat_netdev_ops = { 327static const struct net_device_ops batadv_netdev_ops = {
327 .ndo_open = interface_open, 328 .ndo_open = batadv_interface_open,
328 .ndo_stop = interface_release, 329 .ndo_stop = batadv_interface_release,
329 .ndo_get_stats = interface_stats, 330 .ndo_get_stats = batadv_interface_stats,
330 .ndo_set_mac_address = interface_set_mac_addr, 331 .ndo_set_mac_address = batadv_interface_set_mac_addr,
331 .ndo_change_mtu = interface_change_mtu, 332 .ndo_change_mtu = batadv_interface_change_mtu,
332 .ndo_start_xmit = interface_tx, 333 .ndo_start_xmit = batadv_interface_tx,
333 .ndo_validate_addr = eth_validate_addr 334 .ndo_validate_addr = eth_validate_addr
334}; 335};
335 336
336static void interface_setup(struct net_device *dev) 337static void batadv_interface_setup(struct net_device *dev)
337{ 338{
338 struct bat_priv *priv = netdev_priv(dev); 339 struct bat_priv *priv = netdev_priv(dev);
339 340
340 ether_setup(dev); 341 ether_setup(dev);
341 342
342 dev->netdev_ops = &bat_netdev_ops; 343 dev->netdev_ops = &batadv_netdev_ops;
343 dev->destructor = free_netdev; 344 dev->destructor = free_netdev;
344 dev->tx_queue_len = 0; 345 dev->tx_queue_len = 0;
345 346
@@ -353,7 +354,7 @@ static void interface_setup(struct net_device *dev)
353 /* generate random address */ 354 /* generate random address */
354 eth_hw_addr_random(dev); 355 eth_hw_addr_random(dev);
355 356
356 SET_ETHTOOL_OPS(dev, &bat_ethtool_ops); 357 SET_ETHTOOL_OPS(dev, &batadv_ethtool_ops);
357 358
358 memset(priv, 0, sizeof(*priv)); 359 memset(priv, 0, sizeof(*priv));
359} 360}
@@ -364,7 +365,8 @@ struct net_device *batadv_softif_create(const char *name)
364 struct bat_priv *bat_priv; 365 struct bat_priv *bat_priv;
365 int ret; 366 int ret;
366 367
367 soft_iface = alloc_netdev(sizeof(*bat_priv), name, interface_setup); 368 soft_iface = alloc_netdev(sizeof(*bat_priv), name,
369 batadv_interface_setup);
368 370
369 if (!soft_iface) 371 if (!soft_iface)
370 goto out; 372 goto out;
@@ -456,14 +458,14 @@ void batadv_softif_destroy(struct net_device *soft_iface)
456 458
457int batadv_softif_is_valid(const struct net_device *net_dev) 459int batadv_softif_is_valid(const struct net_device *net_dev)
458{ 460{
459 if (net_dev->netdev_ops->ndo_start_xmit == interface_tx) 461 if (net_dev->netdev_ops->ndo_start_xmit == batadv_interface_tx)
460 return 1; 462 return 1;
461 463
462 return 0; 464 return 0;
463} 465}
464 466
465/* ethtool */ 467/* ethtool */
466static int bat_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 468static int batadv_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
467{ 469{
468 cmd->supported = 0; 470 cmd->supported = 0;
469 cmd->advertising = 0; 471 cmd->advertising = 0;
@@ -479,8 +481,8 @@ static int bat_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
479 return 0; 481 return 0;
480} 482}
481 483
482static void bat_get_drvinfo(struct net_device *dev, 484static void batadv_get_drvinfo(struct net_device *dev,
483 struct ethtool_drvinfo *info) 485 struct ethtool_drvinfo *info)
484{ 486{
485 strcpy(info->driver, "B.A.T.M.A.N. advanced"); 487 strcpy(info->driver, "B.A.T.M.A.N. advanced");
486 strcpy(info->version, SOURCE_VERSION); 488 strcpy(info->version, SOURCE_VERSION);
@@ -488,16 +490,16 @@ static void bat_get_drvinfo(struct net_device *dev,
488 strcpy(info->bus_info, "batman"); 490 strcpy(info->bus_info, "batman");
489} 491}
490 492
491static u32 bat_get_msglevel(struct net_device *dev) 493static u32 batadv_get_msglevel(struct net_device *dev)
492{ 494{
493 return -EOPNOTSUPP; 495 return -EOPNOTSUPP;
494} 496}
495 497
496static void bat_set_msglevel(struct net_device *dev, u32 value) 498static void batadv_set_msglevel(struct net_device *dev, u32 value)
497{ 499{
498} 500}
499 501
500static u32 bat_get_link(struct net_device *dev) 502static u32 batadv_get_link(struct net_device *dev)
501{ 503{
502 return 1; 504 return 1;
503} 505}
@@ -508,7 +510,7 @@ static u32 bat_get_link(struct net_device *dev)
508 */ 510 */
509static const struct { 511static const struct {
510 const char name[ETH_GSTRING_LEN]; 512 const char name[ETH_GSTRING_LEN];
511} bat_counters_strings[] = { 513} batadv_counters_strings[] = {
512 { "forward" }, 514 { "forward" },
513 { "forward_bytes" }, 515 { "forward_bytes" },
514 { "mgmt_tx" }, 516 { "mgmt_tx" },
@@ -527,8 +529,8 @@ static void batadv_get_strings(struct net_device *dev, uint32_t stringset,
527 uint8_t *data) 529 uint8_t *data)
528{ 530{
529 if (stringset == ETH_SS_STATS) 531 if (stringset == ETH_SS_STATS)
530 memcpy(data, bat_counters_strings, 532 memcpy(data, batadv_counters_strings,
531 sizeof(bat_counters_strings)); 533 sizeof(batadv_counters_strings));
532} 534}
533 535
534static void batadv_get_ethtool_stats(struct net_device *dev, 536static void batadv_get_ethtool_stats(struct net_device *dev,
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 3806d9bbf55e..cf7988342f27 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -29,13 +29,14 @@
29 29
30#include <linux/crc16.h> 30#include <linux/crc16.h>
31 31
32static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, 32static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
33 struct orig_node *orig_node); 33 struct orig_node *orig_node);
34static void tt_purge(struct work_struct *work); 34static void batadv_tt_purge(struct work_struct *work);
35static void tt_global_del_orig_list(struct tt_global_entry *tt_global_entry); 35static void
36batadv_tt_global_del_orig_list(struct tt_global_entry *tt_global_entry);
36 37
37/* returns 1 if they are the same mac addr */ 38/* returns 1 if they are the same mac addr */
38static int compare_tt(const struct hlist_node *node, const void *data2) 39static int batadv_compare_tt(const struct hlist_node *node, const void *data2)
39{ 40{
40 const void *data1 = container_of(node, struct tt_common_entry, 41 const void *data1 = container_of(node, struct tt_common_entry,
41 hash_entry); 42 hash_entry);
@@ -43,15 +44,15 @@ static int compare_tt(const struct hlist_node *node, const void *data2)
43 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); 44 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
44} 45}
45 46
46static void tt_start_timer(struct bat_priv *bat_priv) 47static void batadv_tt_start_timer(struct bat_priv *bat_priv)
47{ 48{
48 INIT_DELAYED_WORK(&bat_priv->tt_work, tt_purge); 49 INIT_DELAYED_WORK(&bat_priv->tt_work, batadv_tt_purge);
49 queue_delayed_work(batadv_event_workqueue, &bat_priv->tt_work, 50 queue_delayed_work(batadv_event_workqueue, &bat_priv->tt_work,
50 msecs_to_jiffies(5000)); 51 msecs_to_jiffies(5000));
51} 52}
52 53
53static struct tt_common_entry *tt_hash_find(struct hashtable_t *hash, 54static struct tt_common_entry *batadv_tt_hash_find(struct hashtable_t *hash,
54 const void *data) 55 const void *data)
55{ 56{
56 struct hlist_head *head; 57 struct hlist_head *head;
57 struct hlist_node *node; 58 struct hlist_node *node;
@@ -61,12 +62,12 @@ static struct tt_common_entry *tt_hash_find(struct hashtable_t *hash,
61 if (!hash) 62 if (!hash)
62 return NULL; 63 return NULL;
63 64
64 index = choose_orig(data, hash->size); 65 index = batadv_choose_orig(data, hash->size);
65 head = &hash->table[index]; 66 head = &hash->table[index];
66 67
67 rcu_read_lock(); 68 rcu_read_lock();
68 hlist_for_each_entry_rcu(tt_common_entry, node, head, hash_entry) { 69 hlist_for_each_entry_rcu(tt_common_entry, node, head, hash_entry) {
69 if (!compare_eth(tt_common_entry, data)) 70 if (!batadv_compare_eth(tt_common_entry, data))
70 continue; 71 continue;
71 72
72 if (!atomic_inc_not_zero(&tt_common_entry->refcount)) 73 if (!atomic_inc_not_zero(&tt_common_entry->refcount))
@@ -80,26 +81,26 @@ static struct tt_common_entry *tt_hash_find(struct hashtable_t *hash,
80 return tt_common_entry_tmp; 81 return tt_common_entry_tmp;
81} 82}
82 83
83static struct tt_local_entry *tt_local_hash_find(struct bat_priv *bat_priv, 84static struct tt_local_entry *
84 const void *data) 85batadv_tt_local_hash_find(struct bat_priv *bat_priv, const void *data)
85{ 86{
86 struct tt_common_entry *tt_common_entry; 87 struct tt_common_entry *tt_common_entry;
87 struct tt_local_entry *tt_local_entry = NULL; 88 struct tt_local_entry *tt_local_entry = NULL;
88 89
89 tt_common_entry = tt_hash_find(bat_priv->tt_local_hash, data); 90 tt_common_entry = batadv_tt_hash_find(bat_priv->tt_local_hash, data);
90 if (tt_common_entry) 91 if (tt_common_entry)
91 tt_local_entry = container_of(tt_common_entry, 92 tt_local_entry = container_of(tt_common_entry,
92 struct tt_local_entry, common); 93 struct tt_local_entry, common);
93 return tt_local_entry; 94 return tt_local_entry;
94} 95}
95 96
96static struct tt_global_entry *tt_global_hash_find(struct bat_priv *bat_priv, 97static struct tt_global_entry *
97 const void *data) 98batadv_tt_global_hash_find(struct bat_priv *bat_priv, const void *data)
98{ 99{
99 struct tt_common_entry *tt_common_entry; 100 struct tt_common_entry *tt_common_entry;
100 struct tt_global_entry *tt_global_entry = NULL; 101 struct tt_global_entry *tt_global_entry = NULL;
101 102
102 tt_common_entry = tt_hash_find(bat_priv->tt_global_hash, data); 103 tt_common_entry = batadv_tt_hash_find(bat_priv->tt_global_hash, data);
103 if (tt_common_entry) 104 if (tt_common_entry)
104 tt_global_entry = container_of(tt_common_entry, 105 tt_global_entry = container_of(tt_common_entry,
105 struct tt_global_entry, common); 106 struct tt_global_entry, common);
@@ -107,13 +108,14 @@ static struct tt_global_entry *tt_global_hash_find(struct bat_priv *bat_priv,
107 108
108} 109}
109 110
110static void tt_local_entry_free_ref(struct tt_local_entry *tt_local_entry) 111static void
112batadv_tt_local_entry_free_ref(struct tt_local_entry *tt_local_entry)
111{ 113{
112 if (atomic_dec_and_test(&tt_local_entry->common.refcount)) 114 if (atomic_dec_and_test(&tt_local_entry->common.refcount))
113 kfree_rcu(tt_local_entry, common.rcu); 115 kfree_rcu(tt_local_entry, common.rcu);
114} 116}
115 117
116static void tt_global_entry_free_rcu(struct rcu_head *rcu) 118static void batadv_tt_global_entry_free_rcu(struct rcu_head *rcu)
117{ 119{
118 struct tt_common_entry *tt_common_entry; 120 struct tt_common_entry *tt_common_entry;
119 struct tt_global_entry *tt_global_entry; 121 struct tt_global_entry *tt_global_entry;
@@ -125,16 +127,17 @@ static void tt_global_entry_free_rcu(struct rcu_head *rcu)
125 kfree(tt_global_entry); 127 kfree(tt_global_entry);
126} 128}
127 129
128static void tt_global_entry_free_ref(struct tt_global_entry *tt_global_entry) 130static void
131batadv_tt_global_entry_free_ref(struct tt_global_entry *tt_global_entry)
129{ 132{
130 if (atomic_dec_and_test(&tt_global_entry->common.refcount)) { 133 if (atomic_dec_and_test(&tt_global_entry->common.refcount)) {
131 tt_global_del_orig_list(tt_global_entry); 134 batadv_tt_global_del_orig_list(tt_global_entry);
132 call_rcu(&tt_global_entry->common.rcu, 135 call_rcu(&tt_global_entry->common.rcu,
133 tt_global_entry_free_rcu); 136 batadv_tt_global_entry_free_rcu);
134 } 137 }
135} 138}
136 139
137static void tt_orig_list_entry_free_rcu(struct rcu_head *rcu) 140static void batadv_tt_orig_list_entry_free_rcu(struct rcu_head *rcu)
138{ 141{
139 struct tt_orig_list_entry *orig_entry; 142 struct tt_orig_list_entry *orig_entry;
140 143
@@ -143,15 +146,14 @@ static void tt_orig_list_entry_free_rcu(struct rcu_head *rcu)
143 kfree(orig_entry); 146 kfree(orig_entry);
144} 147}
145 148
146static void tt_orig_list_entry_free_ref(struct tt_orig_list_entry *orig_entry) 149static void
150batadv_tt_orig_list_entry_free_ref(struct tt_orig_list_entry *orig_entry)
147{ 151{
148 /* to avoid race conditions, immediately decrease the tt counter */ 152 call_rcu(&orig_entry->rcu, batadv_tt_orig_list_entry_free_rcu);
149 atomic_dec(&orig_entry->orig_node->tt_size);
150 call_rcu(&orig_entry->rcu, tt_orig_list_entry_free_rcu);
151} 153}
152 154
153static void tt_local_event(struct bat_priv *bat_priv, const uint8_t *addr, 155static void batadv_tt_local_event(struct bat_priv *bat_priv,
154 uint8_t flags) 156 const uint8_t *addr, uint8_t flags)
155{ 157{
156 struct tt_change_node *tt_change_node; 158 struct tt_change_node *tt_change_node;
157 159
@@ -177,7 +179,7 @@ int batadv_tt_len(int changes_num)
177 return changes_num * sizeof(struct tt_change); 179 return changes_num * sizeof(struct tt_change);
178} 180}
179 181
180static int tt_local_init(struct bat_priv *bat_priv) 182static int batadv_tt_local_init(struct bat_priv *bat_priv)
181{ 183{
182 if (bat_priv->tt_local_hash) 184 if (bat_priv->tt_local_hash)
183 return 0; 185 return 0;
@@ -201,7 +203,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
201 struct tt_orig_list_entry *orig_entry; 203 struct tt_orig_list_entry *orig_entry;
202 int hash_added; 204 int hash_added;
203 205
204 tt_local_entry = tt_local_hash_find(bat_priv, addr); 206 tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr);
205 207
206 if (tt_local_entry) { 208 if (tt_local_entry) {
207 tt_local_entry->last_seen = jiffies; 209 tt_local_entry->last_seen = jiffies;
@@ -214,9 +216,9 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
214 if (!tt_local_entry) 216 if (!tt_local_entry)
215 goto out; 217 goto out;
216 218
217 bat_dbg(DBG_TT, bat_priv, 219 batadv_dbg(DBG_TT, bat_priv,
218 "Creating new local tt entry: %pM (ttvn: %d)\n", addr, 220 "Creating new local tt entry: %pM (ttvn: %d)\n", addr,
219 (uint8_t)atomic_read(&bat_priv->ttvn)); 221 (uint8_t)atomic_read(&bat_priv->ttvn));
220 222
221 memcpy(tt_local_entry->common.addr, addr, ETH_ALEN); 223 memcpy(tt_local_entry->common.addr, addr, ETH_ALEN);
222 tt_local_entry->common.flags = NO_FLAGS; 224 tt_local_entry->common.flags = NO_FLAGS;
@@ -226,7 +228,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
226 tt_local_entry->last_seen = jiffies; 228 tt_local_entry->last_seen = jiffies;
227 229
228 /* the batman interface mac address should never be purged */ 230 /* the batman interface mac address should never be purged */
229 if (compare_eth(addr, soft_iface->dev_addr)) 231 if (batadv_compare_eth(addr, soft_iface->dev_addr))
230 tt_local_entry->common.flags |= TT_CLIENT_NOPURGE; 232 tt_local_entry->common.flags |= TT_CLIENT_NOPURGE;
231 233
232 /* The local entry has to be marked as NEW to avoid to send it in 234 /* The local entry has to be marked as NEW to avoid to send it in
@@ -235,20 +237,21 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
235 */ 237 */
236 tt_local_entry->common.flags |= TT_CLIENT_NEW; 238 tt_local_entry->common.flags |= TT_CLIENT_NEW;
237 239
238 hash_added = hash_add(bat_priv->tt_local_hash, compare_tt, choose_orig, 240 hash_added = batadv_hash_add(bat_priv->tt_local_hash, batadv_compare_tt,
239 &tt_local_entry->common, 241 batadv_choose_orig,
240 &tt_local_entry->common.hash_entry); 242 &tt_local_entry->common,
243 &tt_local_entry->common.hash_entry);
241 244
242 if (unlikely(hash_added != 0)) { 245 if (unlikely(hash_added != 0)) {
243 /* remove the reference for the hash */ 246 /* remove the reference for the hash */
244 tt_local_entry_free_ref(tt_local_entry); 247 batadv_tt_local_entry_free_ref(tt_local_entry);
245 goto out; 248 goto out;
246 } 249 }
247 250
248 tt_local_event(bat_priv, addr, tt_local_entry->common.flags); 251 batadv_tt_local_event(bat_priv, addr, tt_local_entry->common.flags);
249 252
250 /* remove address from global hash if present */ 253 /* remove address from global hash if present */
251 tt_global_entry = tt_global_hash_find(bat_priv, addr); 254 tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr);
252 255
253 /* Check whether it is a roaming! */ 256 /* Check whether it is a roaming! */
254 if (tt_global_entry) { 257 if (tt_global_entry) {
@@ -258,8 +261,9 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
258 hlist_for_each_entry_rcu(orig_entry, node, head, list) { 261 hlist_for_each_entry_rcu(orig_entry, node, head, list) {
259 orig_entry->orig_node->tt_poss_change = true; 262 orig_entry->orig_node->tt_poss_change = true;
260 263
261 send_roam_adv(bat_priv, tt_global_entry->common.addr, 264 batadv_send_roam_adv(bat_priv,
262 orig_entry->orig_node); 265 tt_global_entry->common.addr,
266 orig_entry->orig_node);
263 } 267 }
264 rcu_read_unlock(); 268 rcu_read_unlock();
265 /* The global entry has to be marked as ROAMING and 269 /* The global entry has to be marked as ROAMING and
@@ -270,14 +274,15 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
270 } 274 }
271out: 275out:
272 if (tt_local_entry) 276 if (tt_local_entry)
273 tt_local_entry_free_ref(tt_local_entry); 277 batadv_tt_local_entry_free_ref(tt_local_entry);
274 if (tt_global_entry) 278 if (tt_global_entry)
275 tt_global_entry_free_ref(tt_global_entry); 279 batadv_tt_global_entry_free_ref(tt_global_entry);
276} 280}
277 281
278static void tt_realloc_packet_buff(unsigned char **packet_buff, 282static void batadv_tt_realloc_packet_buff(unsigned char **packet_buff,
279 int *packet_buff_len, int min_packet_len, 283 int *packet_buff_len,
280 int new_packet_len) 284 int min_packet_len,
285 int new_packet_len)
281{ 286{
282 unsigned char *new_buff; 287 unsigned char *new_buff;
283 288
@@ -292,14 +297,15 @@ static void tt_realloc_packet_buff(unsigned char **packet_buff,
292 } 297 }
293} 298}
294 299
295static void tt_prepare_packet_buff(struct bat_priv *bat_priv, 300static void batadv_tt_prepare_packet_buff(struct bat_priv *bat_priv,
296 unsigned char **packet_buff, 301 unsigned char **packet_buff,
297 int *packet_buff_len, int min_packet_len) 302 int *packet_buff_len,
303 int min_packet_len)
298{ 304{
299 struct hard_iface *primary_if; 305 struct hard_iface *primary_if;
300 int req_len; 306 int req_len;
301 307
302 primary_if = primary_if_get_selected(bat_priv); 308 primary_if = batadv_primary_if_get_selected(bat_priv);
303 309
304 req_len = min_packet_len; 310 req_len = min_packet_len;
305 req_len += batadv_tt_len(atomic_read(&bat_priv->tt_local_changes)); 311 req_len += batadv_tt_len(atomic_read(&bat_priv->tt_local_changes));
@@ -310,23 +316,24 @@ static void tt_prepare_packet_buff(struct bat_priv *bat_priv,
310 if ((!primary_if) || (req_len > primary_if->soft_iface->mtu)) 316 if ((!primary_if) || (req_len > primary_if->soft_iface->mtu))
311 req_len = min_packet_len; 317 req_len = min_packet_len;
312 318
313 tt_realloc_packet_buff(packet_buff, packet_buff_len, 319 batadv_tt_realloc_packet_buff(packet_buff, packet_buff_len,
314 min_packet_len, req_len); 320 min_packet_len, req_len);
315 321
316 if (primary_if) 322 if (primary_if)
317 hardif_free_ref(primary_if); 323 batadv_hardif_free_ref(primary_if);
318} 324}
319 325
320static int tt_changes_fill_buff(struct bat_priv *bat_priv, 326static int batadv_tt_changes_fill_buff(struct bat_priv *bat_priv,
321 unsigned char **packet_buff, 327 unsigned char **packet_buff,
322 int *packet_buff_len, int min_packet_len) 328 int *packet_buff_len,
329 int min_packet_len)
323{ 330{
324 struct tt_change_node *entry, *safe; 331 struct tt_change_node *entry, *safe;
325 int count = 0, tot_changes = 0, new_len; 332 int count = 0, tot_changes = 0, new_len;
326 unsigned char *tt_buff; 333 unsigned char *tt_buff;
327 334
328 tt_prepare_packet_buff(bat_priv, packet_buff, 335 batadv_tt_prepare_packet_buff(bat_priv, packet_buff,
329 packet_buff_len, min_packet_len); 336 packet_buff_len, min_packet_len);
330 337
331 new_len = *packet_buff_len - min_packet_len; 338 new_len = *packet_buff_len - min_packet_len;
332 tt_buff = *packet_buff + min_packet_len; 339 tt_buff = *packet_buff + min_packet_len;
@@ -382,7 +389,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset)
382 uint32_t i; 389 uint32_t i;
383 int ret = 0; 390 int ret = 0;
384 391
385 primary_if = primary_if_get_selected(bat_priv); 392 primary_if = batadv_primary_if_get_selected(bat_priv);
386 if (!primary_if) { 393 if (!primary_if) {
387 ret = seq_printf(seq, 394 ret = seq_printf(seq,
388 "BATMAN mesh %s disabled - please specify interfaces to enable it\n", 395 "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
@@ -424,16 +431,16 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset)
424 } 431 }
425out: 432out:
426 if (primary_if) 433 if (primary_if)
427 hardif_free_ref(primary_if); 434 batadv_hardif_free_ref(primary_if);
428 return ret; 435 return ret;
429} 436}
430 437
431static void tt_local_set_pending(struct bat_priv *bat_priv, 438static void batadv_tt_local_set_pending(struct bat_priv *bat_priv,
432 struct tt_local_entry *tt_local_entry, 439 struct tt_local_entry *tt_local_entry,
433 uint16_t flags, const char *message) 440 uint16_t flags, const char *message)
434{ 441{
435 tt_local_event(bat_priv, tt_local_entry->common.addr, 442 batadv_tt_local_event(bat_priv, tt_local_entry->common.addr,
436 tt_local_entry->common.flags | flags); 443 tt_local_entry->common.flags | flags);
437 444
438 /* The local client has to be marked as "pending to be removed" but has 445 /* 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 446 * to be kept in the table in order to send it in a full table
@@ -441,9 +448,9 @@ static void tt_local_set_pending(struct bat_priv *bat_priv,
441 */ 448 */
442 tt_local_entry->common.flags |= TT_CLIENT_PENDING; 449 tt_local_entry->common.flags |= TT_CLIENT_PENDING;
443 450
444 bat_dbg(DBG_TT, bat_priv, 451 batadv_dbg(DBG_TT, bat_priv,
445 "Local tt entry (%pM) pending to be removed: %s\n", 452 "Local tt entry (%pM) pending to be removed: %s\n",
446 tt_local_entry->common.addr, message); 453 tt_local_entry->common.addr, message);
447} 454}
448 455
449void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, 456void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr,
@@ -451,18 +458,19 @@ void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr,
451{ 458{
452 struct tt_local_entry *tt_local_entry = NULL; 459 struct tt_local_entry *tt_local_entry = NULL;
453 460
454 tt_local_entry = tt_local_hash_find(bat_priv, addr); 461 tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr);
455 if (!tt_local_entry) 462 if (!tt_local_entry)
456 goto out; 463 goto out;
457 464
458 tt_local_set_pending(bat_priv, tt_local_entry, TT_CLIENT_DEL | 465 batadv_tt_local_set_pending(bat_priv, tt_local_entry, TT_CLIENT_DEL |
459 (roaming ? TT_CLIENT_ROAM : NO_FLAGS), message); 466 (roaming ? TT_CLIENT_ROAM : NO_FLAGS),
467 message);
460out: 468out:
461 if (tt_local_entry) 469 if (tt_local_entry)
462 tt_local_entry_free_ref(tt_local_entry); 470 batadv_tt_local_entry_free_ref(tt_local_entry);
463} 471}
464 472
465static void tt_local_purge(struct bat_priv *bat_priv) 473static void batadv_tt_local_purge(struct bat_priv *bat_priv)
466{ 474{
467 struct hashtable_t *hash = bat_priv->tt_local_hash; 475 struct hashtable_t *hash = bat_priv->tt_local_hash;
468 struct tt_local_entry *tt_local_entry; 476 struct tt_local_entry *tt_local_entry;
@@ -489,19 +497,19 @@ static void tt_local_purge(struct bat_priv *bat_priv)
489 if (tt_local_entry->common.flags & TT_CLIENT_PENDING) 497 if (tt_local_entry->common.flags & TT_CLIENT_PENDING)
490 continue; 498 continue;
491 499
492 if (!has_timed_out(tt_local_entry->last_seen, 500 if (!batadv_has_timed_out(tt_local_entry->last_seen,
493 TT_LOCAL_TIMEOUT)) 501 TT_LOCAL_TIMEOUT))
494 continue; 502 continue;
495 503
496 tt_local_set_pending(bat_priv, tt_local_entry, 504 batadv_tt_local_set_pending(bat_priv, tt_local_entry,
497 TT_CLIENT_DEL, "timed out"); 505 TT_CLIENT_DEL, "timed out");
498 } 506 }
499 spin_unlock_bh(list_lock); 507 spin_unlock_bh(list_lock);
500 } 508 }
501 509
502} 510}
503 511
504static void tt_local_table_free(struct bat_priv *bat_priv) 512static void batadv_tt_local_table_free(struct bat_priv *bat_priv)
505{ 513{
506 struct hashtable_t *hash; 514 struct hashtable_t *hash;
507 spinlock_t *list_lock; /* protects write access to the hash lists */ 515 spinlock_t *list_lock; /* protects write access to the hash lists */
@@ -527,7 +535,7 @@ static void tt_local_table_free(struct bat_priv *bat_priv)
527 tt_local_entry = container_of(tt_common_entry, 535 tt_local_entry = container_of(tt_common_entry,
528 struct tt_local_entry, 536 struct tt_local_entry,
529 common); 537 common);
530 tt_local_entry_free_ref(tt_local_entry); 538 batadv_tt_local_entry_free_ref(tt_local_entry);
531 } 539 }
532 spin_unlock_bh(list_lock); 540 spin_unlock_bh(list_lock);
533 } 541 }
@@ -537,7 +545,7 @@ static void tt_local_table_free(struct bat_priv *bat_priv)
537 bat_priv->tt_local_hash = NULL; 545 bat_priv->tt_local_hash = NULL;
538} 546}
539 547
540static int tt_global_init(struct bat_priv *bat_priv) 548static int batadv_tt_global_init(struct bat_priv *bat_priv)
541{ 549{
542 if (bat_priv->tt_global_hash) 550 if (bat_priv->tt_global_hash)
543 return 0; 551 return 0;
@@ -550,7 +558,7 @@ static int tt_global_init(struct bat_priv *bat_priv)
550 return 0; 558 return 0;
551} 559}
552 560
553static void tt_changes_list_free(struct bat_priv *bat_priv) 561static void batadv_tt_changes_list_free(struct bat_priv *bat_priv)
554{ 562{
555 struct tt_change_node *entry, *safe; 563 struct tt_change_node *entry, *safe;
556 564
@@ -569,8 +577,8 @@ static void tt_changes_list_free(struct bat_priv *bat_priv)
569/* find out if an orig_node is already in the list of a tt_global_entry. 577/* find out if an orig_node is already in the list of a tt_global_entry.
570 * returns 1 if found, 0 otherwise 578 * returns 1 if found, 0 otherwise
571 */ 579 */
572static bool tt_global_entry_has_orig(const struct tt_global_entry *entry, 580static bool batadv_tt_global_entry_has_orig(const struct tt_global_entry *entry,
573 const struct orig_node *orig_node) 581 const struct orig_node *orig_node)
574{ 582{
575 struct tt_orig_list_entry *tmp_orig_entry; 583 struct tt_orig_list_entry *tmp_orig_entry;
576 const struct hlist_head *head; 584 const struct hlist_head *head;
@@ -589,9 +597,9 @@ static bool tt_global_entry_has_orig(const struct tt_global_entry *entry,
589 return found; 597 return found;
590} 598}
591 599
592static void tt_global_add_orig_entry(struct tt_global_entry *tt_global_entry, 600static void
593 struct orig_node *orig_node, 601batadv_tt_global_add_orig_entry(struct tt_global_entry *tt_global_entry,
594 int ttvn) 602 struct orig_node *orig_node, int ttvn)
595{ 603{
596 struct tt_orig_list_entry *orig_entry; 604 struct tt_orig_list_entry *orig_entry;
597 605
@@ -619,8 +627,9 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
619 struct tt_global_entry *tt_global_entry = NULL; 627 struct tt_global_entry *tt_global_entry = NULL;
620 int ret = 0; 628 int ret = 0;
621 int hash_added; 629 int hash_added;
630 struct tt_common_entry *common;
622 631
623 tt_global_entry = tt_global_hash_find(bat_priv, tt_addr); 632 tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr);
624 633
625 if (!tt_global_entry) { 634 if (!tt_global_entry) {
626 tt_global_entry = kzalloc(sizeof(*tt_global_entry), 635 tt_global_entry = kzalloc(sizeof(*tt_global_entry),
@@ -628,26 +637,29 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
628 if (!tt_global_entry) 637 if (!tt_global_entry)
629 goto out; 638 goto out;
630 639
631 memcpy(tt_global_entry->common.addr, tt_addr, ETH_ALEN); 640 common = &tt_global_entry->common;
641 memcpy(common->addr, tt_addr, ETH_ALEN);
632 642
633 tt_global_entry->common.flags = NO_FLAGS; 643 common->flags = NO_FLAGS;
634 tt_global_entry->roam_at = 0; 644 tt_global_entry->roam_at = 0;
635 atomic_set(&tt_global_entry->common.refcount, 2); 645 atomic_set(&common->refcount, 2);
636 646
637 INIT_HLIST_HEAD(&tt_global_entry->orig_list); 647 INIT_HLIST_HEAD(&tt_global_entry->orig_list);
638 spin_lock_init(&tt_global_entry->list_lock); 648 spin_lock_init(&tt_global_entry->list_lock);
639 649
640 hash_added = hash_add(bat_priv->tt_global_hash, compare_tt, 650 hash_added = batadv_hash_add(bat_priv->tt_global_hash,
641 choose_orig, &tt_global_entry->common, 651 batadv_compare_tt,
642 &tt_global_entry->common.hash_entry); 652 batadv_choose_orig, common,
653 &common->hash_entry);
643 654
644 if (unlikely(hash_added != 0)) { 655 if (unlikely(hash_added != 0)) {
645 /* remove the reference for the hash */ 656 /* remove the reference for the hash */
646 tt_global_entry_free_ref(tt_global_entry); 657 batadv_tt_global_entry_free_ref(tt_global_entry);
647 goto out_remove; 658 goto out_remove;
648 } 659 }
649 660
650 tt_global_add_orig_entry(tt_global_entry, orig_node, ttvn); 661 batadv_tt_global_add_orig_entry(tt_global_entry, orig_node,
662 ttvn);
651 } else { 663 } else {
652 /* there is already a global entry, use this one. */ 664 /* there is already a global entry, use this one. */
653 665
@@ -659,22 +671,23 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node,
659 * new one. 671 * new one.
660 */ 672 */
661 if (tt_global_entry->common.flags & TT_CLIENT_ROAM) { 673 if (tt_global_entry->common.flags & TT_CLIENT_ROAM) {
662 tt_global_del_orig_list(tt_global_entry); 674 batadv_tt_global_del_orig_list(tt_global_entry);
663 tt_global_entry->common.flags &= ~TT_CLIENT_ROAM; 675 tt_global_entry->common.flags &= ~TT_CLIENT_ROAM;
664 tt_global_entry->roam_at = 0; 676 tt_global_entry->roam_at = 0;
665 } 677 }
666 678
667 if (!tt_global_entry_has_orig(tt_global_entry, orig_node)) 679 if (!batadv_tt_global_entry_has_orig(tt_global_entry,
668 tt_global_add_orig_entry(tt_global_entry, orig_node, 680 orig_node))
669 ttvn); 681 batadv_tt_global_add_orig_entry(tt_global_entry,
682 orig_node, ttvn);
670 } 683 }
671 684
672 if (wifi) 685 if (wifi)
673 tt_global_entry->common.flags |= TT_CLIENT_WIFI; 686 tt_global_entry->common.flags |= TT_CLIENT_WIFI;
674 687
675 bat_dbg(DBG_TT, bat_priv, 688 batadv_dbg(DBG_TT, bat_priv,
676 "Creating new global tt entry: %pM (via %pM)\n", 689 "Creating new global tt entry: %pM (via %pM)\n",
677 tt_global_entry->common.addr, orig_node->orig); 690 tt_global_entry->common.addr, orig_node->orig);
678 691
679out_remove: 692out_remove:
680 /* remove address from local hash if present */ 693 /* remove address from local hash if present */
@@ -683,15 +696,16 @@ out_remove:
683 ret = 1; 696 ret = 1;
684out: 697out:
685 if (tt_global_entry) 698 if (tt_global_entry)
686 tt_global_entry_free_ref(tt_global_entry); 699 batadv_tt_global_entry_free_ref(tt_global_entry);
687 return ret; 700 return ret;
688} 701}
689 702
690/* print all orig nodes who announce the address for this global entry. 703/* print all orig nodes who announce the address for this global entry.
691 * it is assumed that the caller holds rcu_read_lock(); 704 * it is assumed that the caller holds rcu_read_lock();
692 */ 705 */
693static void tt_global_print_entry(struct tt_global_entry *tt_global_entry, 706static void
694 struct seq_file *seq) 707batadv_tt_global_print_entry(struct tt_global_entry *tt_global_entry,
708 struct seq_file *seq)
695{ 709{
696 struct hlist_head *head; 710 struct hlist_head *head;
697 struct hlist_node *node; 711 struct hlist_node *node;
@@ -728,7 +742,7 @@ int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset)
728 uint32_t i; 742 uint32_t i;
729 int ret = 0; 743 int ret = 0;
730 744
731 primary_if = primary_if_get_selected(bat_priv); 745 primary_if = batadv_primary_if_get_selected(bat_priv);
732 if (!primary_if) { 746 if (!primary_if) {
733 ret = seq_printf(seq, 747 ret = seq_printf(seq,
734 "BATMAN mesh %s disabled - please specify interfaces to enable it\n", 748 "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
@@ -758,18 +772,19 @@ int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset)
758 tt_global_entry = container_of(tt_common_entry, 772 tt_global_entry = container_of(tt_common_entry,
759 struct tt_global_entry, 773 struct tt_global_entry,
760 common); 774 common);
761 tt_global_print_entry(tt_global_entry, seq); 775 batadv_tt_global_print_entry(tt_global_entry, seq);
762 } 776 }
763 rcu_read_unlock(); 777 rcu_read_unlock();
764 } 778 }
765out: 779out:
766 if (primary_if) 780 if (primary_if)
767 hardif_free_ref(primary_if); 781 batadv_hardif_free_ref(primary_if);
768 return ret; 782 return ret;
769} 783}
770 784
771/* deletes the orig list of a tt_global_entry */ 785/* deletes the orig list of a tt_global_entry */
772static void tt_global_del_orig_list(struct tt_global_entry *tt_global_entry) 786static void
787batadv_tt_global_del_orig_list(struct tt_global_entry *tt_global_entry)
773{ 788{
774 struct hlist_head *head; 789 struct hlist_head *head;
775 struct hlist_node *node, *safe; 790 struct hlist_node *node, *safe;
@@ -779,16 +794,17 @@ static void tt_global_del_orig_list(struct tt_global_entry *tt_global_entry)
779 head = &tt_global_entry->orig_list; 794 head = &tt_global_entry->orig_list;
780 hlist_for_each_entry_safe(orig_entry, node, safe, head, list) { 795 hlist_for_each_entry_safe(orig_entry, node, safe, head, list) {
781 hlist_del_rcu(node); 796 hlist_del_rcu(node);
782 tt_orig_list_entry_free_ref(orig_entry); 797 batadv_tt_orig_list_entry_free_ref(orig_entry);
783 } 798 }
784 spin_unlock_bh(&tt_global_entry->list_lock); 799 spin_unlock_bh(&tt_global_entry->list_lock);
785 800
786} 801}
787 802
788static void tt_global_del_orig_entry(struct bat_priv *bat_priv, 803static void
789 struct tt_global_entry *tt_global_entry, 804batadv_tt_global_del_orig_entry(struct bat_priv *bat_priv,
790 struct orig_node *orig_node, 805 struct tt_global_entry *tt_global_entry,
791 const char *message) 806 struct orig_node *orig_node,
807 const char *message)
792{ 808{
793 struct hlist_head *head; 809 struct hlist_head *head;
794 struct hlist_node *node, *safe; 810 struct hlist_node *node, *safe;
@@ -798,28 +814,27 @@ static void tt_global_del_orig_entry(struct bat_priv *bat_priv,
798 head = &tt_global_entry->orig_list; 814 head = &tt_global_entry->orig_list;
799 hlist_for_each_entry_safe(orig_entry, node, safe, head, list) { 815 hlist_for_each_entry_safe(orig_entry, node, safe, head, list) {
800 if (orig_entry->orig_node == orig_node) { 816 if (orig_entry->orig_node == orig_node) {
801 bat_dbg(DBG_TT, bat_priv, 817 batadv_dbg(DBG_TT, bat_priv,
802 "Deleting %pM from global tt entry %pM: %s\n", 818 "Deleting %pM from global tt entry %pM: %s\n",
803 orig_node->orig, tt_global_entry->common.addr, 819 orig_node->orig,
804 message); 820 tt_global_entry->common.addr, message);
805 hlist_del_rcu(node); 821 hlist_del_rcu(node);
806 tt_orig_list_entry_free_ref(orig_entry); 822 batadv_tt_orig_list_entry_free_ref(orig_entry);
807 } 823 }
808 } 824 }
809 spin_unlock_bh(&tt_global_entry->list_lock); 825 spin_unlock_bh(&tt_global_entry->list_lock);
810} 826}
811 827
812static void tt_global_del_struct(struct bat_priv *bat_priv, 828static void batadv_tt_global_del_struct(struct bat_priv *bat_priv,
813 struct tt_global_entry *tt_global_entry, 829 struct tt_global_entry *tt_global_entry,
814 const char *message) 830 const char *message)
815{ 831{
816 bat_dbg(DBG_TT, bat_priv, 832 batadv_dbg(DBG_TT, bat_priv, "Deleting global tt entry %pM: %s\n",
817 "Deleting global tt entry %pM: %s\n", 833 tt_global_entry->common.addr, message);
818 tt_global_entry->common.addr, message);
819 834
820 hash_remove(bat_priv->tt_global_hash, compare_tt, choose_orig, 835 batadv_hash_remove(bat_priv->tt_global_hash, batadv_compare_tt,
821 tt_global_entry->common.addr); 836 batadv_choose_orig, tt_global_entry->common.addr);
822 tt_global_entry_free_ref(tt_global_entry); 837 batadv_tt_global_entry_free_ref(tt_global_entry);
823 838
824} 839}
825 840
@@ -827,10 +842,10 @@ static void tt_global_del_struct(struct bat_priv *bat_priv,
827 * within tt_global entry. If yes, we set the TT_CLIENT_ROAM flag and the timer, 842 * within tt_global entry. If yes, we set the TT_CLIENT_ROAM flag and the timer,
828 * otherwise we simply remove the originator scheduled for deletion. 843 * otherwise we simply remove the originator scheduled for deletion.
829 */ 844 */
830static void tt_global_del_roaming(struct bat_priv *bat_priv, 845static void
831 struct tt_global_entry *tt_global_entry, 846batadv_tt_global_del_roaming(struct bat_priv *bat_priv,
832 struct orig_node *orig_node, 847 struct tt_global_entry *tt_global_entry,
833 const char *message) 848 struct orig_node *orig_node, const char *message)
834{ 849{
835 bool last_entry = true; 850 bool last_entry = true;
836 struct hlist_head *head; 851 struct hlist_head *head;
@@ -859,31 +874,31 @@ static void tt_global_del_roaming(struct bat_priv *bat_priv,
859 /* there is another entry, we can simply delete this 874 /* there is another entry, we can simply delete this
860 * one and can still use the other one. 875 * one and can still use the other one.
861 */ 876 */
862 tt_global_del_orig_entry(bat_priv, tt_global_entry, 877 batadv_tt_global_del_orig_entry(bat_priv, tt_global_entry,
863 orig_node, message); 878 orig_node, message);
864} 879}
865 880
866 881
867 882
868static void tt_global_del(struct bat_priv *bat_priv, 883static void batadv_tt_global_del(struct bat_priv *bat_priv,
869 struct orig_node *orig_node, 884 struct orig_node *orig_node,
870 const unsigned char *addr, 885 const unsigned char *addr,
871 const char *message, bool roaming) 886 const char *message, bool roaming)
872{ 887{
873 struct tt_global_entry *tt_global_entry = NULL; 888 struct tt_global_entry *tt_global_entry = NULL;
874 struct tt_local_entry *tt_local_entry = NULL; 889 struct tt_local_entry *local_entry = NULL;
875 890
876 tt_global_entry = tt_global_hash_find(bat_priv, addr); 891 tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr);
877 if (!tt_global_entry) 892 if (!tt_global_entry)
878 goto out; 893 goto out;
879 894
880 if (!roaming) { 895 if (!roaming) {
881 tt_global_del_orig_entry(bat_priv, tt_global_entry, orig_node, 896 batadv_tt_global_del_orig_entry(bat_priv, tt_global_entry,
882 message); 897 orig_node, message);
883 898
884 if (hlist_empty(&tt_global_entry->orig_list)) 899 if (hlist_empty(&tt_global_entry->orig_list))
885 tt_global_del_struct(bat_priv, tt_global_entry, 900 batadv_tt_global_del_struct(bat_priv, tt_global_entry,
886 message); 901 message);
887 902
888 goto out; 903 goto out;
889 } 904 }
@@ -901,29 +916,29 @@ static void tt_global_del(struct bat_priv *bat_priv,
901 * 2) the client roamed to us => we can directly delete 916 * 2) the client roamed to us => we can directly delete
902 * the global entry, since it is useless now. 917 * the global entry, since it is useless now.
903 */ 918 */
904 tt_local_entry = tt_local_hash_find(bat_priv, 919 local_entry = batadv_tt_local_hash_find(bat_priv,
905 tt_global_entry->common.addr); 920 tt_global_entry->common.addr);
906 if (tt_local_entry) { 921 if (local_entry) {
907 /* local entry exists, case 2: client roamed to us. */ 922 /* local entry exists, case 2: client roamed to us. */
908 tt_global_del_orig_list(tt_global_entry); 923 batadv_tt_global_del_orig_list(tt_global_entry);
909 tt_global_del_struct(bat_priv, tt_global_entry, message); 924 batadv_tt_global_del_struct(bat_priv, tt_global_entry, message);
910 } else 925 } else
911 /* no local entry exists, case 1: check for roaming */ 926 /* no local entry exists, case 1: check for roaming */
912 tt_global_del_roaming(bat_priv, tt_global_entry, orig_node, 927 batadv_tt_global_del_roaming(bat_priv, tt_global_entry,
913 message); 928 orig_node, message);
914 929
915 930
916out: 931out:
917 if (tt_global_entry) 932 if (tt_global_entry)
918 tt_global_entry_free_ref(tt_global_entry); 933 batadv_tt_global_entry_free_ref(tt_global_entry);
919 if (tt_local_entry) 934 if (local_entry)
920 tt_local_entry_free_ref(tt_local_entry); 935 batadv_tt_local_entry_free_ref(local_entry);
921} 936}
922 937
923void batadv_tt_global_del_orig(struct bat_priv *bat_priv, 938void batadv_tt_global_del_orig(struct bat_priv *bat_priv,
924 struct orig_node *orig_node, const char *message) 939 struct orig_node *orig_node, const char *message)
925{ 940{
926 struct tt_global_entry *tt_global_entry; 941 struct tt_global_entry *global_entry;
927 struct tt_common_entry *tt_common_entry; 942 struct tt_common_entry *tt_common_entry;
928 uint32_t i; 943 uint32_t i;
929 struct hashtable_t *hash = bat_priv->tt_global_hash; 944 struct hashtable_t *hash = bat_priv->tt_global_hash;
@@ -941,20 +956,19 @@ void batadv_tt_global_del_orig(struct bat_priv *bat_priv,
941 spin_lock_bh(list_lock); 956 spin_lock_bh(list_lock);
942 hlist_for_each_entry_safe(tt_common_entry, node, safe, 957 hlist_for_each_entry_safe(tt_common_entry, node, safe,
943 head, hash_entry) { 958 head, hash_entry) {
944 tt_global_entry = container_of(tt_common_entry, 959 global_entry = container_of(tt_common_entry,
945 struct tt_global_entry, 960 struct tt_global_entry,
946 common); 961 common);
947 962
948 tt_global_del_orig_entry(bat_priv, tt_global_entry, 963 batadv_tt_global_del_orig_entry(bat_priv, global_entry,
949 orig_node, message); 964 orig_node, message);
950 965
951 if (hlist_empty(&tt_global_entry->orig_list)) { 966 if (hlist_empty(&global_entry->orig_list)) {
952 bat_dbg(DBG_TT, bat_priv, 967 batadv_dbg(DBG_TT, bat_priv,
953 "Deleting global tt entry %pM: %s\n", 968 "Deleting global tt entry %pM: %s\n",
954 tt_global_entry->common.addr, 969 global_entry->common.addr, message);
955 message);
956 hlist_del_rcu(node); 970 hlist_del_rcu(node);
957 tt_global_entry_free_ref(tt_global_entry); 971 batadv_tt_global_entry_free_ref(global_entry);
958 } 972 }
959 } 973 }
960 spin_unlock_bh(list_lock); 974 spin_unlock_bh(list_lock);
@@ -962,7 +976,7 @@ void batadv_tt_global_del_orig(struct bat_priv *bat_priv,
962 orig_node->tt_initialised = false; 976 orig_node->tt_initialised = false;
963} 977}
964 978
965static void tt_global_roam_purge(struct bat_priv *bat_priv) 979static void batadv_tt_global_roam_purge(struct bat_priv *bat_priv)
966{ 980{
967 struct hashtable_t *hash = bat_priv->tt_global_hash; 981 struct hashtable_t *hash = bat_priv->tt_global_hash;
968 struct tt_common_entry *tt_common_entry; 982 struct tt_common_entry *tt_common_entry;
@@ -984,23 +998,23 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv)
984 common); 998 common);
985 if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM)) 999 if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM))
986 continue; 1000 continue;
987 if (!has_timed_out(tt_global_entry->roam_at, 1001 if (!batadv_has_timed_out(tt_global_entry->roam_at,
988 TT_CLIENT_ROAM_TIMEOUT)) 1002 TT_CLIENT_ROAM_TIMEOUT))
989 continue; 1003 continue;
990 1004
991 bat_dbg(DBG_TT, bat_priv, 1005 batadv_dbg(DBG_TT, bat_priv,
992 "Deleting global tt entry (%pM): Roaming timeout\n", 1006 "Deleting global tt entry (%pM): Roaming timeout\n",
993 tt_global_entry->common.addr); 1007 tt_global_entry->common.addr);
994 1008
995 hlist_del_rcu(node); 1009 hlist_del_rcu(node);
996 tt_global_entry_free_ref(tt_global_entry); 1010 batadv_tt_global_entry_free_ref(tt_global_entry);
997 } 1011 }
998 spin_unlock_bh(list_lock); 1012 spin_unlock_bh(list_lock);
999 } 1013 }
1000 1014
1001} 1015}
1002 1016
1003static void tt_global_table_free(struct bat_priv *bat_priv) 1017static void batadv_tt_global_table_free(struct bat_priv *bat_priv)
1004{ 1018{
1005 struct hashtable_t *hash; 1019 struct hashtable_t *hash;
1006 spinlock_t *list_lock; /* protects write access to the hash lists */ 1020 spinlock_t *list_lock; /* protects write access to the hash lists */
@@ -1026,7 +1040,7 @@ static void tt_global_table_free(struct bat_priv *bat_priv)
1026 tt_global_entry = container_of(tt_common_entry, 1040 tt_global_entry = container_of(tt_common_entry,
1027 struct tt_global_entry, 1041 struct tt_global_entry,
1028 common); 1042 common);
1029 tt_global_entry_free_ref(tt_global_entry); 1043 batadv_tt_global_entry_free_ref(tt_global_entry);
1030 } 1044 }
1031 spin_unlock_bh(list_lock); 1045 spin_unlock_bh(list_lock);
1032 } 1046 }
@@ -1036,8 +1050,8 @@ static void tt_global_table_free(struct bat_priv *bat_priv)
1036 bat_priv->tt_global_hash = NULL; 1050 bat_priv->tt_global_hash = NULL;
1037} 1051}
1038 1052
1039static bool _is_ap_isolated(struct tt_local_entry *tt_local_entry, 1053static bool _batadv_is_ap_isolated(struct tt_local_entry *tt_local_entry,
1040 struct tt_global_entry *tt_global_entry) 1054 struct tt_global_entry *tt_global_entry)
1041{ 1055{
1042 bool ret = false; 1056 bool ret = false;
1043 1057
@@ -1062,19 +1076,20 @@ struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv,
1062 int best_tq; 1076 int best_tq;
1063 1077
1064 if (src && atomic_read(&bat_priv->ap_isolation)) { 1078 if (src && atomic_read(&bat_priv->ap_isolation)) {
1065 tt_local_entry = tt_local_hash_find(bat_priv, src); 1079 tt_local_entry = batadv_tt_local_hash_find(bat_priv, src);
1066 if (!tt_local_entry) 1080 if (!tt_local_entry)
1067 goto out; 1081 goto out;
1068 } 1082 }
1069 1083
1070 tt_global_entry = tt_global_hash_find(bat_priv, addr); 1084 tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr);
1071 if (!tt_global_entry) 1085 if (!tt_global_entry)
1072 goto out; 1086 goto out;
1073 1087
1074 /* check whether the clients should not communicate due to AP 1088 /* check whether the clients should not communicate due to AP
1075 * isolation 1089 * isolation
1076 */ 1090 */
1077 if (tt_local_entry && _is_ap_isolated(tt_local_entry, tt_global_entry)) 1091 if (tt_local_entry &&
1092 _batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
1078 goto out; 1093 goto out;
1079 1094
1080 best_tq = 0; 1095 best_tq = 0;
@@ -1098,16 +1113,16 @@ struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv,
1098 rcu_read_unlock(); 1113 rcu_read_unlock();
1099out: 1114out:
1100 if (tt_global_entry) 1115 if (tt_global_entry)
1101 tt_global_entry_free_ref(tt_global_entry); 1116 batadv_tt_global_entry_free_ref(tt_global_entry);
1102 if (tt_local_entry) 1117 if (tt_local_entry)
1103 tt_local_entry_free_ref(tt_local_entry); 1118 batadv_tt_local_entry_free_ref(tt_local_entry);
1104 1119
1105 return orig_node; 1120 return orig_node;
1106} 1121}
1107 1122
1108/* Calculates the checksum of the local table of a given orig_node */ 1123/* Calculates the checksum of the local table of a given orig_node */
1109static uint16_t tt_global_crc(struct bat_priv *bat_priv, 1124static uint16_t batadv_tt_global_crc(struct bat_priv *bat_priv,
1110 struct orig_node *orig_node) 1125 struct orig_node *orig_node)
1111{ 1126{
1112 uint16_t total = 0, total_one; 1127 uint16_t total = 0, total_one;
1113 struct hashtable_t *hash = bat_priv->tt_global_hash; 1128 struct hashtable_t *hash = bat_priv->tt_global_hash;
@@ -1138,8 +1153,8 @@ static uint16_t tt_global_crc(struct bat_priv *bat_priv,
1138 /* find out if this global entry is announced by this 1153 /* find out if this global entry is announced by this
1139 * originator 1154 * originator
1140 */ 1155 */
1141 if (!tt_global_entry_has_orig(tt_global_entry, 1156 if (!batadv_tt_global_entry_has_orig(tt_global_entry,
1142 orig_node)) 1157 orig_node))
1143 continue; 1158 continue;
1144 1159
1145 total_one = 0; 1160 total_one = 0;
@@ -1188,7 +1203,7 @@ static uint16_t batadv_tt_local_crc(struct bat_priv *bat_priv)
1188 return total; 1203 return total;
1189} 1204}
1190 1205
1191static void tt_req_list_free(struct bat_priv *bat_priv) 1206static void batadv_tt_req_list_free(struct bat_priv *bat_priv)
1192{ 1207{
1193 struct tt_req_node *node, *safe; 1208 struct tt_req_node *node, *safe;
1194 1209
@@ -1202,10 +1217,10 @@ static void tt_req_list_free(struct bat_priv *bat_priv)
1202 spin_unlock_bh(&bat_priv->tt_req_list_lock); 1217 spin_unlock_bh(&bat_priv->tt_req_list_lock);
1203} 1218}
1204 1219
1205static void tt_save_orig_buffer(struct bat_priv *bat_priv, 1220static void batadv_tt_save_orig_buffer(struct bat_priv *bat_priv,
1206 struct orig_node *orig_node, 1221 struct orig_node *orig_node,
1207 const unsigned char *tt_buff, 1222 const unsigned char *tt_buff,
1208 uint8_t tt_num_changes) 1223 uint8_t tt_num_changes)
1209{ 1224{
1210 uint16_t tt_buff_len = batadv_tt_len(tt_num_changes); 1225 uint16_t tt_buff_len = batadv_tt_len(tt_num_changes);
1211 1226
@@ -1225,13 +1240,13 @@ static void tt_save_orig_buffer(struct bat_priv *bat_priv,
1225 spin_unlock_bh(&orig_node->tt_buff_lock); 1240 spin_unlock_bh(&orig_node->tt_buff_lock);
1226} 1241}
1227 1242
1228static void tt_req_purge(struct bat_priv *bat_priv) 1243static void batadv_tt_req_purge(struct bat_priv *bat_priv)
1229{ 1244{
1230 struct tt_req_node *node, *safe; 1245 struct tt_req_node *node, *safe;
1231 1246
1232 spin_lock_bh(&bat_priv->tt_req_list_lock); 1247 spin_lock_bh(&bat_priv->tt_req_list_lock);
1233 list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { 1248 list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) {
1234 if (has_timed_out(node->issued_at, TT_REQUEST_TIMEOUT)) { 1249 if (batadv_has_timed_out(node->issued_at, TT_REQUEST_TIMEOUT)) {
1235 list_del(&node->list); 1250 list_del(&node->list);
1236 kfree(node); 1251 kfree(node);
1237 } 1252 }
@@ -1242,16 +1257,16 @@ static void tt_req_purge(struct bat_priv *bat_priv)
1242/* returns the pointer to the new tt_req_node struct if no request 1257/* returns the pointer to the new tt_req_node struct if no request
1243 * has already been issued for this orig_node, NULL otherwise 1258 * has already been issued for this orig_node, NULL otherwise
1244 */ 1259 */
1245static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv, 1260static struct tt_req_node *batadv_new_tt_req_node(struct bat_priv *bat_priv,
1246 struct orig_node *orig_node) 1261 struct orig_node *orig_node)
1247{ 1262{
1248 struct tt_req_node *tt_req_node_tmp, *tt_req_node = NULL; 1263 struct tt_req_node *tt_req_node_tmp, *tt_req_node = NULL;
1249 1264
1250 spin_lock_bh(&bat_priv->tt_req_list_lock); 1265 spin_lock_bh(&bat_priv->tt_req_list_lock);
1251 list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) { 1266 list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) {
1252 if (compare_eth(tt_req_node_tmp, orig_node) && 1267 if (batadv_compare_eth(tt_req_node_tmp, orig_node) &&
1253 !has_timed_out(tt_req_node_tmp->issued_at, 1268 !batadv_has_timed_out(tt_req_node_tmp->issued_at,
1254 TT_REQUEST_TIMEOUT)) 1269 TT_REQUEST_TIMEOUT))
1255 goto unlock; 1270 goto unlock;
1256 } 1271 }
1257 1272
@@ -1269,7 +1284,8 @@ unlock:
1269} 1284}
1270 1285
1271/* data_ptr is useless here, but has to be kept to respect the prototype */ 1286/* data_ptr is useless here, but has to be kept to respect the prototype */
1272static int tt_local_valid_entry(const void *entry_ptr, const void *data_ptr) 1287static int batadv_tt_local_valid_entry(const void *entry_ptr,
1288 const void *data_ptr)
1273{ 1289{
1274 const struct tt_common_entry *tt_common_entry = entry_ptr; 1290 const struct tt_common_entry *tt_common_entry = entry_ptr;
1275 1291
@@ -1278,7 +1294,8 @@ static int tt_local_valid_entry(const void *entry_ptr, const void *data_ptr)
1278 return 1; 1294 return 1;
1279} 1295}
1280 1296
1281static int tt_global_valid_entry(const void *entry_ptr, const void *data_ptr) 1297static int batadv_tt_global_valid(const void *entry_ptr,
1298 const void *data_ptr)
1282{ 1299{
1283 const struct tt_common_entry *tt_common_entry = entry_ptr; 1300 const struct tt_common_entry *tt_common_entry = entry_ptr;
1284 const struct tt_global_entry *tt_global_entry; 1301 const struct tt_global_entry *tt_global_entry;
@@ -1290,15 +1307,15 @@ static int tt_global_valid_entry(const void *entry_ptr, const void *data_ptr)
1290 tt_global_entry = container_of(tt_common_entry, struct tt_global_entry, 1307 tt_global_entry = container_of(tt_common_entry, struct tt_global_entry,
1291 common); 1308 common);
1292 1309
1293 return tt_global_entry_has_orig(tt_global_entry, orig_node); 1310 return batadv_tt_global_entry_has_orig(tt_global_entry, orig_node);
1294} 1311}
1295 1312
1296static struct sk_buff *tt_response_fill_table(uint16_t tt_len, uint8_t ttvn, 1313static struct sk_buff *
1297 struct hashtable_t *hash, 1314batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn,
1298 struct hard_iface *primary_if, 1315 struct hashtable_t *hash,
1299 int (*valid_cb)(const void *, 1316 struct hard_iface *primary_if,
1300 const void *), 1317 int (*valid_cb)(const void *, const void *),
1301 void *cb_data) 1318 void *cb_data)
1302{ 1319{
1303 struct tt_common_entry *tt_common_entry; 1320 struct tt_common_entry *tt_common_entry;
1304 struct tt_query_packet *tt_response; 1321 struct tt_query_packet *tt_response;
@@ -1359,9 +1376,10 @@ out:
1359 return skb; 1376 return skb;
1360} 1377}
1361 1378
1362static int send_tt_request(struct bat_priv *bat_priv, 1379static int batadv_send_tt_request(struct bat_priv *bat_priv,
1363 struct orig_node *dst_orig_node, 1380 struct orig_node *dst_orig_node,
1364 uint8_t ttvn, uint16_t tt_crc, bool full_table) 1381 uint8_t ttvn, uint16_t tt_crc,
1382 bool full_table)
1365{ 1383{
1366 struct sk_buff *skb = NULL; 1384 struct sk_buff *skb = NULL;
1367 struct tt_query_packet *tt_request; 1385 struct tt_query_packet *tt_request;
@@ -1370,14 +1388,14 @@ static int send_tt_request(struct bat_priv *bat_priv,
1370 struct tt_req_node *tt_req_node = NULL; 1388 struct tt_req_node *tt_req_node = NULL;
1371 int ret = 1; 1389 int ret = 1;
1372 1390
1373 primary_if = primary_if_get_selected(bat_priv); 1391 primary_if = batadv_primary_if_get_selected(bat_priv);
1374 if (!primary_if) 1392 if (!primary_if)
1375 goto out; 1393 goto out;
1376 1394
1377 /* The new tt_req will be issued only if I'm not waiting for a 1395 /* The new tt_req will be issued only if I'm not waiting for a
1378 * reply from the same orig_node yet 1396 * reply from the same orig_node yet
1379 */ 1397 */
1380 tt_req_node = new_tt_req_node(bat_priv, dst_orig_node); 1398 tt_req_node = batadv_new_tt_req_node(bat_priv, dst_orig_node);
1381 if (!tt_req_node) 1399 if (!tt_req_node)
1382 goto out; 1400 goto out;
1383 1401
@@ -1406,10 +1424,10 @@ static int send_tt_request(struct bat_priv *bat_priv,
1406 if (!neigh_node) 1424 if (!neigh_node)
1407 goto out; 1425 goto out;
1408 1426
1409 bat_dbg(DBG_TT, bat_priv, 1427 batadv_dbg(DBG_TT, bat_priv,
1410 "Sending TT_REQUEST to %pM via %pM [%c]\n", 1428 "Sending TT_REQUEST to %pM via %pM [%c]\n",
1411 dst_orig_node->orig, neigh_node->addr, 1429 dst_orig_node->orig, neigh_node->addr,
1412 (full_table ? 'F' : '.')); 1430 (full_table ? 'F' : '.'));
1413 1431
1414 batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_TX); 1432 batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_TX);
1415 1433
@@ -1420,7 +1438,7 @@ out:
1420 if (neigh_node) 1438 if (neigh_node)
1421 batadv_neigh_node_free_ref(neigh_node); 1439 batadv_neigh_node_free_ref(neigh_node);
1422 if (primary_if) 1440 if (primary_if)
1423 hardif_free_ref(primary_if); 1441 batadv_hardif_free_ref(primary_if);
1424 if (ret) 1442 if (ret)
1425 kfree_skb(skb); 1443 kfree_skb(skb);
1426 if (ret && tt_req_node) { 1444 if (ret && tt_req_node) {
@@ -1432,8 +1450,8 @@ out:
1432 return ret; 1450 return ret;
1433} 1451}
1434 1452
1435static bool send_other_tt_response(struct bat_priv *bat_priv, 1453static bool batadv_send_other_tt_response(struct bat_priv *bat_priv,
1436 struct tt_query_packet *tt_request) 1454 struct tt_query_packet *tt_request)
1437{ 1455{
1438 struct orig_node *req_dst_orig_node = NULL, *res_dst_orig_node = NULL; 1456 struct orig_node *req_dst_orig_node = NULL, *res_dst_orig_node = NULL;
1439 struct neigh_node *neigh_node = NULL; 1457 struct neigh_node *neigh_node = NULL;
@@ -1446,17 +1464,17 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
1446 struct sk_buff *skb = NULL; 1464 struct sk_buff *skb = NULL;
1447 struct tt_query_packet *tt_response; 1465 struct tt_query_packet *tt_response;
1448 1466
1449 bat_dbg(DBG_TT, bat_priv, 1467 batadv_dbg(DBG_TT, bat_priv,
1450 "Received TT_REQUEST from %pM for ttvn: %u (%pM) [%c]\n", 1468 "Received TT_REQUEST from %pM for ttvn: %u (%pM) [%c]\n",
1451 tt_request->src, tt_request->ttvn, tt_request->dst, 1469 tt_request->src, tt_request->ttvn, tt_request->dst,
1452 (tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); 1470 (tt_request->flags & TT_FULL_TABLE ? 'F' : '.'));
1453 1471
1454 /* Let's get the orig node of the REAL destination */ 1472 /* Let's get the orig node of the REAL destination */
1455 req_dst_orig_node = orig_hash_find(bat_priv, tt_request->dst); 1473 req_dst_orig_node = batadv_orig_hash_find(bat_priv, tt_request->dst);
1456 if (!req_dst_orig_node) 1474 if (!req_dst_orig_node)
1457 goto out; 1475 goto out;
1458 1476
1459 res_dst_orig_node = orig_hash_find(bat_priv, tt_request->src); 1477 res_dst_orig_node = batadv_orig_hash_find(bat_priv, tt_request->src);
1460 if (!res_dst_orig_node) 1478 if (!res_dst_orig_node)
1461 goto out; 1479 goto out;
1462 1480
@@ -1464,7 +1482,7 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
1464 if (!neigh_node) 1482 if (!neigh_node)
1465 goto out; 1483 goto out;
1466 1484
1467 primary_if = primary_if_get_selected(bat_priv); 1485 primary_if = batadv_primary_if_get_selected(bat_priv);
1468 if (!primary_if) 1486 if (!primary_if)
1469 goto out; 1487 goto out;
1470 1488
@@ -1513,10 +1531,11 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
1513 sizeof(struct tt_change); 1531 sizeof(struct tt_change);
1514 ttvn = (uint8_t)atomic_read(&req_dst_orig_node->last_ttvn); 1532 ttvn = (uint8_t)atomic_read(&req_dst_orig_node->last_ttvn);
1515 1533
1516 skb = tt_response_fill_table(tt_len, ttvn, 1534 skb = batadv_tt_response_fill_table(tt_len, ttvn,
1517 bat_priv->tt_global_hash, 1535 bat_priv->tt_global_hash,
1518 primary_if, tt_global_valid_entry, 1536 primary_if,
1519 req_dst_orig_node); 1537 batadv_tt_global_valid,
1538 req_dst_orig_node);
1520 if (!skb) 1539 if (!skb)
1521 goto out; 1540 goto out;
1522 1541
@@ -1533,10 +1552,10 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
1533 if (full_table) 1552 if (full_table)
1534 tt_response->flags |= TT_FULL_TABLE; 1553 tt_response->flags |= TT_FULL_TABLE;
1535 1554
1536 bat_dbg(DBG_TT, bat_priv, 1555 batadv_dbg(DBG_TT, bat_priv,
1537 "Sending TT_RESPONSE %pM via %pM for %pM (ttvn: %u)\n", 1556 "Sending TT_RESPONSE %pM via %pM for %pM (ttvn: %u)\n",
1538 res_dst_orig_node->orig, neigh_node->addr, 1557 res_dst_orig_node->orig, neigh_node->addr,
1539 req_dst_orig_node->orig, req_ttvn); 1558 req_dst_orig_node->orig, req_ttvn);
1540 1559
1541 batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_TX); 1560 batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_TX);
1542 1561
@@ -1555,14 +1574,14 @@ out:
1555 if (neigh_node) 1574 if (neigh_node)
1556 batadv_neigh_node_free_ref(neigh_node); 1575 batadv_neigh_node_free_ref(neigh_node);
1557 if (primary_if) 1576 if (primary_if)
1558 hardif_free_ref(primary_if); 1577 batadv_hardif_free_ref(primary_if);
1559 if (!ret) 1578 if (!ret)
1560 kfree_skb(skb); 1579 kfree_skb(skb);
1561 return ret; 1580 return ret;
1562 1581
1563} 1582}
1564static bool send_my_tt_response(struct bat_priv *bat_priv, 1583static bool batadv_send_my_tt_response(struct bat_priv *bat_priv,
1565 struct tt_query_packet *tt_request) 1584 struct tt_query_packet *tt_request)
1566{ 1585{
1567 struct orig_node *orig_node = NULL; 1586 struct orig_node *orig_node = NULL;
1568 struct neigh_node *neigh_node = NULL; 1587 struct neigh_node *neigh_node = NULL;
@@ -1575,16 +1594,16 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
1575 struct sk_buff *skb = NULL; 1594 struct sk_buff *skb = NULL;
1576 struct tt_query_packet *tt_response; 1595 struct tt_query_packet *tt_response;
1577 1596
1578 bat_dbg(DBG_TT, bat_priv, 1597 batadv_dbg(DBG_TT, bat_priv,
1579 "Received TT_REQUEST from %pM for ttvn: %u (me) [%c]\n", 1598 "Received TT_REQUEST from %pM for ttvn: %u (me) [%c]\n",
1580 tt_request->src, tt_request->ttvn, 1599 tt_request->src, tt_request->ttvn,
1581 (tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); 1600 (tt_request->flags & TT_FULL_TABLE ? 'F' : '.'));
1582 1601
1583 1602
1584 my_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); 1603 my_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn);
1585 req_ttvn = tt_request->ttvn; 1604 req_ttvn = tt_request->ttvn;
1586 1605
1587 orig_node = orig_hash_find(bat_priv, tt_request->src); 1606 orig_node = batadv_orig_hash_find(bat_priv, tt_request->src);
1588 if (!orig_node) 1607 if (!orig_node)
1589 goto out; 1608 goto out;
1590 1609
@@ -1592,7 +1611,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
1592 if (!neigh_node) 1611 if (!neigh_node)
1593 goto out; 1612 goto out;
1594 1613
1595 primary_if = primary_if_get_selected(bat_priv); 1614 primary_if = batadv_primary_if_get_selected(bat_priv);
1596 if (!primary_if) 1615 if (!primary_if)
1597 goto out; 1616 goto out;
1598 1617
@@ -1633,10 +1652,11 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
1633 sizeof(struct tt_change); 1652 sizeof(struct tt_change);
1634 ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); 1653 ttvn = (uint8_t)atomic_read(&bat_priv->ttvn);
1635 1654
1636 skb = tt_response_fill_table(tt_len, ttvn, 1655 skb = batadv_tt_response_fill_table(tt_len, ttvn,
1637 bat_priv->tt_local_hash, 1656 bat_priv->tt_local_hash,
1638 primary_if, tt_local_valid_entry, 1657 primary_if,
1639 NULL); 1658 batadv_tt_local_valid_entry,
1659 NULL);
1640 if (!skb) 1660 if (!skb)
1641 goto out; 1661 goto out;
1642 1662
@@ -1653,10 +1673,10 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
1653 if (full_table) 1673 if (full_table)
1654 tt_response->flags |= TT_FULL_TABLE; 1674 tt_response->flags |= TT_FULL_TABLE;
1655 1675
1656 bat_dbg(DBG_TT, bat_priv, 1676 batadv_dbg(DBG_TT, bat_priv,
1657 "Sending TT_RESPONSE to %pM via %pM [%c]\n", 1677 "Sending TT_RESPONSE to %pM via %pM [%c]\n",
1658 orig_node->orig, neigh_node->addr, 1678 orig_node->orig, neigh_node->addr,
1659 (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); 1679 (tt_response->flags & TT_FULL_TABLE ? 'F' : '.'));
1660 1680
1661 batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_TX); 1681 batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_TX);
1662 1682
@@ -1672,7 +1692,7 @@ out:
1672 if (neigh_node) 1692 if (neigh_node)
1673 batadv_neigh_node_free_ref(neigh_node); 1693 batadv_neigh_node_free_ref(neigh_node);
1674 if (primary_if) 1694 if (primary_if)
1675 hardif_free_ref(primary_if); 1695 batadv_hardif_free_ref(primary_if);
1676 if (!ret) 1696 if (!ret)
1677 kfree_skb(skb); 1697 kfree_skb(skb);
1678 /* This packet was for me, so it doesn't need to be re-routed */ 1698 /* This packet was for me, so it doesn't need to be re-routed */
@@ -1687,26 +1707,28 @@ bool batadv_send_tt_response(struct bat_priv *bat_priv,
1687 if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_request->src)) 1707 if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_request->src))
1688 return true; 1708 return true;
1689 1709
1690 return send_my_tt_response(bat_priv, tt_request); 1710 return batadv_send_my_tt_response(bat_priv, tt_request);
1691 } else { 1711 } else {
1692 return send_other_tt_response(bat_priv, tt_request); 1712 return batadv_send_other_tt_response(bat_priv, tt_request);
1693 } 1713 }
1694} 1714}
1695 1715
1696static void _tt_update_changes(struct bat_priv *bat_priv, 1716static void _batadv_tt_update_changes(struct bat_priv *bat_priv,
1697 struct orig_node *orig_node, 1717 struct orig_node *orig_node,
1698 struct tt_change *tt_change, 1718 struct tt_change *tt_change,
1699 uint16_t tt_num_changes, uint8_t ttvn) 1719 uint16_t tt_num_changes, uint8_t ttvn)
1700{ 1720{
1701 int i; 1721 int i;
1702 int is_wifi; 1722 int is_wifi;
1723 int roams;
1703 1724
1704 for (i = 0; i < tt_num_changes; i++) { 1725 for (i = 0; i < tt_num_changes; i++) {
1705 if ((tt_change + i)->flags & TT_CLIENT_DEL) { 1726 if ((tt_change + i)->flags & TT_CLIENT_DEL) {
1706 tt_global_del(bat_priv, orig_node, 1727 roams = (tt_change + i)->flags & TT_CLIENT_ROAM;
1707 (tt_change + i)->addr, 1728 batadv_tt_global_del(bat_priv, orig_node,
1708 "tt removed by changes", 1729 (tt_change + i)->addr,
1709 (tt_change + i)->flags & TT_CLIENT_ROAM); 1730 "tt removed by changes",
1731 roams);
1710 } else { 1732 } else {
1711 is_wifi = (tt_change + i)->flags & TT_CLIENT_WIFI; 1733 is_wifi = (tt_change + i)->flags & TT_CLIENT_WIFI;
1712 if (!batadv_tt_global_add(bat_priv, orig_node, 1734 if (!batadv_tt_global_add(bat_priv, orig_node,
@@ -1724,21 +1746,22 @@ static void _tt_update_changes(struct bat_priv *bat_priv,
1724 orig_node->tt_initialised = true; 1746 orig_node->tt_initialised = true;
1725} 1747}
1726 1748
1727static void tt_fill_gtable(struct bat_priv *bat_priv, 1749static void batadv_tt_fill_gtable(struct bat_priv *bat_priv,
1728 struct tt_query_packet *tt_response) 1750 struct tt_query_packet *tt_response)
1729{ 1751{
1730 struct orig_node *orig_node = NULL; 1752 struct orig_node *orig_node = NULL;
1731 1753
1732 orig_node = orig_hash_find(bat_priv, tt_response->src); 1754 orig_node = batadv_orig_hash_find(bat_priv, tt_response->src);
1733 if (!orig_node) 1755 if (!orig_node)
1734 goto out; 1756 goto out;
1735 1757
1736 /* Purge the old table first.. */ 1758 /* Purge the old table first.. */
1737 batadv_tt_global_del_orig(bat_priv, orig_node, "Received full table"); 1759 batadv_tt_global_del_orig(bat_priv, orig_node, "Received full table");
1738 1760
1739 _tt_update_changes(bat_priv, orig_node, 1761 _batadv_tt_update_changes(bat_priv, orig_node,
1740 (struct tt_change *)(tt_response + 1), 1762 (struct tt_change *)(tt_response + 1),
1741 ntohs(tt_response->tt_data), tt_response->ttvn); 1763 ntohs(tt_response->tt_data),
1764 tt_response->ttvn);
1742 1765
1743 spin_lock_bh(&orig_node->tt_buff_lock); 1766 spin_lock_bh(&orig_node->tt_buff_lock);
1744 kfree(orig_node->tt_buff); 1767 kfree(orig_node->tt_buff);
@@ -1753,16 +1776,16 @@ out:
1753 batadv_orig_node_free_ref(orig_node); 1776 batadv_orig_node_free_ref(orig_node);
1754} 1777}
1755 1778
1756static void tt_update_changes(struct bat_priv *bat_priv, 1779static void batadv_tt_update_changes(struct bat_priv *bat_priv,
1757 struct orig_node *orig_node, 1780 struct orig_node *orig_node,
1758 uint16_t tt_num_changes, uint8_t ttvn, 1781 uint16_t tt_num_changes, uint8_t ttvn,
1759 struct tt_change *tt_change) 1782 struct tt_change *tt_change)
1760{ 1783{
1761 _tt_update_changes(bat_priv, orig_node, tt_change, tt_num_changes, 1784 _batadv_tt_update_changes(bat_priv, orig_node, tt_change,
1762 ttvn); 1785 tt_num_changes, ttvn);
1763 1786
1764 tt_save_orig_buffer(bat_priv, orig_node, (unsigned char *)tt_change, 1787 batadv_tt_save_orig_buffer(bat_priv, orig_node,
1765 tt_num_changes); 1788 (unsigned char *)tt_change, tt_num_changes);
1766 atomic_set(&orig_node->last_ttvn, ttvn); 1789 atomic_set(&orig_node->last_ttvn, ttvn);
1767} 1790}
1768 1791
@@ -1771,7 +1794,7 @@ bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr)
1771 struct tt_local_entry *tt_local_entry = NULL; 1794 struct tt_local_entry *tt_local_entry = NULL;
1772 bool ret = false; 1795 bool ret = false;
1773 1796
1774 tt_local_entry = tt_local_hash_find(bat_priv, addr); 1797 tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr);
1775 if (!tt_local_entry) 1798 if (!tt_local_entry)
1776 goto out; 1799 goto out;
1777 /* Check if the client has been logically deleted (but is kept for 1800 /* Check if the client has been logically deleted (but is kept for
@@ -1782,7 +1805,7 @@ bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr)
1782 ret = true; 1805 ret = true;
1783out: 1806out:
1784 if (tt_local_entry) 1807 if (tt_local_entry)
1785 tt_local_entry_free_ref(tt_local_entry); 1808 batadv_tt_local_entry_free_ref(tt_local_entry);
1786 return ret; 1809 return ret;
1787} 1810}
1788 1811
@@ -1792,32 +1815,32 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv,
1792 struct tt_req_node *node, *safe; 1815 struct tt_req_node *node, *safe;
1793 struct orig_node *orig_node = NULL; 1816 struct orig_node *orig_node = NULL;
1794 1817
1795 bat_dbg(DBG_TT, bat_priv, 1818 batadv_dbg(DBG_TT, bat_priv,
1796 "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n", 1819 "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n",
1797 tt_response->src, tt_response->ttvn, 1820 tt_response->src, tt_response->ttvn,
1798 ntohs(tt_response->tt_data), 1821 ntohs(tt_response->tt_data),
1799 (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); 1822 (tt_response->flags & TT_FULL_TABLE ? 'F' : '.'));
1800 1823
1801 /* we should have never asked a backbone gw */ 1824 /* we should have never asked a backbone gw */
1802 if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_response->src)) 1825 if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_response->src))
1803 goto out; 1826 goto out;
1804 1827
1805 orig_node = orig_hash_find(bat_priv, tt_response->src); 1828 orig_node = batadv_orig_hash_find(bat_priv, tt_response->src);
1806 if (!orig_node) 1829 if (!orig_node)
1807 goto out; 1830 goto out;
1808 1831
1809 if (tt_response->flags & TT_FULL_TABLE) 1832 if (tt_response->flags & TT_FULL_TABLE)
1810 tt_fill_gtable(bat_priv, tt_response); 1833 batadv_tt_fill_gtable(bat_priv, tt_response);
1811 else 1834 else
1812 tt_update_changes(bat_priv, orig_node, 1835 batadv_tt_update_changes(bat_priv, orig_node,
1813 ntohs(tt_response->tt_data), 1836 ntohs(tt_response->tt_data),
1814 tt_response->ttvn, 1837 tt_response->ttvn,
1815 (struct tt_change *)(tt_response + 1)); 1838 (struct tt_change *)(tt_response + 1));
1816 1839
1817 /* Delete the tt_req_node from pending tt_requests list */ 1840 /* Delete the tt_req_node from pending tt_requests list */
1818 spin_lock_bh(&bat_priv->tt_req_list_lock); 1841 spin_lock_bh(&bat_priv->tt_req_list_lock);
1819 list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { 1842 list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) {
1820 if (!compare_eth(node->addr, tt_response->src)) 1843 if (!batadv_compare_eth(node->addr, tt_response->src))
1821 continue; 1844 continue;
1822 list_del(&node->list); 1845 list_del(&node->list);
1823 kfree(node); 1846 kfree(node);
@@ -1825,7 +1848,7 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv,
1825 spin_unlock_bh(&bat_priv->tt_req_list_lock); 1848 spin_unlock_bh(&bat_priv->tt_req_list_lock);
1826 1849
1827 /* Recalculate the CRC for this orig_node and store it */ 1850 /* Recalculate the CRC for this orig_node and store it */
1828 orig_node->tt_crc = tt_global_crc(bat_priv, orig_node); 1851 orig_node->tt_crc = batadv_tt_global_crc(bat_priv, orig_node);
1829 /* Roaming phase is over: tables are in sync again. I can 1852 /* Roaming phase is over: tables are in sync again. I can
1830 * unset the flag 1853 * unset the flag
1831 */ 1854 */
@@ -1839,20 +1862,20 @@ int batadv_tt_init(struct bat_priv *bat_priv)
1839{ 1862{
1840 int ret; 1863 int ret;
1841 1864
1842 ret = tt_local_init(bat_priv); 1865 ret = batadv_tt_local_init(bat_priv);
1843 if (ret < 0) 1866 if (ret < 0)
1844 return ret; 1867 return ret;
1845 1868
1846 ret = tt_global_init(bat_priv); 1869 ret = batadv_tt_global_init(bat_priv);
1847 if (ret < 0) 1870 if (ret < 0)
1848 return ret; 1871 return ret;
1849 1872
1850 tt_start_timer(bat_priv); 1873 batadv_tt_start_timer(bat_priv);
1851 1874
1852 return 1; 1875 return 1;
1853} 1876}
1854 1877
1855static void tt_roam_list_free(struct bat_priv *bat_priv) 1878static void batadv_tt_roam_list_free(struct bat_priv *bat_priv)
1856{ 1879{
1857 struct tt_roam_node *node, *safe; 1880 struct tt_roam_node *node, *safe;
1858 1881
@@ -1866,13 +1889,13 @@ static void tt_roam_list_free(struct bat_priv *bat_priv)
1866 spin_unlock_bh(&bat_priv->tt_roam_list_lock); 1889 spin_unlock_bh(&bat_priv->tt_roam_list_lock);
1867} 1890}
1868 1891
1869static void tt_roam_purge(struct bat_priv *bat_priv) 1892static void batadv_tt_roam_purge(struct bat_priv *bat_priv)
1870{ 1893{
1871 struct tt_roam_node *node, *safe; 1894 struct tt_roam_node *node, *safe;
1872 1895
1873 spin_lock_bh(&bat_priv->tt_roam_list_lock); 1896 spin_lock_bh(&bat_priv->tt_roam_list_lock);
1874 list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) { 1897 list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) {
1875 if (!has_timed_out(node->first_time, ROAMING_MAX_TIME)) 1898 if (!batadv_has_timed_out(node->first_time, ROAMING_MAX_TIME))
1876 continue; 1899 continue;
1877 1900
1878 list_del(&node->list); 1901 list_del(&node->list);
@@ -1887,8 +1910,8 @@ static void tt_roam_purge(struct bat_priv *bat_priv)
1887 * 1910 *
1888 * returns true if the ROAMING_ADV can be sent, false otherwise 1911 * returns true if the ROAMING_ADV can be sent, false otherwise
1889 */ 1912 */
1890static bool tt_check_roam_count(struct bat_priv *bat_priv, 1913static bool batadv_tt_check_roam_count(struct bat_priv *bat_priv,
1891 uint8_t *client) 1914 uint8_t *client)
1892{ 1915{
1893 struct tt_roam_node *tt_roam_node; 1916 struct tt_roam_node *tt_roam_node;
1894 bool ret = false; 1917 bool ret = false;
@@ -1898,10 +1921,11 @@ static bool tt_check_roam_count(struct bat_priv *bat_priv,
1898 * reply from the same orig_node yet 1921 * reply from the same orig_node yet
1899 */ 1922 */
1900 list_for_each_entry(tt_roam_node, &bat_priv->tt_roam_list, list) { 1923 list_for_each_entry(tt_roam_node, &bat_priv->tt_roam_list, list) {
1901 if (!compare_eth(tt_roam_node->addr, client)) 1924 if (!batadv_compare_eth(tt_roam_node->addr, client))
1902 continue; 1925 continue;
1903 1926
1904 if (has_timed_out(tt_roam_node->first_time, ROAMING_MAX_TIME)) 1927 if (batadv_has_timed_out(tt_roam_node->first_time,
1928 ROAMING_MAX_TIME))
1905 continue; 1929 continue;
1906 1930
1907 if (!atomic_dec_not_zero(&tt_roam_node->counter)) 1931 if (!atomic_dec_not_zero(&tt_roam_node->counter))
@@ -1929,8 +1953,8 @@ unlock:
1929 return ret; 1953 return ret;
1930} 1954}
1931 1955
1932static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, 1956static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
1933 struct orig_node *orig_node) 1957 struct orig_node *orig_node)
1934{ 1958{
1935 struct neigh_node *neigh_node = NULL; 1959 struct neigh_node *neigh_node = NULL;
1936 struct sk_buff *skb = NULL; 1960 struct sk_buff *skb = NULL;
@@ -1941,7 +1965,7 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
1941 /* before going on we have to check whether the client has 1965 /* before going on we have to check whether the client has
1942 * already roamed to us too many times 1966 * already roamed to us too many times
1943 */ 1967 */
1944 if (!tt_check_roam_count(bat_priv, client)) 1968 if (!batadv_tt_check_roam_count(bat_priv, client))
1945 goto out; 1969 goto out;
1946 1970
1947 skb = dev_alloc_skb(sizeof(struct roam_adv_packet) + ETH_HLEN); 1971 skb = dev_alloc_skb(sizeof(struct roam_adv_packet) + ETH_HLEN);
@@ -1956,11 +1980,11 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
1956 roam_adv_packet->header.packet_type = BAT_ROAM_ADV; 1980 roam_adv_packet->header.packet_type = BAT_ROAM_ADV;
1957 roam_adv_packet->header.version = COMPAT_VERSION; 1981 roam_adv_packet->header.version = COMPAT_VERSION;
1958 roam_adv_packet->header.ttl = TTL; 1982 roam_adv_packet->header.ttl = TTL;
1959 primary_if = primary_if_get_selected(bat_priv); 1983 primary_if = batadv_primary_if_get_selected(bat_priv);
1960 if (!primary_if) 1984 if (!primary_if)
1961 goto out; 1985 goto out;
1962 memcpy(roam_adv_packet->src, primary_if->net_dev->dev_addr, ETH_ALEN); 1986 memcpy(roam_adv_packet->src, primary_if->net_dev->dev_addr, ETH_ALEN);
1963 hardif_free_ref(primary_if); 1987 batadv_hardif_free_ref(primary_if);
1964 memcpy(roam_adv_packet->dst, orig_node->orig, ETH_ALEN); 1988 memcpy(roam_adv_packet->dst, orig_node->orig, ETH_ALEN);
1965 memcpy(roam_adv_packet->client, client, ETH_ALEN); 1989 memcpy(roam_adv_packet->client, client, ETH_ALEN);
1966 1990
@@ -1968,9 +1992,9 @@ static void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
1968 if (!neigh_node) 1992 if (!neigh_node)
1969 goto out; 1993 goto out;
1970 1994
1971 bat_dbg(DBG_TT, bat_priv, 1995 batadv_dbg(DBG_TT, bat_priv,
1972 "Sending ROAMING_ADV to %pM (client %pM) via %pM\n", 1996 "Sending ROAMING_ADV to %pM (client %pM) via %pM\n",
1973 orig_node->orig, client, neigh_node->addr); 1997 orig_node->orig, client, neigh_node->addr);
1974 1998
1975 batadv_inc_counter(bat_priv, BAT_CNT_TT_ROAM_ADV_TX); 1999 batadv_inc_counter(bat_priv, BAT_CNT_TT_ROAM_ADV_TX);
1976 2000
@@ -1985,30 +2009,30 @@ out:
1985 return; 2009 return;
1986} 2010}
1987 2011
1988static void tt_purge(struct work_struct *work) 2012static void batadv_tt_purge(struct work_struct *work)
1989{ 2013{
1990 struct delayed_work *delayed_work = 2014 struct delayed_work *delayed_work =
1991 container_of(work, struct delayed_work, work); 2015 container_of(work, struct delayed_work, work);
1992 struct bat_priv *bat_priv = 2016 struct bat_priv *bat_priv =
1993 container_of(delayed_work, struct bat_priv, tt_work); 2017 container_of(delayed_work, struct bat_priv, tt_work);
1994 2018
1995 tt_local_purge(bat_priv); 2019 batadv_tt_local_purge(bat_priv);
1996 tt_global_roam_purge(bat_priv); 2020 batadv_tt_global_roam_purge(bat_priv);
1997 tt_req_purge(bat_priv); 2021 batadv_tt_req_purge(bat_priv);
1998 tt_roam_purge(bat_priv); 2022 batadv_tt_roam_purge(bat_priv);
1999 2023
2000 tt_start_timer(bat_priv); 2024 batadv_tt_start_timer(bat_priv);
2001} 2025}
2002 2026
2003void batadv_tt_free(struct bat_priv *bat_priv) 2027void batadv_tt_free(struct bat_priv *bat_priv)
2004{ 2028{
2005 cancel_delayed_work_sync(&bat_priv->tt_work); 2029 cancel_delayed_work_sync(&bat_priv->tt_work);
2006 2030
2007 tt_local_table_free(bat_priv); 2031 batadv_tt_local_table_free(bat_priv);
2008 tt_global_table_free(bat_priv); 2032 batadv_tt_global_table_free(bat_priv);
2009 tt_req_list_free(bat_priv); 2033 batadv_tt_req_list_free(bat_priv);
2010 tt_changes_list_free(bat_priv); 2034 batadv_tt_changes_list_free(bat_priv);
2011 tt_roam_list_free(bat_priv); 2035 batadv_tt_roam_list_free(bat_priv);
2012 2036
2013 kfree(bat_priv->tt_buff); 2037 kfree(bat_priv->tt_buff);
2014} 2038}
@@ -2016,8 +2040,8 @@ void batadv_tt_free(struct bat_priv *bat_priv)
2016/* This function will enable or disable the specified flags for all the entries 2040/* This function will enable or disable the specified flags for all the entries
2017 * in the given hash table and returns the number of modified entries 2041 * in the given hash table and returns the number of modified entries
2018 */ 2042 */
2019static uint16_t tt_set_flags(struct hashtable_t *hash, uint16_t flags, 2043static uint16_t batadv_tt_set_flags(struct hashtable_t *hash, uint16_t flags,
2020 bool enable) 2044 bool enable)
2021{ 2045{
2022 uint32_t i; 2046 uint32_t i;
2023 uint16_t changed_num = 0; 2047 uint16_t changed_num = 0;
@@ -2052,7 +2076,7 @@ out:
2052} 2076}
2053 2077
2054/* Purge out all the tt local entries marked with TT_CLIENT_PENDING */ 2078/* Purge out all the tt local entries marked with TT_CLIENT_PENDING */
2055static void tt_local_purge_pending_clients(struct bat_priv *bat_priv) 2079static void batadv_tt_local_purge_pending_clients(struct bat_priv *bat_priv)
2056{ 2080{
2057 struct hashtable_t *hash = bat_priv->tt_local_hash; 2081 struct hashtable_t *hash = bat_priv->tt_local_hash;
2058 struct tt_common_entry *tt_common_entry; 2082 struct tt_common_entry *tt_common_entry;
@@ -2075,50 +2099,51 @@ static void tt_local_purge_pending_clients(struct bat_priv *bat_priv)
2075 if (!(tt_common_entry->flags & TT_CLIENT_PENDING)) 2099 if (!(tt_common_entry->flags & TT_CLIENT_PENDING))
2076 continue; 2100 continue;
2077 2101
2078 bat_dbg(DBG_TT, bat_priv, 2102 batadv_dbg(DBG_TT, bat_priv,
2079 "Deleting local tt entry (%pM): pending\n", 2103 "Deleting local tt entry (%pM): pending\n",
2080 tt_common_entry->addr); 2104 tt_common_entry->addr);
2081 2105
2082 atomic_dec(&bat_priv->num_local_tt); 2106 atomic_dec(&bat_priv->num_local_tt);
2083 hlist_del_rcu(node); 2107 hlist_del_rcu(node);
2084 tt_local_entry = container_of(tt_common_entry, 2108 tt_local_entry = container_of(tt_common_entry,
2085 struct tt_local_entry, 2109 struct tt_local_entry,
2086 common); 2110 common);
2087 tt_local_entry_free_ref(tt_local_entry); 2111 batadv_tt_local_entry_free_ref(tt_local_entry);
2088 } 2112 }
2089 spin_unlock_bh(list_lock); 2113 spin_unlock_bh(list_lock);
2090 } 2114 }
2091 2115
2092} 2116}
2093 2117
2094static int tt_commit_changes(struct bat_priv *bat_priv, 2118static int batadv_tt_commit_changes(struct bat_priv *bat_priv,
2095 unsigned char **packet_buff, int *packet_buff_len, 2119 unsigned char **packet_buff,
2096 int packet_min_len) 2120 int *packet_buff_len, int packet_min_len)
2097{ 2121{
2098 uint16_t changed_num = 0; 2122 uint16_t changed_num = 0;
2099 2123
2100 if (atomic_read(&bat_priv->tt_local_changes) < 1) 2124 if (atomic_read(&bat_priv->tt_local_changes) < 1)
2101 return -ENOENT; 2125 return -ENOENT;
2102 2126
2103 changed_num = tt_set_flags(bat_priv->tt_local_hash, 2127 changed_num = batadv_tt_set_flags(bat_priv->tt_local_hash,
2104 TT_CLIENT_NEW, false); 2128 TT_CLIENT_NEW, false);
2105 2129
2106 /* all reset entries have to be counted as local entries */ 2130 /* all reset entries have to be counted as local entries */
2107 atomic_add(changed_num, &bat_priv->num_local_tt); 2131 atomic_add(changed_num, &bat_priv->num_local_tt);
2108 tt_local_purge_pending_clients(bat_priv); 2132 batadv_tt_local_purge_pending_clients(bat_priv);
2109 bat_priv->tt_crc = batadv_tt_local_crc(bat_priv); 2133 bat_priv->tt_crc = batadv_tt_local_crc(bat_priv);
2110 2134
2111 /* Increment the TTVN only once per OGM interval */ 2135 /* Increment the TTVN only once per OGM interval */
2112 atomic_inc(&bat_priv->ttvn); 2136 atomic_inc(&bat_priv->ttvn);
2113 bat_dbg(DBG_TT, bat_priv, "Local changes committed, updating to ttvn %u\n", 2137 batadv_dbg(DBG_TT, bat_priv,
2114 (uint8_t)atomic_read(&bat_priv->ttvn)); 2138 "Local changes committed, updating to ttvn %u\n",
2139 (uint8_t)atomic_read(&bat_priv->ttvn));
2115 bat_priv->tt_poss_change = false; 2140 bat_priv->tt_poss_change = false;
2116 2141
2117 /* reset the sending counter */ 2142 /* reset the sending counter */
2118 atomic_set(&bat_priv->tt_ogm_append_cnt, TT_OGM_APPEND_MAX); 2143 atomic_set(&bat_priv->tt_ogm_append_cnt, TT_OGM_APPEND_MAX);
2119 2144
2120 return tt_changes_fill_buff(bat_priv, packet_buff, 2145 return batadv_tt_changes_fill_buff(bat_priv, packet_buff,
2121 packet_buff_len, packet_min_len); 2146 packet_buff_len, packet_min_len);
2122} 2147}
2123 2148
2124/* when calling this function (hard_iface == primary_if) has to be true */ 2149/* when calling this function (hard_iface == primary_if) has to be true */
@@ -2129,14 +2154,15 @@ int batadv_tt_append_diff(struct bat_priv *bat_priv,
2129 int tt_num_changes; 2154 int tt_num_changes;
2130 2155
2131 /* if at least one change happened */ 2156 /* if at least one change happened */
2132 tt_num_changes = tt_commit_changes(bat_priv, packet_buff, 2157 tt_num_changes = batadv_tt_commit_changes(bat_priv, packet_buff,
2133 packet_buff_len, packet_min_len); 2158 packet_buff_len,
2159 packet_min_len);
2134 2160
2135 /* if the changes have been sent often enough */ 2161 /* if the changes have been sent often enough */
2136 if ((tt_num_changes < 0) && 2162 if ((tt_num_changes < 0) &&
2137 (!atomic_dec_not_zero(&bat_priv->tt_ogm_append_cnt))) { 2163 (!atomic_dec_not_zero(&bat_priv->tt_ogm_append_cnt))) {
2138 tt_realloc_packet_buff(packet_buff, packet_buff_len, 2164 batadv_tt_realloc_packet_buff(packet_buff, packet_buff_len,
2139 packet_min_len, packet_min_len); 2165 packet_min_len, packet_min_len);
2140 tt_num_changes = 0; 2166 tt_num_changes = 0;
2141 } 2167 }
2142 2168
@@ -2153,24 +2179,24 @@ bool batadv_is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src,
2153 if (!atomic_read(&bat_priv->ap_isolation)) 2179 if (!atomic_read(&bat_priv->ap_isolation))
2154 goto out; 2180 goto out;
2155 2181
2156 tt_local_entry = tt_local_hash_find(bat_priv, dst); 2182 tt_local_entry = batadv_tt_local_hash_find(bat_priv, dst);
2157 if (!tt_local_entry) 2183 if (!tt_local_entry)
2158 goto out; 2184 goto out;
2159 2185
2160 tt_global_entry = tt_global_hash_find(bat_priv, src); 2186 tt_global_entry = batadv_tt_global_hash_find(bat_priv, src);
2161 if (!tt_global_entry) 2187 if (!tt_global_entry)
2162 goto out; 2188 goto out;
2163 2189
2164 if (!_is_ap_isolated(tt_local_entry, tt_global_entry)) 2190 if (_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
2165 goto out; 2191 goto out;
2166 2192
2167 ret = true; 2193 ret = true;
2168 2194
2169out: 2195out:
2170 if (tt_global_entry) 2196 if (tt_global_entry)
2171 tt_global_entry_free_ref(tt_global_entry); 2197 batadv_tt_global_entry_free_ref(tt_global_entry);
2172 if (tt_local_entry) 2198 if (tt_local_entry)
2173 tt_local_entry_free_ref(tt_local_entry); 2199 batadv_tt_local_entry_free_ref(tt_local_entry);
2174 return ret; 2200 return ret;
2175} 2201}
2176 2202
@@ -2200,14 +2226,14 @@ void batadv_tt_update_orig(struct bat_priv *bat_priv,
2200 goto request_table; 2226 goto request_table;
2201 } 2227 }
2202 2228
2203 tt_update_changes(bat_priv, orig_node, tt_num_changes, ttvn, 2229 batadv_tt_update_changes(bat_priv, orig_node, tt_num_changes,
2204 (struct tt_change *)tt_buff); 2230 ttvn, (struct tt_change *)tt_buff);
2205 2231
2206 /* Even if we received the precomputed crc with the OGM, we 2232 /* Even if we received the precomputed crc with the OGM, we
2207 * prefer to recompute it to spot any possible inconsistency 2233 * prefer to recompute it to spot any possible inconsistency
2208 * in the global table 2234 * in the global table
2209 */ 2235 */
2210 orig_node->tt_crc = tt_global_crc(bat_priv, orig_node); 2236 orig_node->tt_crc = batadv_tt_global_crc(bat_priv, orig_node);
2211 2237
2212 /* The ttvn alone is not enough to guarantee consistency 2238 /* The ttvn alone is not enough to guarantee consistency
2213 * because a single value could represent different states 2239 * because a single value could represent different states
@@ -2232,12 +2258,12 @@ void batadv_tt_update_orig(struct bat_priv *bat_priv,
2232 if (!orig_node->tt_initialised || ttvn != orig_ttvn || 2258 if (!orig_node->tt_initialised || ttvn != orig_ttvn ||
2233 orig_node->tt_crc != tt_crc) { 2259 orig_node->tt_crc != tt_crc) {
2234request_table: 2260request_table:
2235 bat_dbg(DBG_TT, bat_priv, 2261 batadv_dbg(DBG_TT, bat_priv,
2236 "TT inconsistency for %pM. Need to retrieve the correct information (ttvn: %u last_ttvn: %u crc: %u last_crc: %u num_changes: %u)\n", 2262 "TT inconsistency for %pM. Need to retrieve the correct information (ttvn: %u last_ttvn: %u crc: %u last_crc: %u num_changes: %u)\n",
2237 orig_node->orig, ttvn, orig_ttvn, tt_crc, 2263 orig_node->orig, ttvn, orig_ttvn, tt_crc,
2238 orig_node->tt_crc, tt_num_changes); 2264 orig_node->tt_crc, tt_num_changes);
2239 send_tt_request(bat_priv, orig_node, ttvn, tt_crc, 2265 batadv_send_tt_request(bat_priv, orig_node, ttvn,
2240 full_table); 2266 tt_crc, full_table);
2241 return; 2267 return;
2242 } 2268 }
2243 } 2269 }
@@ -2253,12 +2279,12 @@ bool batadv_tt_global_client_is_roaming(struct bat_priv *bat_priv,
2253 struct tt_global_entry *tt_global_entry; 2279 struct tt_global_entry *tt_global_entry;
2254 bool ret = false; 2280 bool ret = false;
2255 2281
2256 tt_global_entry = tt_global_hash_find(bat_priv, addr); 2282 tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr);
2257 if (!tt_global_entry) 2283 if (!tt_global_entry)
2258 goto out; 2284 goto out;
2259 2285
2260 ret = tt_global_entry->common.flags & TT_CLIENT_ROAM; 2286 ret = tt_global_entry->common.flags & TT_CLIENT_ROAM;
2261 tt_global_entry_free_ref(tt_global_entry); 2287 batadv_tt_global_entry_free_ref(tt_global_entry);
2262out: 2288out:
2263 return ret; 2289 return ret;
2264} 2290}
diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
index b2b76df69607..d021055ad262 100644
--- a/net/batman-adv/unicast.c
+++ b/net/batman-adv/unicast.c
@@ -181,7 +181,7 @@ int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
181 181
182 *new_skb = NULL; 182 *new_skb = NULL;
183 183
184 orig_node = orig_hash_find(bat_priv, unicast_packet->orig); 184 orig_node = batadv_orig_hash_find(bat_priv, unicast_packet->orig);
185 if (!orig_node) 185 if (!orig_node)
186 goto out; 186 goto out;
187 187
@@ -227,7 +227,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
227 int large_tail = 0, ret = NET_RX_DROP; 227 int large_tail = 0, ret = NET_RX_DROP;
228 uint16_t seqno; 228 uint16_t seqno;
229 229
230 primary_if = primary_if_get_selected(bat_priv); 230 primary_if = batadv_primary_if_get_selected(bat_priv);
231 if (!primary_if) 231 if (!primary_if)
232 goto dropped; 232 goto dropped;
233 233
@@ -277,7 +277,7 @@ dropped:
277 kfree_skb(skb); 277 kfree_skb(skb);
278out: 278out:
279 if (primary_if) 279 if (primary_if)
280 hardif_free_ref(primary_if); 280 batadv_hardif_free_ref(primary_if);
281 return ret; 281 return ret;
282} 282}
283 283
diff --git a/net/batman-adv/unicast.h b/net/batman-adv/unicast.h
index 87f8f89d1440..9257b83534fd 100644
--- a/net/batman-adv/unicast.h
+++ b/net/batman-adv/unicast.h
@@ -33,7 +33,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
33 struct hard_iface *hard_iface, 33 struct hard_iface *hard_iface,
34 const uint8_t dstaddr[]); 34 const uint8_t dstaddr[]);
35 35
36static inline int frag_can_reassemble(const struct sk_buff *skb, int mtu) 36static inline int batadv_frag_can_reassemble(const struct sk_buff *skb, int mtu)
37{ 37{
38 const struct unicast_frag_packet *unicast_packet; 38 const struct unicast_frag_packet *unicast_packet;
39 int uneven_correction = 0; 39 int uneven_correction = 0;
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c
index 20eef04645bd..d45989e0bbd7 100644
--- a/net/batman-adv/vis.c
+++ b/net/batman-adv/vis.c
@@ -59,7 +59,7 @@ static int vis_info_cmp(const struct hlist_node *node, const void *data2)
59 d2 = data2; 59 d2 = data2;
60 p1 = (struct vis_packet *)d1->skb_packet->data; 60 p1 = (struct vis_packet *)d1->skb_packet->data;
61 p2 = (struct vis_packet *)d2->skb_packet->data; 61 p2 = (struct vis_packet *)d2->skb_packet->data;
62 return compare_eth(p1->vis_orig, p2->vis_orig); 62 return batadv_compare_eth(p1->vis_orig, p2->vis_orig);
63} 63}
64 64
65/* hash function to choose an entry in a hash table of given size 65/* hash function to choose an entry in a hash table of given size
@@ -127,7 +127,7 @@ static void vis_data_insert_interface(const uint8_t *interface,
127 struct hlist_node *pos; 127 struct hlist_node *pos;
128 128
129 hlist_for_each_entry(entry, pos, if_list, list) { 129 hlist_for_each_entry(entry, pos, if_list, list) {
130 if (compare_eth(entry->addr, interface)) 130 if (batadv_compare_eth(entry->addr, interface))
131 return; 131 return;
132 } 132 }
133 133
@@ -181,7 +181,7 @@ static ssize_t vis_data_read_entry(char *buff,
181 /* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */ 181 /* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */
182 if (primary && entry->quality == 0) 182 if (primary && entry->quality == 0)
183 return sprintf(buff, "TT %pM, ", entry->dest); 183 return sprintf(buff, "TT %pM, ", entry->dest);
184 else if (compare_eth(entry->src, src)) 184 else if (batadv_compare_eth(entry->src, src))
185 return sprintf(buff, "TQ %pM %d, ", entry->dest, 185 return sprintf(buff, "TQ %pM %d, ", entry->dest,
186 entry->quality); 186 entry->quality);
187 187
@@ -208,7 +208,7 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
208 size_t buff_pos, buf_size; 208 size_t buff_pos, buf_size;
209 char *buff; 209 char *buff;
210 210
211 primary_if = primary_if_get_selected(bat_priv); 211 primary_if = batadv_primary_if_get_selected(bat_priv);
212 if (!primary_if) 212 if (!primary_if)
213 goto out; 213 goto out;
214 214
@@ -233,8 +233,8 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
233 for (j = 0; j < packet->entries; j++) { 233 for (j = 0; j < packet->entries; j++) {
234 if (entries[j].quality == 0) 234 if (entries[j].quality == 0)
235 continue; 235 continue;
236 if (compare_eth(entries[j].src, 236 if (batadv_compare_eth(entries[j].src,
237 packet->vis_orig)) 237 packet->vis_orig))
238 continue; 238 continue;
239 vis_data_insert_interface(entries[j].src, 239 vis_data_insert_interface(entries[j].src,
240 &vis_if_list, 240 &vis_if_list,
@@ -245,7 +245,8 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
245 buf_size += 18 + 26 * packet->entries; 245 buf_size += 18 + 26 * packet->entries;
246 246
247 /* add primary/secondary records */ 247 /* add primary/secondary records */
248 if (compare_eth(entry->addr, packet->vis_orig)) 248 if (batadv_compare_eth(entry->addr,
249 packet->vis_orig))
249 buf_size += 250 buf_size +=
250 vis_data_count_prim_sec(&vis_if_list); 251 vis_data_count_prim_sec(&vis_if_list);
251 252
@@ -285,8 +286,8 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
285 for (j = 0; j < packet->entries; j++) { 286 for (j = 0; j < packet->entries; j++) {
286 if (entries[j].quality == 0) 287 if (entries[j].quality == 0)
287 continue; 288 continue;
288 if (compare_eth(entries[j].src, 289 if (batadv_compare_eth(entries[j].src,
289 packet->vis_orig)) 290 packet->vis_orig))
290 continue; 291 continue;
291 vis_data_insert_interface(entries[j].src, 292 vis_data_insert_interface(entries[j].src,
292 &vis_if_list, 293 &vis_if_list,
@@ -305,7 +306,8 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
305 entry->primary); 306 entry->primary);
306 307
307 /* add primary/secondary records */ 308 /* add primary/secondary records */
308 if (compare_eth(entry->addr, packet->vis_orig)) 309 if (batadv_compare_eth(entry->addr,
310 packet->vis_orig))
309 buff_pos += 311 buff_pos +=
310 vis_data_read_prim_sec(buff + buff_pos, 312 vis_data_read_prim_sec(buff + buff_pos,
311 &vis_if_list); 313 &vis_if_list);
@@ -329,7 +331,7 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset)
329 331
330out: 332out:
331 if (primary_if) 333 if (primary_if)
332 hardif_free_ref(primary_if); 334 batadv_hardif_free_ref(primary_if);
333 return ret; 335 return ret;
334} 336}
335 337
@@ -379,7 +381,7 @@ static int recv_list_is_in(struct bat_priv *bat_priv,
379 381
380 spin_lock_bh(&bat_priv->vis_list_lock); 382 spin_lock_bh(&bat_priv->vis_list_lock);
381 list_for_each_entry(entry, recv_list, list) { 383 list_for_each_entry(entry, recv_list, list) {
382 if (compare_eth(entry->mac, mac)) { 384 if (batadv_compare_eth(entry->mac, mac)) {
383 spin_unlock_bh(&bat_priv->vis_list_lock); 385 spin_unlock_bh(&bat_priv->vis_list_lock);
384 return 1; 386 return 1;
385 } 387 }
@@ -433,8 +435,8 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv,
433 } 435 }
434 } 436 }
435 /* remove old entry */ 437 /* remove old entry */
436 hash_remove(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, 438 batadv_hash_remove(bat_priv->vis_hash, vis_info_cmp,
437 old_info); 439 vis_info_choose, old_info);
438 send_list_del(old_info); 440 send_list_del(old_info);
439 kref_put(&old_info->refcount, free_info); 441 kref_put(&old_info->refcount, free_info);
440 } 442 }
@@ -474,8 +476,8 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv,
474 recv_list_add(bat_priv, &info->recv_list, packet->sender_orig); 476 recv_list_add(bat_priv, &info->recv_list, packet->sender_orig);
475 477
476 /* try to add it */ 478 /* try to add it */
477 hash_added = hash_add(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, 479 hash_added = batadv_hash_add(bat_priv->vis_hash, vis_info_cmp,
478 info, &info->hash_entry); 480 vis_info_choose, info, &info->hash_entry);
479 if (hash_added != 0) { 481 if (hash_added != 0) {
480 /* did not work (for some reason) */ 482 /* did not work (for some reason) */
481 kref_put(&info->refcount, free_info); 483 kref_put(&info->refcount, free_info);
@@ -651,7 +653,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
651 if (!router) 653 if (!router)
652 continue; 654 continue;
653 655
654 if (!compare_eth(router->addr, orig_node->orig)) 656 if (!batadv_compare_eth(router->addr, orig_node->orig))
655 goto next; 657 goto next;
656 658
657 if (router->if_incoming->if_status != IF_ACTIVE) 659 if (router->if_incoming->if_status != IF_ACTIVE)
@@ -728,7 +730,8 @@ static void purge_vis_packets(struct bat_priv *bat_priv)
728 if (info == bat_priv->my_vis_info) 730 if (info == bat_priv->my_vis_info)
729 continue; 731 continue;
730 732
731 if (has_timed_out(info->first_seen, VIS_TIMEOUT)) { 733 if (batadv_has_timed_out(info->first_seen,
734 VIS_TIMEOUT)) {
732 hlist_del(node); 735 hlist_del(node);
733 send_list_del(info); 736 send_list_del(info);
734 kref_put(&info->refcount, free_info); 737 kref_put(&info->refcount, free_info);
@@ -803,7 +806,7 @@ static void unicast_vis_packet(struct bat_priv *bat_priv,
803 806
804 packet = (struct vis_packet *)info->skb_packet->data; 807 packet = (struct vis_packet *)info->skb_packet->data;
805 808
806 orig_node = orig_hash_find(bat_priv, packet->target_orig); 809 orig_node = batadv_orig_hash_find(bat_priv, packet->target_orig);
807 if (!orig_node) 810 if (!orig_node)
808 goto out; 811 goto out;
809 812
@@ -828,7 +831,7 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)
828 struct hard_iface *primary_if; 831 struct hard_iface *primary_if;
829 struct vis_packet *packet; 832 struct vis_packet *packet;
830 833
831 primary_if = primary_if_get_selected(bat_priv); 834 primary_if = batadv_primary_if_get_selected(bat_priv);
832 if (!primary_if) 835 if (!primary_if)
833 goto out; 836 goto out;
834 837
@@ -849,7 +852,7 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)
849 852
850out: 853out:
851 if (primary_if) 854 if (primary_if)
852 hardif_free_ref(primary_if); 855 batadv_hardif_free_ref(primary_if);
853} 856}
854 857
855/* called from timer; send (and maybe generate) vis packet. */ 858/* called from timer; send (and maybe generate) vis packet. */
@@ -934,9 +937,9 @@ int batadv_vis_init(struct bat_priv *bat_priv)
934 937
935 INIT_LIST_HEAD(&bat_priv->vis_send_list); 938 INIT_LIST_HEAD(&bat_priv->vis_send_list);
936 939
937 hash_added = hash_add(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, 940 hash_added = batadv_hash_add(bat_priv->vis_hash, vis_info_cmp,
938 bat_priv->my_vis_info, 941 vis_info_choose, bat_priv->my_vis_info,
939 &bat_priv->my_vis_info->hash_entry); 942 &bat_priv->my_vis_info->hash_entry);
940 if (hash_added != 0) { 943 if (hash_added != 0) {
941 pr_err("Can't add own vis packet into hash\n"); 944 pr_err("Can't add own vis packet into hash\n");
942 /* not in hash, need to remove it manually. */ 945 /* not in hash, need to remove it manually. */
@@ -977,7 +980,7 @@ void batadv_vis_quit(struct bat_priv *bat_priv)
977 980
978 spin_lock_bh(&bat_priv->vis_hash_lock); 981 spin_lock_bh(&bat_priv->vis_hash_lock);
979 /* properly remove, kill timers ... */ 982 /* properly remove, kill timers ... */
980 hash_delete(bat_priv->vis_hash, free_info_ref, NULL); 983 batadv_hash_delete(bat_priv->vis_hash, free_info_ref, NULL);
981 bat_priv->vis_hash = NULL; 984 bat_priv->vis_hash = NULL;
982 bat_priv->my_vis_info = NULL; 985 bat_priv->my_vis_info = NULL;
983 spin_unlock_bh(&bat_priv->vis_hash_lock); 986 spin_unlock_bh(&bat_priv->vis_hash_lock);