aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/translation-table.c
diff options
context:
space:
mode:
authorAntonio Quartulli <ordex@autistici.org>2012-09-23 16:38:34 -0400
committerAntonio Quartulli <ordex@autistici.org>2012-11-14 15:00:35 -0500
commit7c1fd91da5a5eecc91674991199940c05f87cb3a (patch)
tree9195dbbe9ea99a09540166dd571779d9b7fde478 /net/batman-adv/translation-table.c
parent28709878b6a7d15362ba63bde01d42c38f88be9d (diff)
batman-adv: substitute tt_poss_change with a per-tt_entry flag
tt_poss_change is a node-wide flag which tells whether the node is in a roaming state (a client recently moved to/away from it) in order to let it apply special re-routing rules. However this flag does not give a clear idea of the current state because it is not possible to understand *which client* is actually involved in the roaming. For this reason a better approach has been chosen: instead of using a node-wide variable, the roaming state is now given by a per-tt_entry ROAM flag which, in case of packet coming through the node, tells the node whether the real destination is in roaming state or not. With this flag change, batadv_check_unicast_ttvn() has also been rearranged in order to better fit the new re-routing logic and to be much more readable. Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net/batman-adv/translation-table.c')
-rw-r--r--net/batman-adv/translation-table.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index f8b9c32c29a5..d7418511448d 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -306,8 +306,6 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
306 head = &tt_global_entry->orig_list; 306 head = &tt_global_entry->orig_list;
307 rcu_read_lock(); 307 rcu_read_lock();
308 hlist_for_each_entry_rcu(orig_entry, node, head, list) { 308 hlist_for_each_entry_rcu(orig_entry, node, head, list) {
309 orig_entry->orig_node->tt_poss_change = true;
310
311 batadv_send_roam_adv(bat_priv, 309 batadv_send_roam_adv(bat_priv,
312 tt_global_entry->common.addr, 310 tt_global_entry->common.addr,
313 orig_entry->orig_node); 311 orig_entry->orig_node);
@@ -512,8 +510,11 @@ uint16_t batadv_tt_local_remove(struct batadv_priv *bat_priv,
512 curr_flags = tt_local_entry->common.flags; 510 curr_flags = tt_local_entry->common.flags;
513 511
514 flags = BATADV_TT_CLIENT_DEL; 512 flags = BATADV_TT_CLIENT_DEL;
515 if (roaming) 513 if (roaming) {
516 flags |= BATADV_TT_CLIENT_ROAM; 514 flags |= BATADV_TT_CLIENT_ROAM;
515 /* mark the local client as ROAMed */
516 tt_local_entry->common.flags |= BATADV_TT_CLIENT_ROAM;
517 }
517 518
518 batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags, message); 519 batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags, message);
519 520
@@ -1945,7 +1946,8 @@ bool batadv_is_my_client(struct batadv_priv *bat_priv, const uint8_t *addr)
1945 /* Check if the client has been logically deleted (but is kept for 1946 /* Check if the client has been logically deleted (but is kept for
1946 * consistency purpose) 1947 * consistency purpose)
1947 */ 1948 */
1948 if (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING) 1949 if ((tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING) ||
1950 (tt_local_entry->common.flags & BATADV_TT_CLIENT_ROAM))
1949 goto out; 1951 goto out;
1950 ret = true; 1952 ret = true;
1951out: 1953out:
@@ -1996,10 +1998,6 @@ void batadv_handle_tt_response(struct batadv_priv *bat_priv,
1996 1998
1997 /* Recalculate the CRC for this orig_node and store it */ 1999 /* Recalculate the CRC for this orig_node and store it */
1998 orig_node->tt_crc = batadv_tt_global_crc(bat_priv, orig_node); 2000 orig_node->tt_crc = batadv_tt_global_crc(bat_priv, orig_node);
1999 /* Roaming phase is over: tables are in sync again. I can
2000 * unset the flag
2001 */
2002 orig_node->tt_poss_change = false;
2003out: 2001out:
2004 if (orig_node) 2002 if (orig_node)
2005 batadv_orig_node_free_ref(orig_node); 2003 batadv_orig_node_free_ref(orig_node);
@@ -2290,7 +2288,6 @@ static int batadv_tt_commit_changes(struct batadv_priv *bat_priv,
2290 batadv_dbg(BATADV_DBG_TT, bat_priv, 2288 batadv_dbg(BATADV_DBG_TT, bat_priv,
2291 "Local changes committed, updating to ttvn %u\n", 2289 "Local changes committed, updating to ttvn %u\n",
2292 (uint8_t)atomic_read(&bat_priv->tt.vn)); 2290 (uint8_t)atomic_read(&bat_priv->tt.vn));
2293 bat_priv->tt.poss_change = false;
2294 2291
2295 /* reset the sending counter */ 2292 /* reset the sending counter */
2296 atomic_set(&bat_priv->tt.ogm_append_cnt, BATADV_TT_OGM_APPEND_MAX); 2293 atomic_set(&bat_priv->tt.ogm_append_cnt, BATADV_TT_OGM_APPEND_MAX);
@@ -2402,11 +2399,6 @@ void batadv_tt_update_orig(struct batadv_priv *bat_priv,
2402 */ 2399 */
2403 if (orig_node->tt_crc != tt_crc) 2400 if (orig_node->tt_crc != tt_crc)
2404 goto request_table; 2401 goto request_table;
2405
2406 /* Roaming phase is over: tables are in sync again. I can
2407 * unset the flag
2408 */
2409 orig_node->tt_poss_change = false;
2410 } else { 2402 } else {
2411 /* if we missed more than one change or our tables are not 2403 /* if we missed more than one change or our tables are not
2412 * in sync anymore -> request fresh tt data 2404 * in sync anymore -> request fresh tt data
@@ -2445,6 +2437,32 @@ out:
2445 return ret; 2437 return ret;
2446} 2438}
2447 2439
2440/**
2441 * batadv_tt_local_client_is_roaming - tells whether the client is roaming
2442 * @bat_priv: the bat priv with all the soft interface information
2443 * @addr: the MAC address of the local client to query
2444 *
2445 * Returns true if the local client is known to be roaming (it is not served by
2446 * this node anymore) or not. If yes, the client is still present in the table
2447 * to keep the latter consistent with the node TTVN
2448 */
2449bool batadv_tt_local_client_is_roaming(struct batadv_priv *bat_priv,
2450 uint8_t *addr)
2451{
2452 struct batadv_tt_local_entry *tt_local_entry;
2453 bool ret = false;
2454
2455 tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr);
2456 if (!tt_local_entry)
2457 goto out;
2458
2459 ret = tt_local_entry->common.flags & BATADV_TT_CLIENT_ROAM;
2460 batadv_tt_local_entry_free_ref(tt_local_entry);
2461out:
2462 return ret;
2463
2464}
2465
2448bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv, 2466bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv,
2449 struct batadv_orig_node *orig_node, 2467 struct batadv_orig_node *orig_node,
2450 const unsigned char *addr) 2468 const unsigned char *addr)