1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-14 15:21:37 +03:00
Commit Graph

171 Commits

Author SHA1 Message Date
Patrik Flykt
f12abb48fc sd-dhcp6-client: Add DHCPv6 IAID functionality
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 is the best we
have.]
2014-06-19 15:44:43 +03:00
Tom Gundersen
fc5414305d network-internal: split out net_get_name() 2014-06-19 15:44:43 +03:00
Tom Gundersen
a276e6d686 sd-dhcp6-client: Initialize DUID
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.
2014-06-19 15:44:43 +03:00
Patrik Flykt
f20a35cc0d sd-icmp6-nd: Add initial Router Advertisement test case
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.
2014-06-19 15:44:43 +03:00
Patrik Flykt
e316912679 sd-icmp6-nd: Add Router Solicitation and Advertisement support
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, section 3.2.

Send Router Solicitations to the all routers multicast group as
described in RFC 4861, section 6. and act on the received Router
Advertisments according to section 6.3.7.

Implement a similar API for ICMPv6 handling as is done for DHCPv4 and
DHCPv6.
2014-06-19 15:44:43 +03:00
Patrik Flykt
139b011ab8 sd-dhcp6-client: Add initial DHCPv6 client files
Add initial structure definition and functions for setting index, MAC
address, callback and event loop. Define protocol values and states.
2014-06-19 15:44:43 +03:00
Lennart Poettering
3bdace9bf7 dhcp-server: simplify dhcp server unref call
No need to use HASHMAP_ITERATE when we destruct all entries anyway.
2014-06-19 00:00:24 +02:00
Thomas Hindoe Paaboel Andersen
f7926298e9 sd-dhcp-client: check return from dhcp_option_append 2014-06-18 23:21:00 +02:00
Thomas Hindoe Paaboel Andersen
02557f973a sd-dhcp-server: fix a leak
We must use free instead of dhcp_lease_free here to avoid freeing
client_id.data.
2014-06-18 23:21:00 +02:00
Michal Sekletar
03966da2ca dhcp-network: remove TODO
There is no need to explicitly check version of L3 protocol in the
ethernet header because we bind socket with .sll_protocol set to
ETH_P_IP, thus we only receive IPv4 packets on the socket.
2014-06-18 18:14:51 +02:00
Tom Gundersen
5a3f198964 networkd: veth - fix memleak 2014-06-17 23:21:31 +02:00
Tom Gundersen
0bbc2c1f3b sd-dhcp: checksum - make endianess-neutral
For efficiency, we group bytes together before adding them up. This
is guaranteed to always work (regardless of the byte order) as long
as the i-th byte in each group lign up with the i-th byte in each
other group.

On big-endian machines this broke when handling the trailing few bytes
which did not make up a full group of 4 bytes. This patch fixes the
problem by explicitly creating a 4 byte zero-padded group out of the
trailing bytes.

