Send connman mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."


Today's Topics:

   1. [PATCH 1/2] ntp: Make threshold value for settimeofday vs
      adjtime configurable. ([email protected])
   2. [PATCH 2/2] ntp: Make TimeUpdateThreshold settable/gettable
      from DBUS ([email protected])
   3. [PATCH] Fix memory leak when realloc fails (Nishant Chaprana)
   4. [PATCH] inet: Corrected usage of unsigned int data-type.
      (Niraj Kumar Goit)
   5. Re: [PATCH] inet: Corrected usage of unsigned int data-type.
      (Michael Olbrich)


----------------------------------------------------------------------

Message: 1
Date: Thu,  3 Mar 2016 12:05:51 +0100
From: [email protected]
To: [email protected]
Subject: [PATCH 1/2] ntp: Make threshold value for settimeofday vs
        adjtime configurable.
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8

From: B?sz?rm?nyi Zolt?n <[email protected]>

The current hardcoded default of 0.128 second threshold for using
settimeofday() instead of adjtime() is too small for some hardware.
Make it configurable via a new knob called TimeUpdateThreshold.

Signed-off-by: Zolt?n B?sz?rm?nyi <[email protected]>

---
 doc/clock-api.txt |  5 +++++
 src/clock.c       | 17 ++++++++++++++++-
 src/connman.h     |  1 +
 src/ntp.c         |  6 +++---
 4 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/doc/clock-api.txt b/doc/clock-api.txt
index 6818f5a..06e14f0 100644
--- a/doc/clock-api.txt
+++ b/doc/clock-api.txt
@@ -46,20 +46,25 @@ Properties  uint64 Time [readonly or readwrite]  
[experimental]
 
                string TimeUpdates [readwrite]  [experimental]
 
                        Possible values are "manual" and "auto" to indicate
                        time update policy.
 
                        With the "auto" setting the system tries to use as
                        many sources as possible to determine the correct
                        and updated time.
 
+               double TimeUpdateThreshold [readwrite]  [experimental]
+
+                       Threshold value in milliseconds for settimeofday()
+                       versus adjtime(). Default 0.128.
+
                string Timezone [readonly or readwrite]  [experimental]
 
                        Current system timezone string. Allowed values
                        are from the standard timezone data (tzdata)
                        package under /usr/share/zoneinfo. For example
                        strings like "America/Vancouver" or "Europe/Berlin".
 
                        This value is present for changing the timezone
                        if TimezoneUpdates is set to manual.
 
diff --git a/src/clock.c b/src/clock.c
index 0fde2c3..fdab868 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -30,21 +30,22 @@
 #include "connman.h"
 
 enum timezone_updates {
        TIMEZONE_UPDATES_UNKNOWN = 0,
        TIMEZONE_UPDATES_MANUAL  = 1,
        TIMEZONE_UPDATES_AUTO    = 2,
 };
 
 static enum time_updates time_updates_config = TIME_UPDATES_AUTO;
 static enum timezone_updates timezone_updates_config = TIMEZONE_UPDATES_AUTO;
