* [B.A.T.M.A.N.] [PATCH] batman-adv: send GW_DEL event when the gw client mode is deselected
@ 2013-07-11 17:47 Antonio Quartulli
2013-07-11 17:53 ` Antonio Quartulli
2013-07-12 21:24 ` Marek Lindner
0 siblings, 2 replies; 3+ messages in thread
From: Antonio Quartulli @ 2013-07-11 17:47 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Antonio Quartulli
From: Antonio Quartulli <antonio@open-mesh.com>
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.
Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
---
gateway_client.c | 28 ++++++++++++++++++++++++++++
gateway_client.h | 1 +
sysfs.c | 2 ++
3 files changed, 31 insertions(+)
diff --git a/gateway_client.c b/gateway_client.c
index 588d27e..bdda464 100644
--- a/gateway_client.c
+++ b/gateway_client.c
@@ -188,6 +188,34 @@ next:
return curr_gw;
}
+/**
+ * batadv_gw_check_client_stop - check if clitn mode has been switched off
+ * @bat_priv: the bat priv with all the soft interface information
+ * @new_mode: the gw mode which the node is switching to
+ *
+ * This function assumes the caller has checked that the gw state *is actually
+ * changing*. This function is not supposed to be called when there is no state
+ * change.
+ */
+void batadv_gw_check_client_stop(struct batadv_priv *bat_priv)
+{
+ struct batadv_gw_node *curr_gw;
+
+ if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_CLIENT)
+ return;
+
+ curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
+ if (!curr_gw)
+ return;
+
+ /* if batman-adv is switching the gw client mode off and a gateway was
+ * already selected, send a DEL uevent
+ */
+ batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL, NULL);
+
+ batadv_gw_node_free_ref(curr_gw);
+}
+
void batadv_gw_election(struct batadv_priv *bat_priv)
{
struct batadv_gw_node *curr_gw = NULL, *next_gw = NULL;
diff --git a/gateway_client.h b/gateway_client.h
index 7ef955a..b235cbf 100644
--- a/gateway_client.h
+++ b/gateway_client.h
@@ -20,6 +20,7 @@
#ifndef _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
#define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
+void batadv_gw_check_client_stop(struct batadv_priv *bat_priv);
void batadv_gw_deselect(struct batadv_priv *bat_priv);
void batadv_gw_election(struct batadv_priv *bat_priv);
struct batadv_orig_node *
diff --git a/sysfs.c b/sysfs.c
index 6ec145d..1126f74 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -409,6 +409,8 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj,
curr_gw_mode_str, buff);
batadv_gw_deselect(bat_priv);
+ /* always call the client check before changing the state */
+ batadv_gw_check_client_stop(bat_priv);
atomic_set(&bat_priv->gw_mode, (unsigned int)gw_mode_tmp);
batadv_gw_tvlv_container_update(bat_priv);
return count;
--
1.8.1.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: send GW_DEL event when the gw client mode is deselected
2013-07-11 17:47 [B.A.T.M.A.N.] [PATCH] batman-adv: send GW_DEL event when the gw client mode is deselected Antonio Quartulli
@ 2013-07-11 17:53 ` Antonio Quartulli
2013-07-12 21:24 ` Marek Lindner
1 sibling, 0 replies; 3+ messages in thread
From: Antonio Quartulli @ 2013-07-11 17:53 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Antonio Quartulli
[-- Attachment #1: Type: text/plain, Size: 555 bytes --]
On Thu, Jul 11, 2013 at 07:47:38PM +0200, Antonio Quartulli wrote:
> From: Antonio Quartulli <antonio@open-mesh.com>
>
> 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.
>
> Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
Reported-by: Marek Lindner <lindner_marek@yahoo.de>
--
Antonio Quartulli
..each of us alone is worth nothing..
Ernesto "Che" Guevara
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: send GW_DEL event when the gw client mode is deselected
2013-07-11 17:47 [B.A.T.M.A.N.] [PATCH] batman-adv: send GW_DEL event when the gw client mode is deselected Antonio Quartulli
2013-07-11 17:53 ` Antonio Quartulli
@ 2013-07-12 21:24 ` Marek Lindner
1 sibling, 0 replies; 3+ messages in thread
From: Marek Lindner @ 2013-07-12 21:24 UTC (permalink / raw)
To: The list for a Better Approach To Mobile Ad-hoc Networking
On Friday, July 12, 2013 01:47:38 Antonio Quartulli wrote:
> + * batadv_gw_check_client_stop - check if clitn mode has been switched off
clitn => client
> + * @bat_priv: the bat priv with all the soft interface information
> + * @new_mode: the gw mode which the node is switching to
The param "new_mode" does not exist.
> batadv_gw_deselect(bat_priv);
> + /* always call the client check before changing the state */
> + batadv_gw_check_client_stop(bat_priv);
I don't get what the "client check" comment is trying to say.
Cheers,
Marek
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-12 21:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-11 17:47 [B.A.T.M.A.N.] [PATCH] batman-adv: send GW_DEL event when the gw client mode is deselected Antonio Quartulli
2013-07-11 17:53 ` Antonio Quartulli
2013-07-12 21:24 ` Marek Lindner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.