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] service: Enable ipconfig only for the changed IP type
      (Saurav Babu)
   2. [PATCH] rtnl: Treat bond interfaces as ethernet (Justin Maggard)
   3. [PATCH] ntp: Use adjtimex to tune the kernel clock
      (Justin Maggard)
   4. Re: [PATCH] connman.service: Use ProtectSystem=true to allow
      writing /etc/localtime (Philip Withnall)


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

Message: 1
Date: Mon, 18 Jul 2016 16:53:23 +0530
From: Saurav Babu <[email protected]>
To: [email protected]
Cc: [email protected], Saurav Babu <[email protected]>
Subject: [PATCH] service: Enable ipconfig only for the changed IP type
Message-ID:
        <[email protected]>

When IPv6.Configuration is changed to "off" then connman starts fresh
DHCP Requests for service after changing its state to Configuration.
In an ideal scenario IPv4 Configurations should not be affected on
changing IPv6.Configuration property.
This patch only enables ipconfig for the changed IP type and leaves
other IP type unchanged
---
 src/service.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/service.c b/src/service.c
index 768426b..37af5fc 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3482,9 +3482,11 @@ static DBusMessage *set_property(DBusConnection *conn,
                if (err < 0) {
                        if (is_connected_state(service, state) ||
                                        is_connecting_state(service, state)) {
-                               
__connman_network_enable_ipconfig(service->network,
+                               if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
+                                       
__connman_network_enable_ipconfig(service->network,
                                                        service->ipconfig_ipv4);
-                               
__connman_network_enable_ipconfig(service->network,
+                               else
+                                       
__connman_network_enable_ipconfig(service->network,
                                                        service->ipconfig_ipv6);
                        }
 
@@ -3497,10 +3499,12 @@ static DBusMessage *set_property(DBusConnection *conn,
                        ipv6_configuration_changed(service);
 
                if (is_connecting(service) || is_connected(service)) {
-                       __connman_network_enable_ipconfig(service->network,
-                                                       service->ipconfig_ipv4);
-                       __connman_network_enable_ipconfig(service->network,
-                                                       service->ipconfig_ipv6);
+                       if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
+                               
__connman_network_enable_ipconfig(service->network,
+                                                               
service->ipconfig_ipv4);
+                       else
+                               
__connman_network_enable_ipconfig(service->network,
+                                                               
service->ipconfig_ipv6);
                }
 
                service_save(service);
-- 
1.9.1



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

Message: 2
Date: Mon, 18 Jul 2016 11:14:34 -0700
From: Justin Maggard <[email protected]>
To: [email protected]
Cc: Justin Maggard <[email protected]>, Justin Maggard
        <[email protected]>
Subject: [PATCH] rtnl: Treat bond interfaces as ethernet
Message-ID: <[email protected]>

Since Linux 3.9, the kernel started setting the sysfs DEVTYPE for bond
interfaces to 'bond', which made connman start classifying the service
type and device type as UNKNOWN.  So we need to handle DEVTYPE=bond so
we can configure bond inferfaces on modern kernels.

Signed-off-by: Justin Maggard <[email protected]>
---
 src/rtnl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/rtnl.c b/src/rtnl.c
index d1b851f..0e58eef 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -173,7 +173,9 @@ static void read_uevent(struct interface_data *interface)
                } else if (strcmp(line + 8, "vlan") == 0) {
                        interface->service_type = CONNMAN_SERVICE_TYPE_ETHERNET;
                        interface->device_type = CONNMAN_DEVICE_TYPE_ETHERNET;
-
+               } else if (strcmp(line + 8, "bond") == 0) {
+                       interface->service_type = CONNMAN_SERVICE_TYPE_ETHERNET;
+                       interface->device_type = CONNMAN_DEVICE_TYPE_ETHERNET;
                } else {
                        interface->service_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
                        interface->device_type = CONNMAN_DEVICE_TYPE_UNKNOWN;
-- 
2.9.1



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

Message: 3
Date: Mon, 18 Jul 2016 11:14:53 -0700
From: Justin Maggard <[email protected]>
To: [email protected]
Cc: Justin Maggard <[email protected]>, Justin Maggard
        <[email protected]>
Subject: [PATCH] ntp: Use adjtimex to tune the kernel clock
Message-ID: <[email protected]>

Replace adjtime()/gettimeofday() calls with the RFC 5905 clock
adjustment algorithm implemented by adjtimex().  This also allows us to
support leap seconds sent from an NTP server.

This code is more-or-less ripped straight from systemd timesyncd.

Signed-off-by: Justin Maggard <[email protected]>
---
 src/ntp.c | 62 ++++++++++++++++++++++++++++++++++++--------------------------
 1 file changed, 36 insertions(+), 26 deletions(-)

diff --git a/src/ntp.c b/src/ntp.c
index dd246eb..9b1bb4f 100644
--- a/src/ntp.c
+++ b/src/ntp.c
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/time.h>
+#include <sys/timex.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>
@@ -66,9 +67,13 @@ struct ntp_msg {
 
 #define OFFSET_1900_1970  2208988800UL /* 1970 - 1900 in seconds */
 
-#define STEPTIME_MIN_OFFSET  0.128
+#define STEPTIME_MIN_OFFSET  0.4
 
 #define LOGTOD(a)  ((a) < 0 ? 1. / (1L << -(a)) : 1L << (int)(a))
+#define NSEC_PER_SEC  ((uint64_t)1000000000ULL)
+#ifndef ADJ_SETOFFSET
+#define ADJ_SETOFFSET          0x0100  /* add 'time' to current time */
+#endif
 
 #define NTP_SEND_TIMEOUT       2
 #define NTP_SEND_RETRIES       3
@@ -247,6 +252,7 @@ static void decode_msg(void *base, size_t len, struct 
timeval *tv,
        double m_delta, org, rec, xmt, dst;
        double delay, offset;
        static guint transmit_delay;
+       struct timex tmx = {};
 
        if (len < sizeof(*msg)) {
                connman_error("Invalid response from time server");
@@ -336,39 +342,43 @@ static void decode_msg(void *base, size_t len, struct 
timeval *tv,
 
        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) {
-               struct timeval adj;
-
-               adj.tv_sec = (long) offset;
-               adj.tv_usec = (offset - adj.tv_sec) * 1000000;
+               tmx.modes = ADJ_STATUS | ADJ_NANO | ADJ_OFFSET | ADJ_TIMECONST 
| ADJ_MAXERROR | ADJ_ESTERROR;
+               tmx.status = STA_PLL;
+               tmx.offset = offset * NSEC_PER_SEC;
+               tmx.constant = msg->poll - 4;
+               tmx.maxerror = 0;
+               tmx.esterror = 0;
+
+               connman_info("ntp: adjust (slew): %+.6f sec", offset);
+       } else {
+               tmx.modes = ADJ_STATUS | ADJ_NANO | ADJ_SETOFFSET;
 
-               DBG("adjusting time %ld seconds, %ld msecs", adj.tv_sec, 
adj.tv_usec);
+               /* ADJ_NANO uses nanoseconds in the microseconds field */
+               tmx.time.tv_sec = (long)offset;
+               tmx.time.tv_usec = (offset - tmx.time.tv_sec) * NSEC_PER_SEC;
 
-               if (adjtime(&adj, &adj) < 0) {
-                       connman_error("Failed to adjust time");
-                       return;
+               /* the kernel expects -0.3s as {-1, 7000.000.000} */
+               if (tmx.time.tv_usec < 0) {
+                       tmx.time.tv_sec  -= 1;
+                       tmx.time.tv_usec += NSEC_PER_SEC;
                }
 
-               DBG("remaining adjustment %ld seconds, %ld msecs", adj.tv_sec, 
adj.tv_usec);
-       } else {
-               struct timeval cur;
-               double dtime;
-
-               gettimeofday(&cur, NULL);
-               dtime = offset + cur.tv_sec + 1.0e-6 * cur.tv_usec;
-               cur.tv_sec = (long) dtime;
-               cur.tv_usec = (dtime - cur.tv_sec) * 1000000;
-
-               DBG("setting time: %ld seconds, %ld msecs", cur.tv_sec, 
cur.tv_usec);
+               connman_info("ntp: adjust (jump): %+.6f sec", offset);
+       }
 
-               if (settimeofday(&cur, NULL) < 0) {
-                       connman_error("Failed to set time");
-                       return;
-               }
+       if (NTP_FLAGS_LI_DECODE(msg->flags) & NTP_FLAG_LI_ADDSECOND)
+               tmx.status |= STA_INS;
+       else if (NTP_FLAGS_LI_DECODE(msg->flags) & NTP_FLAG_LI_DELSECOND)
+               tmx.status |= STA_DEL;
 
+       if (adjtimex(&tmx) < 0) {
+               connman_error("Failed to adjust time");
+               return;
        }
+
+       DBG("interval/delta/delay/drift %fs/%+.3fs/%.3fs/%+ldppm",
+               LOGTOD(msg->poll), offset, delay, tmx.freq / 65536);
 }
 
 static gboolean received_data(GIOChannel *channel, GIOCondition condition,
-- 
2.9.1



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

Message: 4
Date: Mon, 18 Jul 2016 19:33:51 +0100
From: Philip Withnall <[email protected]>
To: Patrik Flykt <[email protected]>, [email protected]
Subject: Re: [PATCH] connman.service: Use ProtectSystem=true to allow
        writing /etc/localtime
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

On Wed, 2016-07-13 at 13:20 +0300, Patrik Flykt wrote:
>       Hi,
> 
> On Mon, 2016-07-11 at 18:27 +0100, Philip Withnall wrote:
> > Setting the timezone requires unlinking and relinking
> > /etc/localtime,
> > so we need /etc to be mounted read?write. This means that commit
> > dc8f151e has to be softened to ProtectSystem=true rather than
> > ProtectSystem=full. This mounts most of the filesystem as read-
> > only,
> > apart from /etc, which is read?write.
> > 
> > Signed-off-by: Philip Withnall <[email protected]>
> > ---
> > ?src/connman.service.in | 2 +-
> > ?1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/connman.service.in b/src/connman.service.in
> > index 57eaaf9..d5d6d44 100644
> > --- a/src/connman.service.in
> > +++ b/src/connman.service.in
> > @@ -15,7 +15,7 @@ ExecStart=@sbindir@/connmand -n
> > ?StandardOutput=null
> > ?CapabilityBoundingSet=CAP_KILL CAP_NET_ADMIN CAP_NET_BIND_SERVICE
> > CAP_NET_RAW CAP_SYS_TIME CAP_SYS_MODULE
> > ?ProtectHome=true
> > -ProtectSystem=full
> > +ProtectSystem=true
> > ?
> > ?[Install]
> > ?WantedBy=multi-user.target
> > --?
> > 2.5.5
> 
> Yes, this will fix the problem. On the other hand there is also a
> desired use case that ConnMan has write access only to as few places
> as
> possible, for run-time information that would be /var/run/connman. In
> order to keep in line with that, I suggest something similar that was
> done for resolv.conf handling. See a few commits
> from?3a9ad49c8c8448875375a67913af98f74bca0ad7 forwards.
> 
> So this could be handled by copying the symlink/file from
> /etc/localtime to /var/run with tmpfiles.d and create the link to
> /etc
> (see e.g. scripts/connman_resolvconf.conf.in).
> 
> What do you think?

I think that sounds feasible, and definitely better than downgrading
from ProtectSystem=full. I?m away for the next couple of weeks, but
will try and look at this when I get back. Sorry for the delay.

Philip
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: 
<http://lists.01.org/pipermail/connman/attachments/20160718/9b7bcfa9/attachment-0001.asc>

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

Subject: Digest Footer

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


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

End of connman Digest, Vol 9, Issue 10
**************************************

Reply via email to