connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Jussi Laakkonen <jussi.laakkonen@jolla.com>
To: connman@lists.linux.dev
Subject: [RFC PATCH 8/9] vpn: Check if connecting when setting state or disconnecting
Date: Tue, 13 Dec 2022 16:07:06 +0200	[thread overview]
Message-ID: <20221213140707.278313-9-jussi.laakkonen@jolla.com> (raw)
In-Reply-To: <20221213140707.278313-1-jussi.laakkonen@jolla.com>

Add checking of connected and connecting state in cases when the state
is being set and state transitions to disconnecting. This change avoids
clearing the transport ident when VPN is waiting for input from VPN
agent (association state).
---
 plugins/vpn.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/plugins/vpn.c b/plugins/vpn.c
index d9a56ae1..bec7f59f 100644
--- a/plugins/vpn.c
+++ b/plugins/vpn.c
@@ -270,6 +270,13 @@ static bool provider_is_connected(struct connection_data *data)
 			g_str_equal(data->state, "configuration"));
 }
 
+static bool provider_is_connected_or_connecting(struct connection_data *data)
+{
+	return data && (g_str_equal(data->state, "ready") ||
+			g_str_equal(data->state, "configuration") ||
+			g_str_equal(data->state, "association"));
+}
+
 static void set_provider_state(struct connection_data *data)
 {
 	enum connman_provider_state state = CONNMAN_PROVIDER_STATE_UNKNOWN;
@@ -278,7 +285,11 @@ static void set_provider_state(struct connection_data *data)
 
 	DBG("provider %p new state %s", data->provider, data->state);
 
-	connected = provider_is_connected(data);
+	/*
+	 * To avoid clearing transport ident when VPN is waiting for agent
+	 * take also connecting state into account.
+	 */
+	connected = provider_is_connected_or_connecting(data);
 
 	if (g_str_equal(data->state, "ready")) {
 		state = CONNMAN_PROVIDER_STATE_READY;
@@ -1076,7 +1087,7 @@ static int provider_disconnect(struct connman_provider *provider)
 	if (!data)
 		return -EINVAL;
 
-	if (provider_is_connected(data))
+	if (provider_is_connected_or_connecting(data))
 		err = disconnect_provider(data);
 
 	if (data->call) {
@@ -1730,7 +1741,7 @@ static void destroy_provider(struct connection_data *data)
 {
 	DBG("data %p", data);
 
-	if (provider_is_connected(data))
+	if (provider_is_connected_or_connecting(data))
 		connman_provider_disconnect(data->provider);
 
 	connman_provider_set_data(data->provider, NULL);
@@ -2183,7 +2194,7 @@ static bool vpn_is_valid_transport(struct connman_service *transport)
 
 static void vpn_disconnect_check_provider(struct connection_data *data)
 {
-	if (provider_is_connected(data)) {
+	if (provider_is_connected_or_connecting(data)) {
 		/* With NULL service ident NULL is returned immediately */
 		struct connman_service *service =
 			connman_service_lookup_from_identifier
-- 
2.30.2


  parent reply	other threads:[~2022-12-13 14:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13 14:06 [RFC PATCH 0/9] Add association state for VPNs Jussi Laakkonen
2022-12-13 14:06 ` [RFC PATCH 1/9] agent: Cancel agent request on NoReply D-Bus error Jussi Laakkonen
2022-12-13 14:07 ` [RFC PATCH 2/9] vpn-provider: Use association state for VPN agent input wait Jussi Laakkonen
2022-12-13 14:07 ` [RFC PATCH 3/9] vpn: Add association state before connect state Jussi Laakkonen
2022-12-13 14:07 ` [RFC PATCH 4/9] vpn-agent: Do connect state transition after input dialog check Jussi Laakkonen
2022-12-13 14:07 ` [RFC PATCH 5/9] service: Explicit VPN connect timeout, ignore in VPN agent wait Jussi Laakkonen
2022-12-13 14:07 ` [RFC PATCH 6/9] provider: Handle VPN configuration and association states Jussi Laakkonen
2022-12-13 14:07 ` [RFC PATCH 7/9] vpn: Add support for association state, add state getter Jussi Laakkonen
2022-12-13 14:07 ` Jussi Laakkonen [this message]
2022-12-13 14:07 ` [RFC PATCH 9/9] doc: Update VPN documentation for association state Jussi Laakkonen
2023-01-02  8:10 ` [RFC PATCH 0/9] Add association state for VPNs Daniel Wagner
2023-01-05 11:39   ` Jussi Laakkonen
2023-02-27  7:34     ` Daniel Wagner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221213140707.278313-9-jussi.laakkonen@jolla.com \
    --to=jussi.laakkonen@jolla.com \
    --cc=connman@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).