Commit Graph
36053 Commits
Author SHA1 Message Date
Lennart Poettering b9d0652263 stat-util: specify O_DIRECTORY when reopening dir in dir_is_empty_at()
That way we can fail earlier if the specified fd is not actually a
directory.

(Also, it's not exactly according to standards to open things without
either O_RDONLY/O_RDWR...)
2021-10-25 21:39:05 +02:00
Yu Watanabe 6681eb021a udev: do not try to rename interface if it is already up
See dev_change_name() in kernel's net/core/dev.c.

Fixes #21105.
2021-10-25 20:18:53 +01:00
Yu Watanabe 756f1f5fd0 network: rename function 2021-10-26 02:27:26 +09:00
Yu Watanabe df8bf72631 network: dhcp6: rename variables 2021-10-26 00:35:22 +09:00
Yu Watanabe 78e50edfd4 network: dhcp6pd: move logic of acquiring subnet prefix into dhcp6_pd_assign_prefix()
Preparation for later commits.
2021-10-26 00:35:22 +09:00
Yu Watanabe 56bbe0ef02 network: dhcp6pd: introduce a simplified and unified method to calculate subnet prefix 2021-10-26 00:35:22 +09:00
Yu Watanabe f595b2e9b4 Merge pull request #21116 from poettering/test-cleaner
make tests a bit cleaner in regards to oomd handling
2021-10-25 23:16:14 +09:00
Yu Watanabe f8aa82e43f Merge pull request #21077 from poettering/mount-setattr
optimize remounting with mount_setattr() syscall
2021-10-25 23:15:10 +09:00
Yu Watanabe 2db32618fe nspawn: fix build when SECCOMP is disabled
Follow-up for 20e458ae3c.
2021-10-25 19:23:55 +09:00
Lennart Poettering 1d1ba68816 varlink: don't try to talk to oomd from unit tests
Talking to external daemons we ourselves maintain is a job for the
integration tests, not the unit tests. This communication is likely to
fail hence don#t even bother.

This makes our tests a bit cleaner.
2021-10-25 10:45:22 +02:00
Lennart Poettering fc594dee98 cgroup: handle gracefully if we can't read oom_kill cgroup attribute 2021-10-25 10:45:22 +02:00
Lennart Poettering 0289948eb4 mount-util: move opening of /proc/self/mountinfo into bind_remount_one_with_mountinfo()
Let's move things around a bit, and open /proc/self/mountinfo if needed
inside of bind_remount_one_with_mountinfo(). That way bind_remount_one()
can become a superthin inline wrapper around
bind_remount_one_with_mountinfo(). Main benefit is that we don't even
have to open /p/s/mi in case mount_setattr() actually worked for us.
2021-10-25 10:41:26 +02:00
Lennart Poettering 874052c501 mount-util: port over bind_remount_recursive_with_mountinfo() to mount_setattr() 2021-10-25 10:41:26 +02:00
Lennart Poettering 4f5644dba6 mount-util: use modern mount_setattr() syscall for bind_remount_one_with_mountinfo()
New kernels have a nice syscall for changing bind mount flags. Let's use
it. This makes the complex libmount based iteration logic unnecessary.
2021-10-25 10:41:26 +02:00
Yu Watanabe 096a154acc Merge pull request #21082 from yuwata/network-dhcp6-pd-trivial-cleanups
network: DHCPv6 PD: several trivial cleanups
2021-10-23 23:58:22 +09:00
Anssi Hannula 37e4637a9e efivars: skip writing if variable is already in wanted state
In order to minimize EFI variable NVRAM wear, do not rewrite variables
if they are already in the wanted state (i.e. same data and attributes).

This allows e.g. performing repeat calls of "bootctl install" (which
always rewrites the EFI boot entry) without consuming EFI NVRAM write
cycles.
2021-10-23 23:57:56 +09:00
Lennart Poettering aa0379f16f homed: don't drop caches on activation
We should drop caches if we are configured to do so in all cases where
we are done with home dir operations: except if that operation is
activation, because in that case we are not destroying anything, but
leaving it on.

Hence, turn off the flag that reminds us that we should drop caches
before exiting, once activation completed fully,

Follow-up for 86019efa44
2021-10-23 17:26:26 +09:00
Yu Watanabe 20e458ae3c nspawn: ignore --suppress-sync=yes when seccomp is disabled
Follow-up for 4a4654e024.

Fixes #21090.
2021-10-22 23:43:20 +02:00
Lennart Poettering dbf1aca619 nspawn: bump RLIMIT_NOFILE for nspawn payload similar to how host PID 1 does it for its payload
We try to pass containers roughly the same rlimits as the host gets from
the kernel. However, this means we'd set the RLIMIT_NOFILE to 4K. Which
is quite limiting though, and is something we actually departed from in
PID1: since 52d6207578 we raise the limit
substantially for all userspace.

Given that nspawn is quite often invoked without proper PID1, let's raise the
limits for container payloads the same way as we do from the real PID1
to its service payloads.
2021-10-22 23:42:55 +02:00
Jan Janssen e6cab77eca sd-boot: Add keys to reboot into firmware interface
This is useful if the auto-firmware setting has been disabled. The
keys used here are based on what the majority of firmware employ in
the wild.
This also ensures there's a chance for the user to discover this in
case they were too slow during POST or simply used the wrong ones.
2021-10-22 19:12:55 +02:00
Lennart Poettering 784c249f41 Merge pull request #21094 from poettering/userns-split
util-lib: split out userns allocation into new helper function
2021-10-22 19:12:21 +02:00
Lennart Poettering 7afef7ed14 Merge pull request #21093 from poettering/homework-trivial-tweaks
homed trivial refactoring
2021-10-22 19:12:01 +02:00
Lennart Poettering a972ab0f25 Merge pull request #21079 from poettering/fd-reopen-directory-tweak
fd-util: when re-opening a directory with fd_reopen() go via openat(……
2021-10-22 17:41:17 +02:00
Lennart Poettering 43cac49092 process-util: move sync() out of freeze()
We are using this for creating userns namespaces, and we really
shouldn't try to sync there. Moreover the use of free() in shutdown code
doesn't need it anyway, since it just sync()ed right before anyway. Only
the third user of freeze() we have actually needs the syc(), hence do it
there and nowhere else.
2021-10-22 16:37:10 +02:00
Lennart Poettering 979b0ff2c4 namespace-util: introduce userns_acquire() as helper for allocating new unbound userns
This returns a namespace fd, and takes a uidmap/gidmap as string. This
is split out out mount-util.c's remount_idmap() logic, so that we can
allocate a userns independently.
2021-10-22 16:34:30 +02:00
Lennart Poettering 8ddefb8eef basic: move freeze() from shared/exec-util.h to basic/process-util.h
That way we can use it in other code from basic/. It fits into both
headers equally well or badly, hence let's just move this one function.
2021-10-22 16:34:30 +02:00
Lennart Poettering 7cb791bcac homework: split home_unshare_and_mount() in two
Previously the call did two things, and the second thing was optional
(depending on first arg being NULL). Let's simplify this and just make
it two distinct functions, where one calls the other.

This should make things a bit more readable, given that we called a
function called "…and_mount()" which didn't actually mount...

No actual code changes, just some refactoring.
2021-10-22 16:09:50 +02:00
Lennart Poettering baa41cee77 homework: use bit fields where we deal with lots of separate boolean flags
No actual code changes, just making a structure a bit shorter.
2021-10-22 16:03:23 +02:00
Lennart Poettering 498abadb8c homework: add macro for "/run/systemd/user-home-mount"
We use this work dir a various places, and it's easy to mistype, hence
let the compiler detect this for us, and introduce a macro for it.

No code changes, just some search/replace.
2021-10-22 16:01:42 +02:00
Yu Watanabe 197aec7e79 network: dhcp6pd: fix the default value of subnet ID
The type of dhcp6_pd_subnet_id is int64_t.
2021-10-22 21:38:29 +09:00
Lennart Poettering 7c26a631ad varlink: disconnect varlink link in one more case
Previously we'd possibly see POLLHUP on a varlink link, and continue to
run epoll on it even though we have nothing to read nor write anymore.

Let's fix that, and once we know that there's nothing to write anymore
(or we saw a write error already) we'll disconnect after POLLHUP.

Fixes: #20062
2021-10-22 21:37:31 +09:00
Lennart Poettering 61fb966ccc test-fd-util: add test case for fd_reopen() 2021-10-22 14:06:08 +02:00
Lennart Poettering d6274e6b8f fd-util: tweak error handling in fd_reopen()
If we know that /proc/ works, then ENOENT when reopening an fd means the
fd didn't exist. Let's return the correct error code for that, i.e.
EBADF.
2021-10-22 14:06:08 +02:00
Lennart Poettering b4f73d1e17 fd-util: when re-opening a directory with fd_reopen() go via openat(…, ".", …)
This adds a tiny shortcut to fd_reopen(): if we are about to reopen the
fd via O_DIRECTORY then we know it#s a directory and we might as well
reopen it via opening "." using the fd as "at fd" in openat().

This has the benefit that we don't need /proc/self/fd/ around for this
special case: fewer sources of errors.
2021-10-22 14:05:12 +02:00
Lennart Poettering e0e914eaf8 test-networkd-address: fix clock type
The clock to use internally is clock_boottime_or_monotonic(), but the
test used CLOCK_MONOTONIC. After one system suspend the test thus likely
starts to fail.
2021-10-22 13:29:12 +02:00
Jan Janssen c496451216 sd-boot: Be more precise about secure boot modes
Fixes: #11559
2021-10-22 10:08:38 +02:00
Yu Watanabe b7f7c78793 network: dhcp6pd: check link state earlier before assigning prefixes to downstream
Also, narrow the acceptable range of the states.
2021-10-22 15:58:42 +09:00
Yu Watanabe a3ad6acf7b network: dhcp6pd: also call dhcp6_pd_prepare() and dhcp6_pd_finalize() for upstream interface
As now the subnet prefix may be assigned to the upstream interface.
2021-10-22 15:58:38 +09:00
Yu Watanabe 796273775c network: dhcp6pd: not necessary to drop routes when Assign=yes 2021-10-22 02:00:46 +09:00
Yu Watanabe f45fb83996 Merge pull request #21072 from yuwata/network-address-lifetime
network: address: use usec_t for handling lifetime
2021-10-22 01:46:55 +09:00
Yu Watanabe a3e33adfb5 Merge pull request #21050 from yuwata/network-bpf-cleanups
libsystemd-network: cleanup BPF code
2021-10-22 01:46:15 +09:00
Yu Watanabe 113e124f9b icmp6: shorten code a bit 2021-10-21 22:40:03 +09:00
Yu Watanabe ea51deb188 dhcp: shorten BPF code a bit
- replace `A = k` and `X = A` with `X = k`,
- replace `A ^= X` and `A == 0` with `A == X`.
- use UINT32_MAX when accept a packet
2021-10-21 22:39:53 +09:00
Yu Watanabe 155943b259 dhcp: rebreak function arguments 2021-10-21 22:39:43 +09:00
Yu Watanabe b8319d748f dhcp: fix assertions 2021-10-21 22:39:43 +09:00
Yu Watanabe d70c78131d dhcp: shorten code a bit 2021-10-21 22:39:43 +09:00
Yu Watanabe 36f1955da8 lldp: shorten code a bit 2021-10-21 22:39:43 +09:00
Yu Watanabe e2c7c38b74 arp-util: shorten BPF code a bit
- replace `A = k` and `X = A` with `X = k`,
- replace `A ^= X` and `A == 0` with `A == X`.
- use UINT32_MAX when accept a packet
2021-10-21 22:39:25 +09:00
Yu Watanabe 16bc8635d5 network: address: use usec_t for handling lifetime
This drops stuct ifa_cacheinfo from Address, and store lifetime with
usec_t.

Why? Now, all requests of address configurations are once stored in
the request queue, and will be processed when it is ready. So, the
timestamp value passed to the kernel must be evaluated on configure.

This also fixes the following two issues.
- Time values in struct ifa_cacheinfo are stored in uint32_t.
  So, the validity check of the address configured by NDisc may fail on
  long running systems.
- If a system uses DHCPv6PD, when an interface may appear or be
  reconfigured later, then the lifetime value may be inappropriate.
  We need to adjust the lifetime with the current time and the timestamp
  of the lease.
2021-10-21 20:58:15 +09:00
Yu Watanabe 03ccc4b423 network: ndisc: rename valid_until -> lifetime_usec 2021-10-21 20:58:15 +09:00