Reported and tested by Thomas Ritter <th.ritter@gmx.at>.
2014-06-17 09:17:07 +02:00
Tom Gundersen
6f08fb7b34 sd-dhcp-server: test - skip when lacking perms 2014-06-13 19:11:31 +02:00
Andreas Henriksson
8186d9dda0 sd-dhcp-client: fix invalid free() in client_send_request()
static int client_send_request(...) in
./src/libsystemd-network/sd-dhcp-client.c tries to initialize
"request" by calling client_message_init(...), which has atleast
5 error cases where it can return without that happening.
This leads to the function finishing without "request" being initialized.
2014-06-13 18:57:33 +02:00
Tom Gundersen
500792d818 sd-dhcp-server: add RELEASE support 2014-06-13 17:07:20 +02:00
Tom Gundersen
5b34277c20 sd-dhcp-server: add dummy DECLINE support 2014-06-13 17:07:20 +02:00
Tom Gundersen
87322b3aee sd-dhcp-server: track bound leases
Make sure we don't hand out the same IP twice. We still don't
handle lease expiry.
2014-06-13 17:07:19 +02:00
Tom Gundersen
c7d9ffe6d6 sd-dhcp-server: add support for clients requesting lease lifetime 2014-06-13 17:07:19 +02:00
Tom Gundersen
bd57b45029 sd-dhcp-server: add basic NAK support 2014-06-13 17:07:19 +02:00
Tom Gundersen
2dead8129f sd-dhcp-server: add basic REQUEST/ACK support 2014-06-13 17:07:19 +02:00
Tom Gundersen
4dc3556804 sd-dhcp-server: add basic DISCOVER/OFFER support 2014-06-13 17:07:19 +02:00
Tom Gundersen
969b009d94 sd-dhcp-server: add support for sending messages 2014-06-13 17:07:19 +02:00
Tom Gundersen
20af7091de sd-dhcp-server: add support for setting the server address 2014-06-13 17:07:19 +02:00
Tom Gundersen
8de4a226c7 sd-dhcp-server: bind to raw socket for sending
We would like to use the UDP socket, but we cannot as we need to specify
the MAC address manually.
2014-06-13 16:53:13 +02:00
Tom Gundersen
816e2e7af9 sd-dhcp-server: add basic message parsing
Parse the maximum message size the client can accept and the client id, falling back to
sane defaults if they are not set.
2014-06-13 16:53:13 +02:00
Tom Gundersen
be077570f7 sd-dhcp-server: add basic message handling and verification 2014-06-13 16:53:13 +02:00
Tom Gundersen
3a864fe4a8 sd-dhcp-server: bind to a given interface
We will (at least at first), restrict our focus to running the server
on at most one interface.
2014-06-13 16:53:13 +02:00
Tom Gundersen
ff734080aa sd-dhcp-server: add basic functionality for starting/stopping server
Bind to UDP socket and listen for messages, discarding anything we receive.
2014-06-13 16:53:13 +02:00
Tom Gundersen
b44cd88210 sd-dhcp-server: add basic functionality for creating/destroying server instance 2014-06-13 16:53:13 +02:00
Tom Gundersen
fef0e0f3b2 dhcp-network: allow UDP socket to listen on any address
For this to work nicely we need to use REUSEADDR so that more than one socket
can be open at the same time. Also, we request the ifindex to be appended
to incoming messages, so we know whence it came.
2014-06-13 16:53:13 +02:00
Camilo Aguilar
63a070415d sd-dhcp-client: allways request broadcast
On systems which cannot receive unicast packets until its IP stack has been configured
we need to request broadcast packets. We are currently not able to reliably detect when
this is necessary, so set it unconditionally for now.

This is set on all packets, but the DHCP server will only broadcast the packets that are
necessary, and unicast the rest.

For more information please refer to this thread in CoreOS: https://github.com/coreos/bugs/issues/12

[tomegun: rephrased commit message]
2014-06-03 10:55:46 +02:00
Tom Gundersen
bddfc8afd3 networkd: drop CAP_SYS_MODULE
Rely on modules being built-in or autoloaded on-demand.

As networkd is a network facing service, we want to limits its capabilities,
as much as possible. Also, we may not have CAP_SYS_MODULE in a container,
and we want networkd to work the same there.

Module autoloading does not always work, but should be fixed by the kernel
patch f98f89a0104454f35a: 'net: tunnels - enable module autoloading', which
is currently in net-next and which people may consider backporting if they
want tunneling support without compiling in the modules.

Early adopters may also use a module-load.d snippet and order
systemd-modules-load.service before networkd to force the module
loading of tunneling modules.

This sholud fix the various build issues people have reported.
2014-06-03 00:40:23 +02:00
Tom Gundersen
4eb20caa4d test-dhcp-option: fix memleak 2014-05-26 21:31:57 +02:00
Cristian Rodríguez
590b6b9188 Use %m instead of strerror(errno) where appropiate 2014-05-25 11:18:28 +08:00
Tom Gundersen
424a873214 sd-dhcp-client: factor out dhcp packet allocation 2014-05-21 16:55:47 +02:00
Tom Gundersen
23289745d7 sd-dhcp: rely on FIONREAD working
This fallback will anyway never get tested, so rip it out.
2014-05-21 16:31:28 +02:00
Tom Gundersen
04b28be1a3 sd-dhcp: option_append - support falling back to 'sname' and 'file' 2014-05-21 16:09:05 +02:00
Tom Gundersen
2688ef60de sd-dhcp: make sure we can not fill options so much that there is no space for END 2014-05-21 15:27:53 +02:00
Tom Gundersen
f5c0c00f40 dhcp-lease: add support for parsing a few more dhcp options 2014-05-20 23:31:22 +02:00
Tom Gundersen
e140ae58f1 dhcp-lease: refactor lease parsing
Use helper functions, and add some more sanity checking/asserts.
2014-05-20 23:31:22 +02:00
Tom Gundersen
32008a9636 sd-dhcp: refactor parse_options
Similar to the previous patch, exchange a length and a pointer with only one offset variable.
Also fix the type of the options to be uint8_t[], rather than uint8_t*.
2014-05-20 23:31:22 +02:00
Tom Gundersen
20b958bf15 sd-dhcp: refactor dhcp_option_append
Store a pointer to the options in the DHCPMessage struct, and pass
this together with an offset around, rather than a uint8_t**.

