Commit graph

33 commits

Author SHA1 Message Date
Lennart Poettering e866e17b0f sd-radv: follow our usualy rule that destructors can take NULL 2018-11-26 22:31:15 +01:00
Lennart Poettering dc0ec5e251 sd-radv: simplify IPv6 address is-null check 2018-11-26 22:31:15 +01:00
Lennart Poettering 83ef9d141b sd-radv: drop const from non-ptr argument 2018-11-26 22:31:15 +01:00
Lennart Poettering ae25915d24 sd-radv: use ether_addr_is_null() where appropriate 2018-11-26 22:31:15 +01:00
Yu Watanabe 807a8edeb1 sd-radv: do not unref() event sources when update or disable them 2018-11-16 22:57:42 +09:00
Yu Watanabe 78f9d24f7b sd-radv: use structured initializer at one more place 2018-11-16 22:57:42 +09:00
Lennart Poettering 8eb41f4c08 sd-radv: EAGAIN is not really unexpected, distinguishit from other errors when logging 2018-10-02 16:26:50 +02:00
Lennart Poettering fdc2afc102 sd-radv: remove log_radv_warning_errno()
According to our CODING_STYLE our library code should generally not log
beyond LOG_DEBUG. Let's hence get rid of log_radv_warning_errno() and
just use log_radv_errno() instead.
2018-10-02 16:22:54 +02:00
Yu Watanabe 8301aa0bf1 tree-wide: use DEFINE_TRIVIAL_REF_UNREF_FUNC() macro or friends where applicable 2018-08-27 14:01:46 +09:00
Chris Lamb 3fe910794b Correct a number of trivial typos. 2018-06-18 22:44:44 +02:00
Lennart Poettering 810adae9e9 tree-wide: use proper unicode © instead of (C) where we can
Let's use a proper unicode copyright symbol where we can, it's prettier.

This important patch is very important.
2018-06-14 10:20:20 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
This part of the copyright blurb stems from the GPL use recommendations:

https://www.gnu.org/licenses/gpl-howto.en.html

The concept appears to originate in times where version control was per
file, instead of per tree, and was a way to glue the files together.
Ultimately, we nowadays don't live in that world anymore, and this
information is entirely useless anyway, as people are very welcome to
copy these files into any projects they like, and they shouldn't have to
change bits that are part of our copyright header for that.

hence, let's just get rid of this old cruft, and shorten our codebase a
bit.
2018-06-14 10:20:20 +02:00
Lennart Poettering 97d7974b18 sd-radv: use strv_isempty() where we can 2018-06-13 17:48:15 +02:00
Lennart Poettering f5a5706ace sd-radv: normalize function parameters a bit
Let's add "const" where we don't change structures passed.

Also, we generally use "unsigned char" for IP prefix length values, do
so here too. Previously different parts of the sd-radv.h API used
different types for this.
2018-06-13 17:48:15 +02:00
Lennart Poettering c4b6dda07f sd-radv: close fd when destroying object 2018-06-13 17:48:15 +02:00
Susant Sahani 6f8a8b84f2 networkd: Don't try to close fd in sd_radv_stop if fd is closed.
sd_radv_stop is called from two places. if sd_radv_stop is alrady
success then just don't try to close it .
```
systemd-networkd[604]: RADV: Stopping IPv6 Router Advertisement daemon
systemd-networkd[604]: RADV: Unable to send last Router Advertisement with router lifetime set to zero: Bad file descriptor <==================HERE
systemd-networkd[604]: RADV: Updated prefix 2a0a:*:*:fc::/64 preferred 1h valid 2h
systemd-networkd[604]: RADV: Started IPv6 Router Advertisement daemon
```

Closes one of the issue #8960
2018-06-13 17:14:47 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00
Yu Watanabe 1cc6c93a95 tree-wide: use TAKE_PTR() and TAKE_FD() macros 2018-04-05 14:26:26 +09:00
Lennart Poettering 38edb7674b
Merge pull request #7582 from pfl/dhcp6_prefix_delegation
DHCPv6 prefix delegation
2018-01-15 12:02:37 +01:00
Hans-Christian Noren Egtvedt 8a2b193a55 sd-radv: avoid redefinition of struct in6_addr
Both netinet/icmp6.h and linux/in6.h will define struct in6_addr, and in
user space we want to use the netinet/icmp6.h variant.

Fixes build problem:
In file included from src/libsystemd-network/sd-radv.c:23:0:
/home/hegtvedt/work/os/product/sunrise/root/_build/v2/include/linux/in6.h:30:8:
error: redefinition of 'struct in6_addr'
2018-01-10 12:32:03 +01:00
Patrik Flykt de661ccec7 radv: Allow setting MTU in all cases
Setting MTU is allowed in all cases and the MTU value will be
announced in the subsequent Router Advertisements.
2018-01-04 15:22:44 +02:00
Patrik Flykt 34c169c462 radv: Add function to remove prefixes
As DHCPv6 leases may expire at some point, the delegated prefixes
have to be removed. Add a prefix removal function to the Router
Advertisement handling code.
2018-01-04 15:22:44 +02: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
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 6852c0f6b0 sd-radv: Allocate space also for DNSSL iov option (#7144)
The iov array needs to hold five entries in addition to the number
of prefixes.
2017-10-20 10:59:15 +02:00
Patrik Flykt f9aa5417d1 sd-radv: Free DNS domain search list on unref (#6858) 2017-09-18 12:09:44 +02:00
Patrik Flykt e965d6aba3 sd-radv: Add Router Advertisement DNS Search List option
Add Router Advertisement DNS Search List option as specified
in RFC 8106. The search list option uses and identical option
header as the RDNSS option and therefore the option header
structure can be reused.

If systemd is compiled with IDNA support, internationalization
of the provided search domain is applied, after which the search
list is written in wire format into the DNSSL option.
2017-09-15 10:34:57 +03:00
Patrik Flykt e9c6da3868 sd-radv: Add Router Advertisement DNS information
Add Router Advertisement Recursive DNS Server information as specified
in RFC 8106.
2017-09-07 09:51:26 +03:00
Patrik Flykt 88d5a3db55 sd-radv: Receive Router Solicitations
Receive Router Solicitations and send a unicast Router Advertisment
in response. Refactor ICMPv6 packet handling code so that the common
ICMPv6 validation parts are reused between the existing router
discovery and the new functionality adding reception of Router
Solicitation messages.
2017-05-15 14:49:50 +03:00
Patrik Flykt 77baf5aee6 sd-radv: Send Router Advertisments
Create and remove the ICMPv6 Router Advertisement socket file
descriptor and implement Router Advertisment sending. As not
all options are mandatory, use IO vectors to point to the included
options and the prefix information.
2017-05-15 14:49:50 +03:00
Patrik Flykt 204fb681f6 sd-radv: Implement Router Advertisement timeout handling
Router Advertisements are sent uniformly distributed between a
minimum and maximum time according to RFC 4861, Section 6.2.4.
Default values from RFC 4861 are for now used as minimum and
maximum Router Advertisement timeouts.

When stopping, a Router Advertisement with a router lifetime set
to zero is sent in order to inform any nodes that the interface
on this host no longer is a router.
2017-05-15 14:49:50 +03:00
Patrik Flykt 204f99d21e sd-radv: Add Router Advertisement functionality
Add Router Advertisement header files, data structures and core
functionality that is quite similar to other parts of networkd.
2017-05-15 14:49:50 +03:00
Patrik Flykt 04473969ef sd-radv: Add Router Advertisement prefix handling
Define Router Advertisement prefix structure. Add the Prefix
Information ICMPv6 option defined in RFC 4861 to the prefix
information structure, as it will simplify sending a Prefix
Information option later on. In order to handle endianness
correctly, the structure is redefined here instead of using
the one in netinet/icmp6.h.

Add functions to create and modify prefix information and set
default values as defined in RFC 4861, Section 6.2.1.
2017-05-15 14:49:50 +03:00