[systemd-devel] How do I monitor for service exit , service failure and service start using DBus ?

2015-07-10 Thread Pradeepa Kumar
Hello systemd-experts,

I am new to systemd and dbus.

I am writing a daemon which starts, stops and monitor services and I am
using dbus to interface with systemd. I send messages on dbus to start or
stop the service and this is working well. I want to achieve the following:


a) Monitor service exit using the systemd dbus interface.

b) Monitor when the service has entered a failed state (the app has been
restarted n times in m seconds).



I am trying to understand what is the right mechanism to implement this
using the systemd dbus interface, I have tried a few things clearly I don’t
understand how this works, any help greatly appreciated.



In my first attempt I subscribed to JobRemoved signal from systemd as
explained here (http://www.freedesktop.org/wiki/Software/systemd/dbus/). I
was able to figure out when the service failed by looking at the result
string.



———

JobNew() and JobRemoved() are sent out each time a new job is queued or
dequeued. Both signals take the numeric job ID, the bus path and the
primary unit name for this job as argument. JobRemoved() also includes a
result string, being one of done, canceled, timeout, failed, dependency,
skipped. done indicates successful execution of a job. canceled indicates
that a job has been canceled (via CancelJob() above) before it finished
execution (this doesn't necessarily mean though that the job operation is
actually cancelled too, see above). timeout indicates that the job timeout
was reached. failed indicates that the job failed. dependency indicates
that a job this job has been depending on failed and the job hence has been
removed too. skipped indicates that a job was skipped because it didn't
apply to the units current state.

——



I soon realized that I was getting spurious JobRemoved signals.



I am now trying to achieve (1) and (2) by subscribing to PropertiesChanged
signal and I have a few questions here:



1) When I get the PropertiesChanged, I query the SubState property to get
the running/stop state of the service. Is querying the SubState property
the right way to get the service status? If SubState value is “running”
then I infer that app is running and its any other value, I infer the app
is down. I am not relying on ActiveState because I see that for some
signal, ActiveState is “active” but SubState as “exited”.

 Is this approach correct?



2) When a service exits, I get multiple PropertiesChanged signal.



   kill -9  myservice will transition myservice to  “stop”,
“auto-restart” and then “running” SubState

   systemctl restart myservice will transition myservice to   “stop”,
“stop-sigterm” and then  “running” SubState.

   systemctl stop myservice will transition myservice to   “stop” and then
 “stop-sigterm” SubState.



What does “stop” and “stop-term” mean here and why are there 2 signals to
indicate stop? Is “stop” a good indicator that the service has stopped?

In my client, I can cache the services and their states.


3)How do I get to know when an application has failed (failed here means
when systemd will not restart application again after n app exits in m
seconds).

When I was using JobRemoved, I used the value of “failed” in “result”
parameter in JobRemoved signal, was this the correct indicator to determine
service failure?



4) How do I get to know when an service has started? When I issue
“systemctl start myservice”, I do not getany PropertiesChanged signal, I
receive JobNew, JobRemoved and then UnitNew signals.



I thought of subscribing to UnitNew signal. But I also get these multiple
(i.e 2) UnitNew and UnitRemoved signal when I do ‘systemctl stop
 myservice’ too. Why do I get UnitNew when a service is being stopped?



From my research I understand that requesting the properties of an unloaded
unit will cause systemd to send a pair of UnitNew/UnitRemoved signals and
this may lead to infinite loop.

How do I fix this?



Am I solving the requirement (a) and (b) correctly or should I be using a
different mechanism to achieve (a) and (b).



Appreciate your help on above queries



Thanks

Prashant
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] difference in restart behavior between 219 and 220?

2015-07-10 Thread Vadim Berezniker
On Thu, Jul 9, 2015 at 8:23 PM, Andrei Borzenkov arvidj...@gmail.com wrote:
 В Thu, 9 Jul 2015 14:56:55 -0700
 Vadim Berezniker va...@berezniker.com пишет:

 Hello,

 I have a scenario where a service restarts after a dependency failure
 in 219, but not in 220.
 I'm wondering if it's a systemd issue or a problem with my configuration.

 I've created a simple, but somewhat contrived repro.
 Service A fails on first attempt, gets restarted and succeeds.
 Service B depends on service A.
 I attempt to start service B.

 In systemd 219, B gets restarted when A succeeds, but in 220 B remains 
 failed.

 What do you mean B is restarted? B cannot be restarted in your case
 because B is not yet started at this point.

 Sounds like this is this commit:

 ...

 Does reverting it change anything?

Thanks Andrei,

That change does seem to be the reason.

If a service fails to start because a dependency fails but that dependency
successfully starts after an automatic restart, I would expect the failed
dependent to attempt to start as well now that its dependency is happy.

Had the dependent failed for other reasons than a dependency, it would
have been retried. Is there a better/different way configure the dependent
so that it's more resilient in case of dependency failures?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 03/11] dhcp6-option: Add helper function for fetching IPv6 addresses

2015-07-10 Thread Patrik Flykt
Add a helper function that extracts a block of IPv6 addresses from
the provided option data.
---
 src/libsystemd-network/dhcp6-internal.h |  5 -
 src/libsystemd-network/dhcp6-option.c   | 23 ++-
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/libsystemd-network/dhcp6-internal.h 
b/src/libsystemd-network/dhcp6-internal.h
index 4f54ad8..87a3588 100644
--- a/src/libsystemd-network/dhcp6-internal.h
+++ b/src/libsystemd-network/dhcp6-internal.h
@@ -5,7 +5,7 @@
 /***
   This file is part of systemd.
 
-  Copyright (C) 2014 Intel Corporation. All rights reserved.
+  Copyright (C) 2014-2015 Intel Corporation. All rights reserved.
 
   systemd is free software; you can redistribute it and/or modify it
   under the terms of the GNU Lesser General Public License as published by
@@ -68,6 +68,9 @@ int dhcp6_option_parse(uint8_t **buf, size_t *buflen, 
uint16_t *optcode,
size_t *optlen, uint8_t **optvalue);
 int dhcp6_option_parse_ia(uint8_t **buf, size_t *buflen, uint16_t iatype,
   DHCP6IA *ia);
+int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,
+struct in6_addr **addrs, size_t count,
+size_t *allocated);
 
 int dhcp6_network_bind_udp_socket(int index, struct in6_addr *address);
 int dhcp6_network_send_udp_socket(int s, struct in6_addr *address,
diff --git a/src/libsystemd-network/dhcp6-option.c 
b/src/libsystemd-network/dhcp6-option.c
index ea863f4..f5ed175 100644
--- a/src/libsystemd-network/dhcp6-option.c
+++ b/src/libsystemd-network/dhcp6-option.c
@@ -3,7 +3,7 @@
 /***
   This file is part of systemd.
 
-  Copyright (C) 2014 Intel Corporation. All rights reserved.
+  Copyright (C) 2014-2015 Intel Corporation. All rights reserved.
 
   systemd is free software; you can redistribute it and/or modify it
   under the terms of the GNU Lesser General Public License as published by
@@ -317,3 +317,24 @@ error:
 
 return r;
 }
+
+int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,
+struct in6_addr **addrs, size_t count,
+size_t *allocated) {
+assert_return(optval, -EINVAL);
+assert_return(addrs, -EINVAL);
+assert_return(allocated, -EINVAL);
+
+if (!optlen || optlen % sizeof(struct in6_addr))
+return -EINVAL;
+
+if (!GREEDY_REALLOC(*addrs, *allocated,
+count * sizeof(struct in6_addr) + optlen))
+return -ENOMEM;
+
+memcpy(*addrs + count, optval, optlen);
+
+count += optlen / sizeof(struct in6_addr);
+
+return count;
+}
-- 
2.1.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 10/11] network: Add function to serialize an IPv6 address

2015-07-10 Thread Patrik Flykt
---
 src/libsystemd-network/network-internal.c | 15 +++
 src/libsystemd-network/network-internal.h |  2 ++
 2 files changed, 17 insertions(+)

diff --git a/src/libsystemd-network/network-internal.c 
b/src/libsystemd-network/network-internal.c
index d579755..1db7dd2 100644
--- a/src/libsystemd-network/network-internal.c
+++ b/src/libsystemd-network/network-internal.c
@@ -32,6 +32,7 @@
 #include conf-parser.h
 #include condition.h
 #include network-internal.h
+#include sd-icmp6-nd.h
 
 const char *net_get_name(struct udev_device *device) {
 const char *name, *field;
@@ -384,6 +385,20 @@ int deserialize_in_addrs(struct in_addr **ret, const char 
*string) {
 return size;
 }
 
+void serialize_in6_addrs(FILE *f, const struct in6_addr *addresses,
+ size_t size) {
+unsigned i;
+
+assert(f);
+assert(addresses);
+assert(size);
+
+for (i = 0; i  size; i++)
+fprintf(f, SD_ICMP6_ADDRESS_FORMAT_STR%s,
+SD_ICMP6_ADDRESS_FORMAT_VAL(addresses[i]),
+(i  (size - 1)) ?  : );
+}
+
 int deserialize_in6_addrs(struct in6_addr **ret, const char *string) {
 _cleanup_free_ struct in6_addr *addresses = NULL;
 int size = 0;
diff --git a/src/libsystemd-network/network-internal.h 
b/src/libsystemd-network/network-internal.h
index 06aba89..4096eab 100644
--- a/src/libsystemd-network/network-internal.h
+++ b/src/libsystemd-network/network-internal.h
@@ -67,6 +67,8 @@ const char *net_get_name(struct udev_device *device);
 
 void serialize_in_addrs(FILE *f, const struct in_addr *addresses, size_t size);
 int deserialize_in_addrs(struct in_addr **addresses, const char *string);
+void serialize_in6_addrs(FILE *f, const struct in6_addr *addresses,
+ size_t size);
 int deserialize_in6_addrs(struct in6_addr **addresses, const char *string);
 
 /* don't include dhcp-lease-internal.h as it causes conflicts between 
netinet/ip.h and linux/ip.h */
-- 
2.1.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 00/11] DHCPv6 DNS and NTP information

2015-07-10 Thread Patrik Flykt

Hi,

This patch set adds support for DNS and NTP DHCPv6 options. The information
obtained is written to file in link_save() in systemd-networkd in order
to be used by others.

The first patch is a bug fix triggered when going from Information request
to the full DHCPv6 address lease in the test case when the lease was also
stored as a part of the information request exchange in patch two.

Two helper functions are introduced and used when extracting DNS, NTP
address, domain search list and NTP host name options. Support was added
also for the deprecated SNTP option, it can still be discovered in some
semi-ancient networks.

The test case is improved to look for the DNS and NTP information and
ystemd-networkd is enhanced with the functionality to write this information
nto the link state file. I might be missing something with systemd-networkd
n this area, though.

I do feel a bit rusty with systemd, some conventions may have changed since
last time.

Please review,

   Patrik


Patrik Flykt (11):
  sd-dhcp6-client: Fix unreferencing DHCPv6 lease on client reset
  sd-dhcp6-client: Save a DHCPv6 lease also with Information Reply
  dhcp6-option: Add helper function for fetching IPv6 addresses
  dhcp6-option: Add helper function for uncompressed domain names
  sd-dhcp6: Add support for DHCPv6 DNS Recursive Name Server option
  sd-dhcp6: Add support for DHCPv6 DNS Domain Search List option
  sd-dhcp6: Add support for DHCPv6 NTP Server Option
  sd-dhcp6: Support deprecated SNTP Configuration Option
  test-dhcp6-client: Add tests for DNS and NTP options
  network: Add function to serialize an IPv6 address
  network: Save DNS and NTP data for a DHCPv6 link

 src/libsystemd-network/dhcp6-internal.h   |   7 +-
 src/libsystemd-network/dhcp6-lease-internal.h |  20 ++-
 src/libsystemd-network/dhcp6-option.c |  77 +-
 src/libsystemd-network/dhcp6-protocol.h   |   8 +-
 src/libsystemd-network/network-internal.c |  15 ++
 src/libsystemd-network/network-internal.h |   2 +
 src/libsystemd-network/sd-dhcp6-client.c  |  43 +-
 src/libsystemd-network/sd-dhcp6-lease.c   | 196 +-
 src/libsystemd-network/test-dhcp6-client.c|  65 -
 src/network/networkd-link.c   |  62 
 src/systemd/sd-dhcp6-lease.h  |   8 +-
 11 files changed, 491 insertions(+), 12 deletions(-)

-- 
2.1.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 04/11] dhcp6-option: Add helper function for uncompressed domain names

2015-07-10 Thread Patrik Flykt
Add a helper function that extracts a string array of domain names from
the provided option data. The domain names are stored uncompressed as
defined in Section 8. of RFC 3315.
---
 src/libsystemd-network/dhcp6-internal.h |  2 ++
 src/libsystemd-network/dhcp6-option.c   | 54 +
 2 files changed, 56 insertions(+)

diff --git a/src/libsystemd-network/dhcp6-internal.h 
b/src/libsystemd-network/dhcp6-internal.h
index 87a3588..83e8192 100644
--- a/src/libsystemd-network/dhcp6-internal.h
+++ b/src/libsystemd-network/dhcp6-internal.h
@@ -71,6 +71,8 @@ int dhcp6_option_parse_ia(uint8_t **buf, size_t *buflen, 
uint16_t iatype,
 int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,
 struct in6_addr **addrs, size_t count,
 size_t *allocated);
+int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen,
+  char ***str_arr);
 
 int dhcp6_network_bind_udp_socket(int index, struct in6_addr *address);
 int dhcp6_network_send_udp_socket(int s, struct in6_addr *address,
diff --git a/src/libsystemd-network/dhcp6-option.c 
b/src/libsystemd-network/dhcp6-option.c
index f5ed175..1647dd3 100644
--- a/src/libsystemd-network/dhcp6-option.c
+++ b/src/libsystemd-network/dhcp6-option.c
@@ -26,6 +26,7 @@
 #include sparse-endian.h
 #include unaligned.h
 #include util.h
+#include strv.h
 
 #include dhcp6-internal.h
 #include dhcp6-protocol.h
@@ -338,3 +339,56 @@ int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t 
optlen,
 
 return count;
 }
+
+int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen,
+  char ***str_arr)
+{
+size_t pos = 0, idx = 0;
+const char *buf = (const char *)optval;
+_cleanup_free_ char **strs = malloc0(sizeof(char *));
+int r;
+
+assert_return(optlen  1, -ENODATA);
+assert_return(optval[optlen] == '\0', -EINVAL);
+
+if (!strs)
+return -ENOMEM;
+
+while (pos  optlen) {
+size_t len, i = 0;
+
+r = strv_extend(strs, buf[pos + 1]);
+if (r  0)
+return -EINVAL;
+
+len = buf[pos];
+if (len  63)
+return -EINVAL;
+
+while (strs[idx][i] != '\0') {
+
+for (i = 0; i  len; i++) {
+if (strs[idx][i] == '\0')
+return -EINVAL;
+}
+
+if (strs[idx][i] != 0) {
+len += strs[idx][i] + 1;
+if (len  63)
+return -EINVAL;
+
+strs[idx][i] = '.';
+i++;
+}
+}
+i++;
+
+pos += i + 1;
+idx++;
+}
+
+*str_arr = strs;
+strs = NULL;
+
+return idx;
+}
-- 
2.1.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 01/11] sd-dhcp6-client: Fix unreferencing DHCPv6 lease on client reset

2015-07-10 Thread Patrik Flykt
When the DHCPv6 client is started by the library user or stopped for
any reason, unref the DHCPv6 lease when resetting the DHCPv6 client
data structure. This makes the DHCPv6 client always start from a clean
state and not keep unnecessary an lease structure around when stopped.

If this is not done, a previously existing lease information can be
interpreted to be from another server when restarting DHCPv6.
---
 src/libsystemd-network/sd-dhcp6-client.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/libsystemd-network/sd-dhcp6-client.c 
b/src/libsystemd-network/sd-dhcp6-client.c
index 85162dc..55fb71a 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -272,6 +272,11 @@ static void client_notify(sd_dhcp6_client *client, int 
event) {
 static int client_reset(sd_dhcp6_client *client) {
 assert_return(client, -EINVAL);
 
+if (client-lease) {
+dhcp6_lease_clear_timers(client-lease-ia);
+client-lease = sd_dhcp6_lease_unref(client-lease);
+}
+
 client-receive_message =
 sd_event_source_unref(client-receive_message);
 
-- 
2.1.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 02/11] sd-dhcp6-client: Save a DHCPv6 lease also with Information Reply

2015-07-10 Thread Patrik Flykt
As the lease structure contains interesting information, save it also
for the Information Reply.
---
 src/libsystemd-network/sd-dhcp6-client.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/libsystemd-network/sd-dhcp6-client.c 
b/src/libsystemd-network/sd-dhcp6-client.c
index 55fb71a..1f8bff1 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -807,10 +807,8 @@ static int client_receive_reply(sd_dhcp6_client *client, 
DHCP6Message *reply,
 client-lease = sd_dhcp6_lease_unref(client-lease);
 }
 
-if (client-state != DHCP6_STATE_INFORMATION_REQUEST) {
-client-lease = lease;
-lease = NULL;
-}
+client-lease = lease;
+lease = NULL;
 
 return DHCP6_STATE_BOUND;
 }
-- 
2.1.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 07/11] sd-dhcp6: Add support for DHCPv6 NTP Server Option

2015-07-10 Thread Patrik Flykt
Support NTP server and multicast addresses and NTP server domain names
as specified in RFC 5908.
---
 src/libsystemd-network/dhcp6-lease-internal.h |  7 +++
 src/libsystemd-network/dhcp6-protocol.h   |  6 ++
 src/libsystemd-network/sd-dhcp6-client.c  |  7 +++
 src/libsystemd-network/sd-dhcp6-lease.c   | 81 +++
 src/systemd/sd-dhcp6-lease.h  |  3 +
 5 files changed, 104 insertions(+)

diff --git a/src/libsystemd-network/dhcp6-lease-internal.h 
b/src/libsystemd-network/dhcp6-lease-internal.h
index 37e7001..ac7f843 100644
--- a/src/libsystemd-network/dhcp6-lease-internal.h
+++ b/src/libsystemd-network/dhcp6-lease-internal.h
@@ -46,6 +46,11 @@ struct sd_dhcp6_lease {
 size_t dns_allocated;
 char **domains;
 size_t domains_count;
+struct in6_addr *ntp;
+size_t ntp_count;
+size_t ntp_allocated;
+char **ntp_fqdn;
+size_t ntp_fqdn_count;
 };
 
 int dhcp6_lease_clear_timers(DHCP6IA *ia);
@@ -65,6 +70,8 @@ int dhcp6_lease_get_iaid(sd_dhcp6_lease *lease, be32_t *iaid);
 int dhcp6_lease_set_dns(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen);
 int dhcp6_lease_set_domains(sd_dhcp6_lease *lease, uint8_t *optval,
 size_t optlen);
+int dhcp6_lease_set_ntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen);
+
 int dhcp6_lease_new(sd_dhcp6_lease **ret);
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp6_lease*, sd_dhcp6_lease_unref);
diff --git a/src/libsystemd-network/dhcp6-protocol.h 
b/src/libsystemd-network/dhcp6-protocol.h
index 3e0f339..9330f23 100644
--- a/src/libsystemd-network/dhcp6-protocol.h
+++ b/src/libsystemd-network/dhcp6-protocol.h
@@ -134,6 +134,12 @@ enum {
 };
 
 enum {
+DHCP6_NTP_SUBOPTION_SRV_ADDR= 1,
+DHCP6_NTP_SUBOPTION_MC_ADDR = 2,
+DHCP6_NTP_SUBOPTION_SRV_FQDN= 3,
+};
+
+enum {
 DHCP6_STATUS_SUCCESS= 0,
 DHCP6_STATUS_UNSPEC_FAIL= 1,
 DHCP6_STATUS_NO_ADDRS_AVAIL = 2,
diff --git a/src/libsystemd-network/sd-dhcp6-client.c 
b/src/libsystemd-network/sd-dhcp6-client.c
index bea7a7a..e6f0c79 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -768,7 +768,14 @@ static int client_parse_message(sd_dhcp6_client *client,
 
 break;
 
+case DHCP6_OPTION_NTP_SERVER:
+r = dhcp6_lease_set_ntp(lease, optval, optlen);
+if (r  0)
+return r;
+
+break;
 }
+
 }
 
 if (r == -ENOMSG)
diff --git a/src/libsystemd-network/sd-dhcp6-lease.c 
b/src/libsystemd-network/sd-dhcp6-lease.c
index ca63800..8631aab 100644
--- a/src/libsystemd-network/sd-dhcp6-lease.c
+++ b/src/libsystemd-network/sd-dhcp6-lease.c
@@ -26,6 +26,7 @@
 #include util.h
 
 #include dhcp6-lease-internal.h
+#include dhcp6-protocol.h
 
 int dhcp6_lease_clear_timers(DHCP6IA *ia) {
 assert_return(ia, -EINVAL);
@@ -246,6 +247,83 @@ int sd_dhcp6_lease_get_domains(sd_dhcp6_lease *lease, char 
***domains) {
 return -ENOENT;
 }
 
+int dhcp6_lease_set_ntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen)
+{
+int r;
+uint16_t subopt;
+size_t sublen;
+uint8_t *subval;
+
+assert_return(lease, -EINVAL);
+assert_return(optval, -EINVAL);
+
+while ((r = dhcp6_option_parse(optval, optlen, subopt, sublen,
+   subval)) = 0) {
+int s;
+char **servers;
+
+switch(subopt) {
+case DHCP6_NTP_SUBOPTION_SRV_ADDR:
+case DHCP6_NTP_SUBOPTION_MC_ADDR:
+if (sublen != 16)
+return 0;
+
+s = dhcp6_option_parse_ip6addrs(subval, sublen,
+lease-ntp,
+lease-ntp_count,
+lease-ntp_allocated);
+if (s  0)
+return s;
+
+lease-ntp_count = s;
+
+break;
+
+case DHCP6_NTP_SUBOPTION_SRV_FQDN:
+r = dhcp6_option_parse_domainname(subval, sublen,
+  servers);
+if (r  0)
+return 0;
+
+lease-ntp_fqdn = strv_free(lease-ntp_fqdn);
+lease-ntp_fqdn = servers;
+lease-ntp_fqdn_count = r;
+
+break;
+}
+}
+
+if (r != -ENOMSG)
+return r;
+
+return 0;
+}
+
+int 

[systemd-devel] [PATCH 06/11] sd-dhcp6: Add support for DHCPv6 DNS Domain Search List option

2015-07-10 Thread Patrik Flykt
Support DHCPv6 DNS search list option as specified in RFC 3646. This
option contains a list of DNS search domains encoded without compression
as specified in Section 8. of RFC 3315.
---
 src/libsystemd-network/dhcp6-lease-internal.h |  4 +++
 src/libsystemd-network/sd-dhcp6-client.c  |  8 +
 src/libsystemd-network/sd-dhcp6-lease.c   | 42 ++-
 src/systemd/sd-dhcp6-lease.h  |  1 +
 4 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/src/libsystemd-network/dhcp6-lease-internal.h 
b/src/libsystemd-network/dhcp6-lease-internal.h
index 0dad0a5..37e7001 100644
--- a/src/libsystemd-network/dhcp6-lease-internal.h
+++ b/src/libsystemd-network/dhcp6-lease-internal.h
@@ -44,6 +44,8 @@ struct sd_dhcp6_lease {
 struct in6_addr *dns;
 size_t dns_count;
 size_t dns_allocated;
+char **domains;
+size_t domains_count;
 };
 
 int dhcp6_lease_clear_timers(DHCP6IA *ia);
@@ -61,6 +63,8 @@ int dhcp6_lease_get_rapid_commit(sd_dhcp6_lease *lease, bool 
*rapid_commit);
 int dhcp6_lease_get_iaid(sd_dhcp6_lease *lease, be32_t *iaid);
 
 int dhcp6_lease_set_dns(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen);
+int dhcp6_lease_set_domains(sd_dhcp6_lease *lease, uint8_t *optval,
+size_t optlen);
 int dhcp6_lease_new(sd_dhcp6_lease **ret);
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp6_lease*, sd_dhcp6_lease_unref);
diff --git a/src/libsystemd-network/sd-dhcp6-client.c 
b/src/libsystemd-network/sd-dhcp6-client.c
index f0c7949..bea7a7a 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -760,6 +760,14 @@ static int client_parse_message(sd_dhcp6_client *client,
 return r;
 
 break;
+
+case DHCP6_OPTION_DOMAIN_LIST:
+r = dhcp6_lease_set_domains(lease, optval, optlen);
+if (r  0)
+return r;
+
+break;
+
 }
 }
 
diff --git a/src/libsystemd-network/sd-dhcp6-lease.c 
b/src/libsystemd-network/sd-dhcp6-lease.c
index 55cefde..ca63800 100644
--- a/src/libsystemd-network/sd-dhcp6-lease.c
+++ b/src/libsystemd-network/sd-dhcp6-lease.c
@@ -1,8 +1,10 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
 /***
   This file is part of systemd.
 
   Copyright (C) 2014 Tom Gundersen
-  Copyright (C) 2014 Intel Corporation. All rights reserved.
+  Copyright (C) 2014-2015 Intel Corporation. All rights reserved.
 
   systemd is free software; you can redistribute it and/or modify it
   under the terms of the GNU Lesser General Public License as published by
@@ -20,6 +22,7 @@
 
 #include errno.h
 
+#include strv.h
 #include util.h
 
 #include dhcp6-lease-internal.h
@@ -209,6 +212,40 @@ int sd_dhcp6_lease_get_dns(sd_dhcp6_lease *lease, struct 
in6_addr **addrs) {
 return -ENOENT;
 }
 
+int dhcp6_lease_set_domains(sd_dhcp6_lease *lease, uint8_t *optval,
+size_t optlen) {
+int r;
+char **domains;
+
+assert_return(lease, -EINVAL);
+assert_return(optval, -EINVAL);
+
+if (!optlen)
+return 0;
+
+r = dhcp6_option_parse_domainname(optval, optlen, domains);
+if (r  0)
+return 0;
+
+free(lease-domains);
+lease-domains = domains;
+lease-domains_count = r;
+
+return r;
+}
+
+int sd_dhcp6_lease_get_domains(sd_dhcp6_lease *lease, char ***domains) {
+assert_return(lease, -EINVAL);
+assert_return(domains, -EINVAL);
+
+if (lease-domains_count) {
+*domains = lease-domains;
+return lease-domains_count;
+}
+
+return -ENOENT;
+}
+
 sd_dhcp6_lease *sd_dhcp6_lease_ref(sd_dhcp6_lease *lease) {
 if (lease)
 assert_se(REFCNT_INC(lease-n_ref) = 2);
@@ -222,6 +259,9 @@ sd_dhcp6_lease *sd_dhcp6_lease_unref(sd_dhcp6_lease *lease) 
{
 dhcp6_lease_free_ia(lease-ia);
 
 free(lease-dns);
+
+lease-domains = strv_free(lease-domains);
+
 free(lease);
 }
 
diff --git a/src/systemd/sd-dhcp6-lease.h b/src/systemd/sd-dhcp6-lease.h
index c98026b..8fdb48e 100644
--- a/src/systemd/sd-dhcp6-lease.h
+++ b/src/systemd/sd-dhcp6-lease.h
@@ -34,6 +34,7 @@ int sd_dhcp6_lease_get_address(sd_dhcp6_lease *lease,
uint32_t *lifetime_valid);
 
 int sd_dhcp6_lease_get_dns(sd_dhcp6_lease *lease, struct in6_addr **addrs);
+int sd_dhcp6_lease_get_domains(sd_dhcp6_lease *lease, char ***domains);
 
 sd_dhcp6_lease *sd_dhcp6_lease_ref(sd_dhcp6_lease *lease);
 sd_dhcp6_lease *sd_dhcp6_lease_unref(sd_dhcp6_lease *lease);
-- 
2.1.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org

[systemd-devel] [PATCH 11/11] network: Save DNS and NTP data for a DHCPv6 link

2015-07-10 Thread Patrik Flykt
Append DNS and NTP data obtained via DHCPv6 when the Link is saved.
---
 src/network/networkd-link.c | 62 +
 1 file changed, 62 insertions(+)

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index dff81a5..2f36abe 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -2161,6 +2161,14 @@ int link_save(Link *link) {
 if (link-network) {
 char **address, **domain;
 bool space;
+sd_dhcp6_lease *dhcp6_lease = NULL;
+
+if (link-dhcp6_client) {
+r = sd_dhcp6_client_get_lease(link-dhcp6_client,
+  dhcp6_lease);
+if (r  0)
+log_link_debug(link, No DHCPv6 lease);
+}
 
 fprintf(f, NETWORK_FILE=%s\n, link-network-filename);
 
@@ -2182,6 +2190,19 @@ int link_save(Link *link) {
 if (space)
 fputc(' ', f);
 serialize_in_addrs(f, addresses, r);
+space = true;
+}
+}
+
+if (link-network-dhcp_dns  dhcp6_lease) {
+struct in6_addr *in6_addrs;
+
+r = sd_dhcp6_lease_get_dns(dhcp6_lease, in6_addrs);
+if (r  0) {
+if (space)
+fputc(' ', f);
+serialize_in6_addrs(f, in6_addrs, r);
+space = true;
 }
 }
 
@@ -2205,6 +2226,32 @@ int link_save(Link *link) {
 if (space)
 fputc(' ', f);
 serialize_in_addrs(f, addresses, r);
+space = true;
+}
+}
+
+if (link-network-dhcp_ntp  dhcp6_lease) {
+struct in6_addr *in6_addrs;
+char **hosts;
+char **hostname;
+
+r = sd_dhcp6_lease_get_ntp_addrs(dhcp6_lease,
+ in6_addrs);
+if (r  0) {
+if (space)
+fputc(' ', f);
+serialize_in6_addrs(f, in6_addrs, r);
+space = true;
+}
+
+r = sd_dhcp6_lease_get_ntp_fqdn(dhcp6_lease, hosts);
+if (r  0) {
+STRV_FOREACH(hostname, hosts) {
+if (space)
+fputc(' ', f);
+fputs(*hostname, f);
+space = true;
+}
 }
 }
 
@@ -2228,6 +2275,21 @@ int link_save(Link *link) {
 if (space)
 fputc(' ', f);
 fputs(domainname, f);
+space = true;
+}
+}
+
+if (link-network-dhcp_domains  dhcp6_lease) {
+char **domains;
+
+r = sd_dhcp6_lease_get_domains(dhcp6_lease, domains);
+if (r = 0) {
+STRV_FOREACH(domain, domains) {
+if (space)
+fputc(' ', f);
+fputs(*domain, f);
+space = true;
+}
 }
 }
 
-- 
2.1.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 08/11] sd-dhcp6: Support deprecated SNTP Configuration Option

2015-07-10 Thread Patrik Flykt
Although the SNTP option specified in RFC 4075 has been deprecated, some
servers are still sending NTP information with this option. Use the SNTP
information provided only if the NTP option is not present.

Update the test case as SNTP information is also requested.
---
 src/libsystemd-network/dhcp6-lease-internal.h |  2 ++
 src/libsystemd-network/dhcp6-protocol.h   |  2 +-
 src/libsystemd-network/sd-dhcp6-client.c  |  8 ++
 src/libsystemd-network/sd-dhcp6-lease.c   | 36 +++
 src/libsystemd-network/test-dhcp6-client.c|  2 +-
 5 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/src/libsystemd-network/dhcp6-lease-internal.h 
b/src/libsystemd-network/dhcp6-lease-internal.h
index ac7f843..037f580 100644
--- a/src/libsystemd-network/dhcp6-lease-internal.h
+++ b/src/libsystemd-network/dhcp6-lease-internal.h
@@ -71,6 +71,8 @@ int dhcp6_lease_set_dns(sd_dhcp6_lease *lease, uint8_t 
*optval, size_t optlen);
 int dhcp6_lease_set_domains(sd_dhcp6_lease *lease, uint8_t *optval,
 size_t optlen);
 int dhcp6_lease_set_ntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen);
+int dhcp6_lease_set_sntp(sd_dhcp6_lease *lease, uint8_t *optval,
+ size_t optlen) ;
 
 int dhcp6_lease_new(sd_dhcp6_lease **ret);
 
diff --git a/src/libsystemd-network/dhcp6-protocol.h 
b/src/libsystemd-network/dhcp6-protocol.h
index 9330f23..b3a28f8 100644
--- a/src/libsystemd-network/dhcp6-protocol.h
+++ b/src/libsystemd-network/dhcp6-protocol.h
@@ -123,7 +123,7 @@ enum {
 DHCP6_OPTION_DNS_SERVERS= 23,  /* RFC 3646 */
 DHCP6_OPTION_DOMAIN_LIST= 24,  /* RFC 3646 */
 
