1
0
mirror of https://github.com/systemd/systemd synced 2025-12-27 19:34:47 +01:00

Compare commits

..

9 Commits

Author SHA1 Message Date
Yu Watanabe
85b6a8110d network: do not add prefix to RA if radv is not configured
Fixes #17017.
2020-09-11 19:28:46 +02:00
Michal Sekletár
882f5f429e cryptsetup: generate the unit to umount keydev filesystem
Previously we would call umount from ExecStartPost= of
systemd-cryptsetup instance in order to get rid of the keydev
mount (i.e. filesystem containing keyfile). Let's generate unit to
handle umount. Making this symmetrical (both mount and umount of keydev
are handled by units) fixes the problem with lingering keydev mounts.

Motivation for the change is the issue where keydev mount would stay
around even if device was successfully unlocked and mount is no longer
needed. That could happen previously because when generator options are
not prefixed with "rd." we run generators twice (e.g. rd.luks.key=...).

In such case disk is unlocked in initramfs phase of boot (assuming the
initrd image contains the generator and is able to handle unlocking of
LUKS devices). After switchroot we however enqueue start job for
systemd-cryptsetup instance (because units are regenerated second time)
and that pulls in its dependencies into transaction. Later the main
systemd-cryptsetup unit not actually started since it is already active
and has RemainaAfterExit=yes. Nevertheless, dependencies get activated
and keydev mount is attached again. Because previously we called umount
from ExecStartPost= of systemd-cryptsetup instance the umount is not
called second time and keydev filesystem stays lingering.
2020-09-11 19:20:28 +02:00
Nazar Vinnichuk
5501da15ba man: document the random delay of persistent timers
The manual states that a persistent timer triggers it's service
immediately on activation to catch up with missed invocations, but since
PR #11608 it is no longer the case if RandomizedDelaySec= is set to a
non-zero value.
2020-09-11 18:08:40 +02:00
Yu Watanabe
766f8f388f test-network: add test for ENOBUFS issue #17012
The issue seems already fixed by PR #16982 and its follow-up commit
4934ba2121d76229659939e19ab7d70a89446629.
2020-09-11 18:07:47 +02:00
Lennart Poettering
e67b818c2f unit: declare BusName= in all our units that are on the bus, event if they don't use Type=dbus
This information is always useful, so let's always declare it,
particular in the light of #16976.
2020-09-11 16:01:22 +02:00
Lennart Poettering
f7c87baeca
Merge pull request #17020 from yuwata/backlight
backlight: validate sysattr value
2020-09-11 14:23:47 +02:00
Yu Watanabe
3bacb7e73b backlight: validate read sysattr value
If actual_brightness is larger than max_brightness, then fall back to
use brightness attribute.

Also, if the saved value is invalid, then this makes remove the file in
/var/lib/systemd/backlight.

Hopefully fixes #17011.
2020-09-11 17:46:11 +09:00
Yu Watanabe
06d98bdc81 backlight: do not claim that ID_BACKLIGHT_CLAMP= property is not set 2020-09-11 17:44:20 +09:00
Yu Watanabe
ea2bc25762 sd-device: introduce sd_device_set_sysattr_valuef() 2020-09-11 17:41:10 +09:00
13 changed files with 441 additions and 63 deletions

View File

@ -297,9 +297,10 @@
<listitem><para>Takes a boolean argument. If true, the time when the service unit was last triggered <listitem><para>Takes a boolean argument. If true, the time when the service unit was last triggered
is stored on disk. When the timer is activated, the service unit is triggered immediately if it is stored on disk. When the timer is activated, the service unit is triggered immediately if it
would have been triggered at least once during the time when the timer was inactive. This is useful would have been triggered at least once during the time when the timer was inactive. Such triggering
to catch up on missed runs of the service when the system was powered down. Note that this setting is nonetheless subject to the delay imposed by <varname>RandomizedDelaySec=</varname>.
only has an effect on timers configured with <varname>OnCalendar=</varname>. Defaults to This is useful to catch up on missed runs of the service when the system was powered down. Note that
this setting only has an effect on timers configured with <varname>OnCalendar=</varname>. Defaults to
<varname>false</varname>.</para> <varname>false</varname>.</para>
<para>Use <command>systemctl clean --what=state …</command> on the timer unit to remove the timestamp <para>Use <command>systemctl clean --what=state …</command> on the timer unit to remove the timestamp

View File

@ -261,17 +261,13 @@ static int get_max_brightness(sd_device *device, unsigned *ret) {
* max_brightness in case of 'backlight' subsystem. This avoids preserving * max_brightness in case of 'backlight' subsystem. This avoids preserving
* an unreadably dim screen, which would otherwise force the user to * an unreadably dim screen, which would otherwise force the user to
* disable state restoration. */ * disable state restoration. */
static int clamp_brightness(sd_device *device, char **value, unsigned max_brightness) { static int clamp_brightness(sd_device *device, bool saved, unsigned max_brightness, unsigned *brightness) {
unsigned brightness, new_brightness, min_brightness; unsigned new_brightness, min_brightness;
const char *subsystem; const char *subsystem;
int r; int r;
assert(value); assert(device);
assert(*value); assert(brightness);
r = safe_atou(*value, &brightness);
if (r < 0)
return log_device_warning_errno(device, r, "Failed to parse brightness \"%s\": %m", *value);
r = sd_device_get_subsystem(device, &subsystem); r = sd_device_get_subsystem(device, &subsystem);
if (r < 0) if (r < 0)
@ -282,22 +278,16 @@ static int clamp_brightness(sd_device *device, char **value, unsigned max_bright
else else
min_brightness = 0; min_brightness = 0;
new_brightness = CLAMP(brightness, min_brightness, max_brightness); new_brightness = CLAMP(*brightness, min_brightness, max_brightness);
if (new_brightness != brightness) { if (new_brightness != *brightness)
char *new_value; log_device_info(device, "%s brightness %u is %s to %u.",
saved ? "Saved" : "Current",
r = asprintf(&new_value, "%u", new_brightness); *brightness,
if (r < 0) new_brightness > *brightness ?
return log_oom();
log_device_info(device, "Saved brightness %s %s to %s.", *value,
new_brightness > brightness ?
"too low; increasing" : "too high; decreasing", "too low; increasing" : "too high; decreasing",
new_value); new_brightness);
free_and_replace(*value, new_value);
}
*brightness = new_brightness;
return 0; return 0;
} }
@ -309,7 +299,8 @@ static bool shall_clamp(sd_device *d) {
r = sd_device_get_property_value(d, "ID_BACKLIGHT_CLAMP", &s); r = sd_device_get_property_value(d, "ID_BACKLIGHT_CLAMP", &s);
if (r < 0) { if (r < 0) {
log_device_debug_errno(d, r, "Failed to get ID_BACKLIGHT_CLAMP property, ignoring: %m"); if (r != -ENOENT)
log_device_debug_errno(d, r, "Failed to get ID_BACKLIGHT_CLAMP property, ignoring: %m");
return true; return true;
} }
@ -322,31 +313,60 @@ static bool shall_clamp(sd_device *d) {
return r; return r;
} }
static int read_brightness(sd_device *device, const char **ret) { static int read_brightness(sd_device *device, unsigned max_brightness, unsigned *ret_brightness) {
const char *subsystem; const char *subsystem, *value;
unsigned brightness;
int r; int r;
assert(device); assert(device);
assert(ret); assert(ret_brightness);
r = sd_device_get_subsystem(device, &subsystem); r = sd_device_get_subsystem(device, &subsystem);
if (r < 0) if (r < 0)
return log_device_debug_errno(device, r, "Failed to get subsystem: %m"); return log_device_debug_errno(device, r, "Failed to get subsystem: %m");
if (streq(subsystem, "backlight")) { if (streq(subsystem, "backlight")) {
r = sd_device_get_sysattr_value(device, "actual_brightness", ret); r = sd_device_get_sysattr_value(device, "actual_brightness", &value);
if (r >= 0) if (r == -ENOENT) {
return 0; log_device_debug_errno(device, r, "Failed to read 'actual_brightness' attribute, "
if (r != -ENOENT) "fall back to use 'brightness' attribute: %m");
goto use_brightness;
}
if (r < 0)
return log_device_debug_errno(device, r, "Failed to read 'actual_brightness' attribute: %m"); return log_device_debug_errno(device, r, "Failed to read 'actual_brightness' attribute: %m");
log_device_debug_errno(device, r, "Failed to read 'actual_brightness' attribute, fall back to use 'brightness' attribute: %m"); r = safe_atou(value, &brightness);
if (r < 0) {
log_device_debug_errno(device, r, "Failed to parse 'actual_brightness' attribute, "
"fall back to use 'brightness' attribute: %s", value);
goto use_brightness;
}
if (brightness > max_brightness) {
log_device_debug(device, "actual_brightness=%u is larger than max_brightness=%u, "
"fall back to use 'brightness' attribute", brightness, max_brightness);
goto use_brightness;
}
*ret_brightness = brightness;
return 0;
} }
r = sd_device_get_sysattr_value(device, "brightness", ret); use_brightness:
r = sd_device_get_sysattr_value(device, "brightness", &value);
if (r < 0) if (r < 0)
return log_device_debug_errno(device, r, "Failed to read 'brightness' attribute: %m"); return log_device_debug_errno(device, r, "Failed to read 'brightness' attribute: %m");
r = safe_atou(value, &brightness);
if (r < 0)
return log_device_debug_errno(device, r, "Failed to parse 'brightness' attribute: %s", value);
if (brightness > max_brightness)
return log_device_debug_errno(device, SYNTHETIC_ERRNO(EINVAL),
"brightness=%u is larger than max_brightness=%u",
brightness, max_brightness);
*ret_brightness = brightness;
return 0; return 0;
} }
@ -354,7 +374,7 @@ static int run(int argc, char *argv[]) {
_cleanup_(sd_device_unrefp) sd_device *device = NULL; _cleanup_(sd_device_unrefp) sd_device *device = NULL;
_cleanup_free_ char *escaped_ss = NULL, *escaped_sysname = NULL, *escaped_path_id = NULL; _cleanup_free_ char *escaped_ss = NULL, *escaped_sysname = NULL, *escaped_path_id = NULL;
const char *sysname, *path_id, *ss, *saved; const char *sysname, *path_id, *ss, *saved;
unsigned max_brightness; unsigned max_brightness, brightness;
int r; int r;
log_setup_service(); log_setup_service();
@ -431,44 +451,50 @@ static int run(int argc, char *argv[]) {
clamp = shall_clamp(device); clamp = shall_clamp(device);
r = read_one_line_file(saved, &value); r = read_one_line_file(saved, &value);
if (IN_SET(r, -ENOENT, 0)) { if (r < 0 && r != -ENOENT)
const char *curval; return log_error_errno(r, "Failed to read %s: %m", saved);
if (r > 0) {
r = safe_atou(value, &brightness);
if (r < 0) {
log_error_errno(r, "Failed to parse saved brightness '%s', removing %s.",
value, saved);
(void) unlink(saved);
} else {
if (clamp)
(void) clamp_brightness(device, true, max_brightness, &brightness);
/* Fallback to clamping current brightness or exit early if /* Do not fall back to read current brightness below. */
* clamping is not supported/enabled. */ r = 1;
}
}
if (r <= 0) {
/* Fallback to clamping current brightness or exit early if clamping is not
* supported/enabled. */
if (!clamp) if (!clamp)
return 0; return 0;
r = read_brightness(device, &curval); r = read_brightness(device, max_brightness, &brightness);
if (r < 0) if (r < 0)
return log_device_error_errno(device, r, "Failed to read current brightness: %m"); return log_device_error_errno(device, r, "Failed to read current brightness: %m");
value = strdup(curval); (void) clamp_brightness(device, false, max_brightness, &brightness);
if (!value) }
return log_oom();
} else if (r < 0)
return log_error_errno(r, "Failed to read %s: %m", saved);
if (clamp) r = sd_device_set_sysattr_valuef(device, "brightness", "%u", brightness);
(void) clamp_brightness(device, &value, max_brightness);
r = sd_device_set_sysattr_value(device, "brightness", value);
if (r < 0) if (r < 0)
return log_device_error_errno(device, r, "Failed to write system 'brightness' attribute: %m"); return log_device_error_errno(device, r, "Failed to write system 'brightness' attribute: %m");
} else if (streq(argv[1], "save")) { } else if (streq(argv[1], "save")) {
const char *value;
if (validate_device(device) == 0) { if (validate_device(device) == 0) {
(void) unlink(saved); (void) unlink(saved);
return 0; return 0;
} }
r = read_brightness(device, &value); r = read_brightness(device, max_brightness, &brightness);
if (r < 0) if (r < 0)
return log_device_error_errno(device, r, "Failed to read current brightness: %m"); return log_device_error_errno(device, r, "Failed to read current brightness: %m");
r = write_string_file(saved, value, WRITE_STRING_FILE_CREATE); r = write_string_filef(saved, WRITE_STRING_FILE_CREATE, "%u", brightness);
if (r < 0) if (r < 0)
return log_device_error_errno(device, r, "Failed to write %s: %m", saved); return log_device_error_errno(device, r, "Failed to write %s: %m", saved);

View File

@ -181,6 +181,47 @@ static int generate_keydev_mount(
return 0; return 0;
} }
static int generate_keydev_umount(const char *name,
const char *keydev_mount,
char **ret_umount_unit) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_free_ char *u = NULL, *name_escaped = NULL, *mount = NULL;
int r;
assert(name);
assert(ret_umount_unit);
name_escaped = cescape(name);
if (!name_escaped)
return -ENOMEM;
u = strjoin("keydev-", name_escaped, "-umount.service");
if (!u)
return -ENOMEM;
r = unit_name_from_path(keydev_mount, ".mount", &mount);
if (r < 0)
return r;
r = generator_open_unit_file(arg_dest, NULL, u, &f);
if (r < 0)
return r;
fprintf(f,
"[Unit]\n"
"DefaultDependencies=no\n"
"After=%s\n\n"
"[Service]\n"
"ExecStart=-" UMOUNT_PATH " %s\n\n", mount, keydev_mount);
r = fflush_and_check(f);
if (r < 0)
return r;
*ret_umount_unit = TAKE_PTR(u);
return 0;
}
static int print_dependencies(FILE *f, const char* device_path) { static int print_dependencies(FILE *f, const char* device_path) {
int r; int r;
@ -314,12 +355,16 @@ static int create_disk(
fprintf(f, "Conflicts=umount.target\n"); fprintf(f, "Conflicts=umount.target\n");
if (keydev) { if (keydev) {
_cleanup_free_ char *unit = NULL; _cleanup_free_ char *unit = NULL, *umount_unit = NULL;
r = generate_keydev_mount(name, keydev, keyfile_timeout_value, keyfile_can_timeout > 0, &unit, &keydev_mount); r = generate_keydev_mount(name, keydev, keyfile_timeout_value, keyfile_can_timeout > 0, &unit, &keydev_mount);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to generate keydev mount unit: %m"); return log_error_errno(r, "Failed to generate keydev mount unit: %m");
r = generate_keydev_umount(name, keydev_mount, &umount_unit);
if (r < 0)
return log_error_errno(r, "Failed to generate keydev umount unit: %m");
password_buffer = path_join(keydev_mount, password); password_buffer = path_join(keydev_mount, password);
if (!password_buffer) if (!password_buffer)
return log_oom(); return log_oom();
@ -331,6 +376,15 @@ static int create_disk(
fprintf(f, "Wants=%s\n", unit); fprintf(f, "Wants=%s\n", unit);
else else
fprintf(f, "Requires=%s\n", unit); fprintf(f, "Requires=%s\n", unit);
if (umount_unit) {
fprintf(f,
"Wants=%s\n"
"Before=%s\n",
umount_unit,
umount_unit
);
}
} }
if (!nofail) if (!nofail)
@ -394,11 +448,6 @@ static int create_disk(
"ExecStartPost=" ROOTLIBEXECDIR "/systemd-makefs swap '/dev/mapper/%s'\n", "ExecStartPost=" ROOTLIBEXECDIR "/systemd-makefs swap '/dev/mapper/%s'\n",
name_escaped); name_escaped);
if (keydev)
fprintf(f,
"ExecStartPost=-" UMOUNT_PATH " %s\n\n",
keydev_mount);
r = fflush_and_check(f); r = fflush_and_check(f);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to write unit file %s: %m", n); return log_error_errno(r, "Failed to write unit file %s: %m", n);

View File

@ -732,4 +732,5 @@ global:
sd_device_get_current_tag_first; sd_device_get_current_tag_first;
sd_device_get_current_tag_next; sd_device_get_current_tag_next;
sd_device_has_current_tag; sd_device_has_current_tag;
sd_device_set_sysattr_valuef;
} LIBSYSTEMD_246; } LIBSYSTEMD_246;

View File

@ -1979,3 +1979,26 @@ _public_ int sd_device_set_sysattr_value(sd_device *device, const char *sysattr,
return 0; return 0;
} }
_public_ int sd_device_set_sysattr_valuef(sd_device *device, const char *sysattr, const char *format, ...) {
_cleanup_free_ char *value = NULL;
va_list ap;
int r;
assert_return(device, -EINVAL);
assert_return(sysattr, -EINVAL);
if (!format) {
device_remove_sysattr_value(device, sysattr);
return 0;
}
va_start(ap, format);
r = vasprintf(&value, format, ap);
va_end(ap);
if (r < 0)
return -ENOMEM;
return sd_device_set_sysattr_value(device, sysattr, value);
}

View File

@ -158,7 +158,8 @@ static int dhcp6_pd_remove_old(Link *link, bool force) {
if (k < 0) if (k < 0)
r = k; r = k;
(void) sd_radv_remove_prefix(link->radv, &route->dst.in6, 64); if (link->radv)
(void) sd_radv_remove_prefix(link->radv, &route->dst.in6, 64);
dhcp6_pd_free(hashmap_get(link->manager->dhcp6_prefixes, &route->dst.in6)); dhcp6_pd_free(hashmap_get(link->manager->dhcp6_prefixes, &route->dst.in6));
} }
@ -198,7 +199,8 @@ int dhcp6_pd_remove(Link *link) {
if (k < 0) if (k < 0)
r = k; r = k;
(void) sd_radv_remove_prefix(link->radv, &route->dst.in6, 64); if (link->radv)
(void) sd_radv_remove_prefix(link->radv, &route->dst.in6, 64);
dhcp6_pd_free(hashmap_get(link->manager->dhcp6_prefixes, &route->dst.in6)); dhcp6_pd_free(hashmap_get(link->manager->dhcp6_prefixes, &route->dst.in6));
} }

View File

@ -681,7 +681,9 @@ int radv_add_prefix(Link *link, const struct in6_addr *prefix, uint8_t prefix_le
int r; int r;
assert(link); assert(link);
assert(link->radv);
if (!link->radv)
return 0;
r = sd_radv_prefix_new(&p); r = sd_radv_prefix_new(&p);
if (r < 0) if (r < 0)

View File

@ -79,6 +79,7 @@ int sd_device_get_property_value(sd_device *device, const char *key, const char
int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, const char **_value); int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, const char **_value);
int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, const char *value); int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, const char *value);
int sd_device_set_sysattr_valuef(sd_device *device, const char *sysattr, const char *format, ...) _sd_printf_(3, 4);
/* device enumerator */ /* device enumerator */

View File

@ -51,3 +51,261 @@ Peer=2001:db8:0:f103::10/128
[Address] [Address]
Address=::/64 Address=::/64
# test for ENOBUFS issue #17012
[Network]
Address=10.3.3.1/16
Address=10.3.3.2/16
Address=10.3.3.3/16
Address=10.3.3.4/16
Address=10.3.3.5/16
Address=10.3.3.6/16
Address=10.3.3.7/16
Address=10.3.3.8/16
Address=10.3.3.9/16
Address=10.3.3.10/16
Address=10.3.3.11/16
Address=10.3.3.12/16
Address=10.3.3.13/16
Address=10.3.3.14/16
Address=10.3.3.15/16
Address=10.3.3.16/16
Address=10.3.3.17/16
Address=10.3.3.18/16
Address=10.3.3.19/16
Address=10.3.3.20/16
Address=10.3.3.21/16
Address=10.3.3.22/16
Address=10.3.3.23/16
Address=10.3.3.24/16
Address=10.3.3.25/16
Address=10.3.3.26/16
Address=10.3.3.27/16
Address=10.3.3.28/16
Address=10.3.3.29/16
Address=10.3.3.30/16
Address=10.3.3.31/16
Address=10.3.3.32/16
Address=10.3.3.33/16
Address=10.3.3.34/16
Address=10.3.3.35/16
Address=10.3.3.36/16
Address=10.3.3.37/16
Address=10.3.3.38/16
Address=10.3.3.39/16
Address=10.3.3.40/16
Address=10.3.3.41/16
Address=10.3.3.42/16
Address=10.3.3.43/16
Address=10.3.3.44/16
Address=10.3.3.45/16
Address=10.3.3.46/16
Address=10.3.3.47/16
Address=10.3.3.48/16
Address=10.3.3.49/16
Address=10.3.3.50/16
Address=10.3.3.51/16
Address=10.3.3.52/16
Address=10.3.3.53/16
Address=10.3.3.54/16
Address=10.3.3.55/16
Address=10.3.3.56/16
Address=10.3.3.57/16
Address=10.3.3.58/16
Address=10.3.3.59/16
Address=10.3.3.60/16
Address=10.3.3.61/16
Address=10.3.3.62/16
Address=10.3.3.63/16
Address=10.3.3.64/16
Address=10.3.3.65/16
Address=10.3.3.66/16
Address=10.3.3.67/16
Address=10.3.3.68/16
Address=10.3.3.69/16
Address=10.3.3.70/16
Address=10.3.3.71/16
Address=10.3.3.72/16
Address=10.3.3.73/16
Address=10.3.3.74/16
Address=10.3.3.75/16
Address=10.3.3.76/16
Address=10.3.3.77/16
Address=10.3.3.78/16
Address=10.3.3.79/16
Address=10.3.3.80/16
Address=10.3.3.81/16
Address=10.3.3.82/16
Address=10.3.3.83/16
Address=10.3.3.84/16
Address=10.3.3.85/16
Address=10.3.3.86/16
Address=10.3.3.87/16
Address=10.3.3.88/16
Address=10.3.3.89/16
Address=10.3.3.90/16
Address=10.3.3.91/16
Address=10.3.3.92/16
Address=10.3.3.93/16
Address=10.3.3.94/16
Address=10.3.3.95/16
Address=10.3.3.96/16
Address=10.3.3.97/16
Address=10.3.3.98/16
Address=10.3.3.99/16
Address=10.3.3.100/16
Address=10.3.3.101/16
Address=10.3.3.101/16
Address=10.3.3.102/16
Address=10.3.3.103/16
Address=10.3.3.104/16
Address=10.3.3.105/16
Address=10.3.3.106/16
Address=10.3.3.107/16
Address=10.3.3.108/16
Address=10.3.3.109/16
Address=10.3.3.110/16
Address=10.3.3.111/16
Address=10.3.3.112/16
Address=10.3.3.113/16
Address=10.3.3.114/16
Address=10.3.3.115/16
Address=10.3.3.116/16
Address=10.3.3.117/16
Address=10.3.3.118/16
Address=10.3.3.119/16
Address=10.3.3.120/16
Address=10.3.3.121/16
Address=10.3.3.122/16
Address=10.3.3.123/16
Address=10.3.3.124/16
Address=10.3.3.125/16
Address=10.3.3.126/16
Address=10.3.3.127/16
Address=10.3.3.128/16
Address=10.3.3.129/16
Address=10.3.3.130/16
Address=10.3.3.131/16
Address=10.3.3.132/16
Address=10.3.3.133/16
Address=10.3.3.134/16
Address=10.3.3.135/16
Address=10.3.3.136/16
Address=10.3.3.137/16
Address=10.3.3.138/16
Address=10.3.3.139/16
Address=10.3.3.140/16
Address=10.3.3.141/16
Address=10.3.3.142/16
Address=10.3.3.143/16
Address=10.3.3.144/16
Address=10.3.3.145/16
Address=10.3.3.146/16
Address=10.3.3.147/16
Address=10.3.3.148/16
Address=10.3.3.149/16
Address=10.3.3.150/16
Address=10.3.3.151/16
Address=10.3.3.152/16
Address=10.3.3.153/16
Address=10.3.3.154/16
Address=10.3.3.155/16
Address=10.3.3.156/16
Address=10.3.3.157/16
Address=10.3.3.158/16
Address=10.3.3.159/16
Address=10.3.3.160/16
Address=10.3.3.161/16
Address=10.3.3.162/16
Address=10.3.3.163/16
Address=10.3.3.164/16
Address=10.3.3.165/16
Address=10.3.3.166/16
Address=10.3.3.167/16
Address=10.3.3.168/16
Address=10.3.3.169/16
Address=10.3.3.170/16
Address=10.3.3.171/16
Address=10.3.3.172/16
Address=10.3.3.173/16
Address=10.3.3.174/16
Address=10.3.3.175/16
Address=10.3.3.176/16
Address=10.3.3.177/16
Address=10.3.3.178/16
Address=10.3.3.179/16
Address=10.3.3.180/16
Address=10.3.3.181/16
Address=10.3.3.182/16
Address=10.3.3.183/16
Address=10.3.3.184/16
Address=10.3.3.185/16
Address=10.3.3.186/16
Address=10.3.3.187/16
Address=10.3.3.188/16
Address=10.3.3.189/16
Address=10.3.3.190/16
Address=10.3.3.191/16
Address=10.3.3.192/16
Address=10.3.3.193/16
Address=10.3.3.194/16
Address=10.3.3.195/16
Address=10.3.3.196/16
Address=10.3.3.197/16
Address=10.3.3.198/16
Address=10.3.3.199/16
Address=10.3.3.200/16
Address=10.3.3.201/16
Address=10.3.3.202/16
Address=10.3.3.203/16
Address=10.3.3.204/16
Address=10.3.3.205/16
Address=10.3.3.206/16
Address=10.3.3.207/16
Address=10.3.3.208/16
Address=10.3.3.209/16
Address=10.3.3.210/16
Address=10.3.3.211/16
Address=10.3.3.212/16
Address=10.3.3.213/16
Address=10.3.3.214/16
Address=10.3.3.215/16
Address=10.3.3.216/16
Address=10.3.3.217/16
Address=10.3.3.218/16
Address=10.3.3.219/16
Address=10.3.3.220/16
Address=10.3.3.221/16
Address=10.3.3.222/16
Address=10.3.3.223/16
Address=10.3.3.224/16
Address=10.3.3.225/16
Address=10.3.3.226/16
Address=10.3.3.227/16
Address=10.3.3.228/16
Address=10.3.3.229/16
Address=10.3.3.230/16
Address=10.3.3.231/16
Address=10.3.3.232/16
Address=10.3.3.233/16
Address=10.3.3.234/16
Address=10.3.3.235/16
Address=10.3.3.236/16
Address=10.3.3.237/16
Address=10.3.3.238/16
Address=10.3.3.239/16
Address=10.3.3.240/16
Address=10.3.3.241/16
Address=10.3.3.242/16
Address=10.3.3.243/16
Address=10.3.3.244/16
Address=10.3.3.245/16
Address=10.3.3.246/16
Address=10.3.3.247/16
Address=10.3.3.248/16
Address=10.3.3.249/16
Address=10.3.3.250/16
Address=10.3.3.251/16
Address=10.3.3.252/16
Address=10.3.3.253/16
Address=10.3.3.254/16

View File

@ -1767,6 +1767,10 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
self.assertRegex(output, 'inet 10.1.2.4/16 brd 10.1.255.255 scope global secondary dummy98') self.assertRegex(output, 'inet 10.1.2.4/16 brd 10.1.255.255 scope global secondary dummy98')
self.assertRegex(output, 'inet 10.2.2.4/16 brd 10.2.255.255 scope global dummy98') self.assertRegex(output, 'inet 10.2.2.4/16 brd 10.2.255.255 scope global dummy98')
# test for ENOBUFS issue #17012
for i in range(1,254):
self.assertRegex(output, f'inet 10.3.3.{i}/16 brd 10.3.255.255')
# invalid sections # invalid sections
self.assertNotRegex(output, '10.10.0.1/16') self.assertNotRegex(output, '10.10.0.1/16')
self.assertNotRegex(output, '10.10.0.2/16') self.assertNotRegex(output, '10.10.0.2/16')
@ -1792,6 +1796,14 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
self.assertRegex(output, 'inet6 2001:db8:0:f103::20 peer 2001:db8:0:f103::10/128 scope global') self.assertRegex(output, 'inet6 2001:db8:0:f103::20 peer 2001:db8:0:f103::10/128 scope global')
self.assertRegex(output, 'inet6 fd[0-9a-f:]*1/64 scope global') self.assertRegex(output, 'inet6 fd[0-9a-f:]*1/64 scope global')
restart_networkd()
self.wait_online(['dummy98:routable'])
# test for ENOBUFS issue #17012
output = check_output('ip -4 address show dev dummy98')
for i in range(1,254):
self.assertRegex(output, f'inet 10.3.3.{i}/16 brd 10.3.255.255')
def test_address_preferred_lifetime_zero_ipv6(self): def test_address_preferred_lifetime_zero_ipv6(self):
copy_unit_to_networkd_unit_path('25-address-preferred-lifetime-zero.network', '12-dummy.netdev') copy_unit_to_networkd_unit_path('25-address-preferred-lifetime-zero.network', '12-dummy.netdev')
start_networkd(5) start_networkd(5)

View File

@ -20,6 +20,7 @@ Wants=systemd-networkd.socket network.target
[Service] [Service]
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW
BusName=org.freedesktop.network1
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW
DeviceAllow=char-* rw DeviceAllow=char-* rw
ExecStart=!!@rootlibexecdir@/systemd-networkd ExecStart=!!@rootlibexecdir@/systemd-networkd

View File

@ -21,6 +21,7 @@ Wants=nss-lookup.target
[Service] [Service]
AmbientCapabilities=CAP_SETPCAP CAP_NET_RAW CAP_NET_BIND_SERVICE AmbientCapabilities=CAP_SETPCAP CAP_NET_RAW CAP_NET_BIND_SERVICE
BusName=org.freedesktop.resolve1
CapabilityBoundingSet=CAP_SETPCAP CAP_NET_RAW CAP_NET_BIND_SERVICE CapabilityBoundingSet=CAP_SETPCAP CAP_NET_RAW CAP_NET_BIND_SERVICE
ExecStart=!!@rootlibexecdir@/systemd-resolved ExecStart=!!@rootlibexecdir@/systemd-resolved
LockPersonality=yes LockPersonality=yes

View File

@ -20,6 +20,7 @@ Wants=time-set.target time-sync.target
[Service] [Service]
AmbientCapabilities=CAP_SYS_TIME AmbientCapabilities=CAP_SYS_TIME
BusName=org.freedesktop.timesync1
CapabilityBoundingSet=CAP_SYS_TIME CapabilityBoundingSet=CAP_SYS_TIME
ExecStart=!!@rootlibexecdir@/systemd-timesyncd ExecStart=!!@rootlibexecdir@/systemd-timesyncd
LockPersonality=yes LockPersonality=yes