originator.c (4389e47af856635eb17d03b2572a50576c12db24) | originator.c (e6c10f433af9c98994c94a10ae862c152fcfb2a9) |
---|---|
1/* 2 * Copyright (C) 2009-2011 B.A.T.M.A.N. contributors: 3 * 4 * Marek Lindner, Simon Wunderlich 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of version 2 of the GNU General Public 8 * License as published by the Free Software Foundation. --- 59 unchanged lines hidden (view full) --- 68{ 69 if (atomic_dec_and_test(&neigh_node->refcount)) 70 call_rcu(&neigh_node->rcu, neigh_node_free_rcu); 71} 72 73struct neigh_node *create_neighbor(struct orig_node *orig_node, 74 struct orig_node *orig_neigh_node, 75 uint8_t *neigh, | 1/* 2 * Copyright (C) 2009-2011 B.A.T.M.A.N. contributors: 3 * 4 * Marek Lindner, Simon Wunderlich 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of version 2 of the GNU General Public 8 * License as published by the Free Software Foundation. --- 59 unchanged lines hidden (view full) --- 68{ 69 if (atomic_dec_and_test(&neigh_node->refcount)) 70 call_rcu(&neigh_node->rcu, neigh_node_free_rcu); 71} 72 73struct neigh_node *create_neighbor(struct orig_node *orig_node, 74 struct orig_node *orig_neigh_node, 75 uint8_t *neigh, |
76 struct batman_if *if_incoming) | 76 struct hard_iface *if_incoming) |
77{ 78 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 79 struct neigh_node *neigh_node; 80 81 bat_dbg(DBG_BATMAN, bat_priv, 82 "Creating new last-hop neighbor of originator\n"); 83 84 neigh_node = kzalloc(sizeof(struct neigh_node), GFP_ATOMIC); --- 397 unchanged lines hidden (view full) --- 482 memcpy(data_ptr, orig_node->bcast_own_sum, 483 (max_if_num - 1) * sizeof(uint8_t)); 484 kfree(orig_node->bcast_own_sum); 485 orig_node->bcast_own_sum = data_ptr; 486 487 return 0; 488} 489 | 77{ 78 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 79 struct neigh_node *neigh_node; 80 81 bat_dbg(DBG_BATMAN, bat_priv, 82 "Creating new last-hop neighbor of originator\n"); 83 84 neigh_node = kzalloc(sizeof(struct neigh_node), GFP_ATOMIC); --- 397 unchanged lines hidden (view full) --- 482 memcpy(data_ptr, orig_node->bcast_own_sum, 483 (max_if_num - 1) * sizeof(uint8_t)); 484 kfree(orig_node->bcast_own_sum); 485 orig_node->bcast_own_sum = data_ptr; 486 487 return 0; 488} 489 |
490int orig_hash_add_if(struct batman_if *batman_if, int max_if_num) | 490int orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num) |
491{ | 491{ |
492 struct bat_priv *bat_priv = netdev_priv(batman_if->soft_iface); | 492 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); |
493 struct hashtable_t *hash = bat_priv->orig_hash; 494 struct hlist_node *node; 495 struct hlist_head *head; 496 struct orig_node *orig_node; 497 int i, ret; 498 499 /* resize all orig nodes because orig_node->bcast_own(_sum) depend on 500 * if_num */ --- 66 unchanged lines hidden (view full) --- 567 568free_own_sum: 569 kfree(orig_node->bcast_own_sum); 570 orig_node->bcast_own_sum = data_ptr; 571 572 return 0; 573} 574 | 493 struct hashtable_t *hash = bat_priv->orig_hash; 494 struct hlist_node *node; 495 struct hlist_head *head; 496 struct orig_node *orig_node; 497 int i, ret; 498 499 /* resize all orig nodes because orig_node->bcast_own(_sum) depend on 500 * if_num */ --- 66 unchanged lines hidden (view full) --- 567 568free_own_sum: 569 kfree(orig_node->bcast_own_sum); 570 orig_node->bcast_own_sum = data_ptr; 571 572 return 0; 573} 574 |
575int orig_hash_del_if(struct batman_if *batman_if, int max_if_num) | 575int orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num) |
576{ | 576{ |
577 struct bat_priv *bat_priv = netdev_priv(batman_if->soft_iface); | 577 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); |
578 struct hashtable_t *hash = bat_priv->orig_hash; 579 struct hlist_node *node; 580 struct hlist_head *head; | 578 struct hashtable_t *hash = bat_priv->orig_hash; 579 struct hlist_node *node; 580 struct hlist_head *head; |
581 struct batman_if *batman_if_tmp; | 581 struct hard_iface *hard_iface_tmp; |
582 struct orig_node *orig_node; 583 int i, ret; 584 585 /* resize all orig nodes because orig_node->bcast_own(_sum) depend on 586 * if_num */ 587 for (i = 0; i < hash->size; i++) { 588 head = &hash->table[i]; 589 590 rcu_read_lock(); 591 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { 592 spin_lock_bh(&orig_node->ogm_cnt_lock); 593 ret = orig_node_del_if(orig_node, max_if_num, | 582 struct orig_node *orig_node; 583 int i, ret; 584 585 /* resize all orig nodes because orig_node->bcast_own(_sum) depend on 586 * if_num */ 587 for (i = 0; i < hash->size; i++) { 588 head = &hash->table[i]; 589 590 rcu_read_lock(); 591 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { 592 spin_lock_bh(&orig_node->ogm_cnt_lock); 593 ret = orig_node_del_if(orig_node, max_if_num, |
594 batman_if->if_num); | 594 hard_iface->if_num); |
595 spin_unlock_bh(&orig_node->ogm_cnt_lock); 596 597 if (ret == -1) 598 goto err; 599 } 600 rcu_read_unlock(); 601 } 602 603 /* renumber remaining batman interfaces _inside_ of orig_hash_lock */ 604 rcu_read_lock(); | 595 spin_unlock_bh(&orig_node->ogm_cnt_lock); 596 597 if (ret == -1) 598 goto err; 599 } 600 rcu_read_unlock(); 601 } 602 603 /* renumber remaining batman interfaces _inside_ of orig_hash_lock */ 604 rcu_read_lock(); |
605 list_for_each_entry_rcu(batman_if_tmp, &hardif_list, list) { 606 if (batman_if_tmp->if_status == IF_NOT_IN_USE) | 605 list_for_each_entry_rcu(hard_iface_tmp, &hardif_list, list) { 606 if (hard_iface_tmp->if_status == IF_NOT_IN_USE) |
607 continue; 608 | 607 continue; 608 |
609 if (batman_if == batman_if_tmp) | 609 if (hard_iface == hard_iface_tmp) |
610 continue; 611 | 610 continue; 611 |
612 if (batman_if->soft_iface != batman_if_tmp->soft_iface) | 612 if (hard_iface->soft_iface != hard_iface_tmp->soft_iface) |
613 continue; 614 | 613 continue; 614 |
615 if (batman_if_tmp->if_num > batman_if->if_num) 616 batman_if_tmp->if_num--; | 615 if (hard_iface_tmp->if_num > hard_iface->if_num) 616 hard_iface_tmp->if_num--; |
617 } 618 rcu_read_unlock(); 619 | 617 } 618 rcu_read_unlock(); 619 |
620 batman_if->if_num = -1; | 620 hard_iface->if_num = -1; |
621 return 0; 622 623err: 624 rcu_read_unlock(); 625 return -ENOMEM; 626} | 621 return 0; 622 623err: 624 rcu_read_unlock(); 625 return -ENOMEM; 626} |