diff options
author | Antonio Quartulli <antonio@open-mesh.com> | 2013-11-04 14:59:41 -0500 |
---|---|---|
committer | Antonio Quartulli <antonio@meshcoding.com> | 2014-01-08 14:49:41 -0500 |
commit | 4e820e72db584e39c7d8699eb359d9a94eb837e3 (patch) | |
tree | 7964442e2f38d00ae5b3f52bca819da87ddb6553 /net/batman-adv | |
parent | f3163181573f3dea264c5ffd578c187aef898bbb (diff) |
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>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/gateway_client.c | 35 | ||||
-rw-r--r-- | net/batman-adv/gateway_client.h | 2 | ||||
-rw-r--r-- | net/batman-adv/gateway_common.c | 2 | ||||
-rw-r--r-- | net/batman-adv/sysfs.c | 8 |
4 files changed, 29 insertions, 18 deletions
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index 53a900952282..a5602ef0f262 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c | |||
@@ -103,7 +103,18 @@ static void batadv_gw_select(struct batadv_priv *bat_priv, | |||
103 | spin_unlock_bh(&bat_priv->gw.list_lock); | 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 | atomic_set(&bat_priv->gw.reselect, 1); | 119 | atomic_set(&bat_priv->gw.reselect, 1); |
109 | } | 120 | } |
@@ -242,7 +253,7 @@ void batadv_gw_election(struct batadv_priv *bat_priv) | |||
242 | 253 | ||
243 | router = batadv_orig_node_get_router(next_gw->orig_node); | 254 | router = batadv_orig_node_get_router(next_gw->orig_node); |
244 | if (!router) { | 255 | if (!router) { |
245 | batadv_gw_deselect(bat_priv); | 256 | batadv_gw_reselect(bat_priv); |
246 | goto out; | 257 | goto out; |
247 | } | 258 | } |
248 | } | 259 | } |
@@ -294,11 +305,11 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv, | |||
294 | 305 | ||
295 | curr_gw_orig = batadv_gw_get_selected_orig(bat_priv); | 306 | curr_gw_orig = batadv_gw_get_selected_orig(bat_priv); |
296 | if (!curr_gw_orig) | 307 | if (!curr_gw_orig) |
297 | goto deselect; | 308 | goto reselect; |
298 | 309 | ||
299 | router_gw = batadv_orig_node_get_router(curr_gw_orig); | 310 | router_gw = batadv_orig_node_get_router(curr_gw_orig); |
300 | if (!router_gw) | 311 | if (!router_gw) |
301 | goto deselect; | 312 | goto reselect; |
302 | 313 | ||
303 | /* this node already is the gateway */ | 314 | /* this node already is the gateway */ |
304 | if (curr_gw_orig == orig_node) | 315 | if (curr_gw_orig == orig_node) |
@@ -326,8 +337,8 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv, | |||
326 | "Restarting gateway selection: better gateway found (tq curr: %i, tq new: %i)\n", | 337 | "Restarting gateway selection: better gateway found (tq curr: %i, tq new: %i)\n", |
327 | gw_tq_avg, orig_tq_avg); | 338 | gw_tq_avg, orig_tq_avg); |
328 | 339 | ||
329 | deselect: | 340 | reselect: |
330 | batadv_gw_deselect(bat_priv); | 341 | batadv_gw_reselect(bat_priv); |
331 | out: | 342 | out: |
332 | if (curr_gw_orig) | 343 | if (curr_gw_orig) |
333 | batadv_orig_node_free_ref(curr_gw_orig); | 344 | batadv_orig_node_free_ref(curr_gw_orig); |
@@ -457,7 +468,7 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv, | |||
457 | */ | 468 | */ |
458 | curr_gw = batadv_gw_get_selected_gw_node(bat_priv); | 469 | curr_gw = batadv_gw_get_selected_gw_node(bat_priv); |
459 | if (gw_node == curr_gw) | 470 | if (gw_node == curr_gw) |
460 | batadv_gw_deselect(bat_priv); | 471 | batadv_gw_reselect(bat_priv); |
461 | } | 472 | } |
462 | 473 | ||
463 | out: | 474 | out: |
@@ -483,7 +494,7 @@ void batadv_gw_node_purge(struct batadv_priv *bat_priv) | |||
483 | struct batadv_gw_node *gw_node, *curr_gw; | 494 | struct batadv_gw_node *gw_node, *curr_gw; |
484 | struct hlist_node *node_tmp; | 495 | struct hlist_node *node_tmp; |
485 | unsigned long timeout = msecs_to_jiffies(2 * BATADV_PURGE_TIMEOUT); | 496 | unsigned long timeout = msecs_to_jiffies(2 * BATADV_PURGE_TIMEOUT); |
486 | int do_deselect = 0; | 497 | int do_reselect = 0; |
487 | 498 | ||
488 | curr_gw = batadv_gw_get_selected_gw_node(bat_priv); | 499 | curr_gw = batadv_gw_get_selected_gw_node(bat_priv); |
489 | 500 | ||
@@ -497,7 +508,7 @@ void batadv_gw_node_purge(struct batadv_priv *bat_priv) | |||
497 | continue; | 508 | continue; |
498 | 509 | ||
499 | if (curr_gw == gw_node) | 510 | if (curr_gw == gw_node) |
500 | do_deselect = 1; | 511 | do_reselect = 1; |
501 | 512 | ||
502 | hlist_del_rcu(&gw_node->list); | 513 | hlist_del_rcu(&gw_node->list); |
503 | batadv_gw_node_free_ref(gw_node); | 514 | batadv_gw_node_free_ref(gw_node); |
@@ -505,9 +516,9 @@ void batadv_gw_node_purge(struct batadv_priv *bat_priv) | |||
505 | 516 | ||
506 | spin_unlock_bh(&bat_priv->gw.list_lock); | 517 | spin_unlock_bh(&bat_priv->gw.list_lock); |
507 | 518 | ||
508 | /* gw_deselect() needs to acquire the gw_list_lock */ | 519 | /* gw_reselect() needs to acquire the gw_list_lock */ |
509 | if (do_deselect) | 520 | if (do_reselect) |
510 | batadv_gw_deselect(bat_priv); | 521 | batadv_gw_reselect(bat_priv); |
511 | 522 | ||
512 | if (curr_gw) | 523 | if (curr_gw) |
513 | batadv_gw_node_free_ref(curr_gw); | 524 | batadv_gw_node_free_ref(curr_gw); |
diff --git a/net/batman-adv/gateway_client.h b/net/batman-adv/gateway_client.h index 43c88336d40f..514cff68890c 100644 --- a/net/batman-adv/gateway_client.h +++ b/net/batman-adv/gateway_client.h | |||
@@ -19,7 +19,7 @@ | |||
19 | #define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ | 19 | #define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ |
20 | 20 | ||
21 | void batadv_gw_check_client_stop(struct batadv_priv *bat_priv); | 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 | void batadv_gw_election(struct batadv_priv *bat_priv); | 23 | void batadv_gw_election(struct batadv_priv *bat_priv); |
24 | struct batadv_orig_node * | 24 | struct batadv_orig_node * |
25 | batadv_gw_get_selected_orig(struct batadv_priv *bat_priv); | 25 | batadv_gw_get_selected_orig(struct batadv_priv *bat_priv); |
diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c index 5e63b8110a57..f76816ce9faf 100644 --- a/net/batman-adv/gateway_common.c +++ b/net/batman-adv/gateway_common.c | |||
@@ -162,7 +162,7 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, | |||
162 | if ((down_curr == down_new) && (up_curr == up_new)) | 162 | if ((down_curr == down_new) && (up_curr == up_new)) |
163 | return count; | 163 | return count; |
164 | 164 | ||
165 | batadv_gw_deselect(bat_priv); | 165 | batadv_gw_reselect(bat_priv); |
166 | batadv_info(net_dev, | 166 | batadv_info(net_dev, |
167 | "Changing gateway bandwidth from: '%u.%u/%u.%u MBit' to: '%u.%u/%u.%u MBit'\n", | 167 | "Changing gateway bandwidth from: '%u.%u/%u.%u MBit' to: '%u.%u/%u.%u MBit'\n", |
168 | down_curr / 10, down_curr % 10, up_curr / 10, up_curr % 10, | 168 | down_curr / 10, down_curr % 10, up_curr / 10, up_curr % 10, |
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c index b652a5648ed3..511e01175654 100644 --- a/net/batman-adv/sysfs.c +++ b/net/batman-adv/sysfs.c | |||
@@ -327,10 +327,10 @@ static ssize_t batadv_show_bat_algo(struct kobject *kobj, | |||
327 | return sprintf(buff, "%s\n", bat_priv->bat_algo_ops->name); | 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 | struct batadv_priv *bat_priv = netdev_priv(net_dev); | 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 | static ssize_t batadv_show_gw_mode(struct kobject *kobj, struct attribute *attr, | 336 | static ssize_t batadv_show_gw_mode(struct kobject *kobj, struct attribute *attr, |
@@ -415,7 +415,7 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj, | |||
415 | * client mode re-activation. This is operation is performed in | 415 | * client mode re-activation. This is operation is performed in |
416 | * batadv_gw_check_client_stop(). | 416 | * batadv_gw_check_client_stop(). |
417 | */ | 417 | */ |
418 | batadv_gw_deselect(bat_priv); | 418 | batadv_gw_reselect(bat_priv); |
419 | /* always call batadv_gw_check_client_stop() before changing the gateway | 419 | /* always call batadv_gw_check_client_stop() before changing the gateway |
420 | * state | 420 | * state |
421 | */ | 421 | */ |
@@ -468,7 +468,7 @@ BATADV_ATTR_SIF_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * BATADV_JITTER, | |||
468 | BATADV_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, BATADV_TQ_MAX_VALUE, | 468 | BATADV_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, BATADV_TQ_MAX_VALUE, |
469 | NULL); | 469 | NULL); |
470 | BATADV_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, BATADV_TQ_MAX_VALUE, | 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 | static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth, | 472 | static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth, |
473 | batadv_store_gw_bwidth); | 473 | batadv_store_gw_bwidth); |
474 | #ifdef CONFIG_BATMAN_ADV_DEBUG | 474 | #ifdef CONFIG_BATMAN_ADV_DEBUG |