connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: "VAUTRIN Emmanuel (Canal Plus Prestataire)" <Emmanuel.VAUTRIN@cpexterne.org>
To: "connman@lists.linux.dev" <connman@lists.linux.dev>
Subject: [PATCH] service: Fix preferred service reordering on ready state
Date: Mon, 14 Jun 2021 09:41:02 +0000	[thread overview]
Message-ID: <PR1PR02MB47942554247F92A1437631E893319@PR1PR02MB4794.eurprd02.prod.outlook.com> (raw)

When a service reaches the ready state, the service list shall always
be reordered according to the PreferredTechnologies config options.

This issue can be reproduced with PreferredTechnologies=ethernet,wifi,
by following the steps above:
1. Starting, Ethernet (E) plugged, with a known Wifi (W) network.
E idle -> online, W idle -> ready
2. Unplug Ethernet.
E online -> idle, W ready -> online
3. Plug Ethernet.
E idle -> ready, W online
Even if Ethernet has the highest priority, it will never be online,
except if Wifi connection is lost.

Fixes: e600366f6035 ("service: Start online check on IP address update")
---
 src/service.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/service.c b/src/service.c
index 20917a8923a4..cadd9fc76881 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4711,15 +4711,11 @@ static void apply_relevant_default_downgrade(struct connman_service *service)
 	struct connman_service *def_service;
 
 	def_service = connman_service_get_default();
-	if (!def_service)
+	if (!def_service || def_service != service ||
+		def_service->state != CONNMAN_SERVICE_STATE_ONLINE)
 		return;
 
-	if (def_service == service &&
-			def_service->state == CONNMAN_SERVICE_STATE_ONLINE) {
-		def_service->state = CONNMAN_SERVICE_STATE_READY;
-		__connman_notifier_leave_online(def_service->type);
-		state_changed(def_service);
-	}
+	downgrade_state(def_service);
 }
 
 static void switch_default_service(struct connman_service *default_service,
@@ -5898,8 +5894,7 @@ static int service_update_preferred_order(struct connman_service *default_servic
 	unsigned int *tech_array;
 	int i;
 
-	if (!default_service || default_service == new_service ||
-			default_service->state != new_state)
+	if (!default_service || default_service == new_service)
 		return 0;
 
 	tech_array = connman_setting_get_uint_list("PreferredTechnologies");
@@ -6051,12 +6046,12 @@ static int service_indicate_state(struct connman_service *service)
 
 		service->new_service = false;
 
-		default_changed();
-
 		def_service = connman_service_get_default();
 
 		service_update_preferred_order(def_service, service, new_state);
 
+		default_changed();
+
 		__connman_service_set_favorite(service, true);
 
 		reply_pending(service, 0);
-- 
2.25.1


             reply	other threads:[~2021-06-14  9:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-14  9:41 VAUTRIN Emmanuel (Canal Plus Prestataire) [this message]
2021-06-14 10:29 ` [PATCH] service: Fix preferred service reordering on ready state Jussi Laakkonen
2021-06-15 12:35   ` VAUTRIN Emmanuel (Canal Plus Prestataire)
2021-06-17  9:07     ` Jussi Laakkonen
2021-06-17 10:22       ` VAUTRIN Emmanuel (Canal Plus Prestataire)
2021-06-21  7:30         ` Daniel Wagner
2021-06-21  8:35           ` VAUTRIN Emmanuel (Canal Plus Prestataire)
2021-06-22 15:38             ` VAUTRIN Emmanuel (Canal Plus Prestataire)

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=PR1PR02MB47942554247F92A1437631E893319@PR1PR02MB4794.eurprd02.prod.outlook.com \
    --to=emmanuel.vautrin@cpexterne.org \
    --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).