public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCHv2 1/2] batman-adv: deselect current GW on client mode switch off
@ 2013-10-27 12:02 Antonio Quartulli
  2013-10-27 12:02 ` [B.A.T.M.A.N.] [PATCHv2 2/2] batman-adv: rename gw_deselect() to gw_reselect() Antonio Quartulli
  0 siblings, 1 reply; 5+ messages in thread
From: Antonio Quartulli @ 2013-10-27 12:02 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli

From: Antonio Quartulli <antonio@open-mesh.com>

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>
---

Changes from v1:
* Introduce patch 2 to rename batadv_gw_deselect()
* add big fat comment in 1/2 that explain why invoking batadv_gw_deselect() is
  not enough to really deselect the current GW

Cheers,


 gateway_client.c | 4 ++++
 sysfs.c          | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/gateway_client.c b/gateway_client.c
index 2449afa..2903bdb 100644
--- a/gateway_client.c
+++ b/gateway_client.c
@@ -207,6 +207,10 @@ 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
 	 */
diff --git a/sysfs.c b/sysfs.c
index 6335433..d1765fd 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -408,6 +408,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_deselect() is not enough to really de-select the
+	 * current GW. It will only instruct the gateway 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 reactivation. 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
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [B.A.T.M.A.N.] [PATCHv2 1/2] batman-adv: deselect current GW on client mode switch off
@ 2013-11-04 19:59 Antonio Quartulli
  2013-11-04 19:59 ` [B.A.T.M.A.N.] [PATCHv2 2/2] batman-adv: rename gw_deselect() to gw_reselect() Antonio Quartulli
  0 siblings, 1 reply; 5+ messages in thread
From: Antonio Quartulli @ 2013-11-04 19:59 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli

From: Antonio Quartulli <antonio@open-mesh.com>

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>
---

Patch 2/2:
- rename gw_deselect to gw_reselect in gw_client.h

Cheers,


 gateway_client.c | 4 ++++
 sysfs.c          | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/gateway_client.c b/gateway_client.c
index 2449afa..2903bdb 100644
--- a/gateway_client.c
+++ b/gateway_client.c
@@ -207,6 +207,10 @@ 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
 	 */
diff --git a/sysfs.c b/sysfs.c
index 6335433..d1765fd 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -408,6 +408,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_deselect() is not enough to really de-select the
+	 * current GW. It will only instruct the gateway 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 reactivation. 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
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-11-05  7:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-27 12:02 [B.A.T.M.A.N.] [PATCHv2 1/2] batman-adv: deselect current GW on client mode switch off Antonio Quartulli
2013-10-27 12:02 ` [B.A.T.M.A.N.] [PATCHv2 2/2] batman-adv: rename gw_deselect() to gw_reselect() Antonio Quartulli
2013-11-04 14:11   ` Antonio Quartulli
  -- strict thread matches above, loose matches on Subject: below --
2013-11-04 19:59 [B.A.T.M.A.N.] [PATCHv2 1/2] batman-adv: deselect current GW on client mode switch off Antonio Quartulli
2013-11-04 19:59 ` [B.A.T.M.A.N.] [PATCHv2 2/2] batman-adv: rename gw_deselect() to gw_reselect() Antonio Quartulli
2013-11-05  7:59   ` Marek Lindner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox