connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Ensure resolving and setting of proper ISO3166 code
@ 2023-12-22 15:46 Jussi Laakkonen
  2023-12-22 15:46 ` [PATCH 1/3] technology: Add global regdom and regdom getter Jussi Laakkonen
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Jussi Laakkonen @ 2023-12-22 15:46 UTC (permalink / raw)
  To: connman

This patch set amends the functionality added in commit
bce73f1bdbf1aa6fc28d2f75b7780f4f1d8b0e3a by making sure that the ISO3166 code:
 - is resolved in every case using both zone1970.tab and zone.tab
 - gets set for the technology when it powers up
 - and, is kept in sync between technology and device(s)

Technology now stores the regulatory domain as an internal value which is
changed whenever a change is detected. Similarly each device ensures that the
value is being kept in sync with technology as it is set always when the device
gets powered. Technology gets the change notifification via Ofono or via the
Localtime setting watched by timezone.

In order to always resolve, or attempt to resolve, the correct ISO3166 code in
every country sub-region both zone1970.tab and the deprecated zone.tab files
are used. Initially the ISO3166 code is retrieved from zone1970.tab but if not
found then the deprecated timezone map is used to get the correct iso ISO3166
which is used as a search parameter to again search from the zone1970.tab but
this time searching from the string lists. This is needed in special cases,
such as Ålands and Pacific/Midway regions to name but a few, to have the
ISO3166 code set. Otherwise in these regions WiFi plugin, for instance, is
told to use the default region, resulting in some channels being inaccessible.


Jussi Laakkonen (3):
  technology: Add global regdom and regdom getter
  device: Setup regdom when powering up to maintain consistency
  timezone: Fix resolving of proper ISO3166 code from tz data

 src/connman.h    |   1 +
 src/device.c     |  11 +++
 src/technology.c |  27 +++++++
 src/timezone.c   | 178 ++++++++++++++++++++++++++++++++++++++++-------
 4 files changed, 191 insertions(+), 26 deletions(-)

-- 
2.30.2


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

* [PATCH 1/3] technology: Add global regdom and regdom getter
  2023-12-22 15:46 [PATCH 0/3] Ensure resolving and setting of proper ISO3166 code Jussi Laakkonen
@ 2023-12-22 15:46 ` Jussi Laakkonen
  2023-12-22 15:46 ` [PATCH 2/3] device: Setup regdom when powering up to maintain consistency Jussi Laakkonen
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Jussi Laakkonen @ 2023-12-22 15:46 UTC (permalink / raw)
  To: connman

Add a global regdom to be saved when setting technology regdom because
the technologies are not loaded yet at bootup. Loading of plugins
initializes technologies which then sets up the regdom if it has been set
up earlier by timezone.c. The getter prioritizes the technology regdom
and then the global regdom and is to be used by devices when powering
up.
---
 src/connman.h    |  1 +
 src/technology.c | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/src/connman.h b/src/connman.h
index 622a7785..34e1463e 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -595,6 +595,7 @@ void __connman_technology_remove_interface(enum connman_service_type type,
 				int index, const char *ident);
 void __connman_technology_notify_regdom_by_device(struct connman_device *device,
 						int result, const char *alpha2);
+const char *__connman_technology_get_regdom(enum connman_service_type type);
 
 #include <connman/device.h>
 
diff --git a/src/technology.c b/src/technology.c
index 5c469111..65fb9854 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -43,6 +43,8 @@ static GHashTable *rfkill_list;
 
 static bool global_offlinemode;
 
+static char *global_regdom = NULL;
+
 struct connman_rfkill {
 	unsigned int index;
 	enum connman_service_type type;
@@ -333,8 +335,14 @@ int connman_technology_set_regdom(const char *alpha2)
 					driver->set_regdom(technology, alpha2);
 			}
 		}
+
+		/* Save regdom for this technology */
+		connman_technology_regdom_notify(technology, alpha2);
 	}
 
+	g_free(global_regdom);
+	global_regdom = g_strdup(alpha2);
+
 	return 0;
 }
 
@@ -354,6 +362,22 @@ static struct connman_technology *technology_find(enum connman_service_type type
 	return NULL;
 }
 
+const char *__connman_technology_get_regdom(enum connman_service_type type)
+{
+	struct connman_technology *technology;
+
+	DBG("type %d/%s", type, get_name(type));
+
+	technology = technology_find(type);
+	if (!technology)
+		return NULL;
+
+	if (technology->regdom)
+		return technology->regdom;
+
+	return global_regdom;
+}
+
 enum connman_service_type connman_technology_get_type
 				(struct connman_technology *technology)
 {
@@ -1283,6 +1307,7 @@ static struct connman_technology *technology_get(enum connman_service_type type)
 	technology_load(technology);
 	technology_list = g_slist_prepend(technology_list, technology);
 	technology->driver_list = tech_drivers;
+	technology->regdom = g_strdup(global_regdom);
 
 	for (list = tech_drivers; list; list = list->next) {
 		driver = list->data;
@@ -1905,4 +1930,6 @@ void __connman_technology_cleanup(void)
 	g_hash_table_destroy(rfkill_list);
 
 	dbus_connection_unref(connection);
+
+	g_free(global_regdom);
 }
-- 
2.30.2


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

* [PATCH 2/3] device: Setup regdom when powering up to maintain consistency
  2023-12-22 15:46 [PATCH 0/3] Ensure resolving and setting of proper ISO3166 code Jussi Laakkonen
  2023-12-22 15:46 ` [PATCH 1/3] technology: Add global regdom and regdom getter Jussi Laakkonen
@ 2023-12-22 15:46 ` Jussi Laakkonen
  2023-12-22 15:46 ` [PATCH 3/3] timezone: Fix resolving of proper ISO3166 code from tz data Jussi Laakkonen
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Jussi Laakkonen @ 2023-12-22 15:46 UTC (permalink / raw)
  To: connman

If the regdom has been set for the technology or for all the
technologies as a global setting apply it when powering up a device that
supports changing regdom. Otherwise the changes made to regdom may not
have been propagated to the device if the change has been made when the
device was powered off, for instance.
---
 src/device.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/device.c b/src/device.c
index 264c5e2d..55670099 100644
--- a/src/device.c
+++ b/src/device.c
@@ -589,6 +589,7 @@ int connman_device_set_powered(struct connman_device *device,
 {
 	struct connman_device_scan_params params;
 	enum connman_service_type type;
+	const char *alpha2;
 	int i;
 
 	DBG("device %p powered %d", device, powered);
@@ -607,6 +608,16 @@ int connman_device_set_powered(struct connman_device *device,
 	if (!device->powered) {
 		__connman_technology_disabled(type);
 		return 0;
+	} else {
+		/*
+		 * Check if the technology has regdom set and apply it for the
+		 * device. Regdom may have been changed when the device was
+		 * powered off and, thus, the new regdom has not been applied
+		 * here.
+		 */
+		alpha2 = __connman_technology_get_regdom(type);
+		if (alpha2)
+			connman_device_set_regdom(device, alpha2);
 	}
 
 	__connman_technology_enabled(type);
-- 
2.30.2


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

* [PATCH 3/3] timezone: Fix resolving of proper ISO3166 code from tz data
  2023-12-22 15:46 [PATCH 0/3] Ensure resolving and setting of proper ISO3166 code Jussi Laakkonen
  2023-12-22 15:46 ` [PATCH 1/3] technology: Add global regdom and regdom getter Jussi Laakkonen
  2023-12-22 15:46 ` [PATCH 2/3] device: Setup regdom when powering up to maintain consistency Jussi Laakkonen
@ 2023-12-22 15:46 ` Jussi Laakkonen
  2023-12-22 16:33 ` [PATCH 0/3] Ensure resolving and setting of proper ISO3166 code Grant Erickson
  2023-12-23 15:30 ` Marcel Holtmann
  4 siblings, 0 replies; 7+ messages in thread
From: Jussi Laakkonen @ 2023-12-22 15:46 UTC (permalink / raw)
  To: connman

It is possible that the region set as localtime region may have matches
in either of the zone map files. And in some cases there may be ISO3166
codes in the deprecated files that are not supported by the backends
such as gsupplicant to set the regulatory domain. Ålands/Mariehamn is an
example of this since as a region it only exists in zone.tab and
provides ISO3166 code AX which cannot be supported as regulatory domain.
But zone1970.tab contains the ISO3166 as a sub-region code for Finland
(FI) that should be set.

Furthermore, the timezone files for sub-regions, like with Ålands in
Finland and Pacific/Midway as UM -> AS, are identical copies and cannot be
compared solely by checking the mmap()'d entries. The path needs to be
taken into account or wrong region might be generated as a search
parameter for getting the ISO3166 code. Otherwise the results in some
cases might be ambiguous and the localtime set would yield another
region as a search parameter for the ISO3661 code.

Therefore, these changes add the real path utilized from the Localtime
path set in ConnMan settings to be used along the comparison of timezone
files. And the resolving of the ISO3661 code supports now more laborous
search if the code is not found using the region as a search parameter.
In such case the ISO3661 code is attempted to be searched from the
deprecated tz map and when found this code is used to search the
zone1970.tab again for a match in any of the defined ISO3166 string
lists. As a result the ISO3166 code of the main region is set that
should be supported by the varying backends to set the WiFi regulatory
domain.
---
 src/timezone.c | 178 +++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 152 insertions(+), 26 deletions(-)

diff --git a/src/timezone.c b/src/timezone.c
index f8d192df..89c44895 100644
--- a/src/timezone.c
+++ b/src/timezone.c
@@ -38,9 +38,10 @@
 
 #include "connman.h"
 
-#define ETC_SYSCONFIG_CLOCK	"/etc/sysconfig/clock"
-#define USR_SHARE_ZONEINFO	"/usr/share/zoneinfo"
-#define USR_SHARE_ZONEINFO_MAP	USR_SHARE_ZONEINFO "/zone1970.tab"
+#define ETC_SYSCONFIG_CLOCK		"/etc/sysconfig/clock"
+#define USR_SHARE_ZONEINFO		"/usr/share/zoneinfo"
+#define USR_SHARE_ZONEINFO_MAP		USR_SHARE_ZONEINFO "/zone1970.tab"
+#define USR_SHARE_ZONEINFO_MAP_OLD	USR_SHARE_ZONEINFO "/zone.tab"
 
 static char *read_key_file(const char *pathname, const char *key)
 {
@@ -115,12 +116,17 @@ static char *read_key_file(const char *pathname, const char *key)
 }
 
 static int compare_file(void *src_map, struct stat *src_st,
-						const char *pathname)
+				const char *real_path, const char *pathname)
 {
 	struct stat dst_st;
 	void *dst_map;
 	int fd, result;
 
+	DBG("real path %s path name %s", real_path, pathname);
+
+	if (real_path && g_strcmp0(real_path, pathname))
+		return -1;
+
 	fd = open(pathname, O_RDONLY | O_CLOEXEC);
 	if (fd < 0)
 		return -1;
@@ -151,7 +157,8 @@ static int compare_file(void *src_map, struct stat *src_st,
 }
 
 static char *find_origin(void *src_map, struct stat *src_st,
-				const char *basepath, const char *subpath)
+				const char* real_path, const char *basepath,
+				const char *subpath)
 {
 	DIR *dir;
 	struct dirent *d;
@@ -186,7 +193,8 @@ static char *find_origin(void *src_map, struct stat *src_st,
 						"%s/%s/%s", basepath,
 							subpath, d->d_name);
 
-			if (compare_file(src_map, src_st, pathname) == 0) {
+			if (compare_file(src_map, src_st, real_path, pathname)
+									== 0) {
 				if (!subpath)
 					str = g_strdup(d->d_name);
 				else
@@ -214,7 +222,8 @@ static char *find_origin(void *src_map, struct stat *src_st,
 				snprintf(pathname, sizeof(pathname),
 						"%s/%s", subpath, d->d_name);
 
-			str = find_origin(src_map, src_st, basepath, pathname);
+			str = find_origin(src_map, src_st, real_path, basepath,
+						pathname);
 			if (str) {
 				closedir(dir);
 				return str;
@@ -228,7 +237,52 @@ static char *find_origin(void *src_map, struct stat *src_st,
 	return NULL;
 }
 
-static char *get_timezone_alpha2(const char *zone)
+/* TZ map file format: Countrycodes Coordinates TZ Comments */
+enum tz_map_item {
+	TZ_MAP_ITEM_ISO3166 = 0,
+	TZ_MAP_ITEM_COORDINATE = 1,
+	TZ_MAP_ITEM_TIMEZONE = 2,
+	TZ_MAP_ITEM_COMMENT = 3,
+};
+
+static bool iso3166_matches(const char *codes, const char *iso3166)
+{
+	gchar **tokens;
+	guint len;
+	guint i;
+	bool ret = false;
+
+	if (!codes || !iso3166)
+		return false;
+
+	tokens = g_strsplit(codes, ",", -1);
+	if (!tokens)
+		return false;
+
+	len = g_strv_length(tokens);
+	if (len < 2) {
+		g_strfreev(tokens);
+		return false;
+	}
+
+	DBG("search %s from %s", iso3166, codes);
+
+	for (i = 0; i < len; i++) {
+		DBG("#%d %s", i, tokens[i]);
+
+		if (!g_strcmp0(tokens[i], iso3166)) {
+			ret = true;
+			break;
+		}
+	}
+
+	g_strfreev(tokens);
+
+	return ret;
+}
+
+static char *get_timezone_alpha2(const char *zone, const char *mapfile,
+						enum tz_map_item map_item)
 {
 	GIOChannel *channel;
 	struct stat st;
@@ -236,15 +290,15 @@ static char *get_timezone_alpha2(const char *zone)
 	char *line;
 	char *alpha2 = NULL;
 	gsize len;
+	bool found = false;
 	int fd;
 
 	if (!zone)
 		return NULL;
 
-	fd = open(USR_SHARE_ZONEINFO_MAP, O_RDONLY | O_CLOEXEC);
+	fd = open(mapfile, O_RDONLY | O_CLOEXEC);
 	if (fd < 0) {
-		connman_warn("failed to open zoneinfo map %s",
-							USR_SHARE_ZONEINFO_MAP);
+		connman_warn("failed to open zoneinfo map %s", mapfile);
 		return NULL;
 	}
 
@@ -256,23 +310,23 @@ static char *get_timezone_alpha2(const char *zone)
 
 	channel = g_io_channel_unix_new(fd);
 	if (!channel) {
-		connman_warn("failed to create io channel for %s",
-							USR_SHARE_ZONEINFO_MAP);
+		connman_warn("failed to create io channel for %s", mapfile);
 		close(fd);
 		return NULL;
 	}
 
-	DBG("read %s for %s", USR_SHARE_ZONEINFO_MAP, zone);
+	DBG("read %s for %s", mapfile, zone);
 	g_io_channel_set_encoding(channel, "UTF-8", NULL);
 
 	while (g_io_channel_read_line(channel, &line, &len, NULL, NULL) ==
 							G_IO_STATUS_NORMAL) {
+		found = false;
+
 		if (!line || !*line || *line == '#' || *line == '\n') {
 			g_free(line);
 			continue;
 		}
 
-		/* File format: Countrycodes Coordinates TZ Comments */
 		tokens = g_strsplit_set(line, " \t", 4);
 		if (!tokens) {
 			connman_warn("line %s failed to parse", line);
@@ -280,13 +334,35 @@ static char *get_timezone_alpha2(const char *zone)
 			continue;
 		}
 
-		if (g_strv_length(tokens) >= 3 && !g_strcmp0(
-						g_strstrip(tokens[2]), zone)) {
+		if (g_strv_length(tokens) >= 3) {
+			switch (map_item) {
+			case TZ_MAP_ITEM_ISO3166:
+
+				if (!g_strcmp0(tokens[0], zone)) {
+					found = true;
+					break;
+				}
+
+				if (iso3166_matches(tokens[0], zone))
+					found = true;
+				break;
+			case TZ_MAP_ITEM_COORDINATE:
+				break;
+			case TZ_MAP_ITEM_TIMEZONE:
+				if (!g_strcmp0(g_strstrip(tokens[2]), zone))
+					found = true;
+				break;
+			case TZ_MAP_ITEM_COMMENT:
+				break;
+			}
+
 			/*
 			 * Multiple country codes can be listed, use the first
-			 * 2 chars.
+			 * 2 chars as backends such as gsupplicant support only
+			 * the main country code.
 			 */
-			alpha2 = g_strndup(g_strstrip(tokens[0]), 2);
+			if (found)
+				alpha2 = g_strndup(g_strstrip(tokens[0]), 2);
 		}
 
 		g_strfreev(tokens);
@@ -300,9 +376,8 @@ static char *get_timezone_alpha2(const char *zone)
 			} else {
 				DBG("Zone %s ISO3166 country code %s", zone,
 									alpha2);
+				break;
 			}
-
-			break;
 		}
 	}
 
@@ -312,6 +387,44 @@ static char *get_timezone_alpha2(const char *zone)
 	return alpha2;
 }
 
+static char *try_get_timezone_alpha2(const char *zone)
+{
+	char *alpha2;
+	char *alpha2_old;
+
+	/* First try the official map */
+	alpha2 = get_timezone_alpha2(zone, USR_SHARE_ZONEINFO_MAP,
+							TZ_MAP_ITEM_TIMEZONE);
+	if (alpha2)
+		return alpha2;
+
+	DBG("%s not found in %s", zone, USR_SHARE_ZONEINFO_MAP);
+
+	/* The zone was not found in official map, try with deprecated */
+	alpha2_old = get_timezone_alpha2(zone, USR_SHARE_ZONEINFO_MAP_OLD,
+							TZ_MAP_ITEM_TIMEZONE);
+	if (!alpha2_old) {
+		DBG("%s not found in %s", zone, USR_SHARE_ZONEINFO_MAP_OLD);
+		return NULL;
+	}
+
+	/*
+	 * Found from deprecated, try to get main region code from official new
+	 * map using the iso3166 search. This is because some of the codes
+	 * defined in the deprecated are not supported by the backends, e.g.,
+	 * gsupplicant and the main code should be used.
+	 */
+	alpha2 = get_timezone_alpha2(alpha2_old, USR_SHARE_ZONEINFO_MAP,
+							TZ_MAP_ITEM_ISO3166);
+
+	DBG("%s -> ISO3166 %s found in %s as %s", zone, alpha2_old,
+						USR_SHARE_ZONEINFO_MAP, alpha2);
+
+	g_free(alpha2_old);
+
+	return alpha2;
+}
+
 char *__connman_timezone_lookup(void)
 {
 	struct stat st;
@@ -319,13 +432,16 @@ char *__connman_timezone_lookup(void)
 	int fd;
 	char *zone;
 	char *alpha2;
+	const char *local_time;
+	char real_path[PATH_MAX];
 
 	zone = read_key_file(ETC_SYSCONFIG_CLOCK, "ZONE");
 
 	DBG("sysconfig zone %s", zone);
 
-	fd = open(connman_setting_get_string("Localtime"),
-							O_RDONLY | O_CLOEXEC);
+	local_time = connman_setting_get_string("Localtime");
+
+	fd = open(local_time, O_RDONLY | O_CLOEXEC);
 	if (fd < 0) {
 		g_free(zone);
 		return NULL;
@@ -334,6 +450,15 @@ char *__connman_timezone_lookup(void)
 	if (fstat(fd, &st) < 0)
 		goto done;
 
+	if (!realpath(local_time, real_path)) {
+		connman_error("Failed to get real path of %s: %d/%s",
+					local_time, errno, strerror(errno));
+		g_free(zone);
+		close(fd);
+
+		return NULL;
+	}
+
 	if (S_ISREG(st.st_mode)) {
 		map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
 		if (!map || map == MAP_FAILED) {
@@ -349,14 +474,15 @@ char *__connman_timezone_lookup(void)
 			snprintf(pathname, PATH_MAX, "%s/%s",
 						USR_SHARE_ZONEINFO, zone);
 
-			if (compare_file(map, &st, pathname) != 0) {
+			if (compare_file(map, &st, NULL, pathname) != 0) {
 				g_free(zone);
 				zone = NULL;
 			}
 		}
 
 		if (!zone)
-			zone = find_origin(map, &st, USR_SHARE_ZONEINFO, NULL);
+			zone = find_origin(map, &st, real_path,
+						USR_SHARE_ZONEINFO, NULL);
 
 		munmap(map, st.st_size);
 	} else {
@@ -370,7 +496,7 @@ done:
 	DBG("localtime zone %s", zone);
 
 	if (connman_setting_get_bool("RegdomFollowsTimezone")) {
-		alpha2 = get_timezone_alpha2(zone);
+		alpha2 = try_get_timezone_alpha2(zone);
 		if (alpha2) {
 			DBG("change regdom to %s", alpha2);
 			connman_technology_set_regdom(alpha2);
-- 
2.30.2


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

* Re: [PATCH 0/3] Ensure resolving and setting of proper ISO3166 code
  2023-12-22 15:46 [PATCH 0/3] Ensure resolving and setting of proper ISO3166 code Jussi Laakkonen
                   ` (2 preceding siblings ...)
  2023-12-22 15:46 ` [PATCH 3/3] timezone: Fix resolving of proper ISO3166 code from tz data Jussi Laakkonen
@ 2023-12-22 16:33 ` Grant Erickson
  2024-01-02 12:16   ` Jussi Laakkonen
  2023-12-23 15:30 ` Marcel Holtmann
  4 siblings, 1 reply; 7+ messages in thread
From: Grant Erickson @ 2023-12-22 16:33 UTC (permalink / raw)
  To: Jussi Laakkonen; +Cc: connman

On Dec 22, 2023, at 7:46 AM, Jussi Laakkonen <jussi.laakkonen@jolla.com> wrote:
> This patch set amends the functionality added in commit
> bce73f1bdbf1aa6fc28d2f75b7780f4f1d8b0e3a by making sure that the ISO3166 code:
> - is resolved in every case using both zone1970.tab and zone.tab
> - gets set for the technology when it powers up
> - and, is kept in sync between technology and device(s)
> 
> Technology now stores the regulatory domain as an internal value which is
> changed whenever a change is detected. Similarly each device ensures that the
> value is being kept in sync with technology as it is set always when the device
> gets powered. Technology gets the change notifification via Ofono or via the
> Localtime setting watched by timezone.
> 
> In order to always resolve, or attempt to resolve, the correct ISO3166 code in
> every country sub-region both zone1970.tab and the deprecated zone.tab files
> are used. Initially the ISO3166 code is retrieved from zone1970.tab but if not
> found then the deprecated timezone map is used to get the correct iso ISO3166
> which is used as a search parameter to again search from the zone1970.tab but
> this time searching from the string lists. This is needed in special cases,
> such as Ålands and Pacific/Midway regions to name but a few, to have the
> ISO3166 code set. Otherwise in these regions WiFi plugin, for instance, is
> told to use the default region, resulting in some channels being inaccessible.
> 
> 
> Jussi Laakkonen (3):
>  technology: Add global regdom and regdom getter
>  device: Setup regdom when powering up to maintain consistency
>  timezone: Fix resolving of proper ISO3166 code from tz data
> 
> src/connman.h    |   1 +
> src/device.c     |  11 +++
> src/technology.c |  27 +++++++
> src/timezone.c   | 178 ++++++++++++++++++++++++++++++++++++++++-------
> 4 files changed, 191 insertions(+), 26 deletions(-)
> 
> -- 
> 2.30.2

Jussi,

Thank you for this patch.

I have a system where the timezone is currently set to "America/Denver" which periodically results in the being incorrectly identified as “Navajo”:

2023-12-22T09:27:46-0700 [19205453]# cat /etc/timezone 
America/Denver

But is identified as “Navajo” here:

connmand[<PID>]: src/timezone.c:__connman_timezone_init() 
connmand[<PID>]: src/timezone.c:__connman_timezone_lookup() sysconfig zone (null)
connmand[<PID>]: src/timezone.c:__connman_timezone_lookup() localtime zone Navajo

But in another run is identified as “America/Denver”:

connmand[<PID>]: src/timezone.c:__connman_timezone_init() 
connmand[<PID>]: src/timezone.c:__connman_timezone_lookup() sysconfig zone (null)
connmand[<PID>]: src/timezone.c:__connman_timezone_lookup() localtime zone America/Denver

I will be eager to see if this patch series fixes this issue.

Best,

Grant

-- 
Principal
Nuovations

gerickson@nuovations.com
http://www.nuovations.com/




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

* Re: [PATCH 0/3] Ensure resolving and setting of proper ISO3166 code
  2023-12-22 15:46 [PATCH 0/3] Ensure resolving and setting of proper ISO3166 code Jussi Laakkonen
                   ` (3 preceding siblings ...)
  2023-12-22 16:33 ` [PATCH 0/3] Ensure resolving and setting of proper ISO3166 code Grant Erickson
@ 2023-12-23 15:30 ` Marcel Holtmann
  4 siblings, 0 replies; 7+ messages in thread
From: Marcel Holtmann @ 2023-12-23 15:30 UTC (permalink / raw)
  To: Jussi Laakkonen; +Cc: connman

Hi Jussi,

> This patch set amends the functionality added in commit
> bce73f1bdbf1aa6fc28d2f75b7780f4f1d8b0e3a by making sure that the ISO3166 code:
> - is resolved in every case using both zone1970.tab and zone.tab
> - gets set for the technology when it powers up
> - and, is kept in sync between technology and device(s)
> 
> Technology now stores the regulatory domain as an internal value which is
> changed whenever a change is detected. Similarly each device ensures that the
> value is being kept in sync with technology as it is set always when the device
> gets powered. Technology gets the change notifification via Ofono or via the
> Localtime setting watched by timezone.
> 
> In order to always resolve, or attempt to resolve, the correct ISO3166 code in
> every country sub-region both zone1970.tab and the deprecated zone.tab files
> are used. Initially the ISO3166 code is retrieved from zone1970.tab but if not
> found then the deprecated timezone map is used to get the correct iso ISO3166
> which is used as a search parameter to again search from the zone1970.tab but
> this time searching from the string lists. This is needed in special cases,
> such as Ålands and Pacific/Midway regions to name but a few, to have the
> ISO3166 code set. Otherwise in these regions WiFi plugin, for instance, is
> told to use the default region, resulting in some channels being inaccessible.
> 
> 
> Jussi Laakkonen (3):
>  technology: Add global regdom and regdom getter
>  device: Setup regdom when powering up to maintain consistency
>  timezone: Fix resolving of proper ISO3166 code from tz data
> 
> src/connman.h    |   1 +
> src/device.c     |  11 +++
> src/technology.c |  27 +++++++
> src/timezone.c   | 178 ++++++++++++++++++++++++++++++++++++++++-------
> 4 files changed, 191 insertions(+), 26 deletions(-)

all 3 patches have been applied.

Regards

Marcel


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

* Re: [PATCH 0/3] Ensure resolving and setting of proper ISO3166 code
  2023-12-22 16:33 ` [PATCH 0/3] Ensure resolving and setting of proper ISO3166 code Grant Erickson
@ 2024-01-02 12:16   ` Jussi Laakkonen
  0 siblings, 0 replies; 7+ messages in thread
From: Jussi Laakkonen @ 2024-01-02 12:16 UTC (permalink / raw)
  To: Grant Erickson; +Cc: connman



On 12/22/23 18:33, Grant Erickson wrote:
> On Dec 22, 2023, at 7:46 AM, Jussi Laakkonen <jussi.laakkonen@jolla.com> wrote:
>> This patch set amends the functionality added in commit
>> bce73f1bdbf1aa6fc28d2f75b7780f4f1d8b0e3a by making sure that the ISO3166 code:
>> - is resolved in every case using both zone1970.tab and zone.tab
>> - gets set for the technology when it powers up
>> - and, is kept in sync between technology and device(s)
>>
>> Technology now stores the regulatory domain as an internal value which is
>> changed whenever a change is detected. Similarly each device ensures that the
>> value is being kept in sync with technology as it is set always when the device
>> gets powered. Technology gets the change notifification via Ofono or via the
>> Localtime setting watched by timezone.
>>
>> In order to always resolve, or attempt to resolve, the correct ISO3166 code in
>> every country sub-region both zone1970.tab and the deprecated zone.tab files
>> are used. Initially the ISO3166 code is retrieved from zone1970.tab but if not
>> found then the deprecated timezone map is used to get the correct iso ISO3166
>> which is used as a search parameter to again search from the zone1970.tab but
>> this time searching from the string lists. This is needed in special cases,
>> such as Ålands and Pacific/Midway regions to name but a few, to have the
>> ISO3166 code set. Otherwise in these regions WiFi plugin, for instance, is
>> told to use the default region, resulting in some channels being inaccessible.
>>
>>
>> Jussi Laakkonen (3):
>>   technology: Add global regdom and regdom getter
>>   device: Setup regdom when powering up to maintain consistency
>>   timezone: Fix resolving of proper ISO3166 code from tz data
>>
>> src/connman.h    |   1 +
>> src/device.c     |  11 +++
>> src/technology.c |  27 +++++++
>> src/timezone.c   | 178 ++++++++++++++++++++++++++++++++++++++++-------
>> 4 files changed, 191 insertions(+), 26 deletions(-)
>>
>> -- 
>> 2.30.2
> 
> Jussi,
> 
> Thank you for this patch.
> 
> I have a system where the timezone is currently set to "America/Denver" which periodically results in the being incorrectly identified as “Navajo”:
> 
> 2023-12-22T09:27:46-0700 [19205453]# cat /etc/timezone
> America/Denver
> 
> But is identified as “Navajo” here:
> 
> connmand[<PID>]: src/timezone.c:__connman_timezone_init()
> connmand[<PID>]: src/timezone.c:__connman_timezone_lookup() sysconfig zone (null)
> connmand[<PID>]: src/timezone.c:__connman_timezone_lookup() localtime zone Navajo
> 
> But in another run is identified as “America/Denver”:
> 
> connmand[<PID>]: src/timezone.c:__connman_timezone_init()
> connmand[<PID>]: src/timezone.c:__connman_timezone_lookup() sysconfig zone (null)
> connmand[<PID>]: src/timezone.c:__connman_timezone_lookup() localtime zone America/Denver
> 
> I will be eager to see if this patch series fixes this issue.
> 
> Best,
> 
> Grant
> 

Hi Grant,

I think it should help with that issue since comparing the tz files by 
their content was not ideal as many of them are either equal files or 
they are symlinks. Like that Navajo vs. America/Denver is, and as well 
as the case that triggered the need for this change; Mariehamn and 
Helsinki is:

$ ls /usr/share/zoneinfo/*/Navajo -l
lrwxrwxrwx 1 root root 14 Dec  1 23:51 /usr/share/zoneinfo/posix/Navajo 
-> America/Denver
lrwxrwxrwx 1 root root 14 Dec  1 23:51 /usr/share/zoneinfo/right/Navajo 
-> America/Denver

and
$ ls /usr/share/zoneinfo/*Navajo -l
lrwxrwxrwx 1 root root 14 Dec  1 23:51 /usr/share/zoneinfo/Navajo -> 
America/Denver


Likewise Mariehamn -> Helsinki:

$ ls /usr/share/zoneinfo/*/Mariehamn -l
lrwxrwxrwx 1 root root 8 Dec  1 23:51 
/usr/share/zoneinfo/Europe/Mariehamn -> Helsinki


Did a small test on our devices and they do seem to set the correct one 
with America/Denver set as timezone, at bootup and when changing it 
manually.

I guess you are also using the option to set the regdom on timezone 
changes in the configuration and not to rely on ofono plugin to set 
regdom? The change for the option was included in commits:
f035539d46ac23ccb8916ed7ae8d38ab553d32b1 to support path for localtime
aaab2161b247588bbee32fefe775ef55acc69c4d to set regdom to follow timezone

Let me know how it works on other systems.

Cheers!

- Jussi

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

end of thread, other threads:[~2024-01-02 12:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-22 15:46 [PATCH 0/3] Ensure resolving and setting of proper ISO3166 code Jussi Laakkonen
2023-12-22 15:46 ` [PATCH 1/3] technology: Add global regdom and regdom getter Jussi Laakkonen
2023-12-22 15:46 ` [PATCH 2/3] device: Setup regdom when powering up to maintain consistency Jussi Laakkonen
2023-12-22 15:46 ` [PATCH 3/3] timezone: Fix resolving of proper ISO3166 code from tz data Jussi Laakkonen
2023-12-22 16:33 ` [PATCH 0/3] Ensure resolving and setting of proper ISO3166 code Grant Erickson
2024-01-02 12:16   ` Jussi Laakkonen
2023-12-23 15:30 ` Marcel Holtmann

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