Commit Graph

4787 Commits

Author SHA1 Message Date
Yu Watanabe
fc4aa64c2d network/dhcp6: skip to check existence of DHCPv6 address when UseAddress=no
Follow-up for 1536b7b2d0 and
5f950e5621.

Fixes #29979.
2023-11-11 03:30:34 +09:00
Yu Watanabe
f5e1781a9e network/dhcp6: use link_check_address_ready() at one more place 2023-11-11 03:30:34 +09:00
Yu Watanabe
706cd85937 network/dhcp-pd: use correct flag when DHCPv4 6rd is enabled
Previously, Link.dhcp6_configured flag was unconditionally used even if
the route is configured based on the DHCPv4 protocol.

Follow-up for a27588d4e7 and
e49bad0179.
2023-11-11 03:30:34 +09:00
Yu Watanabe
37b5051c95 network: fix json generation
When the DHCPv6 client is running in the information requesting mode,
then T1 and T2 are not set.
2023-11-09 01:30:03 +09:00
Yu Watanabe
b2622db0df Merge pull request #29910 from yuwata/rapid-commit
dhcp: about rapid commit
2023-11-08 12:20:17 +09:00
Yu Watanabe
b86f60bfb3 network-generator: refuse unexpected trailing strings 2023-11-08 04:29:45 +09:00
Yu Watanabe
816c269e55 network-generator: allow to specify both IPv4 and IPv6 DNS servers
Follow-up for 923599523c.
2023-11-08 04:29:45 +09:00
Yu Watanabe
8ae81a1e00 network-generator: add missing assertions 2023-11-08 04:29:45 +09:00
Yu Watanabe
0b0865f509 network-generator: drop unused family argument 2023-11-08 04:29:45 +09:00
Yu Watanabe
13a462b9d5 network-generator: relax requirement for peer address, route destination, and gateway
No functional changes, as the caller already sets them.
2023-11-08 04:29:45 +09:00
Yu Watanabe
1fa0a4eff7 network: add [DHCPServer] RapidCommit= setting 2023-11-08 02:42:03 +09:00
Luca Boccassi
58a2ab5e9d Merge pull request #29888 from mrc0mmand/network-generator
test: add a couple of tests for systemd-network-generator
2023-11-07 00:10:43 +00:00
Frantisek Sumsal
cc5244716b network-generator: allow specifying MAC address without MTU
Also, don't panic when both optional arguments are empty. This should
make the syntax compatible-ish with the dracut one from dracut.cmdline(7).

Resolves: #29855
2023-11-06 17:46:59 +01:00
Frantisek Sumsal
923599523c network-generator: correctly handle IPv6 DNS servers in ip=
IPv6 addresses in the ip= assignment need to be enclosed in [], which
was handled for all IP-related fields except for the two optional DNS
fields.
2023-11-06 17:45:57 +01:00
Luca Boccassi
1e70a3c84f Merge pull request #29872 from yuwata/udevadm-trigger-receive-buffer-size
udevadm-trigger: extend receive buffer size
2023-11-06 14:43:23 +00:00
Yu Watanabe
eba449fa81 sd-device-monitor: unconditionally increase buffer size by sd_device_monitor_new()
As suggested at https://github.com/systemd/systemd/pull/29872#discussion_r1382932633:
> socket memory is these days accounted to the process that owns a socket,
> hence we shouldn't be too concerned that this might waste memory.
2023-11-06 20:39:51 +09:00
Yu Watanabe
986e182352 network: do not try to set invalid value for IPv6 hop limit 2023-11-06 15:53:25 +09:00
Yu Watanabe
39713b075f network: fix indentation
Follow-up for f141b2c053.
2023-11-06 15:53:01 +09:00
Yu Watanabe
93e583aaba Revert "ndisc: Also set link hoplimit"
This reverts commit 0ba8374bb8.

- link->network->ipv6_hop_limit must not be updated, as it may be used
  by multiple interfaces,
- We may receive multiple RA from multiple routers with different hop
  limit, and we should not make the default hop limit flicking,
- First of all, there is no reason that we need to update the default hop
  limit,
- The original issue should be caused by the hash and compare functions
  for Route object.
2023-11-06 15:33:10 +09:00
Yu Watanabe
b94f59b9d5 network: make generated configs have higher precedence over default configs
We use 80- for default .network files. So, the generated files from the
kernel command line should have smaller prefix.
2023-11-03 11:42:19 +09:00
Lennart Poettering
b71a721fbc parse-util: add parse_tristate() and use it everywhere
We parse tristates all the time, let's add an explicit parser for them.
2023-11-02 04:52:16 +09:00
Yu Watanabe
ba87a61d05 network: support ID_NET_MANAGED_BY udev property
If the property is set, networkd manages the interface only when its
value is "io.systemd.Network".

Closes #29768.
2023-11-01 10:14:27 +01:00
Lennart Poettering
b3634c45d7 network-generator: add support for ip=link-local 2023-10-31 11:03:49 +01:00
Lennart Poettering
ce3e9428ac network-generator: name enum for "ip=dhcp" case same as literal string
Let's make this less confusing, and use the same string externally as
enum name internally.
2023-10-31 10:56:31 +01: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
Ronan Pigott
9968ca32cf network: free dhcp6_hostname
Fixes: b90480c80d ("network: introduce SendHostname/Hostname DHCPv6 options")
2023-10-31 14:26:44 +09:00
Ronan Pigott
b90480c80d network: introduce SendHostname/Hostname DHCPv6 options
These options were previously reused by the DHCPv6 client from the
DHCPv4 client settings. Let's separate them for consistency.
2023-10-30 11:04:10 +00: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
Yu Watanabe
ef0a234a75 network: update state file when DHCPv6 reply for INFORMATION-REQUEST is received
Otherwise, received information, e.g. DNS servers, may not be saved in
the state file, and will not be propagated to clients like resolved.

Fixes the first issue of #29678.
2023-10-26 12:23:42 +09:00
Luca Boccassi
2e53544c76 Merge pull request #29704 from mrc0mmand/cocci
Another round of Coccinelle tweaks
2023-10-25 13:42:21 +01:00
Frantisek Sumsal
73151fbe30 network: use timestamp_is_set() in one more place 2023-10-25 11:28:12 +02:00
Luca Boccassi
7470e161cf Merge pull request #29553 from keszybz/analyze-cat-config-tldr
analyze/cat-config: add switch to print only "interesting" parts of conffiles
2023-10-25 09:53:19 +01:00
Zbigniew Jędrzejewski-Szmek
063c838206 analyze/cat-config: add switch to print only "interesting" parts of config files
When looking at configuration, often a user wants to suppress the comments and
just look at the parts that actually configure something, roughly equivalent to
  systemd-analyze cat-config … | rg -v '^(#|;|$)
This switch implements this natively, skipping lines that start with a comment
character or only contain whitespace.

For formats that have section headers, section headers are skipped, if only
followed by stuff that would be skipped. (The last section header is printed
when we're about to print some actual output.)

Note that the caller doesn't know if the format has headers or not. We do format
type detection in pretty-print.c. So the caller only specifies tldr=true|false, and
conf_files_cat() figures out if the format has headers and whether those should
be handled specially.

The comments that show the file name are always printed, even if all of the file
is suppressed.

This is a partial answer to the discussions in
https://github.com/systemd/systemd/pull/28919,
https://github.com/systemd/systemd/pull/29248. If the default config is shown in
config files, the user can conveniently use '--tldr' to show the relevant parts.
2023-10-24 15:59:34 +02:00
Yu Watanabe
bd7d902884 network: also synchronously update manager state file 2023-10-24 18:39:47 +09:00
Yu Watanabe
a70c27b834 network: make link_save() static 2023-10-24 18:39:47 +09:00
Yu Watanabe
ac4a69500e network: do not try to save link state file twice on boot
On enumeration, (that is, before manager_start() is called), enumerated
links may already have the dirty flag. In that case, saving the state
file in manager_start() should clear the flag.
2023-10-24 18:39:47 +09: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
8664ded716 dhcp: split dhcp-internal.h into two 2023-10-21 01:54:08 +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
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
Ronan Pigott
06960d1719 network: include SSID in ipv6 stable prefix address generation
The SSID fills the role of the optional Network_ID input parameter
suggested by RFC7217. Including the SSID allows networkd to generate a
different pseudorandom address for different wireless networks, which
should help to obscure the host's identity when roaming between multiple
networks.
2023-10-18 09:48:09 +09:00
Luca Boccassi
8e3fb774ae Merge pull request #29586 from poettering/read-stripped-line
add read_stripped_line() as trivial read_line() + strstrip() combo
2023-10-17 19:54:14 +01:00
Franck Bui
6495361c7d meson: add build option for install path of main config files
This allows distros to install configuration file templates in /usr/lib/systemd
for example.

Currently we install "empty" config files in /etc/systemd/. They serve two
purposes:

- The file contains commented-out values that show the default settings.
- It is easier to edit the right file if it is already there, the user doesn't
  have to type in the path correctly, and the basic file structure is already in
  place so it's easier to edit.

Things that have happened since this approach was put in place:

- We started supporting drop-ins for config files, and drop-ins are the
  recommended way to create local configuration overrides.
- We have systemd-analyze cat-config which takes care of iterating over
  all possible locations (/etc, /run, /usr, /usr/local) and figuring out
  the right file.
- Because of the first two points, systemd-analyze cat-config is much better,
  because it takes care of finding all the drop-ins and figuring out the
  precedence. Looking at files manually is still possible of course, but not
  very convenient.

The disadvantages of the current approach with "empty" files in /etc:

- We clutter up /etc so it's harder to see what the local configuration actually is.
- If a user edits the file, package updates will not override the file (e.g.
  systemd.rpm uses %config(noreplace). This means that the "documented defaults"
  will become stale over time, if the user ever edits the main config file.

Thus, I think that it's reasonable to:

- Install the main config file to /usr/lib so that it serves as reference for
  syntax and option names and default values and is properly updated on package
  upgrades.
- Recommend to users to always use drop-ins for configuration and
  systemd-analyze cat-config to view the documentation.

This setting makes this change opt-in.

Fixes #18420.

[zjs: add more text to the description]
2023-10-17 18:57:45 +02:00
Zbigniew Jędrzejewski-Szmek
ee691c802b Merge pull request #29242 from fbuihuu/update-main-config-file-headers
config files: update their header to reflect that they can be install…
2023-10-17 18:56:09 +02:00
Lennart Poettering
0ff6ff2b29 tree-wide: port various parsers over to read_stripped_line() 2023-10-17 14:36:54 +02:00
Yu Watanabe
d311f5e277 network: do not trigger assertion by forcerenew command
When DHCP server is not running, sending force-renew command triggers
assertion.
2023-10-12 18:38:04 +09:00
Yu Watanabe
9bd91e34aa network: restart dhcp4 client when renewing lease is requested but the client is stopped
Follow-up for fc35a9f8d1.

Fixes the issue https://github.com/systemd/systemd/pull/29472#issuecomment-1759092138.
2023-10-12 18:14:11 +09:00
Yu Watanabe
fc35a9f8d1 network/dhcp4: support IPv6 only mode (RFC 8925)
Co-authored-by: Susant Sahani <ssahani@gmail.com>
2023-10-11 21:42:13 +09:00
Susant Sahani
34bea0a1e9 network/dhcp-server: allow to configure IPv6 only preferred option
Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
2023-10-11 21:42:13 +09:00