aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
authorAntonio Quartulli <ordex@autistici.org>2011-06-17 10:11:27 -0400
committerMarek Lindner <lindner_marek@yahoo.de>2011-07-05 08:28:54 -0400
commit5fbc1598c28555d2aa44bff0ac56ec3739401aff (patch)
tree2664c2483f59a5bd4e36a59e37a8274f375ffba2 /net/batman-adv
parent43676ab590c3f8686fd047d34c3e33803eef71f0 (diff)
batman-adv: unify flags for tt_change/tt_local_entry/tt_global_entry
The tt_local_entry structure now has a 'flags' field. This helps to unify the flags format to all the client related structures (tt_global_entry and tt_change). The 'never_purge' field is now encoded in the 'flags' one. To optimise the usage of this field, its length has been increased to 16bit in order to use the eight leading bits (from 0 to 7) to store flags that have to be sent on the wire, while the eight ending ones are used for local computation only. Moreover 'enum tt_change_flags' is now called 'enum tt_client_flags' and the defined values apply to the tt_local_entry, tt_global_entry and the tt_change 'flags' field. Signed-off-by: Antonio Quartulli <ordex@autistici.org> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/packet.h11
-rw-r--r--net/batman-adv/translation-table.c13
-rw-r--r--net/batman-adv/translation-table.h3
-rw-r--r--net/batman-adv/types.h4
4 files changed, 16 insertions, 15 deletions
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index c5f081dfc6d1..590e4a66089f 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -78,10 +78,13 @@ enum tt_query_flags {
78 TT_FULL_TABLE = 1 << 2 78 TT_FULL_TABLE = 1 << 2
79}; 79};
80 80
81/* TT_CHANGE flags */ 81/* TT_CLIENT flags.
82enum tt_change_flags { 82 * Flags from 1 to 1 << 7 are sent on the wire, while flags from 1 << 8 to
83 TT_CHANGE_DEL = 0x01, 83 * 1 << 15 are used for local computation only */
84 TT_CLIENT_ROAM = 0x02 84enum tt_client_flags {
85 TT_CLIENT_DEL = 1 << 0,
86 TT_CLIENT_ROAM = 1 << 1,
87 TT_CLIENT_NOPURGE = 1 << 8
85}; 88};
86 89
87struct batman_packet { 90struct batman_packet {
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 5f1fcd573633..4208dc71257b 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -211,13 +211,12 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr)
211 211
212 memcpy(tt_local_entry->addr, addr, ETH_ALEN); 212 memcpy(tt_local_entry->addr, addr, ETH_ALEN);
213 tt_local_entry->last_seen = jiffies; 213 tt_local_entry->last_seen = jiffies;
214 tt_local_entry->flags = NO_FLAGS;
214 atomic_set(&tt_local_entry->refcount, 2); 215 atomic_set(&tt_local_entry->refcount, 2);
215 216
216 /* the batman interface mac address should never be purged */ 217 /* the batman interface mac address should never be purged */
217 if (compare_eth(addr, soft_iface->dev_addr)) 218 if (compare_eth(addr, soft_iface->dev_addr))
218 tt_local_entry->never_purge = 1; 219 tt_local_entry->flags |= TT_CLIENT_NOPURGE;
219 else
220 tt_local_entry->never_purge = 0;
221 220
222 hash_add(bat_priv->tt_local_hash, compare_ltt, choose_orig, 221 hash_add(bat_priv->tt_local_hash, compare_ltt, choose_orig,
223 tt_local_entry, &tt_local_entry->hash_entry); 222 tt_local_entry, &tt_local_entry->hash_entry);
@@ -387,7 +386,7 @@ void tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr,
387 if (!tt_local_entry) 386 if (!tt_local_entry)
388 goto out; 387 goto out;
389 388
390 tt_local_event(bat_priv, TT_CHANGE_DEL, tt_local_entry->addr, roaming); 389 tt_local_event(bat_priv, TT_CLIENT_DEL, tt_local_entry->addr, roaming);
391 tt_local_del(bat_priv, tt_local_entry, message); 390 tt_local_del(bat_priv, tt_local_entry, message);
392out: 391out:
393 if (tt_local_entry) 392 if (tt_local_entry)
@@ -410,14 +409,14 @@ static void tt_local_purge(struct bat_priv *bat_priv)
410 spin_lock_bh(list_lock); 409 spin_lock_bh(list_lock);
411 hlist_for_each_entry_safe(tt_local_entry, node, node_tmp, 410 hlist_for_each_entry_safe(tt_local_entry, node, node_tmp,
412 head, hash_entry) { 411 head, hash_entry) {
413 if (tt_local_entry->never_purge) 412 if (tt_local_entry->flags & TT_CLIENT_NOPURGE)
414 continue; 413 continue;
415 414
416 if (!is_out_of_time(tt_local_entry->last_seen, 415 if (!is_out_of_time(tt_local_entry->last_seen,
417 TT_LOCAL_TIMEOUT * 1000)) 416 TT_LOCAL_TIMEOUT * 1000))
418 continue; 417 continue;
419 418
420 tt_local_event(bat_priv, TT_CHANGE_DEL, 419 tt_local_event(bat_priv, TT_CLIENT_DEL,
421 tt_local_entry->addr, false); 420 tt_local_entry->addr, false);
422 atomic_dec(&bat_priv->num_local_tt); 421 atomic_dec(&bat_priv->num_local_tt);
423 bat_dbg(DBG_TT, bat_priv, "Deleting local " 422 bat_dbg(DBG_TT, bat_priv, "Deleting local "
@@ -1335,7 +1334,7 @@ static void _tt_update_changes(struct bat_priv *bat_priv,
1335 int i; 1334 int i;
1336 1335
1337 for (i = 0; i < tt_num_changes; i++) { 1336 for (i = 0; i < tt_num_changes; i++) {
1338 if ((tt_change + i)->flags & TT_CHANGE_DEL) 1337 if ((tt_change + i)->flags & TT_CLIENT_DEL)
1339 tt_global_del(bat_priv, orig_node, 1338 tt_global_del(bat_priv, orig_node,
1340 (tt_change + i)->addr, 1339 (tt_change + i)->addr,
1341 "tt removed by changes", 1340 "tt removed by changes",
diff --git a/net/batman-adv/translation-table.h b/net/batman-adv/translation-table.h
index 1cd2d39529fe..460e5839cdd6 100644
--- a/net/batman-adv/translation-table.h
+++ b/net/batman-adv/translation-table.h
@@ -30,8 +30,7 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr);
30void tt_local_remove(struct bat_priv *bat_priv, 30void tt_local_remove(struct bat_priv *bat_priv,
31 const uint8_t *addr, const char *message, bool roaming); 31 const uint8_t *addr, const char *message, bool roaming);
32int tt_local_seq_print_text(struct seq_file *seq, void *offset); 32int tt_local_seq_print_text(struct seq_file *seq, void *offset);
33void tt_global_add_orig(struct bat_priv *bat_priv, 33void tt_global_add_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
34 struct orig_node *orig_node,
35 const unsigned char *tt_buff, int tt_buff_len); 34 const unsigned char *tt_buff, int tt_buff_len);
36int tt_global_add(struct bat_priv *bat_priv, 35int tt_global_add(struct bat_priv *bat_priv,
37 struct orig_node *orig_node, const unsigned char *addr, 36 struct orig_node *orig_node, const unsigned char *addr,
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 85cf1224881e..25bd1db35370 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -224,7 +224,7 @@ struct socket_packet {
224struct tt_local_entry { 224struct tt_local_entry {
225 uint8_t addr[ETH_ALEN]; 225 uint8_t addr[ETH_ALEN];
226 unsigned long last_seen; 226 unsigned long last_seen;
227 char never_purge; 227 uint16_t flags;
228 atomic_t refcount; 228 atomic_t refcount;
229 struct rcu_head rcu; 229 struct rcu_head rcu;
230 struct hlist_node hash_entry; 230 struct hlist_node hash_entry;
@@ -234,7 +234,7 @@ struct tt_global_entry {
234 uint8_t addr[ETH_ALEN]; 234 uint8_t addr[ETH_ALEN];
235 struct orig_node *orig_node; 235 struct orig_node *orig_node;
236 uint8_t ttvn; 236 uint8_t ttvn;
237 uint8_t flags; /* only TT_GLOBAL_ROAM is used */ 237 uint16_t flags; /* only TT_GLOBAL_ROAM is used */
238 unsigned long roam_at; /* time at which TT_GLOBAL_ROAM was set */ 238 unsigned long roam_at; /* time at which TT_GLOBAL_ROAM was set */
239 atomic_t refcount; 239 atomic_t refcount;
240 struct rcu_head rcu; 240 struct rcu_head rcu;