H A D | network-coding.c | 202 * @nc_path: the nc node to free 204 static void batadv_nc_path_free_ref(struct batadv_nc_path *nc_path) batadv_nc_path_free_ref() argument 206 if (atomic_dec_and_test(&nc_path->refcount)) batadv_nc_path_free_ref() 207 kfree_rcu(nc_path, rcu); batadv_nc_path_free_ref() 219 batadv_nc_path_free_ref(nc_packet->nc_path); batadv_nc_packet_free() 242 * @nc_path: the nc path to check 247 struct batadv_nc_path *nc_path) batadv_nc_to_purge_nc_path_coding() 255 return batadv_has_timed_out(nc_path->last_valid, batadv_nc_to_purge_nc_path_coding() 262 * @nc_path: the nc path to check 267 struct batadv_nc_path *nc_path) batadv_nc_to_purge_nc_path_decoding() 275 return batadv_has_timed_out(nc_path->last_valid, batadv_nc_to_purge_nc_path_decoding() 387 struct batadv_nc_path *nc_path; batadv_nc_purge_paths() local 395 /* For each nc_path in this bin */ batadv_nc_purge_paths() 397 hlist_for_each_entry_safe(nc_path, node_tmp, head, hash_entry) { hlist_for_each_entry_safe() 401 if (to_purge && !to_purge(bat_priv, nc_path)) hlist_for_each_entry_safe() 404 /* purging an non-empty nc_path should never happen, but hlist_for_each_entry_safe() 409 if (!unlikely(list_empty(&nc_path->packet_list))) { hlist_for_each_entry_safe() 412 "Skipping free of non-empty nc_path (%pM -> %pM)!\n", hlist_for_each_entry_safe() 413 nc_path->prev_hop, hlist_for_each_entry_safe() 414 nc_path->next_hop); hlist_for_each_entry_safe() 418 /* nc_path is unused, so remove it */ hlist_for_each_entry_safe() 420 "Remove nc_path %pM -> %pM\n", hlist_for_each_entry_safe() 421 nc_path->prev_hop, nc_path->next_hop); hlist_for_each_entry_safe() 422 hlist_del_rcu(&nc_path->hash_entry); hlist_for_each_entry_safe() 423 batadv_nc_path_free_ref(nc_path); hlist_for_each_entry_safe() 430 * batadv_nc_hash_key_gen - computes the nc_path hash key 451 const struct batadv_nc_path *nc_path = data; batadv_nc_hash_choose() local 454 hash = batadv_hash_bytes(hash, &nc_path->prev_hop, batadv_nc_hash_choose() 455 sizeof(nc_path->prev_hop)); batadv_nc_hash_choose() 456 hash = batadv_hash_bytes(hash, &nc_path->next_hop, batadv_nc_hash_choose() 457 sizeof(nc_path->next_hop)); batadv_nc_hash_choose() 499 * Returns the nc_path if found, NULL otherwise. 506 struct batadv_nc_path *nc_path, *nc_path_tmp = NULL; batadv_nc_hash_find() local 516 hlist_for_each_entry_rcu(nc_path, head, hash_entry) { hlist_for_each_entry_rcu() 517 if (!batadv_nc_hash_compare(&nc_path->hash_entry, data)) hlist_for_each_entry_rcu() 520 if (!atomic_inc_not_zero(&nc_path->refcount)) hlist_for_each_entry_rcu() 523 nc_path_tmp = nc_path; hlist_for_each_entry_rcu() 539 nc_packet->nc_path->next_hop); batadv_nc_send_packet() 547 * @nc_path: the nc path the packet belongs to 558 struct batadv_nc_path *nc_path, batadv_nc_sniffed_purge() 584 * @nc_path: the nc path the packet belongs to 595 struct batadv_nc_path *nc_path, batadv_nc_fwd_flush() 635 struct batadv_nc_path *nc_path; batadv_nc_process_nc_paths() local 648 hlist_for_each_entry_rcu(nc_path, head, hash_entry) { hlist_for_each_entry_rcu() 650 spin_lock_bh(&nc_path->packet_list_lock); hlist_for_each_entry_rcu() 652 &nc_path->packet_list, list) { hlist_for_each_entry_rcu() 653 ret = process_fn(bat_priv, nc_path, nc_packet); hlist_for_each_entry_rcu() 657 spin_unlock_bh(&nc_path->packet_list_lock); hlist_for_each_entry_rcu() 904 * batadv_nc_get_path - get existing nc_path or allocate a new one 910 * Returns pointer to nc_path if the path was found or created, returns NULL 919 struct batadv_nc_path *nc_path, nc_path_key; batadv_nc_get_path() local 923 /* Search for existing nc_path */ batadv_nc_get_path() 924 nc_path = batadv_nc_hash_find(hash, (void *)&nc_path_key); batadv_nc_get_path() 926 if (nc_path) { batadv_nc_get_path() 927 /* Set timestamp to delay removal of nc_path */ batadv_nc_get_path() 928 nc_path->last_valid = jiffies; batadv_nc_get_path() 929 return nc_path; batadv_nc_get_path() 932 /* No existing nc_path was found; create a new */ batadv_nc_get_path() 933 nc_path = kzalloc(sizeof(*nc_path), GFP_ATOMIC); batadv_nc_get_path() 935 if (!nc_path) batadv_nc_get_path() 938 /* Initialize nc_path */ batadv_nc_get_path() 939 INIT_LIST_HEAD(&nc_path->packet_list); batadv_nc_get_path() 940 spin_lock_init(&nc_path->packet_list_lock); batadv_nc_get_path() 941 atomic_set(&nc_path->refcount, 2); batadv_nc_get_path() 942 nc_path->last_valid = jiffies; batadv_nc_get_path() 943 ether_addr_copy(nc_path->next_hop, dst); batadv_nc_get_path() 944 ether_addr_copy(nc_path->prev_hop, src); batadv_nc_get_path() 946 batadv_dbg(BATADV_DBG_NC, bat_priv, "Adding nc_path %pM -> %pM\n", batadv_nc_get_path() 947 nc_path->prev_hop, batadv_nc_get_path() 948 nc_path->next_hop); batadv_nc_get_path() 950 /* Add nc_path to hash table */ batadv_nc_get_path() 953 &nc_path->hash_entry); batadv_nc_get_path() 956 kfree(nc_path); batadv_nc_get_path() 960 return nc_path; batadv_nc_get_path() 1067 first_dest = nc_packet->nc_path->next_hop; batadv_nc_code_packets() 1068 first_source = nc_packet->nc_path->prev_hop; batadv_nc_code_packets() 1080 second_dest = nc_packet->nc_path->next_hop; batadv_nc_code_packets() 1081 second_source = nc_packet->nc_path->prev_hop; batadv_nc_code_packets() 1234 struct batadv_nc_path *nc_path, nc_path_key; batadv_nc_path_search() local 1248 /* Check for coding opportunities in this nc_path */ batadv_nc_path_search() 1250 hlist_for_each_entry_rcu(nc_path, &hash->table[idx], hash_entry) { batadv_nc_path_search() 1251 if (!batadv_compare_eth(nc_path->prev_hop, in_nc_node->addr)) batadv_nc_path_search() 1254 if (!batadv_compare_eth(nc_path->next_hop, out_nc_node->addr)) batadv_nc_path_search() 1257 spin_lock_bh(&nc_path->packet_list_lock); batadv_nc_path_search() 1258 if (list_empty(&nc_path->packet_list)) { batadv_nc_path_search() 1259 spin_unlock_bh(&nc_path->packet_list_lock); batadv_nc_path_search() 1264 &nc_path->packet_list, list) { batadv_nc_path_search() 1276 spin_unlock_bh(&nc_path->packet_list_lock); batadv_nc_path_search() 1318 /* Search for an opportunity in this nc_path */ batadv_nc_skb_src_search() 1426 * @nc_path: path to add skb to 1433 struct batadv_nc_path *nc_path, batadv_nc_skb_add_to_path() 1448 nc_packet->nc_path = nc_path; batadv_nc_skb_add_to_path() 1451 spin_lock_bh(&nc_path->packet_list_lock); batadv_nc_skb_add_to_path() 1452 list_add_tail(&nc_packet->list, &nc_path->packet_list); batadv_nc_skb_add_to_path() 1453 spin_unlock_bh(&nc_path->packet_list_lock); batadv_nc_skb_add_to_path() 1472 struct batadv_nc_path *nc_path; batadv_nc_skb_forward() local 1491 /* Find or create a nc_path for this src-dst pair */ batadv_nc_skb_forward() 1492 nc_path = batadv_nc_get_path(bat_priv, batadv_nc_skb_forward() 1497 if (!nc_path) batadv_nc_skb_forward() 1500 /* Add skb to nc_path */ batadv_nc_skb_forward() 1502 if (!batadv_nc_skb_add_to_path(skb, nc_path, neigh_node, packet_id)) batadv_nc_skb_forward() 1509 batadv_nc_path_free_ref(nc_path); batadv_nc_skb_forward() 1525 struct batadv_nc_path *nc_path; batadv_nc_skb_store_for_decoding() local 1540 /* Find existing nc_path or create a new */ batadv_nc_skb_store_for_decoding() 1541 nc_path = batadv_nc_get_path(bat_priv, batadv_nc_skb_store_for_decoding() 1546 if (!nc_path) batadv_nc_skb_store_for_decoding() 1560 /* Add skb to nc_path */ batadv_nc_skb_store_for_decoding() 1562 if (!batadv_nc_skb_add_to_path(skb, nc_path, NULL, packet_id)) batadv_nc_skb_store_for_decoding() 1571 batadv_nc_path_free_ref(nc_path); batadv_nc_skb_store_for_decoding() 1706 struct batadv_nc_path *nc_path, nc_path_key; batadv_nc_find_decoding_packet() local 1729 hlist_for_each_entry_rcu(nc_path, &hash->table[index], hash_entry) { batadv_nc_find_decoding_packet() 1731 spin_lock_bh(&nc_path->packet_list_lock); batadv_nc_find_decoding_packet() 1733 &nc_path->packet_list, list) { batadv_nc_find_decoding_packet() 1741 spin_unlock_bh(&nc_path->packet_list_lock); batadv_nc_find_decoding_packet() 246 batadv_nc_to_purge_nc_path_coding(struct batadv_priv *bat_priv, struct batadv_nc_path *nc_path) batadv_nc_to_purge_nc_path_coding() argument 266 batadv_nc_to_purge_nc_path_decoding(struct batadv_priv *bat_priv, struct batadv_nc_path *nc_path) batadv_nc_to_purge_nc_path_decoding() argument 557 batadv_nc_sniffed_purge(struct batadv_priv *bat_priv, struct batadv_nc_path *nc_path, struct batadv_nc_packet *nc_packet) batadv_nc_sniffed_purge() argument 594 batadv_nc_fwd_flush(struct batadv_priv *bat_priv, struct batadv_nc_path *nc_path, struct batadv_nc_packet *nc_packet) batadv_nc_fwd_flush() argument 1432 batadv_nc_skb_add_to_path(struct sk_buff *skb, struct batadv_nc_path *nc_path, struct batadv_neigh_node *neigh_node, __be32 packet_id) batadv_nc_skb_add_to_path() argument
|