Commit graph

364 commits

Author SHA1 Message Date
Tom Gundersen 62379e884e networkd: ndisc - always configure dhcp6 client
The ndisc client may trigger the dhcpv6 client to be started (this is the common case),
so we should allocate the dhcpv6 client whenever we allocate the ndisc one.
2015-11-17 13:26:46 +01:00
Tom Gundersen 63348d13fa networkd: ndisc/dhcpv6 - handle starting running clients
The clients may be triggered to be started repeatedly without being stopped first,
simply swallow the error rather than failing the link.
2015-11-16 19:14:22 +01:00
Tom Gundersen a56a2048f9 networkd: check explicit state rather than link->network
When deserializing we can now have an attached network without the various clients yet
having been configured. Hence, don't misused the link->network as a check to determine
if a link is ready to be used, but check the state explicitly.
2015-11-13 15:05:58 +01:00
Lennart Poettering 765afd5c4d networkd: stop managing per-interface IP forwarding settings
As it turns out the kernel does not support per-interface IPv6 packet
forwarding controls (unlike as it does for IPv4), but only supports a
global option (#1597). Also, the current per-interface management of the
setting isn't really useful, as you want it to propagate to at least one
more interface than the one you configure it on. This created much grief
(#1411, #1808).

Hence, let's roll this logic back and simplify this again, so that we
can expose the same behaviour on IPv4 and IPv6 and things start to work
automatically again for most folks: if a network with this setting set
is set up we propagate the setting into the global setting, but this is
strictly one-way: we never reset it again, and we do nothing for network
interfaces where this setting is not enabled.

Fixes: #1808, #1597.
2015-11-13 13:02:50 +01:00
Lennart Poettering d68e2e59b3 networkd: rearrange checks when to write something into sysctl a bit
Move check whether ipv6 is available into link_ipv6_privacy_extensions()
to keep it as internal and early as possible.

Always check if there's a network attached to a link before we apply
sysctls. We do this for most of the sysctl functions already, with this
change we do it for all.
2015-11-13 13:02:50 +01:00
Lennart Poettering 66a6bd6897 networkd: fix a couple of format string types
We really should use %i for ints, and %u for unsigneds, and be careful
what we pick depending on the type we want to print.
2015-11-13 13:02:49 +01:00
Lennart Poettering eb3da9012f util-lib: optionally, when writing a string to a file, verify string on failure
With this change, the idiom:

    r = write_string_file(p, buf, 0);
    if (r < 0) {
           if (verify_one_line_file(p, buf) > 0)
                   r = 0;
    }

gets reduced to:

    r = write_string_file(p, buf, WRITE_STRING_FILE_VERIFY_ON_FAILURE);

i.e. when writing the string fails and the new flag
WRITE_STRING_FILE_VERIFY_ON_FAILURE is specified we'll not return a
failure immediately, but check the contents of the file. If it matches
what we wanted to write we suppress the error and exit cleanly.
2015-11-13 13:02:49 +01:00
Tom Gundersen 5e5b137acc networkd: link - drop foreign config when configuring link
This is a change in behavior:

Before we would never remove any state, only add to it, we now drop unwanted
state from any link the moment we start managing it.

Note however, that we still will not remove any foreign state added at runtime,
to avoid any feedback loops. However, we make no guarantees about coexisting
with third-party tools that change the state of the links we manage.
2015-11-11 16:16:47 +01:00
Tom Gundersen 4058d339f5 networkd: improve logging 2015-11-11 15:42:38 +01:00
Tom Gundersen e7ab854c6c networkd: link - track state of IPv6LL address
This is managed by the kernel, but we should track whether or not we have
a configured IPv6LL address. This fixes two issues:
 - we now wait for IPv6LL before considering the link ready
 - we now wait for IPv6LL before attempting to do NDisc or DHCPv6
   these protocols relies on an LL address being available.
2015-11-11 15:42:38 +01:00
Tom Gundersen 3b015d40c1 networkd: ndisc - handle router advertisement in userspace
Router Discovery is a core part of IPv6, which by default is handled by the kernel.
However, the kernel implementation is meant as a fall-back, and to fully support
the protocol a userspace implementation is desired.

The protocol essentially listens for Router Advertisement packets from routers
on the local link and use these to configure the client automatically. The four
main pieces of information are: what kind (if any) of DHCPv6 configuration should
be performed; a default gateway; the prefixes that should be considered to be on
the local link; and the prefixes with which we can preform SLAAC in order to pick
a global IPv6 address.

A lot of additional information is also available, which we do not yet fully
support, but which will eventually allow us to avoid the need for DHCPv6 in the
common case.

Short-term, the reason for wanting this is in userspace was the desire to fully
track all the addresses on links we manage, and that is not possible for addresses
managed by the kernel (as the kernel does not expose to us the fact that it
manages these addresses). Moreover, we would like to support stable privacy
addresses, which will soon be mandated and the legacy MAC-based global addresses
deprecated, to do this well we need to handle the generation in userspace. Lastly,
more long-term we wish to support more RA options than what the kernel exposes.
2015-11-11 15:42:38 +01:00
Tom Gundersen f5a8c43f39 networkd: IPv6 router discovery - follow IPv6AcceptRouterAdvertisemnt=
The previous behavior:
When DHCPv6 was enabled, router discover was performed first, and then DHCPv6 was
enabled only if the relevant flags were passed in the Router Advertisement message.
Moreover, router discovery was performed even if AcceptRouterAdvertisements=false,
moreover, even if router advertisements were accepted (by the kernel) the flags
indicating that DHCPv6 should be performed were ignored.

New behavior:
If RouterAdvertisements are accepted, and either no routers are found, or an
advertisement is received indicating DHCPv6 should be performed, the DHCPv6
client is started. Moreover, the DHCP option now truly enables the DHCPv6
client regardless of router discovery (though it will probably not be
very useful to get a lease withotu any routes, this seems the more consistent
approach).

The recommended default setting should be to set DHCP=ipv4 and to leave
IPv6AcceptRouterAdvertisements unset.
2015-11-11 15:42:38 +01:00
Susant Sahani b69c318040 networkd: Add support to configure IPV6 hop limit
This patch adds support to configure IPV6 hop limit.

For example:
/proc/sys/net/ipv6/conf/wlp3s0/hop_limit
2015-11-10 09:26:38 +05:30
Daniel Mack 4084052911 Merge pull request #1726 from teg/networkd-2
networkd: (de)serialize more state and support expiring routes
2015-11-03 15:03:50 +01:00
Tom Gundersen c598ac7626 networkd: link - port to extract_first_word() 2015-10-30 12:32:49 +01:00
Tom Gundersen f833694d4f networkd: route - add expiration support
This should really live in the kernel, but the netlink API currently
does not support it. Until support has been added, expire the route
from userspace.
2015-10-30 12:32:49 +01:00
Tom Gundersen f703cc2c57 networkd: link - deserialize routes 2015-10-30 12:32:49 +01:00
Tom Gundersen 0bc70f1d9c networkd: link - (de)serialize IPv4LL and DHCPv4 addresses
This initializes the clients to try rebinding the preexisting
addresses before doing anything else.
2015-10-30 12:32:49 +01:00
Tom Gundersen c4a03a5669 networkd: link - deserialize
For now only deserialize some basic state and the applied addresses.

When a link is added, try to deserialize it's state from /run. This
is relevant only when networkd is restarted at runtime.
2015-10-30 12:32:49 +01:00
Tom Gundersen c1eb9872f6 networkd: link - serialize routes 2015-10-30 12:32:49 +01:00
Tom Gundersen 2ce4095690 networkd: route - rename fields in struct 2015-10-30 12:32:48 +01:00
Hristo Venev 4701725cd5 network: fix use-after-free in link_free
Freeing a link removes it both from addresses and addresses_foreign,
causing SIGSEGV if one of the sets is freed.
2015-10-29 12:18:02 +02:00
Lennart Poettering b5efdb8af4 util-lib: split out allocation calls into alloc-util.[ch] 2015-10-27 13:45:53 +01:00
Lennart Poettering 15a5e95075 util-lib: split out printf() helpers to stdio-util.h 2015-10-27 13:25:57 +01:00
Lennart Poettering 8b43440b7e util-lib: move string table stuff into its own string-table.[ch] 2015-10-27 13:25:56 +01:00
Lennart Poettering 3ffd4af220 util-lib: split out fd-related operations into fd-util.[ch]
There are more than enough to deserve their own .c file, hence move them
over.
2015-10-25 13:19:18 +01:00
Tom Gundersen ceabaf0fea networkd: ndisc - make logging messages uniform
Refer to Router Discovery rather than ICMPv6.
2015-10-22 17:19:54 +02:00
Tom Gundersen de1e9928f1 networkd: rename icmp6 to ndisc 2015-10-22 17:19:54 +02:00
Tom Gundersen 4d7b83da7b sd-ndisc: rename API from sd-icmp6-nd 2015-10-22 17:19:54 +02:00
Tom Gundersen 84de38c569 networkd: manager/link - only serialize once per event-loop iteration
Every time the state is written out we may trigger third-party apps, so
let's be a bit more careful about writing this out unnecessarily.
2015-10-21 03:24:23 +02:00
Tom Gundersen e7780c8d44 networkd: link - serialize addresses 2015-10-21 03:24:23 +02:00
Tom Gundersen adda1ed94a networkd: address - distinguish between addresses added by us and by others
We only keep the addresses that we added ourselves in link->addresses, and
introduce a new set link->addresses_foreign to keep addresses of unknown
origin.

Only functional change is that "foreign" addresses no longer prevent a link
from entering "configured" state.
2015-10-21 02:35:31 +02:00
Tom Gundersen 6666907869 networkd: address - merge _change() into _configure()
These functions are almost entirely the same, so avoid duplication.
2015-10-21 02:35:31 +02:00
Tom Gundersen 8012cd3919 networkd: link - only consider configured when all addresses are ready
We were considering a link configured whilst its IPv6 addresses were still
tentative.

Fixes issue #650.
2015-10-21 02:35:31 +02:00
Susant Sahani 8749cbcd4f networkd: add support for configure IPv6 DAD
Configures Ipv6 Duplicate Address Detection.

10
2015-10-16 10:53:20 +05:30
Lennart Poettering 9ea79b459e Merge pull request #1530 from teg/network-fixes-2
networkd/libsystemd-network: collection of trivial patches v2
2015-10-14 12:15:09 +02:00
Zbigniew Jędrzejewski-Szmek ebf9808112 man: describe IPv6AcceptRouterAdvertisements= better
With the previous description it wasn't clear that the
kernel default is being described.

Add link to kernel docs.
2015-10-12 13:50:29 -04:00
Tom Gundersen ce6c77ebf1 networkd: address - introduce address_is_ready()
Checks that a given address is not tentative nor deprecated.
2015-10-11 15:04:16 +02:00
Tom Gundersen 91b5f99731 networkd: make address_{establish,release}() static
No need to expose these functions, but rather call them from address_{add,drop}.
2015-10-11 15:04:16 +02:00
Tom Gundersen cf1d700da3 networkd: address - store active addresses in a Set rather than a List
We need to be able to look these things up quickly as we will be updating them
continuously and there can in principle be many of them.
2015-10-11 15:04:16 +02:00
Tom Gundersen 200a0868fc networkd: address - process in manager.c rather than link.c 2015-10-11 15:04:16 +02:00
Tom Gundersen 957325b763 networkd: link - refactor (un)ref 2015-10-11 15:04:16 +02:00
Tom Gundersen 5c416fc408 networkd: link - fix error handling in link_add() 2015-10-11 15:04:16 +02:00
Tom Gundersen a2fae7bbb2 networkd: link/network - correctly align log messages 2015-10-11 15:04:16 +02:00
Tom Gundersen f0213e3796 networkd: route/address - simplify and unify creators
Rename new_dynamic() to simply _new() and reuse that from new_static().
2015-10-11 14:21:41 +02:00
reverendhomer d4158938fc networkd-link: remove unused variable assignment in link_save()
fixes Coverity #1317207
2015-10-08 14:43:03 +03:00
Patrik Flykt 3ada37a21e networkd: Be opportunistic when declaring link configured
The DHCP variable in the [Network] section of the network configuration
file moves the link to the configured state according to the following:

DHCP=yes   Link is configured when either DHCPv4 or DHCPv6 succeed
DHCP=ipv4  Link is configured only when DHCPv4 succeeds
DHCP=ipv6  Link is configured only when DHCPv6 succeeds
DHCP=no    Neither DHCPv4 or DHCPv6 is attempted

Reported by Martin Pitt.

Fixes https://github.com/systemd/systemd/issues/1368
2015-09-24 15:20:41 +03:00
Tom Gundersen 5fecc33e32 Merge pull request #1356 from pfl/dhcp6_suspend
DHCPv6 suspend fixes
2015-09-24 00:55:49 +02:00
Patrik Flykt 18d29550b5 networkd: Wait for DHCPv6 before announcing link configured
Wait until DHCPv6 has acquired an address before announcing the link
to be configured. Log the DHCPv6 lease lost event.
2015-09-23 15:24:04 +03:00
Georg Müller 6a512301bb Set accept_ra to "2" if enabled in config
This causes the kernel to accept router advertisments even if
ip forwarding is enabled for this interface.

This fixes #1340.
2015-09-23 10:27:45 +02:00