diff options
Diffstat (limited to 'net/batman-adv/translation-table.c')
-rw-r--r-- | net/batman-adv/translation-table.c | 87 |
1 files changed, 50 insertions, 37 deletions
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 79cd3f76a865..a0487e9f18c7 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -257,7 +257,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, | |||
257 | (uint8_t)atomic_read(&bat_priv->ttvn)); | 257 | (uint8_t)atomic_read(&bat_priv->ttvn)); |
258 | 258 | ||
259 | memcpy(tt_local_entry->common.addr, addr, ETH_ALEN); | 259 | memcpy(tt_local_entry->common.addr, addr, ETH_ALEN); |
260 | tt_local_entry->common.flags = NO_FLAGS; | 260 | tt_local_entry->common.flags = BATADV_NO_FLAGS; |
261 | if (batadv_is_wifi_iface(ifindex)) | 261 | if (batadv_is_wifi_iface(ifindex)) |
262 | tt_local_entry->common.flags |= TT_CLIENT_WIFI; | 262 | tt_local_entry->common.flags |= TT_CLIENT_WIFI; |
263 | atomic_set(&tt_local_entry->common.refcount, 2); | 263 | atomic_set(&tt_local_entry->common.refcount, 2); |
@@ -493,14 +493,17 @@ void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, | |||
493 | const char *message, bool roaming) | 493 | const char *message, bool roaming) |
494 | { | 494 | { |
495 | struct tt_local_entry *tt_local_entry = NULL; | 495 | struct tt_local_entry *tt_local_entry = NULL; |
496 | uint16_t flags; | ||
496 | 497 | ||
497 | tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr); | 498 | tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr); |
498 | if (!tt_local_entry) | 499 | if (!tt_local_entry) |
499 | goto out; | 500 | goto out; |
500 | 501 | ||
501 | batadv_tt_local_set_pending(bat_priv, tt_local_entry, TT_CLIENT_DEL | | 502 | flags = TT_CLIENT_DEL; |
502 | (roaming ? TT_CLIENT_ROAM : NO_FLAGS), | 503 | if (roaming) |
503 | message); | 504 | flags |= TT_CLIENT_ROAM; |
505 | |||
506 | batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags, message); | ||
504 | out: | 507 | out: |
505 | if (tt_local_entry) | 508 | if (tt_local_entry) |
506 | batadv_tt_local_entry_free_ref(tt_local_entry); | 509 | batadv_tt_local_entry_free_ref(tt_local_entry); |
@@ -534,7 +537,7 @@ static void batadv_tt_local_purge(struct bat_priv *bat_priv) | |||
534 | continue; | 537 | continue; |
535 | 538 | ||
536 | if (!batadv_has_timed_out(tt_local_entry->last_seen, | 539 | if (!batadv_has_timed_out(tt_local_entry->last_seen, |
537 | TT_LOCAL_TIMEOUT)) | 540 | BATADV_TT_LOCAL_TIMEOUT)) |
538 | continue; | 541 | continue; |
539 | 542 | ||
540 | batadv_tt_local_set_pending(bat_priv, tt_local_entry, | 543 | batadv_tt_local_set_pending(bat_priv, tt_local_entry, |
@@ -1008,12 +1011,35 @@ void batadv_tt_global_del_orig(struct bat_priv *bat_priv, | |||
1008 | orig_node->tt_initialised = false; | 1011 | orig_node->tt_initialised = false; |
1009 | } | 1012 | } |
1010 | 1013 | ||
1011 | static void batadv_tt_global_roam_purge(struct bat_priv *bat_priv) | 1014 | static void batadv_tt_global_roam_purge_list(struct bat_priv *bat_priv, |
1015 | struct hlist_head *head) | ||
1012 | { | 1016 | { |
1013 | struct hashtable_t *hash = bat_priv->tt_global_hash; | ||
1014 | struct tt_common_entry *tt_common_entry; | 1017 | struct tt_common_entry *tt_common_entry; |
1015 | struct tt_global_entry *tt_global_entry; | 1018 | struct tt_global_entry *tt_global_entry; |
1016 | struct hlist_node *node, *node_tmp; | 1019 | struct hlist_node *node, *node_tmp; |
1020 | |||
1021 | hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, head, | ||
1022 | hash_entry) { | ||
1023 | tt_global_entry = container_of(tt_common_entry, | ||
1024 | struct tt_global_entry, common); | ||
1025 | if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM)) | ||
1026 | continue; | ||
1027 | if (!batadv_has_timed_out(tt_global_entry->roam_at, | ||
1028 | BATADV_TT_CLIENT_ROAM_TIMEOUT)) | ||
1029 | continue; | ||
1030 | |||
1031 | batadv_dbg(DBG_TT, bat_priv, | ||
1032 | "Deleting global tt entry (%pM): Roaming timeout\n", | ||
1033 | tt_global_entry->common.addr); | ||
1034 | |||
1035 | hlist_del_rcu(node); | ||
1036 | batadv_tt_global_entry_free_ref(tt_global_entry); | ||
1037 | } | ||
1038 | } | ||
1039 | |||
1040 | static void batadv_tt_global_roam_purge(struct bat_priv *bat_priv) | ||
1041 | { | ||
1042 | struct hashtable_t *hash = bat_priv->tt_global_hash; | ||
1017 | struct hlist_head *head; | 1043 | struct hlist_head *head; |
1018 | spinlock_t *list_lock; /* protects write access to the hash lists */ | 1044 | spinlock_t *list_lock; /* protects write access to the hash lists */ |
1019 | uint32_t i; | 1045 | uint32_t i; |
@@ -1023,24 +1049,7 @@ static void batadv_tt_global_roam_purge(struct bat_priv *bat_priv) | |||
1023 | list_lock = &hash->list_locks[i]; | 1049 | list_lock = &hash->list_locks[i]; |
1024 | 1050 | ||
1025 | spin_lock_bh(list_lock); | 1051 | spin_lock_bh(list_lock); |
1026 | hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, | 1052 | batadv_tt_global_roam_purge_list(bat_priv, head); |
1027 | head, hash_entry) { | ||
1028 | tt_global_entry = container_of(tt_common_entry, | ||
1029 | struct tt_global_entry, | ||
1030 | common); | ||
1031 | if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM)) | ||
1032 | continue; | ||
1033 | if (!batadv_has_timed_out(tt_global_entry->roam_at, | ||
1034 | TT_CLIENT_ROAM_TIMEOUT)) | ||
1035 | continue; | ||
1036 | |||
1037 | batadv_dbg(DBG_TT, bat_priv, | ||
1038 | "Deleting global tt entry (%pM): Roaming timeout\n", | ||
1039 | tt_global_entry->common.addr); | ||
1040 | |||
1041 | hlist_del_rcu(node); | ||
1042 | batadv_tt_global_entry_free_ref(tt_global_entry); | ||
1043 | } | ||
1044 | spin_unlock_bh(list_lock); | 1053 | spin_unlock_bh(list_lock); |
1045 | } | 1054 | } |
1046 | 1055 | ||
@@ -1278,7 +1287,8 @@ static void batadv_tt_req_purge(struct bat_priv *bat_priv) | |||
1278 | 1287 | ||
1279 | spin_lock_bh(&bat_priv->tt_req_list_lock); | 1288 | spin_lock_bh(&bat_priv->tt_req_list_lock); |
1280 | list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { | 1289 | list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { |
1281 | if (batadv_has_timed_out(node->issued_at, TT_REQUEST_TIMEOUT)) { | 1290 | if (batadv_has_timed_out(node->issued_at, |
1291 | BATADV_TT_REQUEST_TIMEOUT)) { | ||
1282 | list_del(&node->list); | 1292 | list_del(&node->list); |
1283 | kfree(node); | 1293 | kfree(node); |
1284 | } | 1294 | } |
@@ -1298,7 +1308,7 @@ static struct tt_req_node *batadv_new_tt_req_node(struct bat_priv *bat_priv, | |||
1298 | list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) { | 1308 | list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) { |
1299 | if (batadv_compare_eth(tt_req_node_tmp, orig_node) && | 1309 | if (batadv_compare_eth(tt_req_node_tmp, orig_node) && |
1300 | !batadv_has_timed_out(tt_req_node_tmp->issued_at, | 1310 | !batadv_has_timed_out(tt_req_node_tmp->issued_at, |
1301 | TT_REQUEST_TIMEOUT)) | 1311 | BATADV_TT_REQUEST_TIMEOUT)) |
1302 | goto unlock; | 1312 | goto unlock; |
1303 | } | 1313 | } |
1304 | 1314 | ||
@@ -1391,7 +1401,7 @@ batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn, | |||
1391 | 1401 | ||
1392 | memcpy(tt_change->addr, tt_common_entry->addr, | 1402 | memcpy(tt_change->addr, tt_common_entry->addr, |
1393 | ETH_ALEN); | 1403 | ETH_ALEN); |
1394 | tt_change->flags = NO_FLAGS; | 1404 | tt_change->flags = BATADV_NO_FLAGS; |
1395 | 1405 | ||
1396 | tt_count++; | 1406 | tt_count++; |
1397 | tt_change++; | 1407 | tt_change++; |
@@ -1444,7 +1454,7 @@ static int batadv_send_tt_request(struct bat_priv *bat_priv, | |||
1444 | tt_request->header.version = BATADV_COMPAT_VERSION; | 1454 | tt_request->header.version = BATADV_COMPAT_VERSION; |
1445 | memcpy(tt_request->src, primary_if->net_dev->dev_addr, ETH_ALEN); | 1455 | memcpy(tt_request->src, primary_if->net_dev->dev_addr, ETH_ALEN); |
1446 | memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN); | 1456 | memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN); |
1447 | tt_request->header.ttl = TTL; | 1457 | tt_request->header.ttl = BATADV_TTL; |
1448 | tt_request->ttvn = ttvn; | 1458 | tt_request->ttvn = ttvn; |
1449 | tt_request->tt_data = htons(tt_crc); | 1459 | tt_request->tt_data = htons(tt_crc); |
1450 | tt_request->flags = TT_REQUEST; | 1460 | tt_request->flags = TT_REQUEST; |
@@ -1576,7 +1586,7 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv, | |||
1576 | 1586 | ||
1577 | tt_response->header.packet_type = BAT_TT_QUERY; | 1587 | tt_response->header.packet_type = BAT_TT_QUERY; |
1578 | tt_response->header.version = BATADV_COMPAT_VERSION; | 1588 | tt_response->header.version = BATADV_COMPAT_VERSION; |
1579 | tt_response->header.ttl = TTL; | 1589 | tt_response->header.ttl = BATADV_TTL; |
1580 | memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN); | 1590 | memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN); |
1581 | memcpy(tt_response->dst, tt_request->src, ETH_ALEN); | 1591 | memcpy(tt_response->dst, tt_request->src, ETH_ALEN); |
1582 | tt_response->flags = TT_RESPONSE; | 1592 | tt_response->flags = TT_RESPONSE; |
@@ -1697,7 +1707,7 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv, | |||
1697 | 1707 | ||
1698 | tt_response->header.packet_type = BAT_TT_QUERY; | 1708 | tt_response->header.packet_type = BAT_TT_QUERY; |
1699 | tt_response->header.version = BATADV_COMPAT_VERSION; | 1709 | tt_response->header.version = BATADV_COMPAT_VERSION; |
1700 | tt_response->header.ttl = TTL; | 1710 | tt_response->header.ttl = BATADV_TTL; |
1701 | memcpy(tt_response->src, primary_if->net_dev->dev_addr, ETH_ALEN); | 1711 | memcpy(tt_response->src, primary_if->net_dev->dev_addr, ETH_ALEN); |
1702 | memcpy(tt_response->dst, tt_request->src, ETH_ALEN); | 1712 | memcpy(tt_response->dst, tt_request->src, ETH_ALEN); |
1703 | tt_response->flags = TT_RESPONSE; | 1713 | tt_response->flags = TT_RESPONSE; |
@@ -1925,7 +1935,8 @@ static void batadv_tt_roam_purge(struct bat_priv *bat_priv) | |||
1925 | 1935 | ||
1926 | spin_lock_bh(&bat_priv->tt_roam_list_lock); | 1936 | spin_lock_bh(&bat_priv->tt_roam_list_lock); |
1927 | list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) { | 1937 | list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) { |
1928 | if (!batadv_has_timed_out(node->first_time, ROAMING_MAX_TIME)) | 1938 | if (!batadv_has_timed_out(node->first_time, |
1939 | BATADV_ROAMING_MAX_TIME)) | ||
1929 | continue; | 1940 | continue; |
1930 | 1941 | ||
1931 | list_del(&node->list); | 1942 | list_del(&node->list); |
@@ -1955,7 +1966,7 @@ static bool batadv_tt_check_roam_count(struct bat_priv *bat_priv, | |||
1955 | continue; | 1966 | continue; |
1956 | 1967 | ||
1957 | if (batadv_has_timed_out(tt_roam_node->first_time, | 1968 | if (batadv_has_timed_out(tt_roam_node->first_time, |
1958 | ROAMING_MAX_TIME)) | 1969 | BATADV_ROAMING_MAX_TIME)) |
1959 | continue; | 1970 | continue; |
1960 | 1971 | ||
1961 | if (!batadv_atomic_dec_not_zero(&tt_roam_node->counter)) | 1972 | if (!batadv_atomic_dec_not_zero(&tt_roam_node->counter)) |
@@ -1971,7 +1982,8 @@ static bool batadv_tt_check_roam_count(struct bat_priv *bat_priv, | |||
1971 | goto unlock; | 1982 | goto unlock; |
1972 | 1983 | ||
1973 | tt_roam_node->first_time = jiffies; | 1984 | tt_roam_node->first_time = jiffies; |
1974 | atomic_set(&tt_roam_node->counter, ROAMING_MAX_COUNT - 1); | 1985 | atomic_set(&tt_roam_node->counter, |
1986 | BATADV_ROAMING_MAX_COUNT - 1); | ||
1975 | memcpy(tt_roam_node->addr, client, ETH_ALEN); | 1987 | memcpy(tt_roam_node->addr, client, ETH_ALEN); |
1976 | 1988 | ||
1977 | list_add(&tt_roam_node->list, &bat_priv->tt_roam_list); | 1989 | list_add(&tt_roam_node->list, &bat_priv->tt_roam_list); |
@@ -2009,7 +2021,7 @@ static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, | |||
2009 | 2021 | ||
2010 | roam_adv_packet->header.packet_type = BAT_ROAM_ADV; | 2022 | roam_adv_packet->header.packet_type = BAT_ROAM_ADV; |
2011 | roam_adv_packet->header.version = BATADV_COMPAT_VERSION; | 2023 | roam_adv_packet->header.version = BATADV_COMPAT_VERSION; |
2012 | roam_adv_packet->header.ttl = TTL; | 2024 | roam_adv_packet->header.ttl = BATADV_TTL; |
2013 | primary_if = batadv_primary_if_get_selected(bat_priv); | 2025 | primary_if = batadv_primary_if_get_selected(bat_priv); |
2014 | if (!primary_if) | 2026 | if (!primary_if) |
2015 | goto out; | 2027 | goto out; |
@@ -2170,7 +2182,7 @@ static int batadv_tt_commit_changes(struct bat_priv *bat_priv, | |||
2170 | bat_priv->tt_poss_change = false; | 2182 | bat_priv->tt_poss_change = false; |
2171 | 2183 | ||
2172 | /* reset the sending counter */ | 2184 | /* reset the sending counter */ |
2173 | atomic_set(&bat_priv->tt_ogm_append_cnt, TT_OGM_APPEND_MAX); | 2185 | atomic_set(&bat_priv->tt_ogm_append_cnt, BATADV_TT_OGM_APPEND_MAX); |
2174 | 2186 | ||
2175 | return batadv_tt_changes_fill_buff(bat_priv, packet_buff, | 2187 | return batadv_tt_changes_fill_buff(bat_priv, packet_buff, |
2176 | packet_buff_len, packet_min_len); | 2188 | packet_buff_len, packet_min_len); |
@@ -2248,7 +2260,8 @@ void batadv_tt_update_orig(struct bat_priv *bat_priv, | |||
2248 | if ((!orig_node->tt_initialised && ttvn == 1) || | 2260 | if ((!orig_node->tt_initialised && ttvn == 1) || |
2249 | ttvn - orig_ttvn == 1) { | 2261 | ttvn - orig_ttvn == 1) { |
2250 | /* the OGM could not contain the changes due to their size or | 2262 | /* the OGM could not contain the changes due to their size or |
2251 | * because they have already been sent TT_OGM_APPEND_MAX times. | 2263 | * because they have already been sent BATADV_TT_OGM_APPEND_MAX |
2264 | * times. | ||
2252 | * In this case send a tt request | 2265 | * In this case send a tt request |
2253 | */ | 2266 | */ |
2254 | if (!tt_num_changes) { | 2267 | if (!tt_num_changes) { |