FIX: segfault in neighbor/neighbor-2 table
authorHenning Rogge <rogge@fgan.de>
Thu, 23 Apr 2009 09:08:25 +0000 (11:08 +0200)
committerHenning Rogge <rogge@fgan.de>
Thu, 23 Apr 2009 09:08:25 +0000 (11:08 +0200)
src/neighbor_table.c
src/neighbor_table.h
src/two_hop_neighbor_table.c
src/two_hop_neighbor_table.h

index 70606f5..2b0b323 100644 (file)
@@ -116,14 +116,14 @@ olsr_del_nbr2_list(struct neighbor_2_list_entry *nbr2_list)
  * @return positive if entry deleted
  */
 int
-olsr_delete_neighbor_2_pointer(struct neighbor_entry *neighbor, union olsr_ip_addr *address)
+olsr_delete_neighbor_2_pointer(struct neighbor_entry *neighbor, struct neighbor_2_entry *neigh2)
 {
   struct neighbor_2_list_entry *nbr2_list;
 
   nbr2_list = neighbor->neighbor_2_list.next;
 
   while (nbr2_list != &neighbor->neighbor_2_list) {
-    if (olsr_ipcmp(&nbr2_list->neighbor_2->neighbor_2_addr, address) == 0) {
+    if (nbr2_list->neighbor_2 == neigh2) {
       olsr_del_nbr2_list(nbr2_list);
       return 1;
     }
@@ -207,7 +207,7 @@ olsr_delete_neighbor_table(const union olsr_ip_addr *neighbor_addr)
     two_hop_list = two_hop_list->next;
 
     two_hop_to_delete->neighbor_2->neighbor_2_pointer--;
-    olsr_delete_neighbor_pointer(two_hop_to_delete->neighbor_2, &entry->neighbor_main_addr);
+    olsr_delete_neighbor_pointer(two_hop_to_delete->neighbor_2, entry);
 
     olsr_del_nbr2_list(two_hop_to_delete);
   }
@@ -376,7 +376,7 @@ olsr_expire_nbr2_list(void *context)
   nbr2 = nbr2_list->neighbor_2;
 
   nbr2->neighbor_2_pointer--;
-  olsr_delete_neighbor_pointer(nbr2, &nbr->neighbor_main_addr);
+  olsr_delete_neighbor_pointer(nbr2, nbr);
 
   olsr_del_nbr2_list(nbr2_list);
 }
index ccad463..b555bfe 100644 (file)
@@ -94,7 +94,7 @@ EXPORT(neighbortable)[HASHSIZE];
        olsr_init_neighbor_table(void);
 
      int
-       olsr_delete_neighbor_2_pointer(struct neighbor_entry *, union olsr_ip_addr *);
+       olsr_delete_neighbor_2_pointer(struct neighbor_entry *, struct neighbor_2_entry *);
 
      struct neighbor_2_list_entry *olsr_lookup_my_neighbors(const struct neighbor_entry *, const union olsr_ip_addr *);
 
index 9553d40..bedad3b 100644 (file)
@@ -78,11 +78,11 @@ olsr_init_two_hop_table(void)
  *@return nada
  */
 void
-olsr_delete_neighbor_pointer(struct neighbor_2_entry *two_hop_entry, const union olsr_ip_addr *address)
+olsr_delete_neighbor_pointer(struct neighbor_2_entry *two_hop_entry, struct neighbor_entry *neigh)
 {
   struct neighbor_list_entry *entry = two_hop_entry->neighbor_2_nblist.next;
   while (entry != &two_hop_entry->neighbor_2_nblist) {
-    if (olsr_ipcmp(&entry->neighbor->neighbor_main_addr, address) == 0) {
+    if (entry->neighbor == neigh) {
       struct neighbor_list_entry *entry_to_delete = entry;
       entry = entry->next;
 
@@ -115,7 +115,7 @@ olsr_delete_two_hop_neighbor_table(struct neighbor_2_entry *two_hop_neighbor)
     struct neighbor_entry *one_hop_entry = one_hop_list->neighbor;
     struct neighbor_list_entry *entry_to_delete = one_hop_list;
 
-    olsr_delete_neighbor_2_pointer(one_hop_entry, &two_hop_neighbor->neighbor_2_addr);
+    olsr_delete_neighbor_2_pointer(one_hop_entry, two_hop_neighbor);
     one_hop_list = one_hop_list->next;
     /* no need to dequeue */
     free(entry_to_delete);
index 89905ec..ba142a7 100644 (file)
@@ -78,7 +78,7 @@ void
   olsr_init_two_hop_table(void);
 
 void
-  olsr_delete_neighbor_pointer(struct neighbor_2_entry *, const union olsr_ip_addr *);
+  olsr_delete_neighbor_pointer(struct neighbor_2_entry *, struct neighbor_entry *);
 
 void
   olsr_delete_two_hop_neighbor_table(struct neighbor_2_entry *);