Commit 4e820e72db584e39c7d8699eb359d9a94eb837e3

Authored by Antonio Quartulli
Committed by Antonio Quartulli
1 parent f316318157

batman-adv: rename gw_deselect() to gw_reselect()

The function batadv_gw_deselect() is actually not deselecting
anything. It is just informing the GW code to perform a
re-election procedure when possible.
The current gateway is not being touched at all and therefore
the name of this function is rather misleading.

Rename it to batadv_gw_reselect() to batadv_gw_reselect()
to make its behaviour easier to grasp.

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>

Showing 4 changed files with 29 additions and 18 deletions Side-by-side Diff

net/batman-adv/gateway_client.c
... ... @@ -103,7 +103,18 @@
103 103 spin_unlock_bh(&bat_priv->gw.list_lock);
104 104 }
105 105  
106   -void batadv_gw_deselect(struct batadv_priv *bat_priv)
  106 +/**
  107 + * batadv_gw_reselect - force a gateway reselection
  108 + * @bat_priv: the bat priv with all the soft interface information
  109 + *
  110 + * Set a flag to remind the GW component to perform a new gateway reselection.
  111 + * However this function does not ensure that the current gateway is going to be
  112 + * deselected. The reselection mechanism may elect the same gateway once again.
  113 + *
  114 + * This means that invoking batadv_gw_reselect() does not guarantee a gateway
  115 + * change and therefore a uevent is not necessarily expected.
  116 + */
  117 +void batadv_gw_reselect(struct batadv_priv *bat_priv)
107 118 {
108 119 atomic_set(&bat_priv->gw.reselect, 1);
109 120 }
... ... @@ -242,7 +253,7 @@
242 253  
243 254 router = batadv_orig_node_get_router(next_gw->orig_node);
244 255 if (!router) {
245   - batadv_gw_deselect(bat_priv);
  256 + batadv_gw_reselect(bat_priv);
246 257 goto out;
247 258 }
248 259 }
249 260  
... ... @@ -294,11 +305,11 @@
294 305  
295 306 curr_gw_orig = batadv_gw_get_selected_orig(bat_priv);
296 307 if (!curr_gw_orig)
297   - goto deselect;
  308 + goto reselect;
298 309  
299 310 router_gw = batadv_orig_node_get_router(curr_gw_orig);
300 311 if (!router_gw)
301   - goto deselect;
  312 + goto reselect;
302 313  
303 314 /* this node already is the gateway */
304 315 if (curr_gw_orig == orig_node)
... ... @@ -326,8 +337,8 @@
326 337 "Restarting gateway selection: better gateway found (tq curr: %i, tq new: %i)\n",
327 338 gw_tq_avg, orig_tq_avg);
328 339  
329   -deselect:
330   - batadv_gw_deselect(bat_priv);
  340 +reselect:
  341 + batadv_gw_reselect(bat_priv);
331 342 out:
332 343 if (curr_gw_orig)
333 344 batadv_orig_node_free_ref(curr_gw_orig);
... ... @@ -457,7 +468,7 @@
457 468 */
458 469 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
459 470 if (gw_node == curr_gw)
460   - batadv_gw_deselect(bat_priv);
  471 + batadv_gw_reselect(bat_priv);
461 472 }
462 473  
463 474 out:
... ... @@ -483,7 +494,7 @@
483 494 struct batadv_gw_node *gw_node, *curr_gw;
484 495 struct hlist_node *node_tmp;
485 496 unsigned long timeout = msecs_to_jiffies(2 * BATADV_PURGE_TIMEOUT);
486   - int do_deselect = 0;
  497 + int do_reselect = 0;
487 498  
488 499 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
489 500  
... ... @@ -497,7 +508,7 @@
497 508 continue;
498 509  
499 510 if (curr_gw == gw_node)
500   - do_deselect = 1;
  511 + do_reselect = 1;
501 512  
502 513 hlist_del_rcu(&gw_node->list);
503 514 batadv_gw_node_free_ref(gw_node);
... ... @@ -505,9 +516,9 @@
505 516  
506 517 spin_unlock_bh(&bat_priv->gw.list_lock);
507 518  
508   - /* gw_deselect() needs to acquire the gw_list_lock */
509   - if (do_deselect)
510   - batadv_gw_deselect(bat_priv);
  519 + /* gw_reselect() needs to acquire the gw_list_lock */
  520 + if (do_reselect)
  521 + batadv_gw_reselect(bat_priv);
511 522  
512 523 if (curr_gw)
513 524 batadv_gw_node_free_ref(curr_gw);
net/batman-adv/gateway_client.h
... ... @@ -19,7 +19,7 @@
19 19 #define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
20 20  
21 21 void batadv_gw_check_client_stop(struct batadv_priv *bat_priv);
22   -void batadv_gw_deselect(struct batadv_priv *bat_priv);
  22 +void batadv_gw_reselect(struct batadv_priv *bat_priv);
23 23 void batadv_gw_election(struct batadv_priv *bat_priv);
24 24 struct batadv_orig_node *
25 25 batadv_gw_get_selected_orig(struct batadv_priv *bat_priv);
net/batman-adv/gateway_common.c
... ... @@ -162,7 +162,7 @@
162 162 if ((down_curr == down_new) && (up_curr == up_new))
163 163 return count;
164 164  
165   - batadv_gw_deselect(bat_priv);
  165 + batadv_gw_reselect(bat_priv);
166 166 batadv_info(net_dev,
167 167 "Changing gateway bandwidth from: '%u.%u/%u.%u MBit' to: '%u.%u/%u.%u MBit'\n",
168 168 down_curr / 10, down_curr % 10, up_curr / 10, up_curr % 10,
net/batman-adv/sysfs.c
... ... @@ -327,10 +327,10 @@
327 327 return sprintf(buff, "%s\n", bat_priv->bat_algo_ops->name);
328 328 }
329 329  
330   -static void batadv_post_gw_deselect(struct net_device *net_dev)
  330 +static void batadv_post_gw_reselect(struct net_device *net_dev)
331 331 {
332 332 struct batadv_priv *bat_priv = netdev_priv(net_dev);
333   - batadv_gw_deselect(bat_priv);
  333 + batadv_gw_reselect(bat_priv);
334 334 }
335 335  
336 336 static ssize_t batadv_show_gw_mode(struct kobject *kobj, struct attribute *attr,
... ... @@ -415,7 +415,7 @@
415 415 * client mode re-activation. This is operation is performed in
416 416 * batadv_gw_check_client_stop().
417 417 */
418   - batadv_gw_deselect(bat_priv);
  418 + batadv_gw_reselect(bat_priv);
419 419 /* always call batadv_gw_check_client_stop() before changing the gateway
420 420 * state
421 421 */
... ... @@ -468,7 +468,7 @@
468 468 BATADV_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, BATADV_TQ_MAX_VALUE,
469 469 NULL);
470 470 BATADV_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, BATADV_TQ_MAX_VALUE,
471   - batadv_post_gw_deselect);
  471 + batadv_post_gw_reselect);
472 472 static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth,
473 473 batadv_store_gw_bwidth);
474 474 #ifdef CONFIG_BATMAN_ADV_DEBUG