1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-03 05:18:09 +03:00
Commit Graph

75871 Commits

Author SHA1 Message Date
Adrian Vovk
bf2c741fd7
sysupdate: Implement systemd-sysupdated dbus service
Co-authored-by: Tom Coldrick <thomas.coldrick@codethink.co.uk>
Co-authored-by: Abderrahim Kitouni <abderrahim.kitouni@codethink.co.uk>
2024-08-21 09:31:41 +01:00
Peter Hutterer
4fc6bd9e7d logind: warn about EVIOCREVOKE errors other than EINVAL too
EINVAL means the kernel doesn't support it, ENODEV means it's
already revoked or the device is no longer there which has the same
effect anyway. All others - let's print an error to the logs.
2024-08-21 16:33:22 +10:00
Yu Watanabe
7321a87b53 network/ipv4acd: adjust comment and logging 2024-08-21 11:45:57 +09: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
Yu Watanabe
021d39d3d1 network: log and enter failed state in link_reconfigure()
No functional change, just refactoring.
2024-08-21 07:29:30 +09:00
Yu Watanabe
685fd0d729 network: enter initialized state when the interface will be reconfigured
When the interface is in the failed state, link_getlink_handler_internal()
will do nothing and return zero, thus the interface will not be
reconfigured, especially when the reconfiguration is triggered in
link_enter_failed().

Follow-up for c2eb7753dd.
2024-08-21 07:29:19 +09:00
Yu Watanabe
ebf66d0c05 network: introduce reconfigure_data_free() and _freep()
No functional change, just refactoring.
2024-08-21 07:24:43 +09:00
Yu Watanabe
2656f44c3c
Merge pull request #34018 from yuwata/network-address-label
network: allow to configure IPv6 address label in networkd.conf
2024-08-21 02:05:22 +09:00
Kornilios Kourtis
7ac58157ca process-util: handle pidfd_spawn() returning E2BIG
In some kernels (specifically, 5.4) even though the clone3 syscall is
supported, setting CLONE_INTO_CGROUP is not. The error message returned
in this case is E2BIG.

If posix_spawn_wrapper encounters this error, it does not retry, and
cannot spawn any programs in said kernels.

This commit adds a check for the E2BIG error and retries pidfd_spawn()
without the POSIX_SPAWN_SETCGROUP flag.

If we encounter an E2BIG error, and the pidfd_spawn() succeeds after
removing the POSIX_SPAWN_SETCGROUP flag, then we cache the result so
that we do not retry every time.

Originally, this issue was reported in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1077204.

Signed-off-by: Kornilios Kourtis <kornilios@gmail.com>
2024-08-21 02:04:57 +09:00
Daan De Meyer
c8e7cfeddc tests: Don't override QemuKvm= value if TEST_NO_KVM=0
Let's disable KVM if TEST_NO_KVM=1 is set but let's not specify anything
if it's not set so the QemuKvm= setting from mkosi.conf is used.
2024-08-21 01:52:09 +09:00
Yu Watanabe
085818569b test-network: add test for ManageForeignRoutingPolicyRules= 2024-08-20 21:02:31 +09:00
Yu Watanabe
49454d9ced test-network: add tests for Type=table, goto, and nop 2024-08-20 21:02:31 +09:00
Yu Watanabe
936dec4337 test-network: do not pass '[detached]' to 'ip rule del'
That indicates the interface name in 'iif' or 'oif' cannot be resolved
when 'ip rule' command is invoked. That's natural when networkd fail to
remove rule but the corresponding interface is already removed.
To make not the residual rules interfere subsequent test cases, let's
ignore the flag and actually remove unwanted rules.
2024-08-20 21:02:31 +09:00
Yu Watanabe
ac1d8aa5bc network/routing-policy-rule: support all known type of rule
This also adds GoTo= to specify the target priority of goto rule.

Note, table was the default but could not be specified in Type=.
2024-08-20 21:02:31 +09:00
Yu Watanabe
3ac8148e20 network/routing-policy-rule: also manage remaining attributes
Currently, these attributes are not configured by us, but there may be a
existing rule created by user manually with one of these attribute.
To correctly manage such foreign rules, let's read these attributes.
2024-08-20 21:02:30 +09:00
Yu Watanabe
7275739728 sd-netlink: introduce sd_netlink_message_read_u64() 2024-08-20 21:02:30 +09:00
Yu Watanabe
727235006a network/routing-policy-rule: remove rules that have conflicting flags
The kernel does not distinguish rules with different flags in
rule_exists(), but the flags of an existing rule cannot be updated.
Let's remove rules that have conflicting flags, and configure new rules
later with requested flags.
2024-08-20 21:02:30 +09:00
Yu Watanabe
689438419b network/routing-policy-rule: anyway detach rule even when we fail to remove it
When we fail to remove a rule, that mostly means the rule does not exist
in the kernel anymore, e.g. already removed manually and we have not
received notification about that yet.
Let's detach the rule in that case.
2024-08-20 21:02:30 +09:00
Yu Watanabe
65f5f58156 network/routing-policy-rule: do not save rule to Manager before it is configured
Otherwise, if we fail to configure the rule, then the manager will keep
nonexistent rule forever. So, let's first copy the rule and put it on
Request, then on success generate a new copy based on the netlink
notification and store it to Manager.

This is the same as 0a0c2672db, but for
routing policy rule.
2024-08-20 21:02:30 +09:00
Yu Watanabe
4f8b153d90 network/routing-policy-rule: skip requesting when rule is already requested
If it is already requested, the new request will be anyway silently refused by
link_queue_request_safe(), which returns 0 in such case. Let's return earlier.

There should be no functional change, just refactoring.
2024-08-20 21:00:05 +09:00
Yu Watanabe
489671d225 network/address-label: allow to configure IPv6 address label in networkd.conf
Closes #23159.
2024-08-20 20:50:56 +09:00
Yu Watanabe
477defd774 network/queue: introduce manager_queue_request_full()
Currently it is not used, but will be used later.
2024-08-20 20:49:32 +09:00
Yu Watanabe
7b2e07ca4c network/address-label: split out address_label_fill_message()
No functional change, just refactoring and preparation for later
commits.
2024-08-20 20:49:28 +09:00
Yu Watanabe
4dfbecd2ff network/address-label: several cleanups for conf parsers
- Check userdata, instead of data, though they point to the same
  position.
- Support an empty string.
- Use UINT32_MAX, as the label is uint32_t.
2024-08-20 20:48:48 +09:00
Yu Watanabe
c95fa6acb5 network/address-label: introduce custom hash_ops
No functional change, just refactoring.
2024-08-20 20:48:48 +09:00
Yu Watanabe
d37afb5779 network/routing-policy-rule: add trailing period to the log message 2024-08-20 20:48:26 +09:00
Yu Watanabe
fc58350aa4 network/routing-policy-rule: do not modify RountingPolicyRule objects managed by Manager or Network
They are stored in Manager.rules set or Network.rules_by_section hashmap.
For safety, let's not edit them even temporarily.

No functional change, just refactoring.
2024-08-20 20:48:26 +09:00
Lennart Poettering
61242b1f0f shared: invoke agents only when we have a controlling TTY
being connected to a TTY is not really enough to determine
interactivity in many cases. Let's also check if we have a controlling
TTY.

Inspired by #34016
2024-08-20 20:37:50 +09:00
Yu Watanabe
41f5e66cf2
Merge pull request #34044 from poettering/isatty-fixes
fixes around isatty() handling
2024-08-20 20:36:07 +09:00
Lennart Poettering
8915e4aef5 man: fix ID_NET_LABEL_ONBOARD= documentation
We do not prefix the field with anything, since
8c053c83ae.
2024-08-20 20:30:39 +09:00
Luca Boccassi
a8d1f9da55
Merge pull request #34009 from yuwata/network-resolve-polkit
network,resolve: support interactive authentication
2024-08-20 12:14:03 +02: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
Luca Boccassi
2bc7cae70b
Merge pull request #34021 from yuwata/network-routing-policy-rule
network/routing-policy-rule: several cleanups
2024-08-20 11:49:02 +02:00
Ronan Pigott
eded61e410 resolved: demote the global unicast scope
This will greatly reduce the number of cases where the global unicast
scope overlaps with link scopes configured as default-route, making it
feasible to use the global DNS setting in conjunction with per-link dns
servers configured by the network.

This change is preferred over demoting links to default-route=no where
the user prefers to use the network provided DNS servers, and I expect
it is non-disruptive in that it should not degrade the efficacy of any
existing configuration.
2024-08-20 11:45:22 +02:00
Lennart Poettering
300b7e7620 tree-wide: use isatty_safe() more 2024-08-20 11:11:53 +02:00
Lennart Poettering
aae47bf7a3 terminal-util: don't assume errno is correctly set when using isatty_safe()
let's instead generate ENOTTY on our own. This is more correct with out
coding style (since we generally do not propagate errors via errno), and
also addresses #34039 as side effect. (#34039 really needs to be fixed
in musl though, too, this is just a work-around as side-effect).

Fixes: #34039
2024-08-20 10:59:47 +02:00
Lennart Poettering
1b24357c41 terminal-util: fix isatty_safe() on hung-up TTYs
glibc returs EIO on ttys that are hung up. That's not really correct,
POSIX seems to disagree.

Work around this in our code, and turn this into a clean "1", since a
hung up tty doesn't stop being a tty just because it is hung up.

Background: https://github.com/systemd/systemd/pull/34039
2024-08-20 10:57:49 +02:00
Yu Watanabe
0197fb599a test-network: make kernel send NA with router flag
If the router interface send NA without router flag, client interface will drop
SLAAC addresses. To make the router interface send NA with router flag,
IPv6 forwarding needs to be enabled.
===
client: NDISC: Received Neighbor Advertisement from fe80::1034:56ff:fe78:9a99: Router=no, Solicited=yes, Override=no
client: NDISC: Invoking callback for 'neighbor' event.
client: Removing NDisc route (configured): dst: 2002:da8:1:99::/64, src: n/a, gw: n/a, prefsrc: n/a, table: main(254), priority: 1024, proto: ra, scope: global, type: unicast, flags: n/a
client: Removing NDisc route (configured): dst: n/a, src: n/a, gw: fe80::1034:56ff:fe78:9a99, prefsrc: n/a, table: main(254), priority: 1024, proto: ra, scope: global, type: unicast, flags: n/a
client: Removing NDisc address (configured): 2002:da8:1:99:1034:56ff:fe78:9a00/64 (valid for 23h 59min 58s, preferred for 3h 59min 58s), flags: manage-temporary-address,no-prefixroute, scope: global
===
2024-08-20 09:01:08 +02:00
maia x.
010ea061fc namespace: Fix extension release memory leak
In apply_one_mount(), in the MOUNT_EXTENSION_DIRECTORY case,
char **extension_release was used as a return pointer twice but only
cleaned up once in the end. Fix it by removing duplicate code that
was causing this issue.

Fixes issue introduced in 55ea4ef096.
2024-08-20 09:40:52 +09:00
Yu Watanabe
93f91df671 network/routing-policy-rule: drop unused argument 2024-08-20 02:21:21 +09:00
Yu Watanabe
6c72e80a3c network/routing-policy-rule: introduce ref and unref functions for RoutingPolicyRule
No functional change, just refactoring and preparation for later change.
2024-08-20 02:21:21 +09:00
Yu Watanabe
957d94c5bd network/routing-policy-rule: manage all flags
Currently, only FIB_RULE_INVERT flag can be configurable, but for
simplicity and future extension, let's manage all flags.

No functional change, just refactoring.
2024-08-20 02:21:21 +09:00
Yu Watanabe
933448defe network/routing-policy-rule: use int32_t for suppress_prefixlen
The kernel parses FRA_SUPPRESS_PREFIXLEN as uint32_t, but internally
handled as signed integer and negative values as unset. Let's explicitly
specify the size of the variable.

No functional change, just refactoring.
2024-08-20 02:21:21 +09:00
Yu Watanabe
0a3a3a2a1e network/routing-policy-rule: reorder elements of RoutingPolicyRule and add comments
No functional change, just refactoring.
2024-08-20 02:21:21 +09:00
Yu Watanabe
82ddfaa591 network/routing-policy-rule: update hash and compare function for fib rule
Let's manage fib rules with the logic used by the kernel.

Should not change any behavior.
2024-08-20 02:21:16 +09:00
Daan De Meyer
4cf7a676af test-dhcp-server: Gracefully handle the network being down 2024-08-19 11:38:55 +09:00
Yu Watanabe
cc3e48b3c1 run: also enable interactive authentication on opening pty 2024-08-19 11:36:32 +09:00