This avoids us having to (re)compute the pointer; and changes
dhcp_option_append from adjusting both the pointer to the next
option and the remaining size of the options, to just adjusting
the current offset.

This makes the code a bit simpler to follow IMHO, but there should
be no functional change.
2014-05-20 23:31:22 +02:00
Tom Gundersen
81d98a39eb sd-dhcp-lease/sd-network: modernization and fix leak 2014-05-19 18:14:56 +02:00
Tom Gundersen
09bee74d7a sd-dhcp-lease: move in_addr (de)serialization to shared network code 2014-05-19 18:14:56 +02:00
Tom Gundersen
0b44d8c3d7 networkd: manager - don't leak kmod context
Also, keep the kmod_new internal to networkd-manager.c
2014-05-12 17:37:58 +02:00
Susant Sahani
7951dea209 networkd: introduce ipip tunnel
This patch enables basic ipip tunnel support.
It works with kernel module ipip

example conf:

file: ipip.netdev

[NetDev]
Name=ipip-tun
Kind=ipip
MTUBytes=1480

[Tunnel]
Local=192.168.223.238
Remote=192.169.224.239
TTL=64

file: ipip.network

[Match]
Name=em1

[Network]
Tunnel=ipip-tun

[tomegun:
         - drop unused variable
         - take ref when enslaving]
2014-05-12 17:37:12 +02:00
Tom Gundersen
699370c98d sd-dhcp-client: improve logging when stopping client
'Requested by user' was confusing, just drop it.
2014-05-09 14:41:27 +02:00
Tom Gundersen
deb2e5230b sd-network: expose both admin and operational state directly
Also add a call to check if a link is loopback, as this should commonly be ignored.
2014-05-07 16:54:02 +02:00
Tom Gundersen
22fc2420b2 sd-dhcp-client: use asynchronous_close()
close() is a blocking call, which may slow things down measurably when running many dhcp
clients in the same single-threaded main loop. Let's just use the asynchronous version
instead to avoid the problem.
2014-05-06 22:59:22 +02:00
Tom Gundersen
c3d2994b59 sd-dhcp: network - don't leak sockets on failure
Also some general cleanups
2014-05-06 22:15:46 +02:00
Tom Gundersen
85923f79e1 sd-dhcp: network - set TOS on outgoing packets
This should improve performance on busy wireless networks and the
like. Inspired by a similar change in dnsmasq.
2014-05-06 22:09:05 +02:00
Tom Gundersen
085cabf266 dhcp-network: don't pass ifindex to bind_udp_socket
UDP sockets can anyway not be bound to specific netdev's. The packages would have to be filtered
when received instead.
2014-05-06 21:58:08 +02:00
Umut Tezduyar Lindskog
8ddbeaa23c networkd: dont configure route if lease doesn't have one 2014-04-30 00:05:28 +02:00
Tom Gundersen
bc4155669a sd-dhcp-lease: fix double realloc 2014-04-29 21:57:59 +02:00
Tom Gundersen
109731eb25 sd-dhcp-lease: (de)serialize DNS and NTP servers
Also use inet_ntoa rather than inet_ntop.
2014-04-29 15:05:33 +02:00
Tom Gundersen
0b21bde96d sd-dhcp-leaes: use newdup() 2014-04-29 12:46:06 +02:00
Tom Gundersen
4684469639 sd-dhcp-lease: add NTP support
Export the NTP servers so timesyncd can use them.
2014-04-29 12:25:58 +02:00
Umut Tezduyar Lindskog
ccfdc9a112 sd-dhcp-client: log positive error number
Log error no for such client_stop(client, DHCP_EVENT_STOP)
2014-04-27 23:41:46 +02:00
Umut Tezduyar Lindskog
d9bf4f8c6c libnetworkd: add link local tests
- Also only allow positive ifindex on both dhcp and ipv4ll

[tomegun: the kernel always sets a positive ifindex, but some APIs accept
          ifindex=0 with various meanings, so we should protect against
          accidentally passing ifindex=0 along.]
