Commit Graph
1905 Commits
Author SHA1 Message Date
Colin Foster 38557d9ffb test-dhcp-client: utilize log_info instead of printf
log_info appears to be the preferred method to convey information from
tests. Convert all the printfs to log_info to follow this standard.
2024-11-04 11:57:32 +00:00
Ronan Pigott b31b99d76f network: Restrict the valid charset of DNR names
Not all possible DNS names will survive serialization. Restrict the set
of valid dns names to LDH encoded names.

Fixes: 25c33e3500 (network: parse RFC9463 DHCPv4 DNR option, 2024-01-16)
Fixes: a07e83cc58 (network: Parse RFC9463 DHCPv6 DNR option, 2024-01-17)
Fixes: 0c90d1d2f2 (ndisc: Parse RFC9463 encrypted DNS (DNR) option, 2024-01-19)
2024-10-29 14:18:37 -07:00
Ronan Pigott f54f473b36 network: add missing else in dhcp_lease_load
Fixes: 3fd6708cde (network: Serialize DNR servers)
2024-10-28 20:59:17 -07:00
Integral ddb8a639d5 tree-wide: replace for loop with FOREACH_ELEMENT or FOREACH_ARRAY macros (#34893) 2024-10-26 07:10:22 +09:00
Lennart Poettering 119252343e Merge pull request #34848 from yuwata/network-dhcpv6-do-not-request-ia-pd-on-info-req
network/dhcp6: do not request IA_PD on information requesting mode
2024-10-22 18:00:12 +02:00
Lennart Poettering 2d74427a7c Merge pull request #30952 from rpigott/resolved-dnr
RFC9463: Discovery of Network-designated Resolvers
2024-10-22 09:05:36 +02:00
Yu Watanabe 5ff567f74f network/dhcp6: do not request IA_PD when running in the other-information mode
This reverts the following commits:
- 180cc5421d
  "sd-dhcp6-client: allow to request IA_PD on information requesting mode"
- cf7a403e47
  "sd-dhcp6-lease: adjust information refresh time with lifetime of IA_PD"
- 1918eda30d
  "network/dhcp6: process hostname and IA_PD on information requesting mode"

As per discussion in #34299,
https://github.com/systemd/systemd/issues/34299#issuecomment-2425153221
the offending commits violate RFC 8415 section 18.2.6:
> The client uses an Information-request message to obtain
> configuration information without having addresses and/or delegated
> prefixes assigned to it.
2024-10-22 04:34:50 +09:00
Ronan Pigott ee2108dcd5 resolve: move sd-* api into libsystemd-network
This duplicates the svc param constants for the benefit of the
resolved-core library.
2024-10-21 09:10:20 -07:00
Ronan Pigott e3a23b1679 ndisc: implement ndisc_option_build_encrypted_dns
This is only used by the fuzzer so far.
2024-10-21 09:10:20 -07:00
Ronan Pigott 7823f8a784 network: add dnr resolvers to networkctl status json output 2024-10-21 09:10:20 -07:00
Ronan Pigott 0c90d1d2f2 ndisc: Parse RFC9463 encrypted DNS (DNR) option
This option is equivalent to the V4/V6 DNR options for DHCP.
2024-10-21 09:10:19 -07:00
Ronan Pigott c691f9d984 network: Introduce UseDNR DHCPv6 option
This is equivalent to the DHCPv4 option introduced earlier.
2024-10-21 09:10:19 -07:00
Ronan Pigott a07e83cc58 network: Parse RFC9463 DHCPv6 DNR option
Implement the parsing for V6_DNR DHCPv6 option. This does the same as
the DHCP V4_DNR option.
2024-10-21 09:10:19 -07:00
Ronan Pigott 1be9b30a3b dhcp6: use dns_name_from_wire_format
Convert some of the option parsing to use dns_name_from_wire_format,
introduced earlier. No change in behavior intended.
2024-10-21 09:10:19 -07:00
Ronan Pigott 2d9822b634 test-dhcp6: terminate fqdn option
The encoded fqdn in this option must be properly terminated. We will
soon validate that this field is correctly encoded, so correct it in the
test.
2024-10-21 09:10:19 -07:00
Ronan Pigott 3fd6708cde network: Serialize DNR servers
Implement serialization/deserialization for DNR servers. This re-uses
the string format in place for user configuration of DoT servers, and as
a consequence non-DoT servers are discarded when recording the link
configuration, for correctness.

This also enables sd-resolved to use these servers as it would other DNS
servers.
2024-10-21 09:10:19 -07:00
Ronan Pigott b0e716310d network: Add serialization for DoT resolvers
For now only DoT is supported, so DoT resolvers are represented using
the existing configuration format.
2024-10-21 09:10:19 -07:00
Yu Watanabe cf7a403e47 sd-dhcp6-lease: adjust information refresh time with lifetime of IA_PD
For the case when IRT is too large but lifetime of IA_PD is too short.
2024-10-15 18:23:59 +09:00
Yu Watanabe 180cc5421d sd-dhcp6-client: allow to request IA_PD on information requesting mode
To support RFC 7084, WPD-4.
2024-10-15 18:23:59 +09:00
Yu Watanabe 7860677e03 sd-dhcp6-lease: use free_and_replace_full() 2024-10-15 18:23:59 +09:00
Yu Watanabe 098f32e2a1 sd-radv: drop sd_radv_prefix and friends, and use sd_ndisc_option to manage NDisc options
No effective functional change, just refactoring.
2024-10-15 05:59:20 +09:00
Darsey Litzenberger 4bc7a54d75 network/dhcp4: add support for ARPHRD_RAWIP and ARPHRD_NONE network interface types
This should fix QMI wwan modems, as noted in
https://github.com/systemd/systemd/issues/27219
2024-10-10 09:29:30 +09:00
Yu Watanabe 223a67e572 tree-wide: replace reallocarray() with GREEDY_REALLOC() 2024-10-08 19:56:09 +09:00
Yu Watanabe f769518c9a tree-wide: drop doubled empty lines 2024-10-07 09:51:37 +02:00
Mike Yuan a2c8652a2a tree-wide: use strv_extend_strv_consume() where appropriate 2024-09-21 00:53:50 +02:00
Yu Watanabe 146b44d0a0 sd-ipv4acd: fix assertion triggered when an ARP received in STARTED state
When a network is busy, an ARP may be received before the timer event
source triggered first time.

Fixes #34489.
2024-09-20 14:21:42 +02:00
Ronan Pigott 25c33e3500 network: parse RFC9463 DHCPv4 DNR option
This option is another way for DHCP servers to indicate preferred DNS
servers for the network, but includes more detailed info like the server
name, transport (DoT/DoH/DoQ etc.), and port.

Allow our DHCPv4 client to parse this option.
2024-09-13 22:57:51 -07:00
Lennart Poettering 868258cf38 basic: split ifname related calls from format-util.h into format-ifname.h
This way we don't have to pull in net/if.h into format-util.h.

This is supposed to address https://github.com/systemd/systemd/pull/32212#discussion_r1755639881

No actual code changes, just a .c/.h file split-up.
2024-09-13 07:27:47 +02:00
Yu Watanabe 47a71f9852 missing_network: drop unnecessary definition
Now we have ipv6.h, hence the definition is not necessary anymore.
2024-09-09 14:52:18 +09:00
Daan De Meyer 73a1a6f445 test-dhcp-server: Migrate to new assertion macros 2024-08-28 13:30:52 +02:00
Yu Watanabe 22c864d885 sd-dhcp-client: actually restart daemon after sending DECLINE message
client_stop() sets DHCP_STATE_STOPPED to client->state, thus the server
never restarted.
2024-08-21 11:45:57 +09:00
Yu Watanabe 2bb7559ade sd-dhcp-client: stop client without calling notification after sending RELEASE
Otherwise, even the acquired lease is released, the client may be in
e.g. BOUND state or so, and may send renew or rebind after timeout
later.
2024-08-21 11:43:59 +09:00
Yu Watanabe f8cdd37d0a sd-dhcp-client: refuse to send RELEASE or friends gracefully when the daemon is stopped or so
We can easily hit the assertions without checking the internal states of
the DHCP client before calling these functions. That's annoying.
Let's do more gracefully.
2024-08-21 11:34:50 +09:00
Yu Watanabe e5b19cbed2 sd-dhcp-client: do not call callback with SD_DHCP_CLIENT_EVENT_STOP if already stopped
When an interface enters the failed state, even if the DHCP client is
stopped, the acquired DHCP lease is not unreferenced, as the callback
dhcp4_handler() do nothing in that case. When the failed interface is
being reconfigured after that, the DHCP client is stopped again
(though it is already stopped), and SD_DHCP_CLIENT_EVENT_STOP event is
triggered and sd_dhcp_client_send_release() is called, and the
assertion in the function is triggered.

E.g.
===
systemd-networkd[98588]: wlp59s0: DHCPv4 address 192.168.86.250/24, gateway 192.168.86.1 acquired from 192.168.86.1
systemd-networkd[98588]: wlp59s0: Could not set DHCPv4 route: Nexthop has invalid gateway. Network is unreachable
systemd-networkd[98588]: wlp59s0: Failed
systemd-networkd[98588]: wlp59s0: State changed: configuring -> failed
systemd-networkd[98588]: wlp59s0: The interface entered the failed state frequently, refusing to reconfigure it automatically.
systemd-networkd[98588]: wlp59s0: DHCPv4 client: STOPPED
systemd-networkd[98588]: wlp59s0: DHCPv4 client: State changed: bound -> stopped
systemd-networkd[98588]: Got message type=method_call sender=:1.449 destination=org.freedesktop.network1 path=/org/freedesktop/network1 interface=org.freedesktop.network1.Manager member=ReconfigureLink ...
systemd-networkd[98588]: wlp59s0: State changed: failed -> initialized
systemd-networkd[98588]: wlp59s0: found matching network '/etc/systemd/network/50-wifi.network'.
systemd-networkd[98588]: wlp59s0: Configuring with /etc/systemd/network/50-wifi.network.
systemd-networkd[98588]: wlp59s0: DHCPv4 client: STOPPED
systemd-networkd[98588]: Assertion 'sd_dhcp_client_is_running(client)' failed at src/libsystemd-network/sd-dhcp-client.c:2197, function sd_dhcp_client_send_release(). Aborting.
===
2024-08-21 11:34:45 +09:00
Luca Boccassi a16079fccc Merge pull request #34014 from yuwata/network-ip-masquerade
network: make IPMasquerade= imply global IP forwarding settings again
2024-08-20 11:59:30 +02:00
Daan De Meyer 4cf7a676af test-dhcp-server: Gracefully handle the network being down 2024-08-19 11:38:55 +09:00
Yu Watanabe fbcd7e054b sd-lldp-tx: insert missing empty line 2024-08-16 23:29:36 +09:00
Mary Strodl c73883143a sd-dhcp-server: persist hardware addresses in leases 2024-07-23 14:55:48 +01:00
Lennart Poettering be5bee2a13 tree-wide: port over to new builder apis 2024-06-19 22:50:02 +02:00
Zbigniew Jędrzejewski-Szmek bfd5a0687f various: move const ptr indicator to return value 2024-06-19 16:28:28 +02:00
Mike Yuan e2b812c804 string-util: introduce string_is_safe_ascii helper 2024-06-16 19:07:35 +02:00
Lennart Poettering 309a747fa6 libsystemd: turn json.[ch] into a public API
This is preparation for making our Varlink API a public API. Since our
Varlink API is built on top of our JSON API we need to make that public
first (it's a nice API, but JSON APIs there are already enough, this is
purely about the Varlink angle).

I made most of the json.h APIs public, and just placed them in
sd-json.h. Sometimes I wasn't so sure however, since the underlying data
structures would have to be made public too. If in doubt I didn#t risk
it, and moved the relevant API to src/libsystemd/sd-json/json-util.h
instead (without any sd_* symbol prefixes).

This is mostly a giant search/replace patch.
2024-06-12 18:42:22 +02:00
Yu Watanabe 40f9fa0af4 sd-dhcp-server: clear buffer before receive
I do not think this is necessary, but all other places in
libsystemd-network we clear buffer before receive. Without this,
Coverity warns about use-of-uninitialized-values.
Let's silence Coverity.

Closes CID#1469721.
2024-06-12 00:06:46 +01:00
Yu Watanabe a925620f5f sd-ndisc: do not print "(null)" in the log message
If we received RA with no flags set, or with an invalid preference,
previously "(null)" was printed.

Follow-up for 238ed432c3.

Fixes https://github.com/systemd/systemd/pull/32308#discussion_r1600940289.
2024-05-22 22:07:58 +02:00
Yu Watanabe f8ef1df3d1 test: extend timeout for DHCP/NDisc tests
Fixes https://github.com/systemd/systemd/pull/32932#issuecomment-2120424121.
2024-05-20 22:55:07 +02:00
Luca Boccassi 5de20f5619 Merge pull request #32818 from keszybz/libsystemd-network-size-check
Check packet size in libsystemd-network
2024-05-15 17:33:22 +02:00
Zbigniew Jędrzejewski-Szmek 8e41e460e0 test: rename file with stub functions
icmp6-util-linux.c sounds like a specialized implementation of the functions in
icmp6-util.c. But it's just a set of stub versions used in tests. Rename the
file to make this more obvious.
2024-05-14 18:56:41 +02:00
Zbigniew Jędrzejewski-Szmek b17b91db80 libsystemd-network: use normal style for error checking
We generally use a flat list. The switch stmt was generating excessive
indentation.
2024-05-14 18:56:41 +02:00
Zbigniew Jędrzejewski-Szmek caa4bfd468 libsystemd-network: check size of icmpv6 packets
Coverity was complaining that we use the received packet size as a loop bound
without checking. This is indeed a bit iffy, because depending on how the host
is configured, the packet could be rather large. Let's refuse anything more
than the standard size early to prevent suspicious activity.

Resolves coverity CID#1534892, CID#1543949.
2024-05-14 18:56:35 +02:00
Zbigniew Jędrzejewski-Szmek f7a6418d47 libsystemd-network: remove double initialization 2024-05-14 18:55:34 +02:00