Yu Watanabe
dd59d5e57c
libsystemd-network: introduce triple_timestamp_from_cmsg()
...
Follow-up for 461ef3981f .
This should fix compile error on x32 and riscv32.
2023-11-20 15:44:23 +00:00
Yu Watanabe
965040d811
test: always call test_setup_logging()
2023-11-18 03:04:27 +09:00
Luca Boccassi
461ef3981f
sd-dhcp: use CMSG_FIND_AND_COPY_DATA to avoid build failures on x32 architectures
...
On architectures where timeval is 64bit but size_t is 32bit
we have to use CMSG_FIND_AND_COPY_DATA. This affects x32 and riscv32.
Follow-up for 905d0ea7b0
2023-11-16 11:26:57 +09:00
Yu Watanabe
c0b927eb3a
dhcp: do not trigger assertion by malformed messages
...
This also changes error code from -ENODATA -> -EBADMSG,
as we received bad message in that case.
Prompted by #30029 .
2023-11-16 02:32:12 +09:00
Yu Watanabe
fdf759e3ae
sd-dhcp6-client: fix DUID data length passed to hexmem()
...
Fixes a bug introduced by 6b7d5b6eaf .
2023-11-15 14:41:02 +09:00
Yu Watanabe
1ae9a98292
dhcp: fix maximum DUID size
...
This effectively reverts 9291496011 .
This fixes the maximum length of DUID.
See RFC 8415 section 11.1.
2023-11-15 14:38:55 +09:00
Yu Watanabe
b3884498a9
dhcp: drop unused prototype
...
Follow-up for 53488ea352 .
2023-11-15 10:17:34 +09:00
Zbigniew Jędrzejewski-Szmek
fa5a025167
Rename {dual,triple}_timestamp_get to {dual,triple}_timestamp_now
...
Those functions take a pointer to a timestamp and return a timestamp pointer,
so the reader would be justified to think that those are just getters. Rename
them to avoid confusion.
2023-11-13 13:27:07 +01:00
Yu Watanabe
905d0ea7b0
sd-dhcp-client,-server: set timestamp based on the time when received a packet
...
It seems that RFC does not say anything about the timestamp of lease
we should use: time that the client sent a request or received a reply.
In DHCPv6 client and NDisc, we use a timestamp that we receive a packet,
rather than we sent something. So, let's consistently use the same
logic for DHCPv4 client.
By using the logic, we will hopefully not forget to set timestamp again,
which is fixed by 089362976c .
2023-11-08 17:58:51 +09:00
Yu Watanabe
a57dd1d13f
sd-dhcp-client: move packet size check to dhcp_packet_verify_headers()
...
No functional change.
2023-11-08 17:54:52 +09:00
Yu Watanabe
7f42c66015
sd-dhcp-client: split out client_verify_message_header()
...
This is not necessary to be called when a packet is received through the
RAW socket, but should not hurt anything.
2023-11-08 17:54:30 +09:00
Yu Watanabe
69f50bf35e
sd-dhcp-client: make client_handle_message() propagate critical error
...
Then, stop client in the caller side.
This also makes
- ignore all errors except for resource errors like OOM when FORCERENEW
is received,
- trigger assertion when an message received even if the client is
stopped.
This should not change any functionality. Just refactoring.
2023-11-08 13:03:40 +09:00
Yu Watanabe
538ff0a60a
sd-dhcp-server: support rapid commit (RFC4039)
...
https://datatracker.ietf.org/doc/html/rfc4039
2023-11-08 02:39:59 +09:00
Yu Watanabe
089362976c
sd-dhcp-client: unconditionally set sd_dhcp_client.request_sent when a packet is sent
...
If a server replies an ACK for the initial DISCOVER, previously
request_sent was not set, so networkd handle the lease timed out.
Follow-up for 808b65a087 .
2023-11-08 02:18:15 +09:00
Yu Watanabe
c4efe0e51e
sd-dhcp-client: gracefully ignore OFFER with Rapid Commit option
...
Fixes #29904 .
2023-11-07 16:13:54 +01:00
Yu Watanabe
498a6de596
dhcp6: enterprise ID is 32bit
...
Follow-up for 6b44099b3b .
Fixes #29800 .
2023-11-01 13:19:59 +00:00
Yu Watanabe
78101ca9cc
Merge pull request #29247 from naraghavan/naraghavan/dhcpv6-vendor-options
...
networkd: Add DHCP vendor specific sub options to dbus API
2023-10-31 17:14:20 +09:00
Yu Watanabe
d19434fbf8
tree-wide: fix typo
2023-10-31 14:35:33 +09:00
Nandakumar Raghavan
6b44099b3b
networkd: Add DHCP vendor specific options to dbus API
...
Add DHCP vendor specific options to expose in dbus API.
This will be added to the JSON output when we query
org.freedesktop.network1.Manager object.
2023-10-27 12:11:09 +00:00
Ronan Pigott
808b65a087
network: implement RFC4039 DHCP Rapid Commit
...
This implements the DHCPv4 equivalent of the DHCPv6 Rapid Commit option,
enabling a lease to be selected in an accelerated 2-message exchange
instead of the typical 4-message exchange.
2023-10-26 15:26:50 -07:00
Ronan Pigott
5516b0dd20
network: cleanup unreachable condition in dhcp client path
...
The client state is unconditionally set just above, making this
conditional unreachable.
2023-10-26 15:26:50 -07:00
Lennart Poettering
7113640493
fd-uitl: rename PIPE_EBADF → EBADF_PAIR, and add EBADF_TRIPLET
...
We use it for more than just pipe() arrays. For example also for
socketpair(). Hence let's give it a generic name.
Also add EBADF_TRIPLET to mirror this for things like
stdin/stdout/stderr arrays, which we use a bunch of times.
2023-10-26 22:30:42 +02:00
Frantisek Sumsal
25f7271c42
network: ENOTSUP → EOPNOTSUPP
2023-10-25 11:26:19 +02:00
Yu Watanabe
0bc30a2038
network,dhcp: restart client with 'networkctl renew' when delayed by IPv6 only mode
...
This is convenient when the server supports IPv6 only mode.
Otherwise, we cannot request a new address during the client is waiting an
IPv6 connectivity. Note, the minimal timespan is 5min, and a server may
send a quite large value.
2023-10-21 01:54:08 +09:00
Yu Watanabe
95bd6816d7
sd-dhcp-client: always use sd_dhcp_client.timeout_ipv6_only_mode for delaying subsequent task
...
Otherwise, sd_dhcp_client_set_ipv6_connectivity() may not work, as it
checks if the timer event source is enabled or not.
2023-10-21 01:54:08 +09:00
Yu Watanabe
74c102d7e9
sd-dhcp-client: add a short comment about IPv6 only mode
2023-10-21 01:54:08 +09:00
Yu Watanabe
dab96fed0c
sd-dhcp-client: only send RENEW message when the client is in bound state
...
Fixes an issue reported at
https://github.com/systemd/systemd/pull/29544#issuecomment-1762742561 .
2023-10-21 01:54:08 +09:00
Yu Watanabe
a43f922526
sd-dhcp-client: simplify the condition in sd_dhcp_client_get_lease()
...
The condition was outdated, e.g. SELECTING state does not have a lease.
See client_handle_offer() and client_enter_requesting().
The condition based on the state may become much complex in the future.
Let's use simpler condition.
2023-10-21 01:54:08 +09:00
Yu Watanabe
8664ded716
dhcp: split dhcp-internal.h into two
2023-10-21 01:54:08 +09:00
Yu Watanabe
40e4be7e8e
dhcp: move DHCP client specific definitions to dhcp-client-internal.h
2023-10-21 01:54:08 +09:00
Yu Watanabe
9bcbb61458
dhcp: split out dhcp-network.h from dhcp-internal.h
2023-10-21 01:54:07 +09:00
Yu Watanabe
8320db407c
dhcp: move DHCPState to dhcp-client-internal.h
...
All other definitions in dhcp-protocol.h are common for client and
server. Let's move DHCP client specific definitions.
2023-10-21 01:54:07 +09:00
Yu Watanabe
f3d84e20c9
fuzz: include library headers first
2023-10-21 01:54:07 +09:00
Lennart Poettering
bd1ae17833
io-util: split out "struct iovec" related calls into their own .c/.h files
...
This is preparation for #28891 , which adds a bunch more helpers around
"struct iovec", at which point this really deserves its own .c/.h file.
The idea is that we sooner or later can consider "struct iovec" as an
entirely generic mechanism to reference some binary blob, and is the
go-to type for this purpose whenever we need one.
2023-10-20 10:34:33 +02:00
Frantisek Sumsal
4820c9d417
fuzz: unify logging setup
...
Make sure we don't log anything when running in "fuzzing" mode. Also,
when at it, unify the setup logic into a helper, pretty similar to
the test_setup_logging() one.
Addresses:
- https://github.com/systemd/systemd/pull/29558#pullrequestreview-1676060607
- https://github.com/systemd/systemd/pull/29558#discussion_r1358940663
2023-10-19 10:05:20 +01:00
Yu Watanabe
39ba10f19e
sd-dhcp-server: make sd_dhcp_server_is_running() silently work with NULL
...
We already do in the same way for sd-dhcp-client and friends.
2023-10-12 18:35:59 +09:00
Yu Watanabe
a91b888fff
sd-dhcp-client: support IPv6 only mode
...
This makes sd-dhcp-client optionally request IPv6 only preferred
option (RFC 8925).
2023-10-11 21:42:13 +09:00
Susant Sahani and Yu Watanabe
14bd102e3c
sd-dhcp-server: support IPv6 only mode
...
This makes sd-dhcp-server send IPv6 only preferred option (RFC 8925).
Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com >
2023-10-11 21:42:13 +09:00
Yu Watanabe
042c91459a
fuzz: suppress log messages
2023-10-06 13:26:16 +09:00
Yu Watanabe
8b50b3198b
libsystemd-network: introduce $SYSTEMD_NETWORK_TEST_MODE environment variable
...
Then, drop dhcp_client_set_test_mode() and friends.
2023-10-06 13:25:23 +09:00
Alexandre Peixoto Ferreira
13abd00685
sd-dhcp-client: reject NAKs from servers that we did not send an offer to ( #29290 )
...
To support multiple DHCP servers in a network.
2023-09-25 11:46:41 +09:00
Luca Boccassi
f5f4486c65
Merge pull request #29254 from yuwata/sd-ndisc-use-usec_t
...
sd-ndisc: make sd_ndisc return time values in usec
2023-09-22 21:46:50 +01:00
Yu Watanabe
f9edbb80e9
sd-dhcp-client: split out client_parse_message()
...
No functional change, just refactoring and preparation for later
commits.
2023-09-23 01:38:21 +09:00
Yu Watanabe
db849df5a1
sd-dhcp-client: introduce dhcp_lease_unref_and_replace()
2023-09-23 01:38:21 +09:00
Yu Watanabe
8fc725052a
sd-dhcp-client: do not set fallback subnet mask if it is already set
2023-09-23 01:38:21 +09:00
Yu Watanabe
2ff1e23036
sd-dhcp-client: split out client_enter_requesting()
...
No functional change, just refactoring and preparation for later
commits.
2023-09-23 01:38:21 +09:00
Yu Watanabe
525717b87c
sd-dhcp-client: split out client_enter_bound()
...
No functional change, just refactoring and preparation for later
commits.
2023-09-23 01:38:21 +09:00
Yu Watanabe
6197db53ba
sd-ndisc: make sd_ndisc return time values in usec
...
This also introduces sd_ndisc_router_get_lifetime_timestamp() and
friends that return timestamp rather than timespan.
2023-09-23 01:34:56 +09:00
Zbigniew Jędrzejewski-Szmek
a0fe45a93f
Merge pull request #29224 from keszybz/netdev-config-parsing
...
Use a helper to simplify parsing of ranges in netdev config and related changes
2023-09-22 14:29:47 +02:00
Yu Watanabe
3231f624e6
sd-ndisc: rename function arguments for storing results
2023-09-22 02:17:31 +09:00