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