Commit Graph

48145 Commits

Author SHA1 Message Date
Yu Watanabe 8c47d1103f basic/linux: update kernel headers
From kernel commit 34816d20f173a90389c8a7e641166d8ea9dce70a.
2020-12-03 11:20:59 +09:00
Yu Watanabe 2a236f9fc0 network: ignore broadcast address for /31 or /32 addresses
As they do not have broadcast address.
See https://tools.ietf.org/html/rfc3021
2020-12-03 10:23:12 +09:00
Yu Watanabe 05a7023d24 network: fix verification for broadcast address
Fixes a bug caused by fe841414ef.
2020-12-03 10:23:12 +09:00
Yu Watanabe df8aa08642 network: do not set broadcast if prefixlen is 31 or 32
After fe841414ef, broadcast address is
also compared with existing one to determine whether the address is
foregin or not. So, the address object should not contain unnecessary
information.

Fixes #17803.
2020-12-03 10:22:50 +09:00
Lennart Poettering 565147b7bb stub: don't ever respond to datagrams coming in on non-localhost addreses, on the stub 2020-12-03 09:35:40 +09:00
Lennart Poettering 9ca875e80c resolved: beef up logic for suppressing "localhost" entry in /etc/hosts
Either suppress the entry entirely, or not at all. But do not suppress
the "localhost" names we recognize, leaving the ones we do not in place.

On Fedora, where "localhost4.localdomain4" is among those listed in
/etc/hosts for 127.0.0.1 we'd thus otherwise drop the "localhost" but
keep the "localhost4.localdomain4" and then on reverse lookups only
return that, which is highly confusing.
2020-12-03 09:06:27 +09:00
Lennart Poettering 36d892b7e6 resolved: use stat_inode_unmodified() to detect /etc/hosts changes 2020-12-03 08:58:45 +09:00
Lennart Poettering fbbc72189f resolved: never allow _gateway lookups to go to the network
Make them rather fail than go to the network.

Previously we'd filter them on LLMNR (explicitly) and MDNS (implicitly,
because it doesn't have .local suffix), but not on DNS.

In order to make _gateway truly reliable, let's not allow it to go to
DNS either, and keep it local.

This is particular relevant, as clients can now request lookups without
local RR synthesis, where we'd rather have NXDOMAIN returned for
_gateway than have it hit the network.
2020-12-03 08:56:27 +09:00
Lennart Poettering 19bcef9dc3 resolved: lower SERVFAIL cache timeout from 30s to 10s
Apparently 30s is a bit too long for some cases, see #5552. But not
caching SERVFAIL at all also breaks stuff, see explanation in
201d99584e.

Let's try to find some middle ground, by lowering the cache timeout to
10s. This should be ample for the problem
201d99584e attackes, but not as long as
half a miute, as #5552 complains.

Fixes: #5552
2020-12-03 08:52:27 +09:00
Yu Watanabe 34f80876f8
Merge pull request #17807 from poettering/bindtodevice
use SO_BINDTOIFINDEX while connect()
2020-12-03 08:50:43 +09:00
Lennart Poettering 0a489d3f5d resolved: insert large dgram size into EDNS0 only when in LARGE UDP mode
Specifically, in TLS-DO there's no reason to set the exotic dgram size.
2020-12-03 08:49:58 +09:00
Lennart Poettering d80e72ec60 dns-domain: try IDN2003 rules if IDN2008 doesn't work
This follows more closely what web browsers do, and makes sure emojis in
domains work.

Fixes: #14483
2020-12-03 08:48:11 +09:00
Steve Ramage 7d27d39aa7
Adds missing documentation for Assertions (#17825) 2020-12-03 08:47:24 +09:00
Anita Zhang 14d044da23 test: fix TEST-56-OOMD thresholds for linux 5.9 changes
Fixes #17533

The memory pressure values of the units in TEST-56-OOMD seemed to be a
lot lower after updating to linux 5.9. This is likely due to a fix from
e22c6ed90a.

To account for this, I lowered memory.high on testbloat.service to
throttle it even more. This was enough to generate the 50%+ value to trigger
oomd for the test, but as an extra precaution I also lowered the oomd
threshold to 1% so it's certain to try and kill testbloat.service.
2020-12-02 15:27:15 -08:00
Yu Watanabe f01a3b79fa
Merge pull request #17810 from systemd/meson-allows-fuzzer-building
meson: always allow fuzzers to be built
2020-12-03 07:36:43 +09:00
Lennart Poettering 90df0fbea8 resolved: automatically flush caches on clock change
DNSSEC validation takes the system clock into account to validate
signatures. This means if we had incorrect time and the time is then
changed to the correct one we should flush out everything and
re-validate taking the new time into account.

(This logic will also trigger after system suspend, which is not bad
either, given that quite possibly we are connected to a different
network, and thus would get different DNS data, without us noticing
otherwise via link beat).
2020-12-03 07:25:17 +09:00
Christopher Obbard c8037dbf05 virt: Properly detect nested UML inside another hypervisor
UML runs as a user-process so it can quite easily be ran inside of
another hypervisor, for instance inside a KVM instance. UML passes
through the CPUID from the host machine so in this case detect_vm
incorrectly identifies as running under KVM. So check we are running
a UML kernel first, before we check any other hypervisors.

Resolves: #17754

Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>
2020-12-03 07:19:41 +09:00
Lennart Poettering 0b261ac5be resolved: log when a bus client changes per-link DNS info
Fixes: #16298
2020-12-03 07:08:07 +09:00
Zbigniew Jędrzejewski-Szmek 4cbd28af60
Merge pull request #17804 from poettering/write-resolve-conf-less
write resolv.conf less often
2020-12-02 16:56:52 +01:00
Lennart Poettering 7e8a93b77c resolved: properly check per-link NTA list
We need to check for parent domains too. We did this correctly for the
system-wide NTA list, but not for the per-link one. Let's fix that.
2020-12-02 16:56:11 +01:00
Lennart Poettering d301c52383 resolved: bind socket to interface during connect()
Apparently, IF_UNICAST_IF does not influence the routing decisions done
during connect(). But SO_BINDTODEVICE/SO_BINDTOINDEX does, which however
brings a lot of other semantics with it, we are not so interested in
(i.e. it doesn't not allow packets from any other iface to us, even if
routing otherwise allows it).

Hence, let's bind to the ifindex immediately before the connect() and
unbind right after again, so that we get the semantics we want, but not
the ones we don't.

Fixes: #11935
Replaces: #12004
2020-12-02 15:15:02 +01:00
Lennart Poettering 3132597182 socket-util: add sockaddr_in_addr() helper
This extracts the IP address (as union in_addr_union) from a socket
address (i.e. a struct sockaddr).
2020-12-02 15:14:21 +01:00
Zbigniew Jędrzejewski-Szmek 9c2c6692f3
Merge pull request #17707 from yuwata/network-fix-reconfigure
network: fix race in reconfiguring link
2020-12-02 15:10:34 +01:00
Zbigniew Jędrzejewski-Szmek efbbdf2923
Merge pull request #17798 from yuwata/ipv4ll-follow-ups
network: improve debug logs and add tests for IPv4LL
2020-12-02 14:59:33 +01:00
walbit-de 2d453f3597
network: add Protocol= to vlan netdev (#17794) 2020-12-02 14:58:02 +01:00
Zbigniew Jędrzejewski-Szmek 7e299ffe10 meson: allow fuzzers to be built even if fuzz testing is disabled
This makes commands like 'ninja -C build fuzz-journal-remote' or
'ninja -C build fuzzers' work, even if we have -Dfuzz-tests=false.
Two advantages: correctness of the meson declarations is verified even
if fuzzers are not built, and it easier to do a one-off build to check for
regressions or such.

Follow-up for 1763ef1d49.
2020-12-02 13:51:31 +01:00
Yu Watanabe 59c31eba49 network: stop to assign UUID when reconfiguring link
This fixes the following race in reconfiguring link:
1. an interface requests UUID.
2. the interface is reconfigured and link_configure() is called.
3. sd-lldp client is started on the interface (it is enabled by default).
4. networkd acquires UUID, and get_product_uuid_handler() calls
   link_configure() for the link again.
5. link_lldp_rx_configure() fails to set ifindex for already running
   sd-lldp client.
6. the link enters failed state.
2020-12-02 20:31:39 +09:00
Yu Watanabe f63e09ef75 network: use bus_error_message() 2020-12-02 20:31:39 +09:00
Yu Watanabe 0f82a2ab5c meson: use '_' as separator in fuzz test names
Follow-up for d448888924 and ca121e20c4.

Fixes #17568.
2020-12-02 11:14:26 +01:00
Yu Watanabe da115b935a tree-wide: fix typos 2020-12-02 10:53:33 +01:00
Yu Watanabe 5f016e326d network: add debug log about requesting DHCP address
This addresses
https://github.com/systemd/systemd/pull/17474#discussion_r515996491.
2020-12-02 18:50:45 +09:00
Yu Watanabe 240e41372e test-network: confirm that IPv4ll address is dropped after DHCPv4 lease is acquired 2020-12-02 18:50:13 +09:00
Yu Watanabe 878c035a48 sd-ipv4acd: logs current state 2020-12-02 18:42:17 +09:00
Yu Watanabe 3f2c0d8520 sd-ipv4acd,sd-ipv4ll: include interface name in the debug logs 2020-12-02 18:42:13 +09:00
Yu Watanabe 1f1d4d42c1 log-link: introduce log_interface_full_errno() macro 2020-12-02 18:41:01 +09:00
Yu Watanabe 99b06a2f5c sd-ipv4acd,sd-ipv4ll: introduce _get_ifindex() and _get_ifname()
They will be used in later commits.

This also makes sd_ipv4acd_set_ifindex() check the existence of the interface.
2020-12-02 18:40:24 +09:00
Lennart Poettering f3e1f00d03 resolved: don't update resolv.conf snippets unnecessarily
Fixes: #17577
2020-12-02 10:32:17 +01:00
Lennart Poettering 1098142436 fs-util: add conservative_rename() that suppresses unnecessary renames
if the source and destination file match in contents and basic file
attributes, don#t rename, but just remove source.

This is a simple way to suppress inotify events + mtime changes when
atomically updating files.
2020-12-02 10:32:17 +01:00
Lennart Poettering b1b657c48f copy: teach copy_file() that a mode=-1 call means "take mode from original file" 2020-12-02 10:32:17 +01:00
Zbigniew Jędrzejewski-Szmek ebef02dd8f pager: stop disabling urlification under a pager
Less 568 properly shows urlified strings.

Putative NEWS entry:
* Urlification is now enabled by default even when a pager is used.
  Previously it was disabled, because less would not show such markup
  properly. This has been fixed in less 568.
  Please either upgrade less, or use SYSTEMD_URLIFY=0 to disable the
  feature.
2020-12-02 16:50:44 +09:00
Zbigniew Jędrzejewski-Szmek 0a67dd8310
Merge pull request #17692 from yuwata/ipv4ll
network: fold ipv4ll fallback modes into normal ipv4ll addressing
2020-12-01 21:59:30 +01:00
Zbigniew Jędrzejewski-Szmek f319b2b1b0
Merge pull request #17703 from poettering/event-ratelimit
sd-event: add a concept of ratelimiting
2020-12-01 21:47:43 +01:00
Zbigniew Jędrzejewski-Szmek 946f3d868c
Merge pull request #17524 from poettering/fileio-offset
cryptsetup: if keyfile is specified as AF_UNIX socket in the fs, connect to it, and read key data from it
2020-12-01 21:38:52 +01:00
Lennart Poettering a303686fc1 man: document new ratelimiting APIs 2020-12-01 15:15:39 +01:00
Michal Sekletár d586f642fd core: prevent excessive /proc/self/mountinfo parsing 2020-12-01 15:15:39 +01:00
Michal Sekletár 68d8906517 test: add ratelimiting test
(Taken from Michal's #17274 by Lennart, and slightly adjusted)
2020-12-01 15:15:39 +01:00
Lennart Poettering b6d5481b3d sd-event: add ability to ratelimit event sources
Let's a concept of "rate limiting" to event sources: if specific event
sources fire too often in some time interval temporarily take them
offline, and take them back online once the interval passed.

This is a simple scheme of avoiding starvation of event sources if some
event source fires too often.

This introduces the new conceptual states of "offline" and "online" for
event sources: an event source is "online" only when enabled *and* not
ratelimited, and offline in all other cases. An event source that is
online hence has its fds registered in the epoll, its signals in the
signalfd and so on.
2020-12-01 15:11:24 +01:00
Lennart Poettering f41315fceb sd-event: remove earliest_index/latest_index into common part of event source objects
So far we used these fields to organize the earliest/latest timer event
priority queue.  In a follow-up commit we want to introduce ratelimiting
to event sources, at which point we want any kind of event source to be
able to trigger time wakeups, and hence they all need to be included in
the earliest/latest prioqs.  Thus, in preparation let's make this
generic.

No change in behaviour, just some shifting around of struct members from
the type-specific to the generic part.
2020-12-01 15:10:50 +01:00
Lennart Poettering cad143a8f2 sd-event: follow coding style with naming return parameter 2020-12-01 15:10:50 +01:00
Lennart Poettering f814c871e6 sd-event: ref event loop while in sd_event_prepare() ot sd_event_run()
sd_event_prepare() invokes callbacks that might drop the last user ref
on our event loop. Let's make sure we keep an explicit ref around it, so
that we won't end up with an invalid pointer. Similar in sd_event_run().

Basically, any function that is publically callable that might end up
invoking callbacks should ref the relevant objects to be protected
against callbacks destroying these objects while we still want to access
them. We did this correctly in sd_event_dispatch() and sd_event_loop(),
but these are not the only ones which are callable from the outside.
2020-12-01 15:10:50 +01:00