Lines Matching refs:bat_priv

80 batadv_gw_get_selected_gw_node(struct batadv_priv *bat_priv)  in batadv_gw_get_selected_gw_node()  argument
85 gw_node = rcu_dereference(bat_priv->gw.curr_gw); in batadv_gw_get_selected_gw_node()
104 batadv_gw_get_selected_orig(struct batadv_priv *bat_priv) in batadv_gw_get_selected_orig() argument
109 gw_node = batadv_gw_get_selected_gw_node(bat_priv); in batadv_gw_get_selected_orig()
128 static void batadv_gw_select(struct batadv_priv *bat_priv, in batadv_gw_select() argument
133 spin_lock_bh(&bat_priv->gw.list_lock); in batadv_gw_select()
138 curr_gw_node = rcu_replace_pointer(bat_priv->gw.curr_gw, new_gw_node, in batadv_gw_select()
143 spin_unlock_bh(&bat_priv->gw.list_lock); in batadv_gw_select()
157 void batadv_gw_reselect(struct batadv_priv *bat_priv) in batadv_gw_reselect() argument
159 atomic_set(&bat_priv->gw.reselect, 1); in batadv_gw_reselect()
170 void batadv_gw_check_client_stop(struct batadv_priv *bat_priv) in batadv_gw_check_client_stop() argument
174 if (atomic_read(&bat_priv->gw.mode) != BATADV_GW_MODE_CLIENT) in batadv_gw_check_client_stop()
177 curr_gw = batadv_gw_get_selected_gw_node(bat_priv); in batadv_gw_check_client_stop()
184 batadv_gw_select(bat_priv, NULL); in batadv_gw_check_client_stop()
189 batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL, NULL); in batadv_gw_check_client_stop()
198 void batadv_gw_election(struct batadv_priv *bat_priv) in batadv_gw_election() argument
206 if (atomic_read(&bat_priv->gw.mode) != BATADV_GW_MODE_CLIENT) in batadv_gw_election()
209 if (!bat_priv->algo_ops->gw.get_best_gw_node) in batadv_gw_election()
212 curr_gw = batadv_gw_get_selected_gw_node(bat_priv); in batadv_gw_election()
214 if (!batadv_atomic_dec_not_zero(&bat_priv->gw.reselect) && curr_gw) in batadv_gw_election()
221 next_gw = bat_priv->algo_ops->gw.get_best_gw_node(bat_priv); in batadv_gw_election()
232 batadv_gw_reselect(bat_priv); in batadv_gw_election()
239 batadv_gw_reselect(bat_priv); in batadv_gw_election()
245 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, in batadv_gw_election()
247 batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL, in batadv_gw_election()
250 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, in batadv_gw_election()
258 batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_ADD, in batadv_gw_election()
261 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, in batadv_gw_election()
269 batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_CHANGE, in batadv_gw_election()
273 batadv_gw_select(bat_priv, next_gw); in batadv_gw_election()
287 void batadv_gw_check_election(struct batadv_priv *bat_priv, in batadv_gw_check_election() argument
295 if (!bat_priv->algo_ops->gw.is_eligible) in batadv_gw_check_election()
298 curr_gw_orig = batadv_gw_get_selected_orig(bat_priv); in batadv_gw_check_election()
306 if (!bat_priv->algo_ops->gw.is_eligible(bat_priv, curr_gw_orig, in batadv_gw_check_election()
311 batadv_gw_reselect(bat_priv); in batadv_gw_check_election()
325 static void batadv_gw_node_add(struct batadv_priv *bat_priv, in batadv_gw_node_add() argument
331 lockdep_assert_held(&bat_priv->gw.list_lock); in batadv_gw_node_add()
348 hlist_add_head_rcu(&gw_node->list, &bat_priv->gw.gateway_list); in batadv_gw_node_add()
349 bat_priv->gw.generation++; in batadv_gw_node_add()
351 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, in batadv_gw_node_add()
370 struct batadv_gw_node *batadv_gw_node_get(struct batadv_priv *bat_priv, in batadv_gw_node_get() argument
376 hlist_for_each_entry_rcu(gw_node_tmp, &bat_priv->gw.gateway_list, in batadv_gw_node_get()
399 void batadv_gw_node_update(struct batadv_priv *bat_priv, in batadv_gw_node_update() argument
405 spin_lock_bh(&bat_priv->gw.list_lock); in batadv_gw_node_update()
406 gw_node = batadv_gw_node_get(bat_priv, orig_node); in batadv_gw_node_update()
408 batadv_gw_node_add(bat_priv, orig_node, gateway); in batadv_gw_node_update()
409 spin_unlock_bh(&bat_priv->gw.list_lock); in batadv_gw_node_update()
412 spin_unlock_bh(&bat_priv->gw.list_lock); in batadv_gw_node_update()
418 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, in batadv_gw_node_update()
434 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, in batadv_gw_node_update()
441 spin_lock_bh(&bat_priv->gw.list_lock); in batadv_gw_node_update()
445 bat_priv->gw.generation++; in batadv_gw_node_update()
447 spin_unlock_bh(&bat_priv->gw.list_lock); in batadv_gw_node_update()
449 curr_gw = batadv_gw_get_selected_gw_node(bat_priv); in batadv_gw_node_update()
451 batadv_gw_reselect(bat_priv); in batadv_gw_node_update()
465 void batadv_gw_node_delete(struct batadv_priv *bat_priv, in batadv_gw_node_delete() argument
473 batadv_gw_node_update(bat_priv, orig_node, &gateway); in batadv_gw_node_delete()
480 void batadv_gw_node_free(struct batadv_priv *bat_priv) in batadv_gw_node_free() argument
485 spin_lock_bh(&bat_priv->gw.list_lock); in batadv_gw_node_free()
487 &bat_priv->gw.gateway_list, list) { in batadv_gw_node_free()
490 bat_priv->gw.generation++; in batadv_gw_node_free()
492 spin_unlock_bh(&bat_priv->gw.list_lock); in batadv_gw_node_free()
507 struct batadv_priv *bat_priv; in batadv_gw_dump() local
522 bat_priv = netdev_priv(soft_iface); in batadv_gw_dump()
524 primary_if = batadv_primary_if_get_selected(bat_priv); in batadv_gw_dump()
530 if (!bat_priv->algo_ops->gw.dump) { in batadv_gw_dump()
535 bat_priv->algo_ops->gw.dump(msg, cb, bat_priv); in batadv_gw_dump()
683 bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, in batadv_gw_out_of_range() argument
702 orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source, in batadv_gw_out_of_range()
707 gw_node = batadv_gw_node_get(bat_priv, orig_dst_node); in batadv_gw_out_of_range()
711 switch (atomic_read(&bat_priv->gw.mode)) { in batadv_gw_out_of_range()
719 curr_gw = batadv_gw_get_selected_gw_node(bat_priv); in batadv_gw_out_of_range()
731 neigh_curr = batadv_find_router(bat_priv, curr_gw->orig_node, in batadv_gw_out_of_range()
750 neigh_old = batadv_find_router(bat_priv, orig_dst_node, NULL); in batadv_gw_out_of_range()