-DHCP6_OPTION_SNTP_SERVERS   = 31,  /* RFC 4075 */
+DHCP6_OPTION_SNTP_SERVERS   = 31,  /* RFC 4075, deprecated 
*/
 
 /* option code 35 is unassigned */
 
diff --git a/src/libsystemd-network/sd-dhcp6-client.c 
b/src/libsystemd-network/sd-dhcp6-client.c
index e6f0c79..ffab1e4 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -73,6 +73,7 @@ static const uint16_t default_req_opts[] = {
 DHCP6_OPTION_DNS_SERVERS,
 DHCP6_OPTION_DOMAIN_LIST,
 DHCP6_OPTION_NTP_SERVER,
+DHCP6_OPTION_SNTP_SERVERS,
 };
 
 const char * dhcp6_message_type_table[_DHCP6_MESSAGE_MAX] = {
@@ -774,6 +775,13 @@ static int client_parse_message(sd_dhcp6_client *client,
 return r;
 
 break;
+
+case DHCP6_OPTION_SNTP_SERVERS:
+r = dhcp6_lease_set_sntp(lease, optval, optlen);
+if (r  0)
+return r;
+
+break;
 }
 
 }
diff --git a/src/libsystemd-network/sd-dhcp6-lease.c 
b/src/libsystemd-network/sd-dhcp6-lease.c
index 8631aab..f0494b3 100644
--- a/src/libsystemd-network/sd-dhcp6-lease.c
+++ b/src/libsystemd-network/sd-dhcp6-lease.c
@@ -257,6 +257,10 @@ int dhcp6_lease_set_ntp(sd_dhcp6_lease *lease, uint8_t 
*optval, size_t optlen)
 assert_return(lease, -EINVAL);
 assert_return(optval, -EINVAL);
 
+free(lease-ntp);
+lease-ntp_count = 0;
+lease-ntp_allocated = 0;
+
 while ((r = dhcp6_option_parse(optval, optlen, subopt, sublen,
subval)) = 0) {
 int s;
@@ -299,6 +303,38 @@ int dhcp6_lease_set_ntp(sd_dhcp6_lease *lease, uint8_t 
*optval, size_t optlen)
 return 0;
 }
 
