1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00
Commit Graph

1384 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
04499a70fb Drop the text argument from assert_not_reached()
In general we almost never hit those asserts in production code, so users see
them very rarely, if ever. But either way, we just need something that users
can pass to the developers.

We have quite a few of those asserts, and some have fairly nice messages, but
many are like "WTF?" or "???" or "unexpected something". The error that is
printed includes the file location, and function name. In almost all functions
there's at most one assert, so the function name alone is enough to identify
the failure for a developer. So we don't get much extra from the message, and
we might just as well drop them.

Dropping them makes our code a tiny bit smaller, and most importantly, improves
development experience by making it easy to insert such an assert in the code
without thinking how to phrase the argument.
2021-08-03 10:05:10 +02:00
Yu Watanabe
e18f21e349
Merge pull request #20109 from keszybz/timestamp-macros
Add macros that define scratch buffer internally for timestamp/timespan formatting
2021-07-14 16:14:08 +09:00
Frantisek Sumsal
2f0927626a tree-wide: coccinelle fixes
Yet another batch of Coccinelle fixes.
2021-07-09 20:54:22 +01:00
Zbigniew Jędrzejewski-Szmek
5291f26d4a tree-wide: add FORMAT_TIMESPAN() 2021-07-09 11:03:36 +02:00
Zbigniew Jędrzejewski-Szmek
04f5c018ce tree-wide: use FORMAT_TIMESTAMP() 2021-07-09 11:03:35 +02:00
Yu Watanabe
1e59122d45 sd-ipv4ll: introduce sd_ipv4ll_set_check_mac_callback() 2021-07-01 00:49:02 +09:00
Yu Watanabe
9e5aa34fc8 sd-ipv4ll: allow to set MAC address without stopping sd-ipv4ll engine 2021-07-01 00:49:02 +09:00
Yu Watanabe
7f77917c0e sd-ipv4acd: update condition of address conflict
See RFC 5227 section 2.1.1.

This introduces a callback which intend to a library user, e.g.
networkd, checks whether the sender hardware address is a MAC address of
the host's intrerface or not.
2021-07-01 00:49:02 +09:00
Yu Watanabe
5c35c13a4d sd-ipv4acd: allow to change requesting address without restarting sd-ipv4acd 2021-07-01 00:49:02 +09:00
Yu Watanabe
3d817902c4 sd-ipv4acd: set defend window in timeout event and state is IPV4ACD_STATE_STARTED 2021-07-01 00:49:02 +09:00
Yu Watanabe
fcb7345950 sd-ipv4acd: allow to change MAC address without restarting sd-ipv4acd
This also makes sd_ipv4acd_set_mac() refuses null MAC address.
2021-07-01 00:49:02 +09:00
Yu Watanabe
d17ed573aa arp-util: split out logic of setting BPF code into a function 2021-07-01 00:49:02 +09:00
Yu Watanabe
ecad63f850 arp-util: use struct in_addr 2021-07-01 00:49:02 +09:00
Yu Watanabe
e1a3915b41 arp-util: make arp_send_{probe,announcement}() inline 2021-07-01 00:49:02 +09:00
Yu Watanabe
28ba416c99 arp-util: shorten code a bit 2021-07-01 00:49:02 +09:00
Yu Watanabe
504bf2b54a arp-util: check ifindex and mac address 2021-07-01 00:49:02 +09:00
Yu Watanabe
f6720fe62e arp-util: check sent message size 2021-07-01 00:49:02 +09:00
Yu Watanabe
51d113512f arp-util: align elements 2021-07-01 00:49:02 +09:00
Yu Watanabe
265b6d4e0c sd-ipv4acd: include announced address in log message 2021-07-01 00:49:02 +09:00
Yu Watanabe
9be2ba5e12 sd-ipv4acd: use struct in_addr instead of be32_t 2021-07-01 00:49:02 +09:00
Yu Watanabe
38e980a6a5 sd-dhcp-client: tentatively ignore FORCERENEW command
This makes DHCP client ignore FORCERENEW requests, as unauthenticated
FORCERENEW requests causes a security issue (TALOS-2020-1142, CVE-2020-13529).

Let's re-enable this after RFC3118 (Authentication for DHCP Messages)
and/or RFC6704 (Forcerenew Nonce Authentication) are implemented.

Fixes #16774.
2021-06-24 11:25:26 +09:00
Yu Watanabe
551ad0b7de sd-dhcp-client: logs when dhcp client unexpectedly gains a new lease
Previously, such situation is handled silently.
2021-06-24 11:25:26 +09:00
Yu Watanabe
d57b62be0d sd-dhcp-client: shorten code a bit 2021-06-24 11:25:26 +09:00
Yu Watanabe
67d8cd8193 sd-dhcp-client: check error earlier and reduce indentation 2021-06-24 11:25:26 +09:00
Yu Watanabe
af7b405dff sd-dhcp: refuse to set iaid if we cannot find the interface 2021-06-12 03:19:08 +09:00
Yu Watanabe
8d71f2b3a6 dhcp: do not use ifindex when generating iaid in tests 2021-06-12 03:19:08 +09:00
Yu Watanabe
0299deab53 sd-dhcp: do not use detect_container() to guess udev is running or not 2021-06-12 03:19:08 +09:00
Yu Watanabe
0ac655a63b tree-wide: use sd_device_new_from_ifindex/ifname() 2021-06-12 03:19:08 +09:00
Yu Watanabe
b27e5d53f3 sd-dhcp-server: make sd_dhcp_server_start() no-op if it is already running 2021-06-08 06:33:27 +09:00
borna-blazevic
65a0ef2341 sd-dhcp-server: support static address to DHCPv4 offer 2021-05-27 15:15:27 +09:00
Lennart Poettering
319a4f4bc4 alloc-util: simplify GREEDY_REALLOC() logic by relying on malloc_usable_size()
We recently started making more use of malloc_usable_size() and rely on
it (see the string_erase() story). Given that we don't really support
sytems where malloc_usable_size() cannot be trusted beyond statistics
anyway, let's go fully in and rework GREEDY_REALLOC() on top of it:
instead of passing around and maintaining the currenly allocated size
everywhere, let's just derive it automatically from
malloc_usable_size().

I am mostly after this for the simplicity this brings. It also brings
minor efficiency improvements I guess, but things become so much nicer
to look at if we can avoid these allocation size variables everywhere.

Note that the malloc_usable_size() man page says relying on it wasn't
"good programming practice", but I think it does this for reasons that
don't apply here: the greedy realloc logic specifically doesn't rely on
the returned extra size, beyond the fact that it is equal or larger than
what was requested.

(This commit was supposed to be a quick patch btw, but apparently we use
the greedy realloc stuff quite a bit across the codebase, so this ends
up touching *a*lot* of code.)
2021-05-19 16:42:37 +02:00
Lennart Poettering
041ea9f9bb netlink,network: drop "const" from opaque object parameters in supposed-to-be-public APIs
This drops the "const" specifier from the opaque object parameters to
various functions in our API.

This effectively reverts #19292 and more.

Why drop this? Our public APIs should not leak too much information
about how stuff is implemented internally. In our public APIs we
shouldn't give too many guarantees we don#t want to necessarily keep.
Specifically: in many cases it makes sense that getters actually
generate/parse/allocate data on the fly, storing/caching the result
internally, to speed things up, do things lazily or to track memory
allocations so that they can be freed later. Doing this means we need to
change the objects, even though the getters are semantically a read
operation.

We want to retain the freedom that we can change things around
internally. By exposing the objects as "const" we remove a good chunk of
that, for little gain.

See sd_bus_creds_get_description() for a real example of a getter that
implicitly caches and thus modifies the relevant object.

This removes the "const" decorators from sd-dhcp and sd-netlink, two
APIs that we intend to make public eventually even though they still are
not, leaving us the chance to still fix this before it becomes set in
stone.
2021-05-12 16:19:58 +09:00
Yu Watanabe
19cc6d5e54 tree-wide: fix typo 2021-05-09 14:36:19 +09:00
Yegor Alexeyev
11c38d3e51 rfc3046 implementation 2021-05-08 15:59:29 +09:00
Yegor Alexeyev
c95df5879e relay role implementation 2021-04-20 15:11:53 +02:00
Luca Boccassi
2d8c8549ab
Merge pull request #19317 from keszybz/check-return-values-from-log_errno-functions
Check return values from log_errno functions
2021-04-15 20:33:54 +01:00
Zbigniew Jędrzejewski-Szmek
828b603a79 libsystemd-network: fix dhcp option buffer confusion
We were writing to the wrong buffer with a wrong offset :(
Bug present since the original introduction of the code in
04b28be1a3.
2021-04-15 13:46:48 +09:00
Zbigniew Jędrzejewski-Szmek
00dd6d7770 libsystemd-network: check that errno==0 is not passed to log functions 2021-04-14 23:32:10 +02:00
Zbigniew Jędrzejewski-Szmek
a0c2541b6b libsystemd-network: use macro for definitions of log_{lldp,dhcp,…}_errno
No functional change.
2021-04-14 23:32:07 +02:00
Zbigniew Jędrzejewski-Szmek
f407219cd1 Check that errno passed log_{interface,link}_*_errno() is non-zero 2021-04-14 22:53:49 +02:00
Yu Watanabe
22bbba8444 sd-dhcp-client: introduce sd_dhcp_client_is_running() 2021-04-14 22:31:28 +02:00
Zbigniew Jędrzejewski-Szmek
2d359acda5 libsystemd-network: fix dhcp option buffer confusion
We were writing to the wrong buffer with a wrong offset :(
Bug present since the original introduction of the code in
04b28be1a3.
2021-04-14 16:19:54 +02:00
Luca Boccassi
c2b2df604b tree-wide: avoid uninitialized warning on _cleanup_ variables
With some versions of the compiler, the _cleanup_ attr makes it think
the variable might be freed/closed when uninitialized, even though it
cannot happen. The added cost is small enough to be worth the benefit,
and optimized builds will help reduce it even further.
2021-04-14 12:25:06 +01:00
Yegor Alexeyev
21b6b87eb3 dhcp: Implemented BindToInterface= configuration option 2021-04-14 07:30:40 +09:00
Yu Watanabe
9bafb8d504 sd-dhcp-client: constify argument in sd_dhcp_lease_get_xxx() 2021-04-12 09:55:26 +02:00
Yu Watanabe
080e5c2fde sd-dhcp6-client: do not use IN_SET() macro when only one target value 2021-04-10 13:24:56 +01:00
Zbigniew Jędrzejewski-Szmek
82a335db83
Merge pull request #18777 from yuwata/network-set-ifname-to-engines
network: set ifname to dhcp4 client or friends
2021-03-31 10:25:23 +02:00
Luca Boccassi
a9dd1010f0 test-dhcp6-client: add one more assert on memory mapping
Same as 7489d0640a, one more case
that was missed.

Coverity CID #1394277
2021-03-26 20:17:35 +01:00
Luca Boccassi
7489d0640a test-dhcp6-client: add one more assert on memory mapping
Static analyzers need a hint that optval is not pointing
off the end of the msg_advertise array, since pos can go
up to the full length of it. The array is manually
constructed so we know this won't happen, but adding one
more assert should be enough to avoid false positives.

Coverity CID #1394277
2021-03-25 12:02:43 +00:00
Yu Watanabe
fa92d38428 dhcp6: fix wrong length for IA_PD dhcp6 option
Fixes an issue introduced by 73b49d433c.

When PrefixDelegationHint= is not set, dhcp6_option_append_pd() sets
wrong length for IA_PD option, as `r` is `-EINVAL`.

Fixes #19021.
2021-03-16 21:29:49 +01:00
Zbigniew Jędrzejewski-Szmek
63dc82d378
Merge pull request #18852 from yuwata/tree-wide-use-UINT64_MAX
tree-wide: use UINT64_MAX or friends
2021-03-05 17:51:34 +01:00
Yu Watanabe
986c0edfcb dhcp-server: also append specified additional options and vendor specific option on DHCP_OFFER
Fixes #15780.
2021-03-05 11:34:32 +09:00
Yu Watanabe
f5fbe71d95 tree-wide: use UINT64_MAX or friends 2021-03-05 07:10:13 +09:00
Yu Watanabe
a7d757ec29 dhcp6: tighten T1 and T2 value check
Only when T1 and T2 are both 0, they are adjusted later based on
address or prefix T1 and T2. So the first check must be changed.
2021-03-04 05:51:56 +09:00
Yu Watanabe
353887831b libsystemd-network: make log_dhcp_client() or friends include interface name 2021-03-04 05:51:28 +09:00
Yu Watanabe
61a9fa8f0c libsystemd-network: introduce sd_xxx_{set,get}_ifname() 2021-03-04 05:24:54 +09:00
Yu Watanabe
ab7153b3f4 dhcp: use unlink_and_freep() in dhcp_lease_save() 2021-03-03 16:26:32 +09:00
Zbigniew Jędrzejewski-Szmek
d9a65c5976
Merge pull request #18730 from yuwata/dhcp6-client-do-not-set-t1-t2-18090
dhcp6: do not set T1 and T2 in IA_PD option or friends
2021-02-24 09:53:37 +01:00
Lennart Poettering
d9a650bbe8 icmp6-util: add missing variable initialization
Coverity 1446712
2021-02-23 15:45:15 +01:00
Yu Watanabe
73b49d433c dhcp6: do not set T1 and T2 by dhcp6_option_append_pd() in client
Fixes #18090.
2021-02-23 19:36:37 +09:00
Yu Watanabe
e7613578b4 dhcp6: do not set T1 and T2 by dhcp6_option_append_ia() in client 2021-02-23 19:36:37 +09:00
Yu Watanabe
1e84213a43 dhcp6: make dhcp6_option_parse_{address,pdprefix}() return -EINVAL when received address or prefix is refused
And then the caller ignores the error.
Otherwise, `ret_liftime_valid` is not set even if they succeeds.
2021-02-23 19:36:23 +09:00
Yu Watanabe
cf6c33bd6b dhcp6: do not use input value before checking 2021-02-23 18:49:11 +09:00
Lennart Poettering
2324fd3a39 network: suffix types with _t in public headers
Apparently, in our current public headers (i.e. those called sd-*.h) we
suffixed typedefs that we use as values with _t, but we didn't do this
for enum typedefs. Fix that while this stuff is not actually public yet.

With this scheme "value typedefs" now end systematically in _t, and
"object typedefs" (i.e. structures that are typically passed around via
pointers and not values) do not.

No code changes, just some renaming.
2021-02-18 18:17:16 +01:00
Yu Watanabe
c633628daf tree-wide: constify variables if possible 2021-02-18 03:48:07 +09:00
Yu Watanabe
5380707aba network: use in_addr_prefix_to_string() 2021-02-18 03:48:07 +09:00
Yu Watanabe
94876904bb tree-wide: use in_addr_is_set() or friends 2021-02-18 03:48:07 +09:00
Benjamin Robin
0979e4adb5 libsystemd-network: use -EINVAL for _DUID_TYPE_INVALID
Follow-up of #11484
2021-02-16 23:40:30 +01:00
Zbigniew Jędrzejewski-Szmek
75db809ae5 tree-wide: return NULL from freeing functions
I started working on this because I wanted to change how
DEFINE_TRIVIAL_CLEANUP_FUNC is defined. Even independently of that change, it's
nice to make make things more consistent and predictable.
2021-02-16 17:15:10 +01:00
Zbigniew Jędrzejewski-Szmek
2d93c20e5f tree-wide: use -EINVAL for enum invalid values
As suggested in https://github.com/systemd/systemd/pull/11484#issuecomment-775288617.

This does not touch anything exposed in src/systemd. Changing the defines there
would be a compatibility break.

Note that tests are broken after this commit. They will be fixed in the next one.
2021-02-10 14:46:59 +01:00
Zbigniew Jędrzejewski-Szmek
ea3640ac96
Merge pull request #18320 from yuwata/network-reduce-trigger-network-events
network: do not trigger unnecessary network events
2021-01-30 15:30:17 +01:00
Susant Sahani
fe96c0f86d
treewide: tighten variable scope in loops (#18372)
Also use _cleanup_free_ in one more place.
2021-01-27 08:19:39 +01:00
Yu Watanabe
abcf60e730 dhcp: use conservative_rename() 2021-01-22 12:55:54 +09:00
Yu Watanabe
7e2757c42f
Merge pull request #18038 from yuwata/meson-split
meson: various cleanups
2021-01-19 12:22:34 +09:00
Yu Watanabe
e025c9dfe3 meson: move test or fuzzer definitions to relevant meson.build in subdirectories 2021-01-19 07:06:32 +09:00
Yu Watanabe
8d40961c3c meson: slightly disentangle code dependencies
But, still sd-id128 is used in src/basic.
2021-01-19 07:06:32 +09:00
Yu Watanabe
09f7c7c668 fuzzers: move several fuzzers 2021-01-19 07:04:19 +09:00
Susant Sahani
02288f3ef8 network: sd-dhcp6-client - use ordered_hashmap_ensure_put 2021-01-18 21:53:19 +01:00
Susant Sahani
ebffea2a25
network: Use ordered_hashmap_ensure_put (#18233) 2021-01-17 20:07:02 +09:00
Yu Watanabe
019951ec97 dhcp6: refuse zero length vendor class
Also, fixes the maximum length of the vendor class to UINT16_MAX.
Moreover, a memory leak in sd_dhcp6_client_set_request_vendor_class().
2021-01-13 00:07:33 +09:00
Yu Watanabe
361eb4125d dhcp6: add an assert() 2021-01-13 00:00:56 +09:00
Yu Watanabe
8b6ea477a7 dhcp: do not assign value twice 2021-01-13 00:00:56 +09:00
Yu Watanabe
5a99444e4f dhcp6: refuse zero length dhcp user class
This also fixes a memory leak when
sd_dhcp6_client_set_request_user_class() is called multiple times.
2021-01-13 00:00:56 +09:00
Yu Watanabe
e4336c0a5d dhcp: length of each user class field must be positive
This also fixes an memory leak when sd_dhcp_client_set_user_class()
is called multiple times.
2021-01-13 00:00:56 +09:00
Thomas Haller
1835a8a105 sd-dhcp-client: avoid "maybe-uninitialized" warning in client_timeout_resend()
When compiling with CFLAGS='-Werror=maybe-uninitialized -Og' we get a
warning about uninitialized "next_timeout" variable.

Avoid the warning by adding an (unreachable) "default" label.

Fixes: c24288d21e ("sd-dhcp-client: correct dhcpv4 renew/rebind retransmit timeouts")
2020-12-26 09:01:01 +09:00
Yu Watanabe
0afa4d569d sd-ndisc: fix indentation 2020-12-24 17:15:44 +09:00
Dan Streetman
8bc63a0b13 sd-dhcp-client: fix renew/rebind timeout calculation to avoid infinite loop
unfortunately I missed adding the timeout to 'now' which results in
an endless loop of renewal timeouts.

Fixes: 3a23834d6b
2020-12-16 19:49:31 +09:00
Lennart Poettering
94b78105c6
Merge pull request #17967 from poettering/connect-user-bus
add support for "systemctl --user --machine=foobar@.host" for connecting to user bus of user "foobar"
2020-12-15 21:14:01 +01:00
Lennart Poettering
52ef5dd798 hostname-util: flagsify hostname_is_valid(), drop machine_name_is_valid()
Let's clean up hostname_is_valid() a bit: let's turn the second boolean
argument into a more explanatory flags field, and add a flag that
accepts the special name ".host" as valid. This is useful for the
container logic, where the special hostname ".host" refers to the "root
container", i.e. the host system itself, and can be specified at various
places.

let's also get rid of machine_name_is_valid(). It was just an alias,
which is confusing and even more so now that we have the flags param.
2020-12-15 17:59:48 +01:00
Dan Streetman
f3808b872f sd-dhcp-client: correct retransmission timeout to match RFC
This changes the retransmission timeout algorithm for requests
other than RENEW and REBIND. Previously, the retransmission timeout
started at 2 seconds, then doubling each retransmission up to a max
of 64 seconds. This is changed to match what RFC2131 section 4.1 describes,
which skips the initial 2 second timeout and starts with a 4 second timeout
instead. Note that -1 to +1 seconds of random 'fuzz' is added to each
timeout, in previous and current behavior.

This change is therefore slightly slower than the previous behavior in
attempting retransmissions when no server response is received, since the
first transmission times out in 4 seconds instead of 2.

Since TRANSIENT_FAILURE_ATTEMPTS is set to 3, the previous length of time
before a transient failure was reported back to systemd-networkd was
2 + 4 + 8 = 14 seconds, plus, on average, 3 seconds of random 'fuzz' for
a transient failure timeout between 11 and 17 seconds. Now, since the
first timeout starts at 4, the transient failure will be reported at
4 + 8 + 16 = 28 seconds, again plus 3 random seconds for a transient
failure timeout between 25 and 31 seconds.

Additionally, if MaxAttempts= is set, it will take slightly longer to
reach than with previous behavior.
2020-12-14 18:19:29 -05:00
Dan Streetman
c24288d21e sd-dhcp-client: correct dhcpv4 renew/rebind retransmit timeouts
Use the request timeout algorithm specified in RFC2131 section 4.4.5 for
handling timed out RENEW and REBIND requests.

This changes behavior, as previously only 2 RENEW and 2 REBIND requests
were sent, no matter how long the lease lifetime. Now, requests are
send according to the RFC, which results in starting with a timeout
of 1/2 the t1 or t2 period, and halving the timeout for each retry
down to a minimum of 60 seconds.

Fixes: #17909
2020-12-14 18:19:22 -05:00
Dan Streetman
b0d7d8063c sd-dhcp-client: simplify dhcp4 t1/t2 parsing
The parsing of the dhcpv4 lease lifetime, as well as the t1/t2
times, is simplified by this commit.

This differs from previous behavior; previously, the lease lifetime and
t1/t2 values were modified by random 'fuzz' by subtracting 3, then adding
a random number between 0 and (slightly over) 2 seconds. The resulting
values were therefore always between 1-3 seconds shorter than the value
provided by the server (or the default, in case of t1/t2). Now, as
described in RFC2131, the random 'fuzz' is between -1 and +1 seconds,
meaning the actual t1 and t2 value will be up to 1 second earlier or
later than the server-provided (or default) t1/t2 value.

This also differs in handling the lease lifetime, as described above it
previously was adjusted by the random 'fuzz', but the RFC does not state
that the lease expiration time should be adjusted, so now the code uses
exactly the lease lifetime as provided by the server with no adjustment.
2020-12-14 18:19:07 -05:00
Dan Streetman
3d75a443ee sd-dhcp-client: add RFC2131 retransmission details
RFC2131, providing the details for dhcpv4, has specific retransmission
intervals that it outlines. This adds functions to compute the timeouts
as the RFC describes.
2020-12-14 18:19:01 -05:00
Dan Streetman
0c3c59783b sd-dhcp-client: track dhcp4 t1, t2, expire times
Add fields to dhcp4 client to track t1, t2, and lease expiry times
2020-12-14 17:39:26 -05:00
Dan Streetman
f3bd46c657 sd-dhcp-client: don't log timeouts if already expired 2020-12-14 17:39:26 -05:00
Yu Watanabe
878c035a48 sd-ipv4acd: logs current state 2020-12-02 18:42:17 +09:00
Yu Watanabe
3f2c0d8520 sd-ipv4acd,sd-ipv4ll: include interface name in the debug logs 2020-12-02 18:42:13 +09:00
Yu Watanabe
99b06a2f5c sd-ipv4acd,sd-ipv4ll: introduce _get_ifindex() and _get_ifname()
They will be used in later commits.

This also makes sd_ipv4acd_set_ifindex() check the existence of the interface.
2020-12-02 18:40:24 +09:00
Zbigniew Jędrzejewski-Szmek
fb536bc5da sd-dhcp-client: report transient DHCP failure to the caller
So far we only reported major state transitions like failure to acquire
the message. Let's report the initial failure after a few timeouts in
a new event type.

The number of timeouts is hardcoded as 3, since Windows seems to be using
that. I don't think we need to make this configurable out of the box. A
reasonable default may be enough.
2020-11-30 12:37:36 +09:00
Zbigniew Jędrzejewski-Szmek
e4dc0845bc sd-dhcp-client: minor simplification 2020-11-30 12:37:36 +09:00
Yu Watanabe
0d5eb02134
Merge pull request #17478 from yuwata/split-network-internal
libsystemd-network: split network-internal.c
2020-11-27 09:04:19 +09:00
Jörg Thalheim
1d370b2c18 networkd/dhcp6: allow layer3 devices without MAC
Devices with multicast but without mac addresses i.e. tun devices
are not getting setuped correctly:

$ ip tuntap add mode tun dev tun0
$ ip addr show tun0
16: tun0: <NO-CARRIER,POINTOPOINT,MULTICAST,NOARP,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 500
    link/none
$ cat /etc/systemd/network/tun0.network
[Match]
Name = tun0

[Network]
Address=192.168.1.1/32
$ ./systemd-networkd
tun0: DHCP6 CLIENT: Failed to set identifier: Invalid argument
tun0: Failed
2020-11-23 13:56:48 +01:00
Yu Watanabe
787dd704e1 sd-dhcp6-client: insert spaces around ternary operator 2020-11-16 18:59:28 +09:00
Zbigniew Jędrzejewski-Szmek
b5c474f69b libsystemd-network: add comment explaining unusual memory access
Inspired by coverity CID#1435984. I'm confused by the union definion every time I look at it...
Let's at least add a comment to help future readers.
2020-11-10 15:52:32 +01:00
Yu Watanabe
dd1b187075 sd-radv: refuse to set preference except medium when router lifetime is zero 2020-11-10 00:04:52 +09:00
Yu Watanabe
ac138551ce sd-radv: router lifetime is uint16_t 2020-11-10 00:04:52 +09:00
Yu Watanabe
db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Zbigniew Jędrzejewski-Szmek
58f848148f
Merge pull request #17444 from BtbN/fix_ib_dhcp4
networkd: fix DHCP on InfiniBand interfaces
2020-10-29 19:27:29 +01:00
Zbigniew Jędrzejewski-Szmek
4368277c74 tree-wide: use the usual SPDX header for our own files 2020-10-29 10:47:20 +01:00
Yu Watanabe
26f4d32365 meson: drop libsystemd_network from several binaries
This reduces the size of udevadm:

Before:
```
$ ll udevadm
-rwxrwxr-x 1 watanabe watanabe 1203800 Oct 29 01:36 udevadm
```

After:
```
$ ll udevadm
-rwxrwxr-x 1 watanabe watanabe 1094384 Oct 29 01:38 udevadm
```
2020-10-29 14:23:49 +09:00
Yu Watanabe
01ab92af71 tree-wide: drop unnecessary inclusion of network-internal.h 2020-10-29 14:23:49 +09:00
Yu Watanabe
dc7f6c9b94 sd-network: move net_get_unique_predictable_data() and net_get_name_persisten() 2020-10-29 14:23:49 +09:00
Yu Watanabe
7e19cc5462 net-condition: move net_match_config() and related conf parsers 2020-10-29 14:23:49 +09:00
Yu Watanabe
1929ed0e58 sd-network: move link_get_type_string() 2020-10-29 14:23:49 +09:00
Yu Watanabe
0ec2a7a125 libsystemd-network: move config_parse_hwaddr() and config_parse_hwaddrs() 2020-10-29 14:23:49 +09:00
Yu Watanabe
fc27088ae7 udev: move config_parse_ifalias() 2020-10-29 14:23:49 +09:00
Yu Watanabe
796aa313b3 network: move config_parse_bridge_port_priority() 2020-10-29 14:23:49 +09:00
Yu Watanabe
6a74900002 libsystemd-network: make conf parsers accept an empty string 2020-10-29 14:23:49 +09:00
Yu Watanabe
7e7aa4e811 libsystemd-network: downgrade log level in conf parsers 2020-10-29 14:23:49 +09:00
Timo Rothenpieler
14b66dbc92 dhcp4: fix DHCP on InfiniBand interfaces
With these patches applied, networkd is successfully able to get an
address from a DHCP server on an IPoIB interface.

1)
Makes networkd pass the actual interface type to the dhcp client,
instead of hardcoding it to Ethernet.

2)
Fixes some issues in handling the larger (20 Byte) IB MAC addresses in
the dhcp code.

3)
Add a new field to networkds Link struct, which holds the interface
broadcast address.

3.1)
Modify the DHCP code to also expect the broadcast address as parameter.
On an Ethernet-Interface the Broadcast address never changes and is always
all 6 bytes set to 0xFF.
On an IB one however it is not neccesarily always the same, thus
fetching the actual address from the interface is neccesary.

4)
Only the last 8 bytes of an IB MAC are stable, so when using an IB MAC to
generate a client ID, only pass those 8 bytes.
2020-10-28 14:44:43 +01:00
Yu Watanabe
5a8775bb39 Revert "sd-dhcp-client: use asynchronous_close()"
This effectively reverts the commit 22fc2420b2.

The function `asynchronous_close()` confuses valgrind. Before this commit,
valgrind may report the following:

```
HEAP SUMMARY:
    in use at exit: 384 bytes in 1 blocks
  total heap usage: 4,787 allocs, 4,786 frees, 1,379,191 bytes allocated

384 bytes in 1 blocks are possibly lost in loss record 1 of 1
   at 0x483CAE9: calloc (vg_replace_malloc.c:760)
   by 0x401456A: _dl_allocate_tls (in /usr/lib64/ld-2.31.so)
   by 0x4BD212E: pthread_create@@GLIBC_2.2.5 (in /usr/lib64/libpthread-2.31.so)
   by 0x499B662: asynchronous_job (async.c:47)
   by 0x499B7DC: asynchronous_close (async.c:102)
   by 0x4CFA8B: client_initialize (sd-dhcp-client.c:696)
   by 0x4CFC5E: client_stop (sd-dhcp-client.c:725)
   by 0x4D4589: sd_dhcp_client_stop (sd-dhcp-client.c:2134)
   by 0x493C2F: link_stop_clients (networkd-link.c:620)
   by 0x4126DB: manager_free (networkd-manager.c:867)
   by 0x40D193: manager_freep (networkd-manager.h:97)
   by 0x40DAFC: run (networkd.c:20)

LEAK SUMMARY:
   definitely lost: 0 bytes in 0 blocks
   indirectly lost: 0 bytes in 0 blocks
     possibly lost: 384 bytes in 1 blocks
   still reachable: 0 bytes in 0 blocks
        suppressed: 0 bytes in 0 blocks

For lists of detected and suppressed errors, rerun with: -s
ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
```
2020-10-24 13:27:37 +02:00
Lennart Poettering
69f30d4321
Merge pull request #17356 from yuwata/sd-xxx-stop
network: about sd_xxx_stop()
2020-10-21 18:07:38 +02:00
Lennart Poettering
141261f127 dhcp-server: make parameter const 2020-10-21 15:02:16 +09:00
Yu Watanabe
c8bae36372 libsystemd-network: do not request each daemon exist in sd_xxx_stop() 2020-10-15 07:24:17 +09:00
Yu Watanabe
4081756a63 sd-dhcp-client: make sd_dhcp_client_set_request_option() not return -EEXIST
Fixes #16964.
2020-10-14 12:54:55 +09:00
Frantisek Sumsal
d46b79bbe0 tree-wide: drop if braces around single line expressions as well 2020-10-09 15:11:55 +02:00
Frantisek Sumsal
d7a0f1f4f9 tree-wide: assorted coccinelle fixes 2020-10-09 15:02:23 +02:00
Frantisek Sumsal
1d6cc5d0e5 tree-wide: coccinelle fixes 2020-10-04 12:32:21 +02:00
mog422
26a63b8132
sd-dhcp6-client: Fix sending prefix delegation request (#17136)
SD_DHCP6_OPTION_IA_NA does not exist in DHCP6_ADVERTISE packet if DHCP server only provides prefix delegation. So the attempt to send the DHCP6_REQUEST packet fails on r = dhcp6_option_append_ia(&opt, &optlen, &client->lease->ia); forever.
2020-09-24 17:04:52 +02:00
Lennart Poettering
bcaf20dc38
Merge pull request #17143 from keszybz/late-exec-resolution-alt
Late exec resolution (subset)
2020-09-24 09:38:36 +02:00
Lennart Poettering
6333aa9d46 sd-radv: fix indentation
Fix-up for 97efde65d8
2020-09-23 13:44:26 +02:00
Zbigniew Jędrzejewski-Szmek
afa8ffae99 various: remove assignments of unread variables 2020-09-22 17:58:11 +02:00
Zbigniew Jędrzejewski-Szmek
0706c01259 Add CLOSE_AND_REPLACE helper
Similar to free_and_replace. I think this should be uppercase to make it
clear that this is a macro. free_and_replace should probably be uppercased
too.
2020-09-18 15:28:48 +02:00
Lennart Poettering
40eb1b0ae8 tree-wide: prefer AF_xyz over PF_xyz
This really doesn't matter given that AF_xyz and PF_xyz are equivalent
in all ways, but we almost always use AF_xyz, hence stick to it
universally and convert the remaining PF_ to AF_
2020-09-09 23:42:55 +02:00
Zbigniew Jędrzejewski-Szmek
90e74a66e6 tree-wide: define iterator inside of the macro 2020-09-08 12:14:05 +02:00
Yu Watanabe
4dd6a3aad5 sd-ipv4acd: introduce sd_ipv4acd_get_address() 2020-09-04 09:05:45 +09:00
Yu Watanabe
6a776e3a18 sd-ipv4acd: do not call callback in sd_ipv4acd_stop() when it is already stopped 2020-09-04 09:04:43 +09:00
fangxiuning
6d95e7d9b2
tree-wide: drop pointless zero initialization (#16900) 2020-08-30 06:21:20 +09:00
Zbigniew Jędrzejewski-Szmek
d06bd2e785 Merge pull request #16596 from poettering/event-time-rel
Conflict in src/libsystemd-network/test-ndisc-rs.c fixed manually.
2020-08-04 16:07:03 +02:00
Zbigniew Jędrzejewski-Szmek
c9fecf18b9
Merge pull request #16595 from bengal/bg/dhcpv6-fqdn
dhcp6: parse the FQDN option
2020-08-03 15:17:00 +02:00
Beniamino Galvani
c43eea9f2e dhcp6: parse the FQDN option
Parse option 39 (Client Fully Qualified Domain Name, RFC 4704) from the DHCP
reply, which specifies the FQDN assigned by the server to the client.
2020-08-03 09:36:18 +02:00
Lennart Poettering
ee56c072b9
Merge pull request #16590 from keszybz/test-fs-util-relax
Small adjustements to let various tests pass in overloaded Fedora infra and related changes
2020-07-29 15:54:51 +02:00
Lennart Poettering
39cf0351c5 tree-wide: make use of new relative time events in sd-event.h 2020-07-28 11:24:55 +02:00
Zbigniew Jędrzejewski-Szmek
c21ed6812e test-ndisc-rs: increase timeouts
Timestamp: Mon 2020-07-27 13:50:50 UTC
Monotonic: 985702942708
Hop limit: 64
Flags: <|MANAGED>
Preference: medium
Lifetime: 180
No MTU set
>> Option 3
Valid Lifetime: 500
Preferred Lifetime: 440
Flags: <ONLINK|AUTO>
Prefix Length: 64
Prefix: 2001:db8:dead:beef::
>> Option 25
DNS: 2001:db8:dead:beef::1
Lifetime: 60
>> Option 31
Domain: lab.intra
Lifetime: 60
>> Option 1
Address: 782bcbb36d53
NDISC: Started IPv6 Router Solicitation client
backoff timeout interval  1 3.600s <= 3.987s <= 4.400s
NDISC: Sent Router Solicitation, next solicitation in 3s
backoff timeout interval  2 7.576s <= 8.114s <= 8.374s
NDISC: Sent Router Solicitation, next solicitation in 8s
Assertion 'false' failed at src/libsystemd-network/test-ndisc-rs.c:172, function test_rs_hangcheck(). Aborting.
2020-07-28 10:49:13 +02:00
Beniamino Galvani
af710b535b dhcp6: remove assertions in dhcp6_option_parse_domainname()
Assertions are for programming errors; here the input comes directly
from the DHCP response packet.
2020-07-28 09:09:28 +02:00
Michael Marley
97efde65d8 network: radv: Send RA on newly-added dynamic prefix
When a prefix is delegated to an interface that is already sending
RAs, send an RA immediately to inform clients of the new prefix.
This allows them to start using it immediately instead of waiting
up to nearly 10 minutes (depending on when the last timed RA was
sent).  This type of situation might occur if, for example, an
outage of the WAN connection caused the addresses and prefixes to
be lost and later regained after service was restored.  The
condition for the number of RAs sent being above 0 simultaneously
ensures that RADV is already running and that this code doesn't
send any RAs before the timed RAs have started when the interface
first comes up.
2020-07-27 05:28:33 +09:00
Yu Watanabe
96fe813c42 radv: introduce sd_radv_is_running() 2020-07-20 15:29:12 +09:00
Yu Watanabe
0ded0e40ab dhcp4: only renewing lease when the client already has a lease
Follow-up for ceaec54a3c.

Hopefully fixes #16299.
2020-07-16 14:58:54 +09:00
Yuri Chornoivan
d7b34e3841 all: fix minor typos
[thaller@redhat.com: original patch by Yuri, extracted from [1]]

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/565
2020-07-07 18:52:49 +09:00
Yu Watanabe
921693a0f3 dhcp4: do not try to renew address when client has no lease 2020-07-07 10:18:58 +09:00
Yu Watanabe
ceaec54a3c dhcp4: do not renew address if client is not running yet 2020-07-07 10:18:22 +09:00
Yu Watanabe
1a6c913676 libsystemd-network: rename index -> ifindex 2020-07-02 16:58:06 +09:00
Yu Watanabe
7fa69c0a6f dhcp6, radv: only accept valid ifindex 2020-07-02 16:58:06 +09:00
Yu Watanabe
fd1f3b3eed dhcp: fix entry name in parsing lease file 2020-06-23 19:13:06 +09:00
Yu Watanabe
ef0daa1129 libsystemd-network: move prototypes of dhcp_lese_save/load() to network-internal.h 2020-06-23 19:13:05 +09:00
Susant Sahani
6b7d5b6eaf network: DHCP6 - introduce DHCP6 DUID to string 2020-06-10 19:17:28 +02:00
Susant Sahani
d69d4038ec dhcp6: Provide method to access IAID 2020-06-09 19:57:38 +09:00
Thomas Haller
9141594cae lldp: fix assertion checking argument for sd_lldp_set_neighbors_max()
Fixes: 34437b4f9c ('sd-lldp: rework sd-lldp API')
2020-06-06 10:38:50 +02:00
Marc-André Lureau
7be3261222 sd-dhcp-client: add sd_dhcp_client_id_to_string()
Add a human-friendly pretty-printer for client ID.
2020-06-04 11:16:15 +02:00
Marc-André Lureau
00ebe01156 sd-dhcp-client: make struct sd_dhcp_client_id reusable 2020-06-04 11:16:15 +02:00
Marc-André Lureau
36d35f2259 sd-dhcp-server: notify callback on lease changed 2020-06-04 11:16:15 +02:00
Marc-André Lureau
5b03043a75 sd-dhcp-server: add sd_dhcp_server_set_callback() 2020-06-04 11:04:06 +02:00
Yu Watanabe
c643bda5ec network: read driver name from ethtool
To make Driver= in [Match] section work in containers.

Note that ID_NET_DRIVER= property in udev database is set with the
result of the ethtool. So, this should not change anything for
non-container cases.

Closes #15678.
2020-06-03 18:25:37 +02:00
Yu Watanabe
f3e4b1e07c
Merge pull request #15884 from ssahani/dhcpv6-vendor
DHCPv6: Introduce vendor specific
2020-06-01 12:25:54 +09:00
Lennart Poettering
ddb82ec2a2 sd-dhcp: clean-up of DHCP lease server code
This is an attempt to clean-up the DHCP lease server type code a bit. We
now strictly use the same enum everywhere, and store server info in an
array. Moreover, we use the same nomenclature everywhere.

This only makes the changes in the sd-dhcp code. The networkd code is
untouched so far (but should be fixed up like this too. But it's more
complicated since this would then touch actual settings in .network
files).

Note that this also changes some field names in serialized lease files.
But given that these field names have not been part of a released
version of systemd yet, such a change should be ok.

This is pure renaming/refactoring, shouldn't actually change any
behaviour.
2020-05-30 14:18:43 +02:00
Susant Sahani
99ccb8ff89 sd-dhcp6: Introduce vendor specific information
RFC: 8415
21.17.  Vendor-specific Information Option

   This option is used by clients and servers to exchange vendor-
   specific information.

   The format of the Vendor-specific Information option is:

       0                   1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |      OPTION_VENDOR_OPTS       |           option-len          |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |                       enterprise-number                       |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      .                                                               .
      .                       vendor-option-data                      .
      .                                                               .
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

           Figure 30: Vendor-specific Information Option Format

      option-code          OPTION_VENDOR_OPTS (17).

      option-len           4 + length of vendor-option-data field.

      enterprise-number    The vendor's registered Enterprise Number as
                           maintained by IANA [IANA-PEN].  A 4-octet
                           field containing an unsigned integer.

      vendor-option-data   Vendor options, interpreted by
                           vendor-specific code on the clients and
                           servers.  A variable-length field (4 octets
                           less than the value in the option-len field).

 The definition of the information carried in this option is vendor
   specific.  The vendor is indicated in the enterprise-number field.
   Use of vendor-specific information allows enhanced operation,
   utilizing additional features in a vendor's DHCP implementation.  A
   DHCP client that does not receive requested vendor-specific
   information will still configure the node's IPv6 stack to be
   functional.

   The vendor-option-data field MUST be encoded as a sequence of
   code/length/value fields of format identical to the DHCP options (see
   Section 21.1).  The sub-option codes are defined by the vendor
   identified in the enterprise-number field and are not managed by
   IANA.  Each of the sub-options is formatted as follows:

       0                   1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |          sub-opt-code         |         sub-option-len        |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      .                                                               .
      .                        sub-option-data                        .
      .                                                               .
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                 Figure 31: Vendor-specific Options Format

      sub-opt-code         The code for the sub-option.  A 2-octet
                           field.

      sub-option-len       An unsigned integer giving the length of the
                           sub-option-data field in this sub-option in
                           octets.  A 2-octet field.

      sub-option-data      The data area for the sub-option.  The
                           length, in octets, is specified by
                           sub-option-len.

   Multiple instances of the Vendor-specific Information option may
   appear in a DHCP message.  Each instance of the option is interpreted
   according to the option codes defined by the vendor identified by the
   Enterprise Number in that option.  Servers and clients MUST NOT send
   more than one instance of the Vendor-specific Information option with
   the same Enterprise Number.  Each instance of the Vendor-specific
   Information option MAY contain multiple sub-options.

A client that is interested in receiving a Vendor-specific
   Information option:

   -  MUST specify the Vendor-specific Information option in an Option
      Request option.

   -  MAY specify an associated Vendor Class option (see Section 21.16).

   -  MAY specify the Vendor-specific Information option with
      appropriate data.

   Servers only return the Vendor-specific Information options if
   specified in Option Request options from clients and:

   -  MAY use the Enterprise Numbers in the associated Vendor Class
      options to restrict the set of Enterprise Numbers in the
      Vendor-specific Information options returned.

   -  MAY return all configured Vendor-specific Information options.

   -  MAY use other information in the packet or in its configuration to
      determine which set of Enterprise Numbers in the Vendor-specific
      Information options to return.
2020-05-29 13:36:42 +02:00
Susant Sahani
5c95a9134a sd-network: Rectify Advertise Message Processing by a Client
We need to fix RCC 2215 behaviour with rfc7550 errata
and https://tools.ietf.org/html/rfc8415.

[RFC3315] specifies that a client must ignore an Advertise message if
   a server will not assign any addresses to a client, and [RFC3633]
   specifies that a client must ignore an Advertise message if a server
   returns the NoPrefixAvail status to a requesting router.  Thus, a
   client requesting both IA_NA and IA_PD, with a server that only
   offers either addresses or delegated prefixes, is not supported by
   the current protocol specifications.

   Solution: a client SHOULD accept Advertise messages, even when not
   all IA option types are being offered.  And, in this case, the client
   SHOULD include the not offered IA option types in its Request.  A
   client SHOULD only ignore an Advertise message when none of the
   requested IA options include offered addresses or delegated prefixes.
   Note that ignored messages MUST still be processed for SOL_MAX_RT and
   INF_MAX_RT options as specified in [RFC7083].

   Replace Section 17.1.3 of RFC 3315: (existing errata)

     The client MUST ignore any Advertise message that includes a Status
     Code option containing the value NoAddrsAvail, with the exception
     that the client MAY display the associated status message(s) to the
     user.

   With the following text (which addresses the existing erratum
   [Err2471] and includes the changes made by [RFC7083]):

     The client MUST ignore any Advertise message that contains no
     addresses (IAADDR options encapsulated in IA_NA or IA_TA options)
     and no delegated prefixes (IAPREFIX options encapsulated in IA_PD
     options; see RFC 3633) with the exception that the client:

       - MUST process an included SOL_MAX_RT option (RFC 7083) and
       - MUST process an included INF_MAX_RT option (RFC 7083).

     A client can display any associated status message(s) to the user
     or activity log.

     The client ignoring this Advertise message MUST NOT restart the
     Solicit retransmission timer.
2020-05-29 16:17:36 +09:00
Yu Watanabe
63b00fa77d
Merge pull request #15619 from ddstreet/ignore_carrier_loss_default
Set IgnoreCarrierLoss= default to value of ConfigureWithoutCarrier=
2020-05-29 10:04:00 +09:00
Dan Streetman
6b8a1aa6a3 network: return 1 on start and 0 if ipv4ll is already started
Instead of -EBUSY, return 0 from sd_ipv4ll_start() if it's already started,
and change successful start return value to 1.

This matches sd_ndisc_start() behavior; 1 indicates successful start, and
0 indicates already started.
2020-05-26 09:52:50 -04:00
Zbigniew Jędrzejewski-Szmek
d8bff5cc37 network: simplify how initial space is handled 2020-05-26 10:19:31 +02:00
Zbigniew Jędrzejewski-Szmek
00813316b0 sd-dhcp6: constify output arguments in get_{ntp,nds}_addr
This matches what we do for ipv4 and is in general better.
2020-05-26 09:47:45 +02:00
Zbigniew Jędrzejewski-Szmek
dddc8d1e1e sd-network: reduce scope of some variables 2020-05-26 09:47:45 +02:00
Zbigniew Jędrzejewski-Szmek
929d07ddcb
Merge pull request #15274 from ssahani/network-issue-9610
DHCP4: Allow lease time to be set when missing from offer
2020-05-20 16:39:41 +02:00
Lennart Poettering
400530c1e2
Merge pull request #15490 from ssahani/dhcpv6-vendor-class
network: DHCPv6 - Add support to send vendor class information
2020-05-20 16:18:18 +02:00
Susant Sahani
579ca0a2b2 sd-network: DHCPv4 - Add user class, extra option and send generic options in request state 2020-05-20 15:43:20 +02:00
Susant Sahani
2d3adfa6c4 DHCPv6: MUD URL lengh - use UINT8_MAX instead of 255 2020-05-20 07:59:01 +02:00
Susant Sahani
ed0d1b2e99 network: DHCPv6 - Add support to send vendor class information
Frame 1: 177 bytes on wire (1416 bits), 177 bytes captured (1416 bits) on interface veth-peer, id 0
Ethernet II, Src: 1e:04:f8:b8:2f:d4 (1e:04:f8:b8:2f:d4), Dst: IPv6mcast_01:00:02 (33:33:00:01:00:02)
Internet Protocol Version 6, Src: fe80::1c04:f8ff:feb8:2fd4, Dst: ff02::1:2
User Datagram Protocol, Src Port: 546, Dst Port: 547
DHCPv6
    Message type: Solicit (1)
    Transaction ID: 0x5ca46b
    Rapid Commit
    Identity Association for Non-temporary Address
    Fully Qualified Domain Name
    Vendor Class
        Option: Vendor Class (16)
        Length: 23
        Value: 0000ab11000048656c6c6f3a686f773a6172653a796f75
        Enterprise ID: Tom Gundersen (systemd) (43793)
        vendor-class-data: Hello:how:are:you
    Identity Association for Prefix Delegation
    Option Request
    Client Identifier
    Elapsed time
2020-05-20 07:58:03 +02:00
Susant Sahani
73c8ced784 sd-network: DHCPv6 - Add support to send vendor class data
```
21.16.  Vendor Class Option

   This option is used by a client to identify the vendor that
   manufactured the hardware on which the client is running.  The
   information contained in the data area of this option is contained in
   one or more opaque fields that identify details of the hardware
   configuration.  The format of the Vendor Class option is:

       0                   1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |      OPTION_VENDOR_CLASS      |           option-len          |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |                       enterprise-number                       |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      .                                                               .
      .                       vendor-class-data                       .
      .                             . . .                             .
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                   Figure 28: Vendor Class Option Format

      option-code          OPTION_VENDOR_CLASS (16).

      option-len           4 + length of vendor-class-data field.

      enterprise-number    The vendor's registered Enterprise Number as
                           maintained by IANA [IANA-PEN].  A 4-octet
                           field containing an unsigned integer.

      vendor-class-data    The hardware configuration of the node on
                           which the client is running.  A
                           variable-length field (4 octets less than the
                           value in the option-len field).

   The vendor-class-data field is composed of a series of separate
   items, each of which describes some characteristic of the client's
   hardware configuration.  Examples of vendor-class-data instances
   might include the version of the operating system the client is
   running or the amount of memory installed on the client.

   Each instance of vendor-class-data is formatted as follows:

      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...-+-+-+-+-+-+-+
      |       vendor-class-len        |          opaque-data          |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...-+-+-+-+-+-+-+

               Figure 29: Format of vendor-class-data Field

   The vendor-class-len field is 2 octets long and specifies the length
   of the opaque vendor-class-data in network byte order.

   Servers and clients MUST NOT include more than one instance of
   OPTION_VENDOR_CLASS with the same Enterprise Number.  Each instance
   of OPTION_VENDOR_CLASS can carry multiple vendor-class-data
   instances.
   ```
2020-05-20 07:52:19 +02:00
Susant Sahani
4c0b8d563d sd-dhcpv4: Allow to configure lease lifetime 2020-05-20 06:30:05 +02:00
Susant Sahani
3392392518 sd-network: DHCPv6 - add support to send userclass option
sd-network: DHCPv6 - add support to send userclass option

21.15.  User Class Option

   The User Class option is used by a client to identify the type or
   category of users or applications it represents.

   The format of the User Class option is:

       0                   1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |       OPTION_USER_CLASS       |          option-len           |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      .                                                               .
      .                          user-class-data                      .
      .                                                               .
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Figure 26: User Class Option Format

      option-code          OPTION_USER_CLASS (15).

      option-len           Length of user-class-data field.

      user-class-data      The user classes carried by the client.  The
                           length, in octets, is specified by
                           option-len.

The information contained in the data area of this option is
   contained in one or more opaque fields that represent the user class
   or classes of which the client is a member.  A server selects
   configuration information for the client based on the classes
   identified in this option.  For example, the User Class option can be
   used to configure all clients of people in the accounting department
   with a different printer than clients of people in the marketing
   department.  The user class information carried in this option MUST
   be configurable on the client.

   The data area of the User Class option MUST contain one or more
   instances of user-class-data information.  Each instance of
   user-class-data is formatted as follows:

      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...-+-+-+-+-+-+-+
      |        user-class-len         |          opaque-data          |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...-+-+-+-+-+-+-+

                Figure 27: Format of user-class-data Field
2020-05-19 11:44:51 +02:00
Lennart Poettering
01bcea4999 dhcp6: slightly improve log message
Let's clarify that we proceed anyway.

Prompted-by: #15830
2020-05-19 08:25:43 +02:00
Susant Sahani
28a060688f dhcpv6 tests: Update since we allow arbitrary options to be set 2020-05-17 11:18:46 +02:00
Susant Sahani
2b20ca653c sd-dhcp6: Allow to add arbitary request option 2020-05-17 10:54:43 +02:00
Lennart Poettering
90810f7a37 sd-dhcp-server: some function prototype fix-ups
Let's use size_t for numbers of entries in memory.

Let's use const wherever appropriate.

Drop `_server` suffix from function name where we don't have it for
similar other cases.
2020-05-14 17:11:44 +02:00
Benjamin Robin
243945e95e test: Add return 0 to main() function (even it is not strictly necessary) 2020-05-13 22:56:42 +02:00
Benjamin Robin
81c5a5961f network: 'cur' variable cannot be null, so simplify code 2020-05-13 22:56:42 +02:00
Andrew Doran
e7d5fe17db DHCP client: make SendOption work for DHCPv6 too. 2020-05-11 16:31:08 +02:00
Lennart Poettering
fb29cdbef2 tree-wide: make sure our control buffers are properly aligned
We always need to make them unions with a "struct cmsghdr" in them, so
that things properly aligned. Otherwise we might end up at an unaligned
address and the counting goes all wrong, possibly making the kernel
refuse our buffers.

Also, let's make sure we initialize the control buffers to zero when
sending, but leave them uninitialized when reading.

Both the alignment and the initialization thing is mentioned in the
cmsg(3) man page.
2020-05-07 14:39:44 +02:00
Lennart Poettering
a258f4915a tree-wide: use CMSG_SPACE() (and not CMSG_LEN()) to allocate control buffers
We need to use the CMSG_SPACE() macro to size the control buffers, not
CMSG_LEN(). The former is rounded up to next alignment boundary, the
latter is not. The former should be used for allocations, the latter for
encoding how much of it is actually initialized. See cmsg(3) man page
for details about this.

Given how confusing this is, I guess we don't have to be too ashamed
here, in most cases we actually did get this right.
2020-05-07 14:39:44 +02:00
Thomas Haller
feb7d7a212 dhcp6: make string argument to sd_dhcp6_client_set_request_mud_url() const 2020-04-24 10:13:33 +02:00
Zbigniew Jędrzejewski-Szmek
11f9379866
Merge pull request #15570 from poettering/cmsg-find
CMSG_FIND_DATA() and cmsg_find() work
2020-04-24 07:45:07 +02:00
Lennart Poettering
2efa5bc6fa dhcp-server: port to recvmsg_safe()
Split out of #15457, let's see if this is the culprit of the CI failure.
2020-04-24 07:43:42 +02:00
Lennart Poettering
2adfd1bda1 icmp6-util: port to recvmsg_safe()
Split out of #15457, let's see if this is the culprit of the CI failure.
2020-04-24 07:41:32 +02:00
Lennart Poettering
84b5d3e532 dhcp-client: port to recvmsg_safe()
Split out of #15457, let's see if this is the culprit of the CI failure.

(also setting green label here, since @keszybz already greenlit it in that other PR)
2020-04-24 07:40:32 +02:00
Lennart Poettering
dac556fa7b tree-wide: use cmsg_find() helper at various places where appropriate 2020-04-23 19:41:15 +02:00
Lennart Poettering
a9ab5cdb50
Merge pull request #15472 from keszybz/dbus-api-docs
A few more dbus api documentation updates
2020-04-23 17:01:11 +02:00
Zbigniew Jędrzejewski-Szmek
73781de41f
Merge pull request #15530 from ssahani/lpr-dhcpv4-option-9
network: add support to DHCPv4 server/client option 9 LPR
2020-04-23 09:10:14 +02:00
Susant Sahani
50018bfa84 sd-network: DHCPv4 Add support to send and receive LPR servers. 2020-04-22 14:48:11 +02:00
Frantisek Sumsal
86b52a3958 tree-wide: fix spelling errors
Based on a report from Fossies.org using Codespell.

Followup to #15436
2020-04-21 23:21:08 +02:00
Frantisek Sumsal
e4ff03935c tree-wide: formatting tweaks reported by Coccinelle 2020-04-21 23:21:04 +02:00