diff options
author | Antonio Quartulli <antonio@open-mesh.com> | 2013-07-12 18:06:00 -0400 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2013-08-28 05:33:00 -0400 |
commit | c6eaa3f067d6f9fa55fd9645e93ed79411bebdaf (patch) | |
tree | e5d5136abe4c857cae4b04985c22c38ccbeaca71 | |
parent | c00a072d3fec446d763e68b50f6f6cfd9e2957e2 (diff) |
batman-adv: send GW_DEL event when the gw client mode is deselected
Whenever the GW client mode is deselected, a DEL event has
to be sent in order to tell userspace that the current
gateway has been lost. Send the uevent on state change only
if a gateway was currently selected.
Reported-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
-rw-r--r-- | net/batman-adv/gateway_client.c | 27 | ||||
-rw-r--r-- | net/batman-adv/gateway_client.h | 1 | ||||
-rw-r--r-- | net/batman-adv/sysfs.c | 4 |
3 files changed, 32 insertions, 0 deletions
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index 7614af31daff..1ce4b8763ef2 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c | |||
@@ -190,6 +190,33 @@ next: | |||
190 | return curr_gw; | 190 | return curr_gw; |
191 | } | 191 | } |
192 | 192 | ||
193 | /** | ||
194 | * batadv_gw_check_client_stop - check if client mode has been switched off | ||
195 | * @bat_priv: the bat priv with all the soft interface information | ||
196 | * | ||
197 | * This function assumes the caller has checked that the gw state *is actually | ||
198 | * changing*. This function is not supposed to be called when there is no state | ||
199 | * change. | ||
200 | */ | ||
201 | void batadv_gw_check_client_stop(struct batadv_priv *bat_priv) | ||
202 | { | ||
203 | struct batadv_gw_node *curr_gw; | ||
204 | |||
205 | if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_CLIENT) | ||
206 | return; | ||
207 | |||
208 | curr_gw = batadv_gw_get_selected_gw_node(bat_priv); | ||
209 | if (!curr_gw) | ||
210 | return; | ||
211 | |||
212 | /* if batman-adv is switching the gw client mode off and a gateway was | ||
213 | * already selected, send a DEL uevent | ||
214 | */ | ||
215 | batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL, NULL); | ||
216 | |||
217 | batadv_gw_node_free_ref(curr_gw); | ||
218 | } | ||
219 | |||
193 | void batadv_gw_election(struct batadv_priv *bat_priv) | 220 | void batadv_gw_election(struct batadv_priv *bat_priv) |
194 | { | 221 | { |
195 | struct batadv_gw_node *curr_gw = NULL, *next_gw = NULL; | 222 | struct batadv_gw_node *curr_gw = NULL, *next_gw = NULL; |
diff --git a/net/batman-adv/gateway_client.h b/net/batman-adv/gateway_client.h index 1037d75da51f..ceef4ebe8bcd 100644 --- a/net/batman-adv/gateway_client.h +++ b/net/batman-adv/gateway_client.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #ifndef _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ | 20 | #ifndef _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ |
21 | #define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ | 21 | #define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ |
22 | 22 | ||
23 | void batadv_gw_check_client_stop(struct batadv_priv *bat_priv); | ||
23 | void batadv_gw_deselect(struct batadv_priv *bat_priv); | 24 | void batadv_gw_deselect(struct batadv_priv *bat_priv); |
24 | void batadv_gw_election(struct batadv_priv *bat_priv); | 25 | void batadv_gw_election(struct batadv_priv *bat_priv); |
25 | struct batadv_orig_node * | 26 | struct batadv_orig_node * |
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c index 929e304dacb2..4114b961bc2c 100644 --- a/net/batman-adv/sysfs.c +++ b/net/batman-adv/sysfs.c | |||
@@ -385,6 +385,10 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj, | |||
385 | curr_gw_mode_str, buff); | 385 | curr_gw_mode_str, buff); |
386 | 386 | ||
387 | batadv_gw_deselect(bat_priv); | 387 | batadv_gw_deselect(bat_priv); |
388 | /* always call batadv_gw_check_client_stop() before changing the gateway | ||
389 | * state | ||
390 | */ | ||
391 | batadv_gw_check_client_stop(bat_priv); | ||
388 | atomic_set(&bat_priv->gw_mode, (unsigned int)gw_mode_tmp); | 392 | atomic_set(&bat_priv->gw_mode, (unsigned int)gw_mode_tmp); |
389 | return count; | 393 | return count; |
390 | } | 394 | } |