2014-04-27 23:39:13 +02:00
Tom Gundersen
3a67e927e3 networkd-wait-online: improve interoptability and enable by default
To make sure we don't delay boot on systems where (some) network links are managed by someone else
we don't block if something else has successfully brought up a link.

We will still block until all links we are aware of that are  managed by networkd have been
configured, but if no such links exist, and someone else have configured a link sufficiently
that it has a carrier, it may be that the link is ready so we should no longer block.

Note that in all likelyhood the link is not ready (no addresses/routes configured),
so whatever network managment daemon configured it should provide a similar wait-online
service to block network-online.target until it is ready.

The aim is to block as long as we know networking is not fully configured, but no longer. This
will allow systemd-networkd-wait-online.service to be enabled on any system, even if we don't
know whether networkd is the main/only network manager.

Even in the case networking is fully configured by networkd, the default behavior may not be
sufficient: if two links need to be configured, but the first is fully configured before the
second one appears we will assume the network is up. To work around that, we allow specifying
specific devices to wait for before considering the network up.

This unit is enabled by default, just like systemd-networkd, but will only be pulled in if
anyone pulls in network-online.target.
2014-04-24 00:23:07 +02:00
Tom Gundersen
6317519517 sd-dhcp-client: log ifindex and mac address when starting 2014-04-20 19:20:26 +02:00
Tom Gundersen
505f8da732 networkd: tie links to rtnl rather than udev
This essentially swaps the roles of rtnl and udev in networkd. After this
change libudev is only used for waiting for udev to initialize devices and
to get udev-specific information needed for some [Match] attributes.

This in particular simplifies the code in containers where udev is not really
useful, but also simplifies things and reduces round-trips in the non-container
case.
2014-04-19 18:41:58 +02:00
Zbigniew Jędrzejewski-Szmek
6e00a80641 test-dhcp-client: unref lease objects to make valgrind happy
Also unref client objects in test code, and initalize logging,
to DEBUG by default.
2014-04-12 10:20:55 -04:00
Tom Gundersen
730b306208 sd-dhcp-client: drop logging about T1/T2
These are redundant now that the REQUEST messages contain the same information.
2014-04-12 11:20:28 +02:00
Tom Gundersen
998d804702 sd-dhcp-client: improve logging
Specify what kind of REQUEST we send, and distinguish between REBOOT and START.
Also log stop reasons as strings rather than numbers.
2014-04-12 01:01:13 +02:00
Tom Gundersen
7739a40b45 sd-dhcp-client: use client_initialiez and client_restart for REBOOT 2014-04-12 00:34:05 +02:00
Tom Gundersen
50d6810ea8 sd-dhcp-client: document message creation a bit more
Also reshuffle some code to make the correspondence with the RFC a bit more
obvious.

Small functional change: fail if we try to send a message from the wrong state.
2014-04-11 22:24:26 +02:00
Tom Gundersen
8a9e761600 sd-dhcp-client: assert that we can only create DISCOVER or REQUEST messages 2014-04-11 22:24:25 +02:00
Tom Gundersen
eb105b96d5 sd-dhcp-client: rebind raw socket when resetting transaction id
As we are now filtering the raw socket based on the transaction id, we must
reset the BPF when we reset the transaction id.
2014-04-11 18:02:54 +02:00
Patrik Flykt
4d978a4669 sd-ipv4ll: Add an explicit stop state for IPv4LL
Add an explicit stop state for IPv4LL so that the user can stop the
IPv4LL client from the callback. When returning from the callback,
check also the stop state in order to halt any further protocol
processing.
2014-04-11 10:54:12 +03:00
Patrik Flykt
56cd007ab8 sd-ipv4ll: Add reference counting for IPv4LL
Similar to DHCP, the IPv4LL library user can decide to free the LL
client any time the callback is called. Guard against freeing the
LL client in the callback by introducing proper reference counting.

Also update code using the IPv4LL library to properly handle a
returned NULL from the notify and stop functions if the IPv4LL
client was freed.
2014-04-11 10:53:52 +03:00
Patrik Flykt
781ca7a13f sd-dhcp-client: Add an explicit stop state for the DHCP client
Add an explicit stop state for the DHCP client so that the library
user can issue a stop at any time the callback has been called.
When returning from the callback, check also the stop state and
stop any further DHCP processing.
2014-04-11 10:53:34 +03:00
Patrik Flykt
e5b04c8de8 sd-dhcp-client: Add reference counting for DHCP
The DHCP library user can decide to free the DHCP client any time
the callback is called. After the callback has been called, other
computations may still be needed - the best example being a full
restart of the DHCP procedure in case of lease expiry.

Fix this by introducing proper reference counting. Properly handle
a returned NULL from the notify and stop functions if the DHCP
client was freed.
2014-04-11 10:53:10 +03:00
Tom Gundersen
48a4612e6b sd-dhcp-client: recevie_message - verify cmsg_len before reading 2014-04-11 00:52:23 +02:00
Tom Gundersen
d47e1de40e sd-dhcp-client: test - fix for jenkins
This test should have been updated when changing the magic cookie handling around.

Reported by Ken MacLeod.
2014-04-10 17:08:32 +02:00
Tom Gundersen
aa6fc9b8c8 sd-dhcp-client: include client id in debug messages 2014-04-08 19:16:30 +02:00
Zbigniew Jędrzejewski-Szmek
c4acff1275 test-dhcp-client: style fixes 2014-04-07 21:02:47 -04:00
Tom Gundersen
d576127429 libsystemd-network: Speed up checksum computation using 64 bit integers
Improve the checksum computation by using 64 bit integers instead of the 16 bit
integers in the existing implementation. This change speeds up the computation
with approximately 78% both on 64 bit and 32 bit systems.

Please see RFC 1071 for details.
2014-04-07 15:39:21 +03:00
Tom Gundersen
298f77c60c ipv4ll: use BPF on raw socket
This should significantly reduce spurious wakeups.
2014-04-07 09:24:18 +02:00
Tom Gundersen
463b73e24e sd-ipv4ll: fix packet broadcasting
Umut said: 'I have noticed a bug that we are sending PROBE/ANNOUNCE messages on
00:00:00:00:00:00 address where it should be broadcast.'
2014-04-07 09:13:02 +02:00
Tom Gundersen
7429b07f82 sd-dhcp-client: improve BPF
Try a bit harder to make the kernel drop packets not for us. This should reduce
the number of wakeups from n^2 to n in the number of dhcp clients, which admittedly
only makes a differenc in very extreme cases.
2014-04-06 19:42:11 +02:00
Tom Gundersen
0c79c68d93 sd-dhcp-client: eagerly drop too small packets
If they are too small to fit the IP+UDP+DHCP headers they can be of no use, so
don't waste resources parsing them. This is at the cost of losing some verbosity
in the logging.
2014-04-06 19:42:11 +02:00
Tom Gundersen
3b7ca119fd sd-dhcp-client: move magic cookie into DHCPMessage struct
Also move the checking of it to the main message handler, rather than the
options parser.

Fix a bug, so we now drop the packet if any of the magic bytes don't match.
Before we used to only drop the packet if they were all wrong.
2014-04-06 19:36:05 +02:00
Umut Tezduyar Lindskog
aba496a58a networkd: smooth transition from ipv4ll to dhcp address
Currently when both ipv4ll and dhcp are enabled, ipv4ll
address (if one has been claimed) is removed when dhcp
address is aquired. This is not the best thing to do
since there might be clients unaware of the removal
trying to communicate.

This patch provides a smooth transition between ipv4ll
and dhcp. If ipv4ll address was claimed [1] before dhcp,
address is marked as deprecated. Deprecated address is still
a valid address and packets can be received on it but address
cannot be selected as a source address. If dhcp lease cannot
be extended, then ipv4ll address is marked as valid again.

[1] If there is no collision, claiming IPv4LL takes between 4 to
7 seconds.
2014-04-03 16:00:25 +02:00
Tom Gundersen
bc29e507e2 sd-dhcp-client: use BPF on raw socket
Filter out everything except UDP packets destined for the DHCP client port,
this should avoid the vast majority of spurious wakeups.

Filter based on [0], with permission.

Possible improvemnts: also check for the DHCP magic cookie to drop invalid
packets. Check for our xid to filter out packets destined for other clients.

[0]: <https://github.com/ambrop72/badvpn/blob/master/dhcpclient/BDHCPClient.c#L57>
2014-04-02 14:49:51 +02:00
Tom Gundersen
bcf3ce7b39 sd-ipv4ll: speed up bind() in the same way as for dhcp 2014-04-01 21:29:56 +02:00
Tom Gundersen
66a67effcc sd-dhcp-client: --omg-optimized
Passing the protocol to socket() is redundant as it will be specified again in
bind(). Dropping the redundancy reduces the cost of bind() from ~30ms to ~0ms.
For details see [0].

networkd in a container (i.e., with next to no network latency) can now
negotiate a DHCP lease in 0.7 - 5 ms.

Thanks to Kay for help with debugging and to Daniel Borkmann for the pointer
to fix the problem.

[0]: <https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=902fefb82ef72a50c78cb4a20cc954b037a98d1c>
2014-04-01 00:32:51 +02:00
Tom Gundersen
2ad7561f9f sd-dhcp: avoid checksum calculation if possible
When receiving lots of packets that are not meant for us, we waste a relatively large amount
of cpu time computing their checksums before discarding them. Move the checksum calculation last
so we never compute it for packets which would otherwise be discarded.
2014-03-30 20:46:40 +02:00
Tom Gundersen
6e34949d72 sd-dhcp: check for ipv4 packets 2014-03-30 20:46:40 +02:00
Umut Tezduyar Lindskog
d454a6748c sd-dhcp: check for udp packets
Do not try to parse ICMP packets

[tomegun: slightly tweaked debug message]
2014-03-30 20:46:20 +02:00
Thomas Hindoe Paaboel Andersen
9f2a50a300 silence warnings 2014-03-27 20:16:49 +01:00
Lennart Poettering
6a0f1f6d5a sd-event: rework API to support CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM, too 2014-03-24 02:58:41 +01:00
Tom Gundersen
2afa65c312 sd-dhcp-client: test - don't close socket twice
One end of the socketpair is closed by the library, so only close our end. Also switch to
the safe_close() so we get notified about problems with closing.
2014-03-22 10:52:49 +01:00
Tom Gundersen
c6f7c917a1 libsystemd-network: move network-utils from src/shared
This does not belong in shared as it is mostly a detail of our networking subsystem.

Moreover, now we can use libudev here, which will simplify things.
2014-03-21 21:54:37 +01:00
Umut Tezduyar Lindskog
b5db00e52e sd-ipv4ll/networkd: generate predictable addresses
Increase the chance of using the same link local address between reboots. The
pseudo random sequence of addresses we attempt is now seeded with data that is
very likely to stay the same between reboots, but at the same time be unique
to the specific machine/nic.

First we try to use the ID_NET_NAME_* data from the udev db combined with the
machin-id, which is guaranteed to be unique and persistent, if available. If
that is not possible (e.g., in containers where we don't have access to the
udev db) we fallback to using the MAC address of the interface, which is
guaranteed to be unique, and likely to be persistent.

[tomegun: three minor changes:

 - don't expose HASH_KEY in the siphash24 header
 - get rid of some compile-warnings (and some casts at the same time),
   by using uint8_t[8] rather than uint64_t in the api
 - added commit message]
2014-03-21 20:24:10 +01:00
Tom Gundersen
4644fee04f sd-dhcp-client/sd-ipv4ll: allow mac address to be updated at any time
If necessary, restart the clients to deal with a changing mac address
at runtime. This will solve the problem of starting clients on bridges
before they have received their final MAC address.
2014-03-21 18:36:32 +01:00
Tom Gundersen
9e64dd7276 sd-dhcp-client: add fallback subnet masks
The DHCP RFC does not require the DHCP server to send a subnet mask, so if it
is missing, let's try to use the default subnet masks based on address class.
In case the class the address belongs to does not have a default subnet mask,
we fail as before.

Also improve logging when handling invalid dhcp messages, and simply ignore them
rather than stop the whole dhcp client.
2014-03-21 17:52:42 +01:00
Tom Gundersen
022446adf9 sd-dhcp-client: make timeout handling a bit more robust
Accept any lease lifetime greater than one second. Server should not
hand out extremely short leases, but let's not be the ones to fail.

Do not fail when arming a timer in the past, but also only arm one such
timer.

Avoid rounding errors when computing the default timeouts, this may be
an issue if we are handed a very short lease.

Also, don't pass 'time_now' around, as that can be found in the event
object when needed.
2014-03-21 17:52:42 +01:00
Tom Gundersen
58ec2d3e6e sd-dhcp-client: do not reset 'secs' when entering INIT-REBOOT
Also keep start_time in sync, but that shouldn't matter.
2014-03-20 17:07:43 +01:00
Tom Gundersen
6236f49b23 sd-dhcp-client: don't pass around 'secs'
The value is stored in the client object, so get it there when needed.
2014-03-20 17:07:43 +01:00