Commit Graph

13 Commits

Author SHA1 Message Date
Lennart Poettering ae2a15bc14 macro: introduce TAKE_PTR() macro
This macro will read a pointer of any type, return it, and set the
pointer to NULL. This is useful as an explicit concept of passing
ownership of a memory area between pointers.

This takes inspiration from Rust:

https://doc.rust-lang.org/std/option/enum.Option.html#method.take

and was suggested by Alan Jenkins (@sourcejedi).

It drops ~160 lines of code from our codebase, which makes me like it.
Also, I think it clarifies passing of ownership, and thus helps
readability a bit (at least for the initiated who know the new macro)
2018-03-22 20:21:42 +01:00
Yu Watanabe 9c3b99feb8 network: fix indentation
Follow-up for 56a23cb40a.
2018-01-15 23:49:55 +09:00
Patrik Flykt d601b56687 radv: Add prefixes with dynamically updated lifetimes
Add a boolean that indicates whether the prefixes will always exist
or if they will time out after the assigned valid lifetime. In the
latter case calculate the expiry times for both preferred and valid
lifetimes for the prefixes, and decrease the remaining lifetimes
each time when a Router Advertisement is sent.

Should the prefix be updated, re-calculate the prefix lifetime. When
updating, update the existing entry, if any, with the lifetimes of
the added entry as the existing entry has its lifetimes set
according to its previously calculated expiry times.
2018-01-04 15:22:44 +02:00
Patrik Flykt 56a23cb40a networkd: Add DHCPv6 as a configuration option to radv prefixes
The Network section IPv6PrefixDelegation= option takes two new
configuration values, namely "static" and "dhcpv6" in addition
to boolean yes and no values. Static prefixes in IPv6Prefix
sections are used when IPv6PrefixDelegation= option contains
"static", and DHCPv6 is queried for prefixes when the option
contains "dhcpv6". Both DHCPv6 and static prefixes are used when
the option contains a boolean true value. The default value is
false as before, meaning no prefixes are delegated.
2018-01-04 15:22:43 +02:00
Patrik Flykt 6e849e95ad networkd: Move Router Advertisement functionality to a single file
Centralize Router Advertisement functionality in networkd-radv instead
of keeping it in networkd-address.
2018-01-04 15:22:43 +02:00
Patrik Flykt 349a981d32 networkd: Ignore DNS information when uplink is not managed (#7571)
When another networking daemon or configuration is handling the
uplink connection, systemd-networkd won't have a network configuration
associated with the link, and therefore link->network will be NULL.
An assert will be triggered later on in the code when link->network is
NULL.
2017-12-08 13:33:40 +01:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-11-19 19:08:15 +01:00
Patrik Flykt c555a358ce networkd: Automatically set DNS and search domain information
When EmitDNS or EmitDomains is set, automatically look up values
for Router Advertisement DNS and DNS search domain options starting
with the values in the IPv6PrefixDelegationsection, if any. If none
are found, use the values set for the network, and as a last resort
try with the preferred upstream network.

The default DNS lifetime and therefore Router Advertisement interval
is added to the public sd_radv.h header as the DNS lifetime depends
on the maximum advertisement interval.
2017-10-06 12:30:27 +03:00
Patrik Flykt 5e35aa815b networkd-radv: Set DNSSL information on Router Advertisement enabling 2017-09-15 10:34:57 +03:00
Patrik Flykt f1eca3774d networkd-radv: Set RDNSS information on Router Advertisement enabling 2017-09-07 09:51:26 +03:00
Patrik Flykt 945e32252e networkd-radv: Fix router lifetime assignment
Router lifetime is stored as usec_t, use value accordingly.
2017-06-16 09:45:46 +03:00
Patrik Flykt 301a2fb99a networkd: Fix comment
Comment about not being a router is in the wrong place. Router lifetime
is assigned with config_parse_sec().
2017-06-16 09:44:45 +03:00
Patrik Flykt 091214b636 networkd-radv: Helper function for Router Advertisement initialization
Add a helper function for configuring Router Advertisement on a
specific network link. Add the prefixes that are going to be advertised.
2017-05-15 14:49:50 +03:00