return 0;
}
-struct neigh_node *
-create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node,
- uint8_t *neigh, struct batman_if *if_incoming)
+void neigh_node_free_ref(struct kref *refcount)
+{
+ struct neigh_node *neigh_node;
+
+ neigh_node = container_of(refcount, struct neigh_node, refcount);
+ kfree(neigh_node);
+}
+
+struct neigh_node *create_neighbor(struct orig_node *orig_node,
+ struct orig_node *orig_neigh_node,
+ uint8_t *neigh,
+ struct batman_if *if_incoming)
{
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
struct neigh_node *neigh_node;
memcpy(neigh_node->addr, neigh, ETH_ALEN);
neigh_node->orig_node = orig_neigh_node;
neigh_node->if_incoming = if_incoming;
+ kref_init(&neigh_node->refcount);
list_add_tail(&neigh_node->list, &orig_node->neigh_list);
return neigh_node;
neigh_node = list_entry(list_pos, struct neigh_node, list);
list_del(list_pos);
- kfree(neigh_node);
+ kref_put(&neigh_node->refcount, neigh_node_free_ref);
}
frag_list_free(&orig_node->frag_list);
neigh_purged = true;
list_del(list_pos);
- kfree(neigh_node);
+ kref_put(&neigh_node->refcount, neigh_node_free_ref);
} else {
if ((!*best_neigh_node) ||
(neigh_node->tq_avg > (*best_neigh_node)->tq_avg))
void originator_free(struct bat_priv *bat_priv);
void purge_orig_ref(struct bat_priv *bat_priv);
struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr);
-struct neigh_node *
-create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node,
- uint8_t *neigh, struct batman_if *if_incoming);
+struct neigh_node *create_neighbor(struct orig_node *orig_node,
+ struct orig_node *orig_neigh_node,
+ uint8_t *neigh,
+ struct batman_if *if_incoming);
+void neigh_node_free_ref(struct kref *refcount);
int orig_seq_print_text(struct seq_file *seq, void *offset);
int orig_hash_add_if(struct batman_if *batman_if, int max_if_num);
int orig_hash_del_if(struct batman_if *batman_if, int max_if_num);
struct neigh_node *neigh_node,
unsigned char *hna_buff, int hna_buff_len)
{
+ struct neigh_node *neigh_node_tmp;
+
/* route deleted */
if ((orig_node->router) && (!neigh_node)) {
orig_node->router->addr);
}
+ if (neigh_node)
+ kref_get(&neigh_node->refcount);
+ neigh_node_tmp = orig_node->router;
orig_node->router = neigh_node;
+ if (neigh_node_tmp)
+ kref_put(&neigh_node_tmp->refcount, neigh_node_free_ref);
}
struct neigh_node *next_bond_candidate;
unsigned long last_valid;
unsigned long real_bits[NUM_WORDS];
+ struct kref refcount;
struct orig_node *orig_node;
struct batman_if *if_incoming;
};