Skip to content

Commit

Permalink
batman-adv: deselect current GW on client mode switch off
Browse files Browse the repository at this point in the history
When switching from gw_mode client to either off or server
the current selected gateway has to be deselected.
In this way when client mode is enabled again a gateway
re-election is forced and a GW_ADD event is consequently
sent.

The current behaviour instead is to keep the current gateway
leading to no GW_ADD event when gw_mode client is selected
for a second time

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
  • Loading branch information
Antonio Quartulli authored and Antonio Quartulli committed Jan 8, 2014
1 parent ebf38fb commit f316318
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions net/batman-adv/gateway_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ void batadv_gw_check_client_stop(struct batadv_priv *bat_priv)
if (!curr_gw)
return;

/* deselect the current gateway so that next time that client mode is
* enabled a proper GW_ADD event can be sent
*/
batadv_gw_select(bat_priv, NULL);

/* if batman-adv is switching the gw client mode off and a gateway was
* already selected, send a DEL uevent
*/
Expand Down
9 changes: 9 additions & 0 deletions net/batman-adv/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,15 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj,
batadv_info(net_dev, "Changing gw mode from: %s to: %s\n",
curr_gw_mode_str, buff);

/* Invoking batadv_gw_reselect() is not enough to really de-select the
* current GW. It will only instruct the gateway client code to perform
* a re-election the next time that this is needed.
*
* When gw client mode is being switched off the current GW must be
* de-selected explicitly otherwise no GW_ADD uevent is thrown on
* client mode re-activation. This is operation is performed in
* batadv_gw_check_client_stop().
*/
batadv_gw_deselect(bat_priv);
/* always call batadv_gw_check_client_stop() before changing the gateway
* state
Expand Down

0 comments on commit f316318

Please sign in to comment.