+int dhcp6_lease_set_sntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t 
optlen) {
+int r;
+
+assert_return(lease, -EINVAL);
+assert_return(optval, -EINVAL);
+
+if (!optlen)
+return 0;
+
+if (lease-ntp || lease-ntp_fqdn) {
+log_dhcp6_client(client, NTP information already provided);
+
+return 0;
+}
+
+log_dhcp6_client(client, Using deprecated SNTP information);
+
+r = dhcp6_option_parse_ip6addrs(optval, optlen, lease-ntp,
+lease-ntp_count,
+lease-ntp_allocated);
+if (r  0) {
+log_dhcp6_client(client, Invalid SNTP server option: %s,
+ strerror(-r));
+
+return r;
+}
+
+lease-ntp_count = r;
+
+return 0;
+}
+
 int sd_dhcp6_lease_get_ntp_addrs(sd_dhcp6_lease *lease,
  struct in6_addr **addrs) {
 assert_return(lease, -EINVAL);
diff --git a/src/libsystemd-network/test-dhcp6-client.c 
b/src/libsystemd-network/test-dhcp6-client.c
index 7618547..b61fd38 100644
--- a/src/libsystemd-network/test-dhcp6-client.c
+++ b/src/libsystemd-network/test-dhcp6-client.c
@@ -73,7 +73,7 @@ static int test_client_basic(sd_event *e) {
 

[systemd-devel] [PATCH 09/11] test-dhcp6-client: Add tests for DNS and NTP options

2015-07-10 Thread Patrik Flykt
Test option setting and getting in test_advertise_option(). Verify
that the information provided in DHCPv6 Reply messages is also
available in the Information and Solicit callbacks.
---
 src/libsystemd-network/test-dhcp6-client.c | 63 ++
 1 file changed, 63 insertions(+)

diff --git a/src/libsystemd-network/test-dhcp6-client.c 
b/src/libsystemd-network/test-dhcp6-client.c
index b61fd38..6e62262 100644
--- a/src/libsystemd-network/test-dhcp6-client.c
+++ b/src/libsystemd-network/test-dhcp6-client.c
@@ -216,6 +216,8 @@ static int test_advertise_option(sd_event *e) {
 uint32_t lt_pref, lt_valid;
 int r;
 bool opt_clientid = false;
+struct in6_addr *addrs;
+char **domains;
 
 if (verbose)
 printf(* %s\n, __FUNCTION__);
@@ -276,6 +278,24 @@ static int test_advertise_option(sd_event *e) {
 
 break;
 
+case DHCP6_OPTION_DNS_SERVERS:
+assert_se(optlen == 16);
+assert_se(dhcp6_lease_set_dns(lease, optval,
+  optlen) = 0);
+break;
+
+case DHCP6_OPTION_DOMAIN_LIST:
+assert_se(optlen == 11);
+assert_se(dhcp6_lease_set_domains(lease, optval,
+  optlen) = 0);
+break;
+
+case DHCP6_OPTION_SNTP_SERVERS:
+assert_se(optlen == 16);
+assert_se(dhcp6_lease_set_sntp(lease, optval,
+   optlen) = 0);
+break;
+
 default:
 break;
 }
@@ -315,6 +335,19 @@ static int test_advertise_option(sd_event *e) {
 assert_se(dhcp6_lease_get_preference(lease, preference) = 0);
 assert_se(preference == 0);
 
+r = sd_dhcp6_lease_get_dns(lease, addrs);
+assert_se(r == 1);
+assert_se(!memcmp(addrs, msg_advertise[124], r * 16));
+
+r = sd_dhcp6_lease_get_domains(lease, domains);
+assert_se(r == 1);
+assert_se(!strcmp(lab.intra, domains[0]));
+assert_se(domains[1] == NULL);
+
+r = sd_dhcp6_lease_get_ntp_addrs(lease, addrs);
+assert_se(r == 1);
+assert_se(!memcmp(addrs, msg_advertise[159], r * 16));
+
 return 0;
 }
 
@@ -339,10 +372,25 @@ int detect_virtualization(const char **id) {
 static void test_client_solicit_cb(sd_dhcp6_client *client, int event,
void *userdata) {
 sd_event *e = userdata;
+sd_dhcp6_lease *lease;
+struct in6_addr *addrs;
+char **domains;
 
 assert_se(e);
 assert_se(event == DHCP6_EVENT_IP_ACQUIRE);
 
+assert_se(sd_dhcp6_client_get_lease(client, lease) = 0);
+
+assert_se(sd_dhcp6_lease_get_domains(lease, domains) == 1);
+assert_se(!strcmp(lab.intra, domains[0]));
+assert_se(domains[1] == NULL);
+
+assert_se(sd_dhcp6_lease_get_dns(lease, addrs) == 1);
+assert_se(!memcmp(addrs, msg_advertise[124], 16));
+
+assert_se(sd_dhcp6_lease_get_ntp_addrs(lease, addrs) == 1);
+assert_se(!memcmp(addrs, msg_advertise[159], 16));
+
 assert_se(sd_dhcp6_client_set_request_option(client, 
DHCP6_OPTION_DNS_SERVERS) == -EBUSY);
 
 if (verbose)
@@ -524,10 +572,25 @@ static int test_client_verify_solicit(DHCP6Message 
*solicit, uint8_t *option,
 static void test_client_information_cb(sd_dhcp6_client *client, int event,
void *userdata) {
 sd_event *e = userdata;
+sd_dhcp6_lease *lease;
+struct in6_addr *addrs;
+char **domains;
 
 assert_se(e);
 assert_se(event == DHCP6_EVENT_INFORMATION_REQUEST);
 
+assert_se(sd_dhcp6_client_get_lease(client, lease) = 0);
+
+assert_se(sd_dhcp6_lease_get_domains(lease, domains) == 1);
+assert_se(!strcmp(lab.intra, domains[0]));
+assert_se(domains[1] == NULL);
+
+assert_se(sd_dhcp6_lease_get_dns(lease, addrs) == 1);
+assert_se(!memcmp(addrs, msg_advertise[124], 16));
+
+assert_se(sd_dhcp6_lease_get_ntp_addrs(lease, addrs) == 1);
+assert_se(!memcmp(addrs, msg_advertise[159], 16));
+
 if (verbose)
 printf(  got DHCPv6 event %d\n, event);
 
-- 
2.1.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 05/11] sd-dhcp6: Add support for DHCPv6 DNS Recursive Name Server option

2015-07-10 Thread Patrik Flykt
Support DHCPv6 DNS server option as specified in RFC 3646. This option
contains a list of IPv6 DNS server addresses.
---
 src/libsystemd-network/dhcp6-lease-internal.h |  7 -
 src/libsystemd-network/sd-dhcp6-client.c  |  9 ++-
 src/libsystemd-network/sd-dhcp6-lease.c   | 37 +++
 src/systemd/sd-dhcp6-lease.h  |  4 ++-
 4 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/src/libsystemd-network/dhcp6-lease-internal.h 
b/src/libsystemd-network/dhcp6-lease-internal.h
index 109e0f4..0dad0a5 100644
--- a/src/libsystemd-network/dhcp6-lease-internal.h
+++ b/src/libsystemd-network/dhcp6-lease-internal.h
@@ -6,7 +6,7 @@
   This file is part of systemd.
 
   Copyright (C) 2014 Tom Gundersen
-  Copyright (C) 2014 Intel Corporation. All rights reserved.
+  Copyright (C) 2014-2015 Intel Corporation. All rights reserved.
 
   systemd is free software; you can redistribute it and/or modify it
   under the terms of the GNU Lesser General Public License as published by
@@ -40,6 +40,10 @@ struct sd_dhcp6_lease {
 DHCP6IA ia;
 
 DHCP6Address *addr_iter;
+
+struct in6_addr *dns;
+size_t dns_count;
+size_t dns_allocated;
 };
 
 int dhcp6_lease_clear_timers(DHCP6IA *ia);
@@ -56,6 +60,7 @@ int dhcp6_lease_get_rapid_commit(sd_dhcp6_lease *lease, bool 
*rapid_commit);
 
 int dhcp6_lease_get_iaid(sd_dhcp6_lease *lease, be32_t *iaid);
 
+int dhcp6_lease_set_dns(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen);
 int dhcp6_lease_new(sd_dhcp6_lease **ret);
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp6_lease*, sd_dhcp6_lease_unref);
diff --git a/src/libsystemd-network/sd-dhcp6-client.c 
b/src/libsystemd-network/sd-dhcp6-client.c
index 1f8bff1..f0c7949 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -3,7 +3,7 @@
 /***
   This file is part of systemd.
 
-  Copyright (C) 2014 Intel Corporation. All rights reserved.
+  Copyright (C) 2014-2015 Intel Corporation. All rights reserved.
 
   systemd is free software; you can redistribute it and/or modify it
   under the terms of the GNU Lesser General Public License as published by
@@ -753,6 +753,13 @@ static int client_parse_message(sd_dhcp6_client *client,
 return r;
 
 break;
+
+case DHCP6_OPTION_DNS_SERVERS:
+r = dhcp6_lease_set_dns(lease, optval, optlen);
+if (r  0)
+return r;
+
+break;
 }
 }
 
diff --git a/src/libsystemd-network/sd-dhcp6-lease.c 
b/src/libsystemd-network/sd-dhcp6-lease.c
index 2442269..55cefde 100644
--- a/src/libsystemd-network/sd-dhcp6-lease.c
+++ b/src/libsystemd-network/sd-dhcp6-lease.c
@@ -173,6 +173,42 @@ void sd_dhcp6_lease_reset_address_iter(sd_dhcp6_lease 
*lease) {
 lease-addr_iter = lease-ia.addresses;
 }
 
+int dhcp6_lease_set_dns(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) 
{
+int r;
+
+assert_return(lease, -EINVAL);
+assert_return(optval, -EINVAL);
+
+if (!optlen)
+return 0;
+
+r = dhcp6_option_parse_ip6addrs(optval, optlen, lease-dns,
+lease-dns_count,
+lease-dns_allocated);
+if (r  0) {
+log_dhcp6_client(client, Invalid DNS server option: %s,
+ strerror(-r));
+
+return r;
+}
+
+lease-dns_count = r;
+
+return 0;
+}
+
+int sd_dhcp6_lease_get_dns(sd_dhcp6_lease *lease, struct in6_addr **addrs) {
+assert_return(lease, -EINVAL);
+assert_return(addrs, -EINVAL);
+
+if (lease-dns_count) {
+*addrs = lease-dns;
+return lease-dns_count;
+}
+
+return -ENOENT;
+}
+
 sd_dhcp6_lease *sd_dhcp6_lease_ref(sd_dhcp6_lease *lease) {
 if (lease)
 assert_se(REFCNT_INC(lease-n_ref) = 2);
@@ -185,6 +221,7 @@ sd_dhcp6_lease *sd_dhcp6_lease_unref(sd_dhcp6_lease *lease) 
{
 free(lease-serverid);
 dhcp6_lease_free_ia(lease-ia);
 
+free(lease-dns);
 free(lease);
 }
 
diff --git a/src/systemd/sd-dhcp6-lease.h b/src/systemd/sd-dhcp6-lease.h
index 716d767..c98026b 100644
--- a/src/systemd/sd-dhcp6-lease.h
+++ b/src/systemd/sd-dhcp6-lease.h
@@ -7,7 +7,7 @@
   This file is part of systemd.
 
   Copyright (C) 2014 Tom Gundersen
-  Copyright (C) 2014 Intel Corporation. All rights reserved.
+  Copyright (C) 2014-2015 Intel Corporation. All rights reserved.
 
   systemd is free software; you can redistribute it and/or modify it
   under the terms of the GNU Lesser General Public License as published by
@@ -33,6 +33,8 @@ int sd_dhcp6_lease_get_address(sd_dhcp6_lease *lease,
uint32_t 

[systemd-devel] Fwd: kernel logging_journald_journalctl question

2015-07-10 Thread Anne Mulhern
Advice appreciated.

Thanks,

- mulhern

- Forwarded Message -
 From: Anne Mulhern amulh...@redhat.com
 To: OS Development List os-devel-l...@redhat.com
 Sent: Thursday, July 9, 2015 4:46:13 PM
 Subject: kernel logging_journald_journalctl question
 
 Hi!
 
 My ultimate goal is that the following example line:
 
 journalctl _WWN=wwn-0x5002e100
 
 should be meaningful, i.e.,
 * yield all log messages pertaining to a device w/ that particular wwn
 * the _WWN value should be guaranteed with the same certainty as journalctl's
 other unfakeable values with underscores, e.g., _UID.
 
 One subgoal is, therefore, to make sure that _correct_ _WWN information gets
 into
 the journal when that information is available.
 
 In principle, journal messages about devices that possess WWN's might
 originate in a
 variety of places. This makes things complicated, since it is possible that
 the appropriate way of discovering the WWN may vary with the origin of the
 message.
 (For example, lsscsi discovers the WWN of the current device by searching
 /dev/disk/by-id/.)
 
 However, I'm focusing on messages that originate in the kernel via
 dev_printk() in
 the SCSI mid-layer. I infer that journald reads them from the kernel log
 buffer in the
 dev_kmsg_record() method. I also know that dev_printk guarantees to print two
 key/value pairs,
 SUBSYSTEM and DEVICE.
 
 What is the best way to make information about the WWN available to journald?
 Can it reliably extract this information from the DEVICE field in the
 dev_kmsg_record()
 method? Is there a process that I don't know about that picks up messages
 from the kernel
 and augments them with extra metadata before they end up in /dev/kmsg that
 can be modified?
 Would dev_printk() itself have to be extended to include WWN information as
 another field
 in addition to SUBSYSTEM and DEVICE? Must I fall back on making sure that
 individual calls
 to dev_printk() include some essential information that can be parsed back
 out by journald?
 
 It would also be nice to take into consideration that messages regarding
 devices could
 be logged from other sources, like the journald API, and it would be nice to
 reliably store
 the WWN information from those messages in the journal, as well.
 
 Thanks in advance for any help,
 
 - mulhern
 
 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Extlinux - GCC 5

2015-07-10 Thread poma
On 10.07.2015 23:14, Daniel Mack wrote:
 On 07/10/2015 05:00 PM, poma wrote:
 What do you think, what is it about?
 
 ?
 

Enjoy the summertime.


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Extlinux - GCC 5

2015-07-10 Thread Daniel Mack
On 07/10/2015 05:00 PM, poma wrote:
 What do you think, what is it about?

?

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Extlinux - GCC 5

2015-07-10 Thread poma

What do you think, what is it about?

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel