[systemd-devel] [PATCH 1/4] libsystemd-network: Export checksum function to test case

2014-03-13 Thread Patrik Flykt
Remove identical checksum function implementation from the test case code. --- src/libsystemd-network/dhcp-internal.h| 2 ++ src/libsystemd-network/dhcp-packet.c | 10 +- src/libsystemd-network/test-dhcp-client.c | 30 +++--- 3 files changed, 10

[systemd-devel] [PATCH 0/4] Add DHCPv4 client restart and Init-Reboot support

2014-03-13 Thread Patrik Flykt
the previous IP address be acceptable to the server. Cheers, Patrik Patrik Flykt (4): libsystemd-network: Export checksum function to test case libsystemd-network: Add hangcheck timer for DHCP client test libsystemd-network: Restart DHCP acquisition if the lease expires libsystemd

[systemd-devel] [PATCH 4/4] libsystemd-network: Add Init-Reboot support

2014-03-13 Thread Patrik Flykt
Init-Reboot is tried if a client IP address has been given when the DHCP client is started. In Init-Reboot, start by sending a broadcasted DHCP Request including the supplied client IP address but without the server identifier. After sending the request, enter Reboot state. If a DHCP Ack is

[systemd-devel] [PATCH 3/4] libsystemd-network: Restart DHCP acquisition if the lease expires

2014-03-13 Thread Patrik Flykt
This causes the DHCP client struct initialization and DHCP client starting to be factored out into functions of their own. --- src/libsystemd-network/sd-dhcp-client.c | 74 +++-- 1 file changed, 52 insertions(+), 22 deletions(-) diff --git

[systemd-devel] [PATCH 2/4] libsystemd-network: Add hangcheck timer for DHCP client test

2014-03-13 Thread Patrik Flykt
--- src/libsystemd-network/test-dhcp-client.c | 16 1 file changed, 16 insertions(+) diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c index cfc75ae..9509eec 100644 --- a/src/libsystemd-network/test-dhcp-client.c +++

Re: [systemd-devel] [PATCH 2/4] libsystemd-network: Add hangcheck timer for DHCP client test

2014-03-17 Thread Patrik Flykt
Hi, On Sat, 2014-03-15 at 03:56 +0100, Zbigniew Jędrzejewski-Szmek wrote: On Fri, Mar 14, 2014 at 08:05:10PM +0100, Tom Gundersen wrote: On Thu, Mar 13, 2014 at 12:01 PM, Patrik Flykt patrik.fl...@linux.intel.com wrote: --- src/libsystemd-network/test-dhcp-client.c | 16

Re: [systemd-devel] [PATCH 4/4] libsystemd-network: Add Init-Reboot support

2014-03-17 Thread Patrik Flykt
On Sat, 2014-03-15 at 04:02 +0100, Zbigniew Jędrzejewski-Szmek wrote: This means that I can complain about spelling :) There's no such word as broadcasted. Past tense and adjective are broadcast. Yes :-) Spelling fixed. -if (client-state == DHCP_STATE_REQUESTING) +

Re: [systemd-devel] [PATCH 4/4] libsystemd-network: Add Init-Reboot support

2014-03-19 Thread Patrik Flykt
On Mon, 2014-03-17 at 15:08 +0100, Zbigniew Jędrzejewski-Szmek wrote: If there are no more comments, I can probably go ahead and apply these four patches? Yes, they look fine. Rebased to latest taking Tom's changes from yesterday into account and applied these. Cheers, Patrik

[systemd-devel] [PATCH] libsystemd-network: Prepend hardware type byte to client identifier

2014-03-19 Thread Patrik Flykt
Even though client identifiers SHOULD be treated as opaque objects by DHCP servers, follow the recommendation of a hardware type field with value 0x01 (ethernet) followed by the hardware address as described in RFC 2132. --- Hi, This change fixes the DHCP client identifier to use the

[systemd-devel] [PATCH] libsystemd-network: Don't unnecessarily send too long packets

2014-03-19 Thread Patrik Flykt
Since the length used by options is known, send packets with no extra padding. --- Hi, Discovered that the full buffer was sent out even though the length of all options would indicate a shorter one. Shave off extra padding from the packets by properly setting the buffer length.

Re: [systemd-devel] [PATCH] libsystemd-network: Prepend hardware type byte to client identifier

2014-03-20 Thread Patrik Flykt
On Wed, 2014-03-19 at 13:53 +0200, Patrik Flykt wrote: Even though client identifiers SHOULD be treated as opaque objects by DHCP servers, follow the recommendation of a hardware type field with value 0x01 (ethernet) followed by the hardware address as described in RFC 2132. Applied

Re: [systemd-devel] [PATCH] libsystemd-network: Don't unnecessarily send too long packets

2014-03-20 Thread Patrik Flykt
On Wed, 2014-03-19 at 14:38 +0200, Patrik Flykt wrote: Since the length used by options is known, send packets with no extra padding. Applied this patch too. Cheers, Patrik ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org

Re: [systemd-devel] systemd-networkd bridge with DHCP not working

2014-03-21 Thread Patrik Flykt
On Thu, 2014-03-20 at 20:29 +0100, Tom Gundersen wrote: My proposal is: Whenever the MAC address changes under us networkd calls sd_{dhcp_client,ipv4ll}_set_mac(), and it is the libs' responsibility to then do the right thing. Currently the libs don't support this and will fail with

[systemd-devel] [PATCH] libsystemd-network: Support setting DHCP client initial delay

2014-04-03 Thread Patrik Flykt
Section 4.4.1 in RFC 2131 says that a DHCP client SHOULD wait a random time between one and ten seconds to desynchronize DHCP clients on startup. This is supported such that the application can optionally set an initial delay of approximately two and eight seconds or leave the initial value unset

Re: [systemd-devel] [PATCH 17/17] networkd: add dhcp server support

2014-05-28 Thread Patrik Flykt
On Tue, 2014-05-27 at 13:39 +0200, David Herrmann wrote: I strongly disagree. One major example is Wifi-P2P which requires a DHCP-Server for ad-hoc P2P connections. A network-daemon manages the local address-space, so it should also be responsible of assigning those ranges to an ad-hoc DHCP

Re: [systemd-devel] [PATCH] sd-dhcp-client: Sets broadcast flag to 1

2014-05-30 Thread Patrik Flykt
On Thu, 2014-05-29 at 00:03 +0100, Tom Gundersen wrote: On Wed, May 28, 2014 at 7:43 PM, Camilo Aguilar camilo.agui...@gmail.com wrote: In systems running on hypervisors this flag needs to be set ON, so offers can reach the virtual machines. For more information please refer to this

Re: [systemd-devel] [PATCH] sd-dhcp-client: Sets broadcast flag to 1

2014-05-30 Thread Patrik Flykt
On Thu, 2014-05-29 at 18:18 +0100, Tom Gundersen wrote: + if (link-udev_device) { + const char *l2; + + l2 = udev_device_get_sysattr_value(link-udev_device, layer2); + if (l2) { + unsigned layer2; + + r = safe_atou(l2, layer2); + if (r 0)

Re: [systemd-devel] [PATCH] sd-dhcp-client: Sets broadcast flag to 1

2014-06-02 Thread Patrik Flykt
On Fri, 2014-05-30 at 17:42 +0100, Tom Gundersen wrote: Actually, I have had recent reports from users that there seems to exist a category of networking devices Do you have any more info on this by any chance? Any way we may classify these devices in a robust way? Unfortunately it was

Re: [systemd-devel] [PATCH] sd-dhcp-client: Sets broadcast flag to 1

2014-06-02 Thread Patrik Flykt
On Fri, 2014-05-30 at 17:21 +0100, Tom Gundersen wrote: I'm wondering if the criterion should be to request broadcast if and only if we have not configured an IP address (I.e. only in discovering, requesting and init-reboot), as that seems to be the problem, or did I get that wrong? Yes, I

[systemd-devel] [PATCH 03/24] sd-dhcp6-client: Add initial Router Advertisement test case

2014-06-13 Thread Patrik Flykt
Feed a Router Advertisement to the code and expect proper events each time. The sending part is ignored, as all of it is static code in the real dhcp_network_icmp6_send_rs() function. --- Makefile.am| 13 ++- src/libsystemd-network/test-dhcp6-rs.c | 155

[systemd-devel] [PATCH 04/24] sd-dhcp6-client: Initialize Router Solicitation on startup

2014-06-13 Thread Patrik Flykt
Try DHCPv6 if router solicitation times out as a link without routers may use DHCPv6 according to RFC 4862 section 5.5.2. --- src/libsystemd-network/sd-dhcp6-client.c | 70 +++- src/systemd/sd-dhcp6-client.h| 1 + 2 files changed, 69 insertions(+), 2

[systemd-devel] [PATCH 14/24] sd-dhcp6-lease: Add DHCPv6 lease handling

2014-06-13 Thread Patrik Flykt
Create a structure describing a DHCPv6 lease. Add internal functions for creating a new lease and accessing the server ID, preference and IAID. Provide functions for clearing addresses and associated timers. External users are initially given only the capabilities of referencing and unreferencing

[systemd-devel] [PATCH 11/24] sd-dhcp6-client: Add functions to bind to DHCPv6 UDP socket

2014-06-13 Thread Patrik Flykt
Add a function that creates a UDP socket bound to the given interface and optionally to an IPv6 address. Add another function that will send the DHCPv6 UDP packet to its destination. Using IPV6_PKTINFO in setsockopt to bind the IPv6 socket to an interface is documented in section 4. of RFC 3542,

[systemd-devel] [PATCH 09/24] sd-dhcp6-client: Add DHCPv6 client Solicitation timeout handling

2014-06-13 Thread Patrik Flykt
Add the core of DHCPv6 client message retransmission and upper bound timer and message count handling according to RFC 3315 Secions 7.1.2 and 14. Omit the DHCPv6 initial delay; for now it is assumed that systemd-networkd will provide decent startup randomization that will desynchronize the

[systemd-devel] [PATCH 10/24] sd-dhcp6-client: Add basic DHCPv6 option handling

2014-06-13 Thread Patrik Flykt
Add option appending and parsing. DHCPv6 options are not aligned, thus the option handling code must be able to handle options starting at any byte boundary. Add a test case for the basic option handling. --- Makefile.am| 4 +-

[systemd-devel] [PATCH 16/24] sd-dhcp6-client: Receive and parse Advertise messages

2014-06-13 Thread Patrik Flykt
When receiving DHCPv6 messages, discard the ones that are not meant for DHCPv6 clients and verify the transaction id. Once that is done, process the Advertise message and select the Advertise with the highest preference. Create a separate function for lease information parsing so that it can be

[systemd-devel] [PATCH 20/24] sd-dhcp6-client: Add Request message sending

2014-06-13 Thread Patrik Flykt
As described in RFC 3315, Section 17.1.2, a client has to wait until the first timeout has elapsed before it is allowed to request IPv6 addresses from the DHCPv6 server. This is indicated by a non-NULL lease and a non-zero resend count. Should the Advertisement contain a preference value of 255 or

[systemd-devel] [PATCH 13/24] sd-dhcp6-client: Add RA and DHCPv6 Solicit test case

2014-06-13 Thread Patrik Flykt
Copy Router Advertisement functions and data from the previous test case and verify the created Solicit message. The test will take some non-trivial time to run due to the DHCPv6 initial delay. --- Makefile.am| 1 + src/libsystemd-network/test-dhcp6-client.c |

[systemd-devel] [PATCH 21/24] sd-dhcp6-client: Add Advertise sending for test cases

2014-06-13 Thread Patrik Flykt
Enhance the test case by replying with an Advertise message to the client. Copy the transaction id, IAID and DUID from the Solicit message. Verify the Request message created by the DHCPv6 client implementation and move the main loop exit to the end of the Request message verification. Provide

[systemd-devel] [PATCH 22/24] sd-dhcp6-client: Receive and parse a reply and set T1 and T2 timers

2014-06-13 Thread Patrik Flykt
Receive and parse a Reply from the server. Set up T1 and T2 timers and notify the library user of an acquired DHCPv6 lease. --- src/libsystemd-network/dhcp6-protocol.h | 1 + src/libsystemd-network/sd-dhcp6-client.c | 145 +++ src/systemd/sd-dhcp6-client.h

[systemd-devel] [PATCH 15/24] sd-dhcp6-client: Add IA Address option parsing

2014-06-13 Thread Patrik Flykt
Add functionality to parse DHCPv6 Identity Association for Non-temporary (IA_NA) and Temporary Addresses (IA_TA) options. Both of them contain one or more IA Address (IAADDR) options and optinally a status code option. Only the IA_NA option contains lease lifetimes. See RFC 3315, sections 22.4.,

[systemd-devel] [PATCH 06/24] network-internal: split out net_get_name()

2014-06-13 Thread Patrik Flykt
From: Tom Gundersen t...@jklm.no --- src/libsystemd-network/network-internal.c | 26 +++--- src/libsystemd-network/network-internal.h | 1 + 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/libsystemd-network/network-internal.c

[systemd-devel] [PATCH 12/24] sd-dhcp6-client: Add DHCPv6 Solicit message creation and sending

2014-06-13 Thread Patrik Flykt
Implement the initial functionality used for creating a DHCPv6 Solicit message containing the needed options and send it to the DHCPv6 broadcast address. Increase the sent message count and ensure that the Solicit Initial Retransmission Time is strictly greater than the Solicitation IRT as

[systemd-devel] [PATCH 07/24] sd-dhcp6-client: Add DHCPv6 IAID functionality

2014-06-13 Thread Patrik Flykt
Create structures describing Identity Association IDentifiers and IPv6 lease addresses. [tomegun: initialize the IAID when client is started. Base this off of the predictable udev names, if available, as these satisfy the requirement of the IAID, and base it off the mac addres otherwise, as that

[systemd-devel] [PATCH 24/24] networkd: Add initial DHCPv6 support

2014-06-13 Thread Patrik Flykt
Enable DHCPv6 support by creating a DHCPv6 boolean in the Network section. Add necessary dhcp6 structures and initial function calls. --- src/network/networkd-link.c | 75 src/network/networkd-network-gperf.gperf | 1 + src/network/networkd.h

[systemd-devel] [PATCH 17/24] sd-dhcp6-lease: Add functions for accessing lease and addresses

2014-06-13 Thread Patrik Flykt
Add support functions for accessing the current client lease as well as iterating over the addresses and get their preferred and valid lifetimes. --- src/libsystemd-network/dhcp6-lease-internal.h | 2 ++ src/libsystemd-network/sd-dhcp6-client.c | 12 +

[systemd-devel] [PATCH 19/24] sd-dhcp6-client: Update start function to take a state

2014-06-13 Thread Patrik Flykt
Updated the start function so that the client state can be conveniently changed with the previous message resend timers cleared. On initial startup also create and bind to the UDP socket. --- src/libsystemd-network/sd-dhcp6-client.c | 62 +--- 1 file changed, 42

[systemd-devel] [PATCH 02/24] sd-dhcp6-client: Add Router Solicitation and Advertisement support

2014-06-13 Thread Patrik Flykt
Provide functions to bind the ICMPv6 socket to the approriate interface and set multicast sending and receiving according to RFC 3493, section 5.2. and RFC 3542, sections 3. and 3.3. Filter out all ICMPv6 messages except Router Advertisements for the socket in question according to RFC 3542,

[systemd-devel] [PATCH 00/24] Initial DHCPv6 client support

2014-06-13 Thread Patrik Flykt
messaging going back and forth between the client and the server. Have fun while reviewing, Patrik Patrik Flykt (22): sd-dhcp6-client: Add initial DHCPv6 client files sd-dhcp6-client: Add Router Solicitation and Advertisement support sd-dhcp6-client: Add initial Router

[systemd-devel] [PATCH 08/24] sd-dhcp6-client: Add basic DHCPv6 test cases

2014-06-13 Thread Patrik Flykt
Add test cases for basic DHCPv6 client handling, e.g. setting interface index, mac address and attaching event loop. --- Makefile.am| 13 - src/libsystemd-network/test-dhcp6-client.c | 76 ++ 2 files changed, 88 insertions(+), 1

[systemd-devel] [PATCH 05/24] sd-dhcp6-client: Initialize DUID

2014-06-13 Thread Patrik Flykt
From: Tom Gundersen t...@jklm.no Initialize DHCP Unique Identifier when creating the client. The DUID is generated based on the machine-id, which satisfies all the requirements of what an DUID should be. The DUID type is DUID-EN. Based on patch by Patrik Flykt. --- src/libsystemd-network/sd

[systemd-devel] [PATCH 23/24] sd-dhcp6-client: Add reply sending for test

2014-06-13 Thread Patrik Flykt
Enhance the test case by generating a Reply. With a properly formed Reply the callback function will be called and the additional earlier event loop exit can now be removed. --- src/libsystemd-network/test-dhcp6-client.c | 45 ++ 1 file changed, 40 insertions(+), 5

Re: [systemd-devel] [PATCH 02/24] sd-dhcp6-client: Add Router Solicitation and Advertisement support

2014-06-16 Thread Patrik Flykt
Hi, On Fri, 2014-06-13 at 12:17 -0500, Dan Williams wrote: 1) usage of struct ether_addr may prevent correct operation on non-ethernet links, like Infiniband or PPP or GRE. They don't have 6-byte MAC addresses, so anywhere that currently uses a MAC address I'd suggest passing u8*,

Re: [systemd-devel] [PATCH 09/24] sd-dhcp6-client: Add DHCPv6 client Solicitation timeout handling

2014-06-19 Thread Patrik Flykt
Hi, On Wed, 2014-06-18 at 15:50 +0200, Zbigniew Jędrzejewski-Szmek wrote: +if (!client-retransmit_time) { +client-retransmit_time = + client_timeout_compute_random(init_retransmit_time); +} else { +if

Re: [systemd-devel] [PATCH 12/24] sd-dhcp6-client: Add DHCPv6 Solicit message creation and sending

2014-06-19 Thread Patrik Flykt
On Wed, 2014-06-18 at 16:25 +0200, Zbigniew Jędrzejewski-Szmek wrote: On Wed, Jun 18, 2014 at 07:05:35AM -0700, Filipe Brandenburger wrote: On Wed, Jun 18, 2014 at 6:58 AM, Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl wrote: +if (client-fd 0) +

Re: [systemd-devel] [PATCH 02/24] sd-dhcp6-client: Add Router Solicitation and Advertisement support

2014-06-19 Thread Patrik Flykt
On Wed, 2014-06-18 at 16:27 +0200, Zbigniew Jędrzejewski-Szmek wrote: Go ahead and push. It is probably simpler to make further suggestions/comments in terms of patches anyway. Agreed. I made some small comments, but the patch set looks great. Patch set fixed according to your comments

Re: [systemd-devel] [PATCH 02/24] sd-dhcp6-client: Add Router Solicitation and Advertisement support

2014-06-19 Thread Patrik Flykt
On Wed, 2014-06-18 at 16:27 +0200, Zbigniew Jędrzejewski-Szmek wrote: Go ahead and push. It is probably simpler to make further suggestions/comments in terms of patches anyway. Agreed. I made some small comments, but the patch set looks great. Polished a bit more and pushed, enjoy! Cheers,

[systemd-devel] [PATCH 0/8] Basic DHCPv6 client implementation

2014-06-26 Thread Patrik Flykt
is done in patch 07, seems that the DHCP server I'm using doesn't want to rapid commit anything here, perhaps due to a missing IPv6 address to request or something. Last but not least the TODO file lists a few items that are left for later. Cheers, Patrik Patrik Flykt (8): sd-dhcp6

[systemd-devel] [PATCH 3/8] networkd: Properly stop router solicitation and DHCPv6 client

2014-06-26 Thread Patrik Flykt
When a link fails or looses carrier, always stop ongoing router solicitation and any DHCPv6 client that may be running. --- src/network/networkd-link.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c

[systemd-devel] [PATCH 4/8] sd-dhcp6-client: Add Option Request Option support

2014-06-26 Thread Patrik Flykt
Provide a function to request more options from the DHCPv6 server. Provide a sensible default set at startup and add test basic test cases for the intended usage. Define DNS and NTP related option codes and add comments for the unassigned codes. --- src/libsystemd-network/dhcp6-protocol.h|

[systemd-devel] [PATCH 5/8] sd-dhcp6-lease: Add helper function to compute remaining expiry time

2014-06-26 Thread Patrik Flykt
Create a helper function to compute the remaining time in seconds from time T2 to the IPv6 address with the longest lifetime. The computed time is used as the Maximum Retransmission Duration in Rebinding state. See RFC 3315, section 18.1.4. for details. ---

[systemd-devel] [PATCH 2/8] sd-icmp6-nd: Add function to stop ongoing ICMPv6 discovery

2014-06-26 Thread Patrik Flykt
In some use cases stopping an ongoing ICMPv6 discovery is more useful than always unreferencing the whole structure. --- src/libsystemd-network/sd-icmp6-nd.c | 13 + src/libsystemd-network/test-icmp6-rs.c | 4 src/systemd/sd-icmp6-nd.h | 1 + 3 files changed, 18

[systemd-devel] [PATCH 6/8] sd-dhcp6-client: Implement Renew and Rebind

2014-06-26 Thread Patrik Flykt
Start sending Renew and Rebind DHCPv6 messages when respective timers T1 and T2 expire. Rebind messages do not include a Server ID option and the Rebind procedure ends when the last IPv6 address valid lifetime expires, whereafter the client restarts the address acquisition procedure by Soliciting

[systemd-devel] [PATCH 1/8] sd-dhcp6-client: return NULL from _unref() like the other sd-* libraries

2014-06-26 Thread Patrik Flykt
In order to keep the refcounting working, a DONT_DESTROY macro similar to the one in sd-bus has been added also to DHCPv6. --- src/libsystemd-network/sd-dhcp6-client.c | 37 +++- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git

[systemd-devel] [PATCH 8/8] TODO: Add items for the DHCPv6 implementation

2014-06-26 Thread Patrik Flykt
--- TODO | 16 1 file changed, 16 insertions(+) diff --git a/TODO b/TODO index a5f482b..8d8d694 100644 --- a/TODO +++ b/TODO @@ -624,6 +624,22 @@ Features: - export timezone information - FORCERENEW +* dhcp6: + - add functions to set previously stored IPv6 addresses

Re: [systemd-devel] [PATCH 4/8] sd-dhcp6-client: Add Option Request Option support

2014-06-26 Thread Patrik Flykt
On Thu, 2014-06-26 at 12:59 +0200, Zbigniew Jędrzejewski-Szmek wrote: +if (!GREEDY_REALLOC(client-req_opts, client-req_opts_allocated, +(client-req_opts_len + 1) * sizeof(option))) +return -ENOMEM; GREEDY_REALLOC takes the number of

Re: [systemd-devel] [PATCH 5/8] sd-dhcp6-lease: Add helper function to compute remaining expiry time

2014-06-26 Thread Patrik Flykt
On Thu, 2014-06-26 at 13:01 +0200, Zbigniew Jędrzejewski-Szmek wrote: +*expire = 0; + +LIST_FOREACH(addresses, addr, ia-addresses) { +t = be32toh(addr-lifetime_valid); +if (*expire t) +*expire = t; +}

Re: [systemd-devel] [PATCH 5/8] sd-dhcp6-lease: Add helper function to compute remaining expiry time

2014-06-26 Thread Patrik Flykt
On Thu, 2014-06-26 at 14:07 +0200, Zbigniew Jędrzejewski-Szmek wrote: No comments, the rest looks great, as usual. I think you can push it. Thanks. And pushed. Cheers, Patrik ___ systemd-devel mailing list

Re: [systemd-devel] [PATCH 0/8] Basic DHCPv6 client implementation

2014-06-26 Thread Patrik Flykt
On Thu, 2014-06-26 at 13:24 +0300, Patrik Flykt wrote: With this patch set it looks like basic DHCPv6 client functionality should be covered as Renew and Rebind are now also handled. Patch set updated according to Zbyszek's comments and pushed. Cheers, Patrik

[systemd-devel] [PATCH 03/28] dhcp: Add test for DHCP client initialization and parameter setting

2013-11-13 Thread Patrik Flykt
--- src/dhcp/test-dhcp-client.c | 81 +++ 1 file changed, 81 insertions(+) create mode 100644 src/dhcp/test-dhcp-client.c diff --git a/src/dhcp/test-dhcp-client.c b/src/dhcp/test-dhcp-client.c new file mode 100644 index 000..26857b6 --- /dev/null

[systemd-devel] [PATCH 23/28] dhcp: Add maximum message size option

2013-11-13 Thread Patrik Flykt
Add maximum message size option to keep some DHCP server implementations from sending too big messages. See ConnMan commit 0c5c862749c05193cf4c513628328c6db02b5222. --- src/dhcp/client.c | 10 ++ src/dhcp/protocol.h |1 + 2 files changed, 11 insertions(+) diff --git

[systemd-devel] [PATCH 11/28] dhcp: Add function for sending a raw packet

2013-11-13 Thread Patrik Flykt
Open a packet socket, create a link level header, send packet and close socket. Adding it to a separate file makes testing of the DHCP sending much easier, as the test program can supply any socket to the DHCP client code. --- src/dhcp/internal.h |2 ++ src/dhcp/network.c | 63

[systemd-devel] [PATCH 20/28] dhcp: Add timeout and main loop support

2013-11-13 Thread Patrik Flykt
Require a main loop to be set when creating a DHCP client. Set up a timer to resend DHCP Discover messages and add a 0-2 second delay to the timeout value. Move to state Selecting after successful sending of a Discover message. --- src/dhcp/client.c | 77

[systemd-devel] [PATCH 14/28] dhcp: Add test for discover DHCP packet creation

2013-11-13 Thread Patrik Flykt
Set a fake MAC address and emulate raw packet sending. When the buffer containing the Discover message is received, check selected IP and UDP headers and compute IP header and UDP message checksums. Also send the DHCP message for option parsing and expect a successful outcome. --- Makefile.am

[systemd-devel] [PATCH 01/28] dhcp: Add DHCP protocol structures and initial defines

2013-11-13 Thread Patrik Flykt
Create a new directory to host DHCP components. --- src/dhcp/protocol.h | 93 +++ 1 file changed, 93 insertions(+) create mode 100644 src/dhcp/protocol.h diff --git a/src/dhcp/protocol.h b/src/dhcp/protocol.h new file mode 100644 index

[systemd-devel] [PATCH 04/28] build: Add initial build support

2013-11-13 Thread Patrik Flykt
The client test program is the only one to be built so far. --- Makefile.am | 15 +++ configure.ac |9 + src/dhcp/Makefile |1 + 3 files changed, 25 insertions(+) create mode 12 src/dhcp/Makefile diff --git a/Makefile.am b/Makefile.am index

[systemd-devel] [PATCH 15/28] dhcp: Add example DHCP client test program

2013-11-13 Thread Patrik Flykt
The test program runs the DHCP protocol using libsystemd-dhcp. --- src/dhcp/dhcp-example-client.c | 112 1 file changed, 112 insertions(+) create mode 100644 src/dhcp/dhcp-example-client.c diff --git a/src/dhcp/dhcp-example-client.c

[systemd-devel] [PATCH 16/28] build: Add example DHCP test program

2013-11-13 Thread Patrik Flykt
--- Makefile.am | 10 ++ 1 file changed, 10 insertions(+) diff --git a/Makefile.am b/Makefile.am index 1c73423..f079822 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3760,6 +3760,12 @@ libsystemd_dhcp_la_LDFLAGS = \ libsystemd_dhcp_la_LIBADD = \ libsystemd-shared.la

[systemd-devel] [PATCH 07/28] build: Add DHCP option test

2013-11-13 Thread Patrik Flykt
--- Makefile.am | 10 ++ src/dhcp/test-dhcp-option.c | 16 +++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Makefile.am b/Makefile.am index cc52f01..aeca484 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3740,6 +3740,15 @@ endif #

[systemd-devel] [PATCH 02/28] dhcp: Add DHCP client initialization

2013-11-13 Thread Patrik Flykt
Provide functionality for initializing a DHCP client struct, setting interface index, last used address and additional options to request. On initialization the most useful options are added by default. --- src/dhcp/client.c | 137 +

[systemd-devel] [PATCH 00/28] Initial DHCP v4 library implementation

2013-11-13 Thread Patrik Flykt
client code running as normally as possible. A very small example client is also created, I used it to watch the client- server interaction via Wireshark. Please review and comment, Patrik Patrik Flykt (28): dhcp: Add DHCP protocol structures and initial defines dhcp: Add DHCP client

[systemd-devel] [PATCH 21/28] dhcp: Handle received DHCP Offer message

2013-11-13 Thread Patrik Flykt
Create a function for handling the full IP, UDP and DHCP packet and tie it to the main loop. Verify IP and UDP headers and checksum. Creat a new lease structure with using the values supplied in the DHCP message. Free the lease structure when client is stopped. Split out socket handling into a

[systemd-devel] [PATCH 25/28] dhcp: Compute expire, T1 and T2 timers

2013-11-13 Thread Patrik Flykt
Compute the default T1 and T2 timer values if they were not set by the DHCP server. Verify that the values are reasonable. --- src/dhcp/client.c | 123 ++- src/dhcp/protocol.h |2 + 2 files changed, 124 insertions(+), 1 deletion(-) diff

[systemd-devel] [PATCH 17/28] dhcp: Support seconds elapsed since start of DHCP negotiation

2013-11-13 Thread Patrik Flykt
It was noticed by Grant Erickson in ConnMan commit 95e15c09350acf58d4707056ae2614570883ef66 that: Certain DHCP servers, such as that implemented in Mac OS X ( 10.7) for its Internet Sharing feature, refuse to issue a DHCP lease to clients that have not set a non-zero value in their

[systemd-devel] [PATCH 19/28] build: Add dependency on libsystemd-bus needed for main loop

2013-11-13 Thread Patrik Flykt
--- Makefile.am |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index f079822..433383d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3758,7 +3758,8 @@ libsystemd_dhcp_la_LDFLAGS = \ $(AM_LDFLAGS) libsystemd_dhcp_la_LIBADD = \ -

[systemd-devel] [PATCH 22/28] dhcp: Send DHCP Request to acquire an IP address

2013-11-13 Thread Patrik Flykt
Create and send a DHCP Request message reusing already existing parts of the code. This causes factoring out IP and UDP header creation and moving next timeout calculation to be done every time in the timer callback function independent of DHCP state. Also add an exponential part to the timer

[systemd-devel] [PATCH 27/28] dhcp: Add function to free DHCP client data

2013-11-13 Thread Patrik Flykt
--- src/dhcp/client.c | 11 +++ src/dhcp/client.h |2 ++ 2 files changed, 13 insertions(+) diff --git a/src/dhcp/client.c b/src/dhcp/client.c index 0144c70..a274549 100644 --- a/src/dhcp/client.c +++ b/src/dhcp/client.c @@ -994,6 +994,17 @@ int dhcp_client_stop(DHCPClient *client)

[systemd-devel] [PATCH 06/28] dhcp: Add buffer length and invalid cookie tests for DHCP options

2013-11-13 Thread Patrik Flykt
Create an initial simple test program for these two cases. --- src/dhcp/test-dhcp-option.c | 54 +++ 1 file changed, 54 insertions(+) create mode 100644 src/dhcp/test-dhcp-option.c diff --git a/src/dhcp/test-dhcp-option.c b/src/dhcp/test-dhcp-option.c

[systemd-devel] [PATCH 10/28] dhcp: Add test function for computing checksum

2013-11-13 Thread Patrik Flykt
--- src/dhcp/test-dhcp-client.c | 40 1 file changed, 40 insertions(+) diff --git a/src/dhcp/test-dhcp-client.c b/src/dhcp/test-dhcp-client.c index 26857b6..94f576a 100644 --- a/src/dhcp/test-dhcp-client.c +++ b/src/dhcp/test-dhcp-client.c @@ -22,6

[systemd-devel] [PATCH 12/28] dhcp: Add DHCP discover sending

2013-11-13 Thread Patrik Flykt
On starting the client, use the supplied interface mac address and create a transaction id. Puzzle together an IP/UDP/DHCP Discover message, compute checksums and send it out as a raw packet. Create an additional function that constructs default options common to all DHCP messages. Set the DHCP

[systemd-devel] [PATCH 24/28] dhcp: Process DHCP Ack/Nak message

2013-11-13 Thread Patrik Flykt
Process a DHCP Ack/Nak in much the same way as an DHCP Offer. Factor out header verification and process options sent. Add notification functionality with discrete values for the outcome of the DHCP Ack/ Nak processing. --- src/dhcp/client.c | 145

[systemd-devel] [PATCH 13/28] build: Add libsystemd-dhcp

2013-11-13 Thread Patrik Flykt
--- Makefile.am | 20 1 file changed, 20 insertions(+) diff --git a/Makefile.am b/Makefile.am index aeca484..5c350ab 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3740,6 +3740,26 @@ endif # --

[systemd-devel] [PATCH 18/28] dhcp: Add function to stop the DHCP client

2013-11-13 Thread Patrik Flykt
The client is stopped and brought back to its initial state. --- src/dhcp/client.c | 35 +++ src/dhcp/client.h |1 + 2 files changed, 36 insertions(+) diff --git a/src/dhcp/client.c b/src/dhcp/client.c index dc92880..79ac93b 100644 --- a/src/dhcp/client.c

[systemd-devel] [PATCH 08/28] dhcp: Add tests for DHCP options, file and sname fields

2013-11-13 Thread Patrik Flykt
Add a structure describing the DHCP file, sname and trailing options fields. Create a messge holding these fields and call the internal option parsing function. In the test callback function verify that only regular options are passed and figure out which part of the DHCP message is the one that

[systemd-devel] [PATCH 26/28] dhcp: Add notification callback

2013-11-13 Thread Patrik Flykt
Define a notification callback and events for stopping and client lease expiry. Add functions to fetch IP parameters from a lease. --- src/dhcp/client.c | 98 - src/dhcp/client.h |9 + 2 files changed, 106 insertions(+), 1 deletion(-)

[systemd-devel] [PATCH 09/28] dhcp: Add option append tests

2013-11-13 Thread Patrik Flykt
Add checks for invalid lengths and parameters when using the option appending function. Add also checks for adding options, see to it that the resulting array is identical to the array of options added. --- src/dhcp/test-dhcp-option.c | 71 +++ 1 file

Re: [systemd-devel] systemd-networkd questions

2013-11-13 Thread Patrik Flykt
Hi, On Wed, 2013-11-13 at 17:39 +0100, Tom Gundersen wrote: I'm sure I would like avoid that :) Hopefully we'll be able to reuse the dhcp client from connman, but as the work of converting that into a library has not yet finished I don't know yet exactly how that will work out.

Re: [systemd-devel] [PATCH 00/28] Initial DHCP v4 library implementation

2013-11-13 Thread Patrik Flykt
Hi, On Thu, 2013-11-14 at 06:31 +0900, Greg KH wrote: Nice stuff. Where did this code come from, conman? If so, for some reason I thought that it would be easier to make a library of the existing conman dhcp code and have both projects use it instead of forking and having two

Re: [systemd-devel] [PATCH 02/28] dhcp: Add DHCP client initialization

2013-11-15 Thread Patrik Flykt
Hi, On Thu, 2013-11-14 at 01:01 +0100, Lennart Poettering wrote: Hmm, struct in_addr contains nothing but a uint32_t. It really sounds overkill allocating such a structure individually on the stack. Shouldn't this structure be directly inside DHCPClient? Or actually, do we really

Re: [systemd-devel] [PATCH 05/28] dhcp: Add option appending and parsing

2013-11-15 Thread Patrik Flykt
On Thu, 2013-11-14 at 01:06 +0100, Lennart Poettering wrote: +int __dhcp_option_append(uint8_t **buf, int *buflen, uint8_t code, + uint8_t optlen, void *optval); + The __ prefix is actually private property by the C compiler, according to ANSI C. Please do not

Re: [systemd-devel] [PATCH 15/28] dhcp: Add example DHCP client test program

2013-11-15 Thread Patrik Flykt
On Thu, 2013-11-14 at 01:22 +0100, Lennart Poettering wrote: Also, rtnl sounds the better option. And if not, then this call appears to be totally identical to glibc's ifname_to_index(), no? Better use that then... This is only part of the example DHCP test client. It's usefulness is

Re: [systemd-devel] [PATCH 17/28] dhcp: Support seconds elapsed since start of DHCP negotiation

2013-11-15 Thread Patrik Flykt
On Thu, 2013-11-14 at 01:23 +0100, Lennart Poettering wrote: It was noticed by Grant Erickson in ConnMan commit 95e15c09350acf58d4707056ae2614570883ef66 that: Certain DHCP servers, such as that implemented in Mac OS X ( 10.7) for its Internet Sharing feature, refuse to issue

Re: [systemd-devel] [PATCH 20/28] dhcp: Add timeout and main loop support

2013-11-15 Thread Patrik Flykt
Hi, On Thu, 2013-11-14 at 01:30 +0100, Lennart Poettering wrote: +err = sd_event_add_monotonic(sd_event_get(s), next_timeout, + 10 * USEC_PER_MSEC, + client_timeout_resend,

[systemd-devel] [PATCH v2 23/26] dhcp: Process DHCP Ack/Nak message

2013-11-24 Thread Patrik Flykt
Process a DHCP Ack/Nak in much the same way as an DHCP Offer. Factor out header verification and process options sent. Add notification functionality with discrete values for the outcome of the DHCP Ack/ Nak processing. --- v2: - previous 24/28 - replace 'err' with 'r' and fix fd as suggested

[systemd-devel] [PATCH v2 20/26] dhcp: Handle received DHCP Offer message

2013-11-24 Thread Patrik Flykt
Create a function for handling the full IP, UDP and DHCP packet and tie it to the main loop. Verify IP and UDP headers and checksum. Creat a new lease structure with using the values supplied in the DHCP message. Free the lease structure when client is stopped. Split out socket handling into a

[systemd-devel] [PATCH v2 08/26] dhcp: Add tests for DHCP options, file and sname fields

2013-11-24 Thread Patrik Flykt
Add a structure describing the DHCP file, sname and trailing options fields. Create a messge holding these fields and call the internal option parsing function. In the test callback function verify that only regular options are passed and figure out which part of the DHCP message is the one that

[systemd-devel] [PATCH v2 06/26] dhcp: Add buffer length and invalid cookie tests for DHCP options

2013-11-24 Thread Patrik Flykt
Create an initial simple test program for these two cases. --- src/dhcp/test-dhcp-option.c | 51 +++ 1 file changed, 51 insertions(+) create mode 100644 src/dhcp/test-dhcp-option.c diff --git a/src/dhcp/test-dhcp-option.c b/src/dhcp/test-dhcp-option.c

[systemd-devel] [PATCH v2 01/26] dhcp: Add DHCP protocol structures and initial defines

2013-11-24 Thread Patrik Flykt
Create a new directory to host DHCP components. --- v2: use _packed_, be*_t where appropriate and anonymous enums src/dhcp/protocol.h | 104 +++ 1 file changed, 104 insertions(+) create mode 100644 src/dhcp/protocol.h diff --git

[systemd-devel] [PATCH v2 09/26] dhcp: Add option append tests

2013-11-24 Thread Patrik Flykt
Add checks for invalid lengths and parameters when using the option appending function. Add also checks for adding options, see to it that the resulting array is identical to the array of options added. --- src/dhcp/test-dhcp-option.c | 71 +++ 1 file

[systemd-devel] [PATCH v2 13/26] dhcp: Add DHCP discover sending

2013-11-24 Thread Patrik Flykt
On starting the client, use the supplied interface mac address and create a transaction id. Puzzle together an IP/UDP/DHCP Discover message, compute checksums and send it out as a raw packet. Create an additional function that constructs default options common to all DHCP messages. Set the DHCP

  1   2   3   >