Commit Graph

75713 Commits

Author SHA1 Message Date
Ronan Pigott
bebec88653 Revert "resolved: demote the global unicast scope"
This commit may have been a breaking change for sd-resolved foreign
resolv.conf mode, where a legacy network management daemon directly
modifies resolv.conf and sd-resolved consumes that.

This reverts commit eded61e410.
2024-08-21 06:59:22 -07:00
Daan De Meyer
1ce69e0661 Revert "cgroup-util: Don't try to open pidfd for kernel threads"
The kernel patch was reverted so let's try again to open pidfds
for kernel threads.

This reverts commit ead48ec35c.
2024-08-21 14:32:54 +02:00
Luca Boccassi
bdf75118ba
Merge pull request #34049 from yuwata/network-routing-policy-rule
network: further rework for routing policy rule
2024-08-21 12:46:37 +02: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
Yu Watanabe
1b8a74678c run: use sd_bus_set_allow_interactive_authorization() 2024-08-19 11:36:32 +09:00
Yu Watanabe
04834552ed mount: use sd_bus_set_allow_interactive_authorization() 2024-08-19 11:36:32 +09:00
Yu Watanabe
335608593c timedatectl: drop unnecessary temporal variables
Also drop unnecessary spaces.
2024-08-19 11:36:32 +09:00
Yu Watanabe
f3cf6167ef tree-wide: voidify polkit_agent_open_if_enabled() 2024-08-19 11:36:32 +09:00
Yu Watanabe
69e7d2efdf timedatectl: enable interactive authentication for DBus methods 2024-08-19 11:36:32 +09:00
Yu Watanabe
470cea62da resolve: inherit server userdata
No functional change, just refactoring.
2024-08-19 11:36:32 +09:00
Yu Watanabe
cf01bbb7a4 resolve: support polkit authentication for io.systemd.Resolve.Monitor
Then, non-privilege user can call e.g. 'resolvectl monitor' with
authentication.
2024-08-19 11:36:32 +09:00