connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] service: Fix preferred service reordering on ready state
@ 2021-06-14  9:41 VAUTRIN Emmanuel (Canal Plus Prestataire)
  2021-06-14 10:29 ` Jussi Laakkonen
  0 siblings, 1 reply; 8+ messages in thread
From: VAUTRIN Emmanuel (Canal Plus Prestataire) @ 2021-06-14  9:41 UTC (permalink / raw)
  To: connman

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


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

end of thread, other threads:[~2021-06-22 15:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-14  9:41 [PATCH] service: Fix preferred service reordering on ready state VAUTRIN Emmanuel (Canal Plus Prestataire)
2021-06-14 10:29 ` 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)

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