Commit Graph

23 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 5d4fc0e665 sysctl: set ipv4 settings in a race-free way
Fixes #6282.

This solution is a bit busy, but we close the race without setting *.all.*, so
it is still possible to set a different setting for particular interfaces.
Setting just "default" is not very useful because any interfaces present before
systemd-sysctl is invoked are not affected. Setting "all" is too harsh, because
the kernel takes the stronger of the device-specific setting and the "all" value,
so effectively having a weaker setting for specific interfaces is not possible.
2020-02-04 00:01:50 +01:00
Zbigniew Jędrzejewski-Szmek def9443793 Revert "sysctl: always write net.ipv4.conf.all.xyz= in addition to net.ipv4.conf.default.xyz="
This reverts commits 1836bf9e1d
and 9fefb9e3cd.

The race is reintroduced, and will be fixed later.
2020-01-30 10:48:43 +01:00
Lennart Poettering 000500c9d6 sysctl: prefix ping port range setting with a dash
Fixes: #13177
2019-07-26 09:26:07 +02:00
Lennart Poettering 0338934f4b Revert "Revert "sysctl: Enable ping(8) inside rootless Podman containers""
This reverts commit be74f51605.

Let's add this again. With the new sysctl "-" thing we can make this
work.
2019-07-26 09:25:09 +02:00
Evgeny Vereshchagin be74f51605 Revert "sysctl: Enable ping(8) inside rootless Podman containers"
This reverts commit 90ce7627df.

See https://github.com/systemd/systemd/issues/13177#issuecomment-514931461
2019-07-26 06:56:58 +00:00
Debarshi Ray 90ce7627df sysctl: Enable ping(8) inside rootless Podman containers
This makes ping(8) work without CAP_NET_ADMIN and CAP_NET_RAW because
those aren't effective inside rootless Podman containers.

It's quite useful when using OSTree based operating systems like Fedora
Silverblue, where development environments are often set up using
rootless Podman containers with helpers like Toolbox [1]. Not having
a basic network utility like ping(8) work inside the development
environment can be inconvenient.

See:
https://lwn.net/Articles/422330/
http://man7.org/linux/man-pages/man7/icmp.7.html
https://github.com/containers/libpod/issues/1550

The upper limit of the range of group identifiers is set to 2147483647,
which is 2^31-1. Values greater than that get rejected by the kernel
because of this definition in linux/include/net/ping.h:
  #define GID_T_MAX (((gid_t)~0U) >> 1)

That's not so bad because values between 2^31 and 2^32-1 are reserved
on systemd-based systems anyway [2].

[1] https://github.com/debarshiray/toolbox
[2] https://systemd.io/UIDS-GIDS.html#summary
2019-07-24 16:41:45 +02:00
Yu Watanabe 0e0d424c0f sysctl: bump pid range only on 64-bit systems
Closes #12604.
2019-05-20 18:13:59 +02:00
Lennart Poettering 45497f4d3b sysctl: let's by default increase the numeric PID range from 2^16 to 2^22
This should PID collisions a tiny bit less likely, and thus improve
security and robustness.

2^22 isn't particularly a lot either, but it's the current kernel
limitation.

Bumping this limit was suggested by Linus himself:

https://lwn.net/ml/linux-kernel/CAHk-=wiZ40LVjnXSi9iHLE_-ZBsWFGCgdmNiYZUXn1-V5YBg2g@mail.gmail.com/

Let's experiment with this in systemd upstream first. Downstreams and
users can after all still comment this easily.

Besides compat concern the most often heard issue with such high PIDs is
usability, since they are potentially hard to type. I am not entirely sure though
whether 4194304 (as largest new PID) is that much worse to type or to
copy than 65563.

This should also simplify management of per system tasks limits as by
this move the sysctl /proc/sys/kernel/threads-max becomes the primary
knob to control how many processes to have in parallel.
2019-04-09 11:22:52 +02:00
Lucas Werkmeister 2732587540 Enable regular file and FIFO protection
These sysctls were added in Linux 4.19 (torvalds/linux@30aba6656f), and
we should enable them just like we enable the older hardlink/symlink
protection since v199. Implements #11414.
2019-01-16 12:22:01 +01:00
Lubomir Rintel 230450d4e4 sysctl.d: switch net.ipv4.conf.all.rp_filter from 1 to 2
This switches the RFC3704 Reverse Path filtering from Strict mode to Loose
mode. The Strict mode breaks some pretty common and reasonable use cases,
such as keeping connections via one default route alive after another one
appears (e.g. plugging an Ethernet cable when connected via Wi-Fi).

The strict filter also makes it impossible for NetworkManager to do
connectivity check on a newly arriving default route (it starts with a
higher metric and is bumped lower if there's connectivity).

Kernel's default is 0 (no filter), but a Loose filter is good enough. The
few use cases where a Strict mode could make sense can easily override
this.

The distributions that don't care about the client use cases and prefer a
strict filter could just ship a custom configuration in
/usr/lib/sysctl.d/ to override this.
2018-11-28 16:29:01 +01:00
Thomas Hindoe Paaboel Andersen 1e190dfd5b Revert "sysctl.d: request ECN on both in and outgoing connections"
Turning on ECN still causes slow or broken network on linux. Our tcp
is not yet ready for wide spread use of ECN.

This reverts commit 919472741dba6ad0a3f6c2b76d390a02d0e2fdc3.
2018-08-20 09:37:41 +02:00
Thomas H. P. Andersen 6f130e85c7 sysctl.d: request ECN on both in and outgoing connections (#9143)
To further avoid bufferbloat Explicit Congestion Notification (ECN)
should be enabled for both in and outgoing connections. The kernel
default is to enable it when requested for incoming connections, but
not to request it on outgoing connections. This patch enables it for
both.

A long time ago enabling these was causing problems, but these issues
have since been dealt with.

Fixes #9087.
2018-05-31 13:30:10 +02:00
Hristo Venev 9fefb9e3cd Do not set `net.ipv4.conf.default.*`
It is redundant because in these cases the values in
`net.ipv4.conf.all.*` take precedence. Also, setting the `default` does
nothing for devices that already exist.
2017-12-05 16:34:59 +02:00
Peter Körner bd9bb4ca61 sysctl.d: replace URL of SysRq key documentation (#5274)
The kernel documentation page is not distribution specific and also more
likely to be up to date than the Fedora wiki page referenced previously.
2017-02-08 19:42:43 +01:00
Torstein Husebø 61233823aa treewide: fix typos and remove accidental repetition of words 2016-07-11 16:18:43 +02:00
Lennart Poettering 19854865a8 core: bump net.unix.max_dgram_qlen really early during boot
Only that way it actually has an effect on all our sockets, including
$NOTIFY_SOCKET.
2015-11-02 23:44:05 +01:00
Lennart Poettering cacea34bd1 sysctl.d: bump number of queueable AF_UNIX/SOCK_DGRAM datagrams
The default of 16 is pretty low, let's bump this to accomodate for more
queued datagrams. This is useful for AF_UNIX/SOCK_DGRAM logging and
sd_notify() sockets as this allows queuing more datagrams before things
start to block, thus improving parallelization and logging performance.
2015-10-31 19:09:20 +01:00
Zbigniew Jędrzejewski-Szmek 16b65d7f46 sysctl: add some hints how to override settings
Also a link to decent documentation for sysrq keys. It is surprising
hard to find.

https://lists.fedoraproject.org/pipermail/devel/2015-February/208412.html
2015-02-26 19:07:38 -05:00
Michal Schmidt e6c253e363 sysctl.d: default to fq_codel, fight bufferbloat
Quoting from Jon Corbet's report of Stephen Hemminger's talk at Linux
Plumbers Conference 2014 (https://lwn.net/Articles/616241/):

    [...] So Stephen encouraged everybody to run a command like:

    sysctl -w net.core.default_qdisc=fq_codel

    That will cause fq_codel to be used for all future connections
    [Qdiscs apply to interfaces, not connections. Pointed out by TomH
    in the article comments. -- mschmidt] (up to the next reboot).
    Unfortunately, the default queuing discipline cannot be changed,
    since it will certainly disturb some user's workload somewhere.

Let's have the recommended default in systemd.

Thanks to Dave Täht for advice and the summary at
https://lists.bufferbloat.net/pipermail/cerowrt-devel/2014-October/003701.html
2014-10-20 18:19:00 +02:00
Lennart Poettering 1836bf9e1d sysctl: always write net.ipv4.conf.all.xyz= in addition to net.ipv4.conf.default.xyz=
Otherwise we have a boot-time race, where interfaces that popped up
after the sysctl service would get the settings applied, but all others
wouldn't.
2014-08-15 12:07:33 +02:00
Tom Gundersen ad8bc9ea50 sysctl.d: enable promote_secondaries by default
Without this, secondary addresses would get deleted when the primary one is. This is not
the desired behavior when one would like to transition from one address to another in the
same subnet (such as when a new IP address is given over DHCP).

In networkd, when given a new IP over DHCP we will add it, without explicitly removing the
old one first (and hence never have a window without an IP address configured). Assuming the
addresses are in the same subnet, that means that the old address is the primary and the new
address is the secondary one. Once the old address expires, the kernel will drop it. With the
old behavior this means that both addresses would be lost, which is clearly not what we want.
With the new behavior, only the old address is lost, and the new one is promoted to primary.

Reported by Michael Olbrich <m.olbrich@pengutronix.de>
2014-07-25 11:18:12 +02:00
Kay Sievers 0f59fe5171 sysctl: default - add safe sysrq options 2013-03-15 19:30:53 +01:00
Kay Sievers 8f27a2212e sysctl: add 50-default.conf 2013-03-15 16:37:58 +01:00