-
+#define TIME_UPDATE_DEFAULT_THRESHOLD  (0.128)
+static double time_update_threshold_config = TIME_UPDATE_DEFAULT_THRESHOLD;
 static char *timezone_config = NULL;
 
 static const char *time_updates2string(enum time_updates value)
 {
        switch (value) {
        case TIME_UPDATES_UNKNOWN:
                break;
        case TIME_UPDATES_MANUAL:
                return "manual";
        case TIME_UPDATES_AUTO:
@@ -87,20 +88,21 @@ static enum timezone_updates string2timezone_updates(const 
char *value)
 
         return TIMEZONE_UPDATES_UNKNOWN;
 }
 
 static void clock_properties_load(void)
 {
        GKeyFile *keyfile;
        char *str;
        enum time_updates time_value;
        enum timezone_updates timezone_value;
+       double time_update_threshold;
 
        keyfile = __connman_storage_load_global();
        if (!keyfile)
                return;
 
        str = g_key_file_get_string(keyfile, "global", "TimeUpdates", NULL);
 
        time_value = string2time_updates(str);
        if (time_value != TIME_UPDATES_UNKNOWN)
                time_updates_config = time_value;
@@ -109,20 +111,24 @@ static void clock_properties_load(void)
 
        str = g_key_file_get_string(keyfile, "global", "TimezoneUpdates",
                        NULL);
 
        timezone_value = string2timezone_updates(str);
        if (timezone_value != TIMEZONE_UPDATES_UNKNOWN)
                timezone_updates_config = timezone_value;
 
        g_free(str);
 
+       time_update_threshold = g_key_file_get_double(keyfile, "global", 
"TimeUpdateThreshold", NULL);
+       if (time_update_threshold > 0.001 && time_update_threshold != 
TIME_UPDATE_DEFAULT_THRESHOLD)
+               time_update_threshold_config = time_update_threshold;
+
        g_key_file_free(keyfile);
 }
 
 static void clock_properties_save(void)
 {
        GKeyFile *keyfile;
        const char *str;
 
        keyfile = __connman_storage_load_global();
        if (!keyfile)
@@ -135,30 +141,39 @@ static void clock_properties_save(void)
                g_key_file_remove_key(keyfile, "global", "TimeUpdates", NULL);
 
        str = timezone_updates2string(timezone_updates_config);
        if (str)
                g_key_file_set_string(keyfile, "global", "TimezoneUpdates",
                                str);
        else
                g_key_file_remove_key(keyfile, "global", "TimezoneUpdates",
                                NULL);
 
+       if (time_update_threshold_config != TIME_UPDATE_DEFAULT_THRESHOLD)
+               g_key_file_set_double(keyfile, "global", "TimeUpdateThreshold",
+                               time_update_threshold_config);
+
        __connman_storage_save_global(keyfile);
 
        g_key_file_free(keyfile);
 }
 
 enum time_updates __connman_clock_timeupdates(void)
 {
        return time_updates_config;
 }
 
+double __connman_clock_timeupdate_threshold(void)
+{
+       return time_update_threshold_config;
+}
+
 static void append_timeservers(DBusMessageIter *iter, void *user_data)
 {
        int i;
        char **timeservers = __connman_timeserver_system_get();
 
        if (!timeservers)
                return;
 
        for (i = 0; timeservers[i]; i++) {
                dbus_message_iter_append_basic(iter,
diff --git a/src/connman.h b/src/connman.h
index 447bdd7..93b2baf 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -58,20 +58,21 @@ DBusMessage *__connman_error_invalid_property(DBusMessage 
*msg);
 int __connman_manager_init(void);
 void __connman_manager_cleanup(void);
 
 enum time_updates {
        TIME_UPDATES_UNKNOWN = 0,
        TIME_UPDATES_MANUAL  = 1,
        TIME_UPDATES_AUTO    = 2,
 };
 
 enum time_updates __connman_clock_timeupdates(void);
+double __connman_clock_timeupdate_threshold(void);
 int __connman_clock_init(void);
 void __connman_clock_cleanup(void);
 
 void __connman_clock_update_timezone(void);
 
 int __connman_timezone_init(void);
 void __connman_timezone_cleanup(void);
 
 char *__connman_timezone_lookup(void);
 int __connman_timezone_change(const char *zone);
diff --git a/src/ntp.c b/src/ntp.c
index dd246eb..f61e803 100644
--- a/src/ntp.c
+++ b/src/ntp.c
@@ -59,22 +59,20 @@ struct ntp_msg {
        struct ntp_short rootdisp;      /* Root dispersion */
        uint32_t refid;                 /* Reference ID */
        struct ntp_time reftime;        /* Reference timestamp */
        struct ntp_time orgtime;        /* Origin timestamp */
        struct ntp_time rectime;        /* Receive timestamp */
        struct ntp_time xmttime;        /* Transmit timestamp */
 } __attribute__ ((packed));
 
 #define OFFSET_1900_1970  2208988800UL /* 1970 - 1900 in seconds */
 
-#define STEPTIME_MIN_OFFSET  0.128
-
 #define LOGTOD(a)  ((a) < 0 ? 1. / (1L << -(a)) : 1L << (int)(a))
 
 #define NTP_SEND_TIMEOUT       2
 #define NTP_SEND_RETRIES       3
 
 #define NTP_FLAG_LI_SHIFT      6
 #define NTP_FLAG_LI_MASK       0x3
 #define NTP_FLAG_LI_NOWARNING  0x0
 #define NTP_FLAG_LI_ADDSECOND  0x1
 #define NTP_FLAG_LI_DELSECOND  0x2
@@ -239,20 +237,21 @@ static void reset_timeout(void)
 
        retries = 0;
 }
 
 static void decode_msg(void *base, size_t len, struct timeval *tv,
                struct timespec *mrx_time)
 {
        struct ntp_msg *msg = base;
        double m_delta, org, rec, xmt, dst;
        double delay, offset;
+       double threshold;
        static guint transmit_delay;
 
        if (len < sizeof(*msg)) {
                connman_error("Invalid response from time server");
                return;
        }
 
        if (!tv) {
                connman_error("Invalid packet timestamp from time server");
                return;
@@ -331,21 +330,22 @@ static void decode_msg(void *base, size_t len, struct 
timeval *tv,
         */
        if (poll_id > 0)
                g_source_remove(poll_id);
 
        DBG("Timeserver %s, next sync in %d seconds", timeserver, 
transmit_delay);
 
        poll_id = g_timeout_add_seconds(transmit_delay, next_poll, NULL);
 
        connman_info("ntp: time slew %+.6f s", offset);
 
-       if (offset < STEPTIME_MIN_OFFSET && offset > -STEPTIME_MIN_OFFSET) {
+       threshold = __connman_clock_timeupdate_threshold();
+       if (offset < threshold && offset > -threshold) {
                struct timeval adj;
 
                adj.tv_sec = (long) offset;
                adj.tv_usec = (offset - adj.tv_sec) * 1000000;
 
                DBG("adjusting time %ld seconds, %ld msecs", adj.tv_sec, 
adj.tv_usec);
 
                if (adjtime(&adj, &adj) < 0) {
                        connman_error("Failed to adjust time");
                        return;
-- 
2.5.0



------------------------------

Message: 2
Date: Thu,  3 Mar 2016 12:05:52 +0100
From: [email protected]
To: [email protected]
Subject: [PATCH 2/2] ntp: Make TimeUpdateThreshold settable/gettable
        from DBUS
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8

From: B?sz?rm?nyi Zolt?n <[email protected]>

Make TimeUpdateThreshold visible through DBUS.

Signed-off-by: Zolt?n B?sz?rm?nyi <[email protected]>

---
 src/clock.c | 19 +++++++++++++++++++
 src/dbus.c  |  3 +++
 2 files changed, 22 insertions(+)

diff --git a/src/clock.c b/src/clock.c
index fdab868..a6d0484 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -218,20 +218,23 @@ static DBusMessage *get_properties(DBusConnection *conn,
                                        DBUS_TYPE_STRING, &timezone_config);
 
        str = timezone_updates2string(timezone_updates_config);
        if (str)
                connman_dbus_dict_append_basic(&dict, "TimezoneUpdates",
                                                DBUS_TYPE_STRING, &str);
 
        connman_dbus_dict_append_array(&dict, "Timeservers",
                                DBUS_TYPE_STRING, append_timeservers, NULL);
 
+       connman_dbus_dict_append_basic(&dict, "TimeUpdateThreshold",
+                                               DBUS_TYPE_DOUBLE, 
&time_update_threshold_config);
+
        connman_dbus_dict_close(&array, &dict);
 
        return reply;
 }
 
 static DBusMessage *set_property(DBusConnection *conn,
                                        DBusMessage *msg, void *data)
 {
        DBusMessageIter iter, value;
        const char *name;
@@ -370,20 +373,36 @@ static DBusMessage *set_property(DBusConnection *conn,
                }
 
                __connman_timeserver_system_set(str);
 
                if (str)
                        g_strfreev(str);
 
                connman_dbus_property_changed_array(CONNMAN_MANAGER_PATH,
                                CONNMAN_CLOCK_INTERFACE, "Timeservers",
                                DBUS_TYPE_STRING, append_timeservers, NULL);
+       } else if (g_str_equal(name, "TimeUpdateThreshold")) {
+               double newval;
+
+               if (type != DBUS_TYPE_DOUBLE)
+                       return __connman_error_invalid_arguments(msg);
+
+               dbus_message_iter_get_basic(&value, &newval);
+
+               if (newval <= 0.001)
+                       return __connman_error_invalid_arguments(msg);
+
+               time_update_threshold_config = newval;
+
+               connman_dbus_property_changed_basic(CONNMAN_MANAGER_PATH,
+                               CONNMAN_CLOCK_INTERFACE, "TimeUpdateThreshold",
+                               DBUS_TYPE_DOUBLE, &newval);
        } else
                return __connman_error_invalid_property(msg);
 
        return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 }
 
 static const GDBusMethodTable clock_methods[] = {
        { GDBUS_METHOD("GetProperties",
                        NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
                        get_properties) },
diff --git a/src/dbus.c b/src/dbus.c
index d80a46c..88a34fe 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -104,20 +104,23 @@ void connman_dbus_property_append_basic(DBusMessageIter 
*iter,
                break;
        case DBUS_TYPE_INT32:
                signature = DBUS_TYPE_INT32_AS_STRING;
                break;
        case DBUS_TYPE_UINT64:
                signature = DBUS_TYPE_UINT64_AS_STRING;
                break;
        case DBUS_TYPE_INT64:
                signature = DBUS_TYPE_INT64_AS_STRING;
                break;
+       case DBUS_TYPE_DOUBLE:
+               signature = DBUS_TYPE_DOUBLE_AS_STRING;
+               break;
        case DBUS_TYPE_OBJECT_PATH:
                signature = DBUS_TYPE_OBJECT_PATH_AS_STRING;
                break;
        default:
                signature = DBUS_TYPE_VARIANT_AS_STRING;
                break;
        }
 
        dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
                                                        signature, &value);
-- 
2.5.0



------------------------------

Message: 3
Date: Thu, 03 Mar 2016 18:06:22 +0530
From: Nishant Chaprana <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH] Fix memory leak when realloc fails
Message-ID: <[email protected]>

---
 src/inet.c         |  8 +++++++-
 vpn/vpn-provider.c | 11 +++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/inet.c b/src/inet.c
index dc788ea..f6b3466 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -2648,8 +2648,14 @@ char **__connman_inet_get_running_interfaces(void)
 
        g_free(ifr);
 
-       if (count < numif)
+       if (count < numif) {
+               char **tmp_result = result;
                result = g_try_realloc(result, (count + 1) * sizeof(char *));
+               if (!result) {
+                       g_free(tmp_result);
+                       goto error;
+               }
+       }
 
        return result;
 
diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index afd7ca6..30c78db 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -811,16 +811,20 @@ static gchar **create_network_list(GSList *networks, 
gsize *count)
 {
        GSList *list;
        gchar **result = NULL;
+       gchar **tmp_result;
        unsigned int num_elems = 0;
 
        for (list = networks; list; list = g_slist_next(list)) {
                struct vpn_route *route = list->data;
                int family;
 
+               tmp_result = result;
                result = g_try_realloc(result,
                                (num_elems + 1) * sizeof(gchar *));
-               if (!result)
+               if (!result) {
+                       g_free(tmp_result);
                        return NULL;
+               }
 
                switch (route->family) {
                case AF_INET:
@@ -841,9 +845,12 @@ static gchar **create_network_list(GSList *networks, gsize 
*count)
                num_elems++;
        }
 
+       tmp_result = result;
        result = g_try_realloc(result, (num_elems + 1) * sizeof(gchar *));
-       if (!result)
+       if (!result) {
+               g_free(tmp_result);
                return NULL;
+       }
 
        result[num_elems] = NULL;
        *count = num_elems;
-- 
1.9.1



------------------------------

Message: 4
Date: Thu, 03 Mar 2016 19:45:53 +0530
From: Niraj Kumar Goit <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH] inet: Corrected usage of unsigned int data-type.
Message-ID: <[email protected]>

unsigned integer never falls below 0, so it is not useful to
compare unsigned int data-type for negative values.
---
 src/inet.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/inet.c b/src/inet.c
index dc788ea..cdc2479 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -2565,7 +2565,7 @@ bool connman_inet_check_hostname(const char *ptr, size_t 
len)
                         */
                        size_t d = p - ptr;
 
-                       if ((d <= 0) || (d >= 64))
+                       if ((d = 0) || (d >= 64))
                                return false;
 
                        ptr = p + 1; /* Jump to the next label */
-- 
1.7.9.5




------------------------------

Message: 5
Date: Thu, 3 Mar 2016 15:38:26 +0100
From: Michael Olbrich <[email protected]>
To: [email protected]
Subject: Re: [PATCH] inet: Corrected usage of unsigned int data-type.
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Thu, Mar 03, 2016 at 07:45:53PM +0530, Niraj Kumar Goit wrote:
> unsigned integer never falls below 0, so it is not useful to
> compare unsigned int data-type for negative values.
> ---
>  src/inet.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/inet.c b/src/inet.c
> index dc788ea..cdc2479 100644
> --- a/src/inet.c
> +++ b/src/inet.c
> @@ -2565,7 +2565,7 @@ bool connman_inet_check_hostname(const char *ptr, 
> size_t len)
>                        */
>                       size_t d = p - ptr;
>  
> -                     if ((d <= 0) || (d >= 64))
> +                     if ((d = 0) || (d >= 64))

'==' not '='.

Michael

>                               return false;
>  
>                       ptr = p + 1; /* Jump to the next label */
> -- 
> 1.7.9.5
> 
> 
> _______________________________________________
> connman mailing list
> [email protected]
> https://lists.01.org/mailman/listinfo/connman
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


------------------------------

Subject: Digest Footer

_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman


------------------------------

End of connman Digest, Vol 5, Issue 4
*************************************

Reply via email to