Yu Watanabe
f814cd80de
sd-dhcp6-client: make state transition stricter
2022-02-14 14:45:14 +09:00
Yu Watanabe
c2c878d806
sd-dhcp6-client: prohibit spurious state transition
...
Previously, `client_set_state(client, DHCP6_STATE_STOPPED)` might make
the client enter the SOLICIT state.
2022-02-14 14:45:14 +09:00
Yu Watanabe
220a88ca75
sd-dhcp6-client: disable T1 timer on T2
...
Otherwise, the client may be enter RENEW state after REBIND state.
2022-02-14 14:45:14 +09:00
Yu Watanabe
c41bdb17fc
sd-dhcp6-client: call client_notify() in client_enter_bound_state()
2022-02-14 14:45:14 +09:00
Yu Watanabe
cdf3d8c584
sd-dhcp6-client: fix lifetime handling
...
This fixes the following issues:
- if T1 is finite and T2 is infinite, then the timer for T1 was not
enabled,
- after T1 and T2 are randomized, T1 may be longer than T2.
2022-02-14 14:45:07 +09:00
Yu Watanabe
1d6cb4ce2a
sd-dhcp6-client: use event_reset_time_relative()
2022-02-14 14:43:45 +09:00
Yu Watanabe
02354ee738
sd-dhcp6-client: introduce client_enter_bound_state()
...
To make client_set_state() smaller. This should not change any behavior.
2022-02-14 14:43:45 +09:00
Yu Watanabe
cc5184823f
sd-dhcp6-client: fix overflow in calculating timeout value
2022-02-14 14:43:45 +09:00
Yu Watanabe
d0875a07dd
sd-dhcp6-client: disable event source when client is stopped or freed
2022-02-14 14:43:45 +09:00
Yu Watanabe
7771233127
sd-dhcp6-client: use in6_addr_to_string()
2022-02-14 14:43:45 +09:00
Yu Watanabe
4db6334c9a
sd-dhcp6-client: stop client on error in client state transition
2022-02-14 14:43:45 +09:00
Yu Watanabe
bfa1139af4
sd-dhcp6-client: add missing one more error handling
2022-02-14 14:43:45 +09:00
Yu Watanabe
06d5e856f8
sd-dhcp6-client: rename client_start() -> client_set_state()
2022-02-14 14:43:45 +09:00
Yu Watanabe
07a3b3408b
sd-dhcp6-client: introduce client_process_*()
...
This is mostly for shortening `client_receive_message()`.
This also fixes the following:
- do not trigger SD_DHCP6_CLIENT_EVENT_INFORMATION_REQUEST notification
when non-reply message,
- add several missing error handlings caused in client_start().
2022-02-14 14:43:45 +09:00
Yu Watanabe
0123b2dbac
sd-dhcp6-client: fix possible unaligned read or write
2022-02-14 14:43:45 +09:00
Yu Watanabe
16347c15d8
sd-dhcp6-client: voidify client_reset()
2022-02-14 14:43:45 +09:00
Yu Watanabe
65ece4c85b
sd-dhcp6-client: introduce dhcp6_lease_new_from_message()
2022-02-14 14:43:45 +09:00
Yu Watanabe
c930925841
sd-dhcp6-client: use structured initializer
2022-02-14 14:43:45 +09:00
Yu Watanabe
f4fbea7a0f
sd-dhcp6-lease: unify lease lifetime calculation
2022-02-14 14:43:45 +09:00
Yu Watanabe
126277aceb
sd-dhcp6-client: always use ENODATA when a lease does not have requested data
2022-02-14 14:43:45 +09:00
Yu Watanabe
29858a0f9e
sd-dhcp6-client: unify dhcp6_option_append_{ia,pd}()
2022-02-14 14:43:45 +09:00
Yu Watanabe
877bfc78fd
sd-dhcp6-client: store PD prefix hint in ia_pd
...
And allows to specify multiple hints.
2022-02-14 14:43:45 +09:00
Yu Watanabe
e5b0b87f51
sd-dhcp6-client: introduce dhcp6_ia_free()
2022-02-14 14:43:45 +09:00
Yu Watanabe
4b0f27173c
sd-dhcp6-client: unify IA option header
...
This also fixes possible unaligned read of message.
2022-02-14 14:43:45 +09:00
Yu Watanabe
93bd7c4192
sd-dhcp6-lease: reset client or server ID when length is zero
...
Addresses https://github.com/systemd/systemd/pull/22406#issuecomment-1029391091 .
2022-02-14 14:43:45 +09:00
Yu Watanabe
049fddfa7d
sd-dhcp6-lease: convert assert_return() -> assert() in non-public functions
2022-02-14 14:43:45 +09:00
Yu Watanabe
7c999d38fa
sd-dhcp6-client: rename ia -> ia_na, pd -> ia_pd in sd_dhcp6_lease
...
The previous naming is quite misleading.
2022-02-14 14:43:45 +09:00
Yu Watanabe
43b7a412b1
sd-dhcp6-client: fix typo ia_pd -> ia_na
...
Fortunately, currently both ia_pd and ia_na in sd_dhcp6_client are
equivalent now.
2022-02-14 14:43:45 +09:00
Yu Watanabe
5e4d135c60
sd-dhcp6-client: introduce two helpers to create message
2022-02-14 14:43:45 +09:00
Yu Watanabe
6fcf356b9a
sd-dhcp6-client: trigger assertion whn invalid IA type is provided
...
If the condition hits, then it is an error in coding, instead of a user
misconfiguration or invalid receivd message.
2022-02-14 14:40:57 +09:00
Yu Watanabe
8448321571
sd-dhcp6-client: add missing address existence check
...
This adds similar check as 58da18251f .
2022-02-10 21:50:02 +09:00
Evgeny Vereshchagin
be1eae4fad
tests: also fuzz packets sent in the DHCP6_STATE_SOLICITATION state
...
With aborts enabled the fuzzer can catch issues like
https://github.com/systemd/systemd/commit/26a63b81322a3bd8b9fbd43f75897c391708de2c
Let's extend it a bit to let it cover issues like
https://github.com/systemd/systemd/pull/22406#discussion_r798932098
2022-02-05 14:50:12 +09:00
Thomas Haller
58da18251f
sd-dhcp6-client: fix sending prefix delegation request during rebind
...
Fixes an assertion failure "pd->type == SD_DHCP6_OPTION_IA_PD" in dhcp6_option_append_pd().
Something similar was done in commit 26a63b8132 ('sd-dhcp6-client: Fix
sending prefix delegation request (#17136 )'). The justification is
probably the same.
2022-02-05 14:11:33 +09:00
Evgeny Vereshchagin
697bb76589
tests: fuzz client_send_message
...
to make sure outgoing packets based on incoming packets are fine.
It's just another follow-up to
https://github.com/systemd/systemd/pull/10200 .
Better late than never :-)
2022-02-03 13:43:49 +09:00
Evgeny Vereshchagin
9216fddc5a
dhcp-identifier: always use a fixed machine-id while fuzzing
...
It's a follow-up to https://github.com/systemd/systemd/pull/10200 where
that fuzzer was introduced. At the time it was run regularly on machines
where machine-id wasn't present so it was kind of reproducible. Now
it's run on CIFuzz and CFLite using GHActions with the public OSS-Fuzz
corpora (based on that particular machine-id) so to fully utilize
those corpora it's necessary to use it always. Other than that
it makes it possible for fuzzers targeting outgoing packets
based on incoming packets like https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1795921
to get past client_parse_message on my machine :-)
2022-02-02 20:44:27 +09:00
Yu Watanabe
32f8a613c5
sd-dhcp-lease: store static routes and classless static routes in different arrays
...
When classless static routes option is provided, then static routes
option should not be used. Hence, let's not mix and store them in one
storage.
This introduce sd_dhcp_lease_get_static_routes() and
sd_dhcp_lease_get_classless_routes().
2022-02-02 10:02:44 +09:00
Yu Watanabe
6a8ab6dd1e
Merge pull request #22332 from yuwata/network-dhcp-server-dns-server-address
...
network: dhcp-server: allow to specify server address for DNS= or friends
2022-02-02 07:07:22 +09:00
Yu Watanabe
82140e956c
Merge pull request #22310 from yuwata/sd-dhcp-lease-fixes
...
sd-dhcp-lease: two fixes
2022-02-02 04:55:07 +09:00
Yu Watanabe
c0fdc91e44
sd-dhcp-server: convert null address for e.g. DNS to server address
2022-02-01 16:09:17 +09:00
Yu Watanabe
c997f51c0f
sd-dhcp-server: use free_and_replace() at one more place
2022-02-01 15:49:52 +09:00
Yu Watanabe
06cf04dff4
sd-dhcp-lease: fix memleak
...
Fixes https://github.com/systemd/systemd/pull/22294#issuecomment-1024840811 .
2022-02-01 12:23:59 +09:00
Yu Watanabe
7b86854307
sd-dhcp-lease: fix reading unaligned memory
...
The destination address was read twice, one is for prefixlen, and
other is for destination address itself. And for prefixlen, the address
might be read from unaligned buffer.
This also modernizes the code.
2022-02-01 12:23:55 +09:00
Yu Watanabe
a46abf2e34
fuzz-dhcp-server: add static leases
2022-02-01 11:56:22 +09:00
Yu Watanabe
6796c5a9c4
test-dhcp-server: add tests for static lease
2022-02-01 11:56:22 +09:00
Yu Watanabe
7b5445e74e
test-dhcp-server: add tests for setting static DHCP lease
2022-02-01 11:56:22 +09:00
Yu Watanabe
99e65b7df3
test-dhcp-server: add usual headers
2022-02-01 11:56:22 +09:00
Yu Watanabe
4f3cb2465a
test-dhcp-server: run a test earlier which does not require privilege
2022-02-01 11:56:22 +09:00
Yu Watanabe
4e2319afe4
test-dhcp-server: move sd-event allocation
2022-02-01 11:56:22 +09:00
Yu Watanabe
7e0a8bf1ce
test-dhcp-server: use log_tests_skipped_errno()
2022-02-01 11:56:22 +09:00
Yu Watanabe
8b572f7ab2
sd-dhcp-server: split out logic to ACK request
2022-02-01 11:56:22 +09:00