New upstream version 244.1

This commit is contained in:
Michael Biebl 2020-01-25 16:48:55 +01:00
parent e1f67bc783
commit 763f54adb3
30 changed files with 219 additions and 106 deletions

2
NEWS
View File

@ -8,7 +8,7 @@ CHANGES WITH 244:
AllowedMemoryNodes= setting.
* The signal used in restart jobs (as opposed to e.g. stop jobs) may
now be configured using a new RestartKillSignal= settting. This
now be configured using a new RestartKillSignal= setting. This
allows units which signals to request termination to implement
different behaviour when stopping in preparation for a restart.

View File

@ -199,7 +199,7 @@
</row>
<row>
<entry><option>enabled-runtime</option></entry>
<entry>Like <option>enabled</option>, but the the unit files have been made available transiently only, i.e. the <command>attach</command> command has been invoked with the <option>--runtime</option> option.</entry>
<entry>Like <option>enabled</option>, but the unit files have been made available transiently only, i.e. the <command>attach</command> command has been invoked with the <option>--runtime</option> option.</entry>
</row>
<row>
<entry><option>running</option></entry>

View File

@ -60,7 +60,7 @@
</para>
<para>Any access permission errors and attempts to write variables not defined on the local system are
logged, but do not cause the the service to fail. Moreover, if a variable assignment is prefixed with a
logged, but do not cause the service to fail. Moreover, if a variable assignment is prefixed with a
single <literal>-</literal> character, failure to set the variable will be logged, but will not cause the
service to fail. All other errors when setting variables cause the service to return failure at the end
(other variables are still processed).</para>

View File

@ -262,7 +262,7 @@
<varlistentry>
<term><constant>v238</constant></term>
<listitem><para>This is the naming naming that was implemented in systemd 238.</para></listitem>
<listitem><para>This is the naming scheme that was implemented in systemd 238.</para></listitem>
</varlistentry>
<varlistentry>

View File

@ -859,7 +859,7 @@
effect.</para>
<example>
<title>A service with with the the <varname>SuccessExitStatus=</varname> setting</title>
<title>A service with with the <varname>SuccessExitStatus=</varname> setting</title>
<programlisting>SuccessExitStatus=TEMPFAIL 250 SIGUSR1</programlisting>

View File

@ -163,6 +163,11 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
/* align to next higher power-of-2 (except for: 0 => 0, overflow => 0) */
static inline unsigned long ALIGN_POWER2(unsigned long u) {
/* Avoid subtraction overflow */
if (u == 0)
return 0;
/* clz(0) is undefined */
if (u == 1)
return 1;

View File

@ -33,7 +33,7 @@ static inline int missing_pivot_root(const char *new_root, const char *put_old)
#if !HAVE_MEMFD_CREATE
/* may be (invalid) negative number due to libseccomp, see PR 13319 */
# if ! (defined __NR_memfd_create && __NR_memfd_create > 0)
# if ! (defined __NR_memfd_create && __NR_memfd_create >= 0)
# if defined __NR_memfd_create
# undef __NR_memfd_create
# endif
@ -80,7 +80,7 @@ static inline int missing_memfd_create(const char *name, unsigned int flags) {
#if !HAVE_GETRANDOM
/* may be (invalid) negative number due to libseccomp, see PR 13319 */
# if ! (defined __NR_getrandom && __NR_getrandom > 0)
# if ! (defined __NR_getrandom && __NR_getrandom >= 0)
# if defined __NR_getrandom
# undef __NR_getrandom
# endif
@ -143,7 +143,7 @@ static inline pid_t missing_gettid(void) {
#if !HAVE_NAME_TO_HANDLE_AT
/* may be (invalid) negative number due to libseccomp, see PR 13319 */
# if ! (defined __NR_name_to_handle_at && __NR_name_to_handle_at > 0)
# if ! (defined __NR_name_to_handle_at && __NR_name_to_handle_at >= 0)
# if defined __NR_name_to_handle_at
# undef __NR_name_to_handle_at
# endif
@ -184,7 +184,7 @@ static inline int missing_name_to_handle_at(int fd, const char *name, struct fil
#if !HAVE_SETNS
/* may be (invalid) negative number due to libseccomp, see PR 13319 */
# if ! (defined __NR_setns && __NR_setns > 0)
# if ! (defined __NR_setns && __NR_setns >= 0)
# if defined __NR_setns
# undef __NR_setns
# endif
@ -225,7 +225,7 @@ static inline pid_t raw_getpid(void) {
#if !HAVE_RENAMEAT2
/* may be (invalid) negative number due to libseccomp, see PR 13319 */
# if ! (defined __NR_renameat2 && __NR_renameat2 > 0)
# if ! (defined __NR_renameat2 && __NR_renameat2 >= 0)
# if defined __NR_renameat2
# undef __NR_renameat2
# endif
@ -274,7 +274,7 @@ static inline int missing_renameat2(int oldfd, const char *oldname, int newfd, c
#if !HAVE_KCMP
static inline int missing_kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) {
# if defined __NR_kcmp && __NR_kcmp > 0
# if defined __NR_kcmp && __NR_kcmp >= 0
return syscall(__NR_kcmp, pid1, pid2, type, idx1, idx2);
# else
errno = ENOSYS;
@ -289,7 +289,7 @@ static inline int missing_kcmp(pid_t pid1, pid_t pid2, int type, unsigned long i
#if !HAVE_KEYCTL
static inline long missing_keyctl(int cmd, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5) {
# if defined __NR_keyctl && __NR_keyctl > 0
# if defined __NR_keyctl && __NR_keyctl >= 0
return syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5);
# else
errno = ENOSYS;
@ -300,7 +300,7 @@ static inline long missing_keyctl(int cmd, unsigned long arg2, unsigned long arg
}
static inline key_serial_t missing_add_key(const char *type, const char *description, const void *payload, size_t plen, key_serial_t ringid) {
# if defined __NR_add_key && __NR_add_key > 0
# if defined __NR_add_key && __NR_add_key >= 0
return syscall(__NR_add_key, type, description, payload, plen, ringid);
# else
errno = ENOSYS;
@ -311,7 +311,7 @@ static inline key_serial_t missing_add_key(const char *type, const char *descrip
}
static inline key_serial_t missing_request_key(const char *type, const char *description, const char * callout_info, key_serial_t destringid) {
# if defined __NR_request_key && __NR_request_key > 0
# if defined __NR_request_key && __NR_request_key >= 0
return syscall(__NR_request_key, type, description, callout_info, destringid);
# else
errno = ENOSYS;
@ -326,7 +326,7 @@ static inline key_serial_t missing_request_key(const char *type, const char *des
#if !HAVE_COPY_FILE_RANGE
/* may be (invalid) negative number due to libseccomp, see PR 13319 */
# if ! (defined __NR_copy_file_range && __NR_copy_file_range > 0)
# if ! (defined __NR_copy_file_range && __NR_copy_file_range >= 0)
# if defined __NR_copy_file_range
# undef __NR_copy_file_range
# endif
@ -368,7 +368,7 @@ static inline ssize_t missing_copy_file_range(int fd_in, loff_t *off_in,
#if !HAVE_BPF
/* may be (invalid) negative number due to libseccomp, see PR 13319 */
# if ! (defined __NR_bpf && __NR_bpf > 0)
# if ! (defined __NR_bpf && __NR_bpf >= 0)
# if defined __NR_bpf
# undef __NR_bpf
# endif
@ -409,7 +409,7 @@ static inline int missing_bpf(int cmd, union bpf_attr *attr, size_t size) {
#ifndef __IGNORE_pkey_mprotect
/* may be (invalid) negative number due to libseccomp, see PR 13319 */
# if ! (defined __NR_pkey_mprotect && __NR_pkey_mprotect > 0)
# if ! (defined __NR_pkey_mprotect && __NR_pkey_mprotect >= 0)
# if defined __NR_pkey_mprotect
# undef __NR_pkey_mprotect
# endif
@ -445,7 +445,7 @@ static inline int missing_bpf(int cmd, union bpf_attr *attr, size_t size) {
#if !HAVE_STATX
/* may be (invalid) negative number due to libseccomp, see PR 13319 */
# if ! (defined __NR_statx && __NR_statx > 0)
# if ! (defined __NR_statx && __NR_statx >= 0)
# if defined __NR_statx
# undef __NR_statx
# endif
@ -496,7 +496,7 @@ enum {
static inline long missing_set_mempolicy(int mode, const unsigned long *nodemask,
unsigned long maxnode) {
long i;
# if defined __NR_set_mempolicy && __NR_set_mempolicy > 0
# if defined __NR_set_mempolicy && __NR_set_mempolicy >= 0
i = syscall(__NR_set_mempolicy, mode, nodemask, maxnode);
# else
errno = ENOSYS;

View File

@ -29,6 +29,7 @@
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "tmpfile-util.h"
#include "umask-util.h"
#include "user-util.h"
@ -1640,6 +1641,44 @@ int temporary_filesystem_add(
return 0;
}
static int make_tmp_prefix(const char *prefix) {
_cleanup_free_ char *t = NULL;
int r;
/* Don't do anything unless we know the dir is actually missing */
r = access(prefix, F_OK);
if (r >= 0)
return 0;
if (errno != ENOENT)
return -errno;
r = mkdir_parents(prefix, 0755);
if (r < 0)
return r;
r = tempfn_random(prefix, NULL, &t);
if (r < 0)
return r;
if (mkdir(t, 0777) < 0)
return -errno;
if (chmod(t, 01777) < 0) {
r = -errno;
(void) rmdir(t);
return r;
}
if (rename(t, prefix) < 0) {
r = -errno;
(void) rmdir(t);
return r == -EEXIST ? 0 : r; /* it's fine if someone else created the dir by now */
}
return 0;
}
static int setup_one_tmp_dir(const char *id, const char *prefix, char **path) {
_cleanup_free_ char *x = NULL;
char bid[SD_ID128_STRING_MAX];
@ -1661,6 +1700,10 @@ static int setup_one_tmp_dir(const char *id, const char *prefix, char **path) {
if (!x)
return -ENOMEM;
r = make_tmp_prefix(prefix);
if (r < 0)
return r;
RUN_WITH_UMASK(0077)
if (!mkdtemp(x))
return -errno;

View File

@ -117,7 +117,8 @@ static void swap_init(Unit *u) {
s->exec_context.std_output = u->manager->default_std_output;
s->exec_context.std_error = u->manager->default_std_error;
s->parameters_proc_swaps.priority = s->parameters_fragment.priority = -1;
s->parameters_proc_swaps.priority = s->parameters_fragment.priority = 0;
s->parameters_fragment.priority_set = false;
s->control_command_id = _SWAP_EXEC_COMMAND_INVALID;
@ -433,6 +434,7 @@ static int swap_setup_unit(
SWAP(u)->from_proc_swaps = true;
p->priority = priority;
p->priority_set = true;
unit_add_to_dbus_queue(u);
return 0;
@ -766,15 +768,15 @@ static void swap_enter_activating(Swap *s) {
s->control_command = s->exec_command + SWAP_EXEC_ACTIVATE;
if (s->from_fragment) {
int priority = -1;
int priority = 0;
r = fstab_find_pri(s->parameters_fragment.options, &priority);
if (r < 0)
log_warning_errno(r, "Failed to parse swap priority \"%s\", ignoring: %m", s->parameters_fragment.options);
else if (r == 1 && s->parameters_fragment.priority >= 0)
else if (r == 1 && s->parameters_fragment.priority_set)
log_warning("Duplicate swap priority configuration by Priority and Options fields.");
if (r <= 0 && s->parameters_fragment.priority >= 0) {
if (r <= 0 && s->parameters_fragment.priority_set) {
if (s->parameters_fragment.options)
r = asprintf(&opts, "%s,pri=%i", s->parameters_fragment.options, s->parameters_fragment.priority);
else

View File

@ -33,6 +33,7 @@ typedef struct SwapParameters {
char *what;
char *options;
int priority;
bool priority_set;
} SwapParameters;
struct Swap {

View File

@ -441,7 +441,7 @@ int sd_ipv4acd_is_running(sd_ipv4acd *acd) {
return acd->state != IPV4ACD_STATE_INIT;
}
int sd_ipv4acd_start(sd_ipv4acd *acd) {
int sd_ipv4acd_start(sd_ipv4acd *acd, bool reset_conflicts) {
int r;
assert_return(acd, -EINVAL);
@ -458,7 +458,9 @@ int sd_ipv4acd_start(sd_ipv4acd *acd) {
safe_close(acd->fd);
acd->fd = r;
acd->defend_window = 0;
acd->n_conflict = 0;
if (reset_conflicts)
acd->n_conflict = 0;
r = sd_event_add_io(acd->event, &acd->receive_message_event_source, acd->fd, EPOLLIN, ipv4acd_on_packet, acd);
if (r < 0)

View File

@ -241,7 +241,7 @@ static int ipv4ll_start_internal(sd_ipv4ll *ll, bool reset_generation) {
picked_address = true;
}
r = sd_ipv4acd_start(ll->acd);
r = sd_ipv4acd_start(ll->acd, reset_generation);
if (r < 0) {
/* We couldn't start? If so, let's forget the picked address again, the user might make a change and

View File

@ -47,7 +47,7 @@ static int client_run(int ifindex, const struct in_addr *pa, const struct ether_
log_info("starting IPv4ACD client");
assert_se(sd_ipv4acd_start(acd) >= 0);
assert_se(sd_ipv4acd_start(acd, true) >= 0);
assert_se(sd_event_loop(e) >= 0);

View File

@ -102,7 +102,6 @@ BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_common_errors[] = {
SD_BUS_ERROR_MAP(BUS_ERROR_NO_PRODUCT_UUID, EOPNOTSUPP),
SD_BUS_ERROR_MAP(BUS_ERROR_SPEED_METER_INACTIVE, EOPNOTSUPP),
SD_BUS_ERROR_MAP(BUS_ERROR_UNMANAGED_INTERFACE, EOPNOTSUPP),
SD_BUS_ERROR_MAP_END

View File

@ -81,7 +81,6 @@
#define BUS_ERROR_NO_PRODUCT_UUID "org.freedesktop.hostname1.NoProductUUID"
#define BUS_ERROR_SPEED_METER_INACTIVE "org.freedesktop.network1.SpeedMeterInactive"
#define BUS_ERROR_UNMANAGED_INTERFACE "org.freedesktop.network1.UnmanagedInterface"
BUS_ERROR_MAP_ELF_USE(bus_common_errors);

View File

@ -349,8 +349,7 @@ static int acquire_link_bitrates(sd_bus *bus, LinkInfo *link) {
"org.freedesktop.network1.Link",
"BitRates");
if (r < 0) {
bool quiet = sd_bus_error_has_name(&error, SD_BUS_ERROR_UNKNOWN_PROPERTY) ||
sd_bus_error_has_name(&error, BUS_ERROR_SPEED_METER_INACTIVE);
bool quiet = sd_bus_error_has_name(&error, SD_BUS_ERROR_UNKNOWN_PROPERTY);
return log_full_errno(quiet ? LOG_DEBUG : LOG_WARNING,
r, "Failed to query link bit rates: %s", bus_error_message(&error, r));
@ -368,7 +367,7 @@ static int acquire_link_bitrates(sd_bus *bus, LinkInfo *link) {
if (r < 0)
return bus_log_parse_error(r);
link->has_bitrates = true;
link->has_bitrates = link->tx_bitrate != UINT64_MAX && link->rx_bitrate != UINT64_MAX;
return 0;
}
@ -404,7 +403,7 @@ static void acquire_wlan_link_info(LinkInfo *link) {
if (r < 0)
log_debug_errno(r, "%s: failed to query ssid: %m", link->name);
if (link->iftype == NL80211_IFTYPE_STATION) {
if (link->wlan_iftype == NL80211_IFTYPE_STATION) {
k = wifi_get_station(genl, link->ifindex, &link->bssid);
if (k < 0)
log_debug_errno(k, "%s: failed to query bssid: %m", link->name);

View File

@ -279,7 +279,7 @@ int config_parse_dhcp_send_option(
_cleanup_(sd_dhcp_option_unrefp) sd_dhcp_option *opt = NULL, *old = NULL;
_cleanup_free_ char *word = NULL, *q = NULL;
OrderedHashmap **options = userdata;
OrderedHashmap **options = data;
union in_addr_union addr;
DHCPOptionDataType type;
uint8_t u, uint8_data;

View File

@ -41,14 +41,10 @@ static int property_get_bit_rates(
manager = link->manager;
if (!manager->use_speed_meter)
return sd_bus_error_set(error, BUS_ERROR_SPEED_METER_INACTIVE, "Speed meter is disabled.");
if (manager->speed_meter_usec_old == 0)
return sd_bus_error_set(error, BUS_ERROR_SPEED_METER_INACTIVE, "Speed meter is not active.");
if (!link->stats_updated)
return sd_bus_error_set(error, BUS_ERROR_SPEED_METER_INACTIVE, "Failed to measure bit-rates.");
if (!manager->use_speed_meter ||
manager->speed_meter_usec_old == 0 ||
!link->stats_updated)
return sd_bus_message_append(reply, "(tt)", UINT64_MAX, UINT64_MAX);
assert(manager->speed_meter_usec_new > manager->speed_meter_usec_old);
interval_sec = (manager->speed_meter_usec_new - manager->speed_meter_usec_old) / USEC_PER_SEC;

View File

@ -36,6 +36,7 @@
#include "qdisc.h"
#include "set.h"
#include "socket-util.h"
#include "stat-util.h"
#include "stdio-util.h"
#include "string-table.h"
#include "strv.h"
@ -43,7 +44,6 @@
#include "tmpfile-util.h"
#include "udev-util.h"
#include "util.h"
#include "virt.h"
#include "vrf.h"
uint32_t link_get_vrf_table(Link *link) {
@ -1341,7 +1341,7 @@ int link_set_mtu(Link *link, uint32_t mtu) {
if (link_ipv6_enabled(link) && mtu < IPV6_MIN_MTU) {
log_link_warning(link, "Bumping MTU to " STRINGIFY(IPV6_MIN_MTU) ", as "
"IPv6 is requested and requires a minimum MTU of " STRINGIFY(IPV6_MIN_MTU) " bytes: %m");
"IPv6 is requested and requires a minimum MTU of " STRINGIFY(IPV6_MIN_MTU) " bytes");
mtu = IPV6_MIN_MTU;
}
@ -2378,9 +2378,23 @@ static int link_set_ipv6_mtu(Link *link) {
if (link->network->ipv6_mtu == 0)
return 0;
/* IPv6 protocol requires a minimum MTU of IPV6_MTU_MIN(1280) bytes
* on the interface. Bump up IPv6 MTU bytes to IPV6_MTU_MIN. */
if (link->network->ipv6_mtu < IPV6_MIN_MTU) {
log_link_notice(link, "Bumping IPv6 MTU to "STRINGIFY(IPV6_MIN_MTU)" byte minimum required");
link->network->ipv6_mtu = IPV6_MIN_MTU;
}
r = sysctl_write_ip_property_uint32(AF_INET6, link->ifname, "mtu", link->network->ipv6_mtu);
if (r < 0)
log_link_warning_errno(link, r, "Cannot set IPv6 MTU for interface: %m");
if (r < 0) {
if (link->mtu < link->network->ipv6_mtu)
log_link_warning(link, "Cannot set IPv6 MTU %"PRIu32" higher than device MTU %"PRIu32,
link->network->ipv6_mtu, link->mtu);
else
log_link_warning_errno(link, r, "Cannot set IPv6 MTU for interface: %m");
}
link->ipv6_mtu_set = true;
return 0;
}
@ -2669,10 +2683,6 @@ static int link_configure(Link *link) {
if (r < 0)
return r;
r = link_set_ipv6_mtu(link);
if (r < 0)
return r;
if (link_ipv4ll_enabled(link, ADDRESS_FAMILY_IPV4 | ADDRESS_FAMILY_FALLBACK_IPV4)) {
r = ipv4ll_configure(link);
if (r < 0)
@ -2745,6 +2755,12 @@ static int link_configure_after_setting_mtu(Link *link) {
if (link->setting_mtu)
return 0;
/* The kernel resets ipv6 mtu after changing device mtu;
* we must set this here, after we've set device mtu */
r = link_set_ipv6_mtu(link);
if (r < 0)
return r;
if (link_has_carrier(link) || link->network->configure_without_carrier) {
r = link_acquire_conf(link);
if (r < 0)
@ -2924,7 +2940,7 @@ int link_reconfigure(Link *link, bool force) {
if (r < 0)
return r;
if (!IN_SET(link->state, LINK_STATE_UNMANAGED, LINK_STATE_PENDING)) {
if (!IN_SET(link->state, LINK_STATE_UNMANAGED, LINK_STATE_PENDING, LINK_STATE_INITIALIZED)) {
log_link_debug(link, "State is %s, dropping config", link_state_to_string(link->state));
r = link_drop_foreign_config(link);
if (r < 0)
@ -3292,8 +3308,8 @@ int link_add(Manager *m, sd_netlink_message *message, Link **ret) {
if (r < 0)
return r;
if (detect_container() <= 0) {
/* not in a container, udev will be around */
if (path_is_read_only_fs("/sys") <= 0) {
/* udev should be around */
sprintf(ifindex_str, "n%d", link->ifindex);
r = sd_device_new_from_device_id(&device, ifindex_str);
if (r < 0) {
@ -3303,7 +3319,7 @@ int link_add(Manager *m, sd_netlink_message *message, Link **ret) {
r = sd_device_get_is_initialized(device);
if (r < 0) {
log_link_warning_errno(link, r, "Could not determine whether the device is initialized or not: %m");
log_link_warning_errno(link, r, "Could not determine whether the device is initialized: %m");
goto failed;
}
if (r == 0) {
@ -3314,11 +3330,11 @@ int link_add(Manager *m, sd_netlink_message *message, Link **ret) {
r = device_is_renaming(device);
if (r < 0) {
log_link_warning_errno(link, r, "Failed to determine the device is renamed or not: %m");
log_link_warning_errno(link, r, "Failed to determine the device is being renamed: %m");
goto failed;
}
if (r > 0) {
log_link_debug(link, "Interface is under renaming, pending initialization.");
log_link_debug(link, "Interface is being renamed, pending initialization.");
return 0;
}
@ -3419,7 +3435,7 @@ static int link_carrier_lost(Link *link) {
if (r < 0)
return r;
if (!IN_SET(link->state, LINK_STATE_UNMANAGED, LINK_STATE_PENDING)) {
if (!IN_SET(link->state, LINK_STATE_UNMANAGED, LINK_STATE_PENDING, LINK_STATE_INITIALIZED)) {
log_link_debug(link, "State is %s, dropping config", link_state_to_string(link->state));
r = link_drop_foreign_config(link);
if (r < 0)
@ -3453,11 +3469,30 @@ int link_carrier_reset(Link *link) {
return 0;
}
/* This is called every time an interface admin state changes to up;
* specifically, when IFF_UP flag changes from unset to set */
static int link_admin_state_up(Link *link) {
int r;
/* We set the ipv6 mtu after the device mtu, but the kernel resets
* ipv6 mtu on NETDEV_UP, so we need to reset it. The check for
* ipv6_mtu_set prevents this from trying to set it too early before
* the link->network has been setup; we only need to reset it
* here if we've already set it during normal initialization. */
if (link->ipv6_mtu_set) {
r = link_set_ipv6_mtu(link);
if (r < 0)
return r;
}
return 0;
}
int link_update(Link *link, sd_netlink_message *m) {
struct ether_addr mac;
const char *ifname;
uint32_t mtu;
bool had_carrier, carrier_gained, carrier_lost;
bool had_carrier, carrier_gained, carrier_lost, link_was_admin_up;
int old_master, r;
assert(link);
@ -3587,12 +3622,22 @@ int link_update(Link *link, sd_netlink_message *m) {
old_master = link->master_ifindex;
(void) sd_netlink_message_read_u32(m, IFLA_MASTER, (uint32_t *) &link->master_ifindex);
link_was_admin_up = link->flags & IFF_UP;
had_carrier = link_has_carrier(link);
r = link_update_flags(link, m, old_master != link->master_ifindex);
if (r < 0)
return r;
if (!link_was_admin_up && (link->flags & IFF_UP)) {
log_link_info(link, "Link UP");
r = link_admin_state_up(link);
if (r < 0)
return r;
} else if (link_was_admin_up && !(link->flags & IFF_UP))
log_link_info(link, "Link DOWN");
r = link_update_lldp(link);
if (r < 0)
return r;

View File

@ -116,6 +116,7 @@ typedef struct Link {
bool routing_policy_rules_configured:1;
bool qdiscs_configured:1;
bool setting_mtu:1;
bool ipv6_mtu_set:1;
LIST_HEAD(Address, pool_addresses);

View File

@ -105,7 +105,7 @@ static int qdisc_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
return 1;
}
if (link->route_messages == 0) {
if (link->qdisc_messages == 0) {
log_link_debug(link, "QDiscs configured");
link->qdiscs_configured = true;
link_check_ready(link);

View File

@ -12,8 +12,6 @@ typedef struct QDiscs {
NetworkConfigSection *section;
Network *network;
Link *link;
int family;
uint32_t handle;

View File

@ -19,6 +19,7 @@
#include "stat-util.h"
#include "string-util.h"
#include "strv.h"
#include "udev-util.h"
#include "util.h"
#define HOST_HASH_KEY SD_ID128_MAKE(1a,37,6f,c7,46,ec,45,0b,ad,a3,d5,31,06,60,5d,b1)
@ -395,24 +396,33 @@ int remove_bridge(const char *bridge_name) {
static int parse_interface(const char *name) {
_cleanup_(sd_device_unrefp) sd_device *d = NULL;
char ifi_str[2 + DECIMAL_STR_MAX(int)];
int ifi, r;
r = parse_ifindex_or_ifname(name, &ifi);
if (r < 0)
return log_error_errno(r, "Failed to resolve interface %s: %m", name);
sprintf(ifi_str, "n%i", ifi);
r = sd_device_new_from_device_id(&d, ifi_str);
if (r < 0)
return log_error_errno(r, "Failed to get device for interface %s: %m", name);
if (path_is_read_only_fs("/sys") <= 0) {
char ifi_str[2 + DECIMAL_STR_MAX(int)];
r = sd_device_get_is_initialized(d);
if (r < 0)
return log_error_errno(r, "Failed to determine whether interface %s is initialized or not: %m", name);
if (r == 0) {
log_error("Network interface %s is not initialized yet.", name);
return -EBUSY;
/* udev should be around. */
sprintf(ifi_str, "n%i", ifi);
r = sd_device_new_from_device_id(&d, ifi_str);
if (r < 0)
return log_error_errno(r, "Failed to get device %s: %m", name);
r = sd_device_get_is_initialized(d);
if (r < 0)
return log_error_errno(r, "Failed to determine whether interface %s is initialized: %m", name);
if (r == 0)
return log_error_errno(SYNTHETIC_ERRNO(EBUSY), "Network interface %s is not initialized yet.", name);
r = device_is_renaming(d);
if (r < 0)
return log_error_errno(r, "Failed to determine the interface %s is being renamed: %m", name);
if (r > 0)
return log_error_errno(SYNTHETIC_ERRNO(EBUSY), "Interface %s is being renamed.", name);
}
return ifi;

View File

@ -186,8 +186,7 @@ int fstab_extract_values(const char *opts, const char *name, char ***values) {
int fstab_find_pri(const char *options, int *ret) {
_cleanup_free_ char *opt = NULL;
int r;
unsigned pri;
int r, pri;
assert(ret);
@ -197,14 +196,11 @@ int fstab_find_pri(const char *options, int *ret) {
if (r == 0 || !opt)
return 0;
r = safe_atou(opt, &pri);
r = safe_atoi(opt, &pri);
if (r < 0)
return r;
if ((int) pri < 0)
return -ERANGE;
*ret = (int) pri;
*ret = pri;
return 1;
}

View File

@ -1584,6 +1584,7 @@ assert_cc(SCMP_SYS(shmdt) > 0);
int seccomp_memory_deny_write_execute(void) {
uint32_t arch;
int r;
int loaded = 0;
SECCOMP_FOREACH_LOCAL_ARCH(arch) {
_cleanup_(seccomp_releasep) scmp_filter_ctx seccomp = NULL;
@ -1593,22 +1594,23 @@ int seccomp_memory_deny_write_execute(void) {
switch (arch) {
/* Note that on some architectures shmat() isn't available, and the call is multiplexed through ipc().
* We ignore that here, which means there's still a way to get writable/executable
* memory, if an IPC key is mapped like this. That's a pity, but no total loss. */
case SCMP_ARCH_X86:
case SCMP_ARCH_S390:
filter_syscall = SCMP_SYS(mmap2);
block_syscall = SCMP_SYS(mmap);
shmat_syscall = SCMP_SYS(shmat);
/* shmat multiplexed, see above */
break;
case SCMP_ARCH_PPC:
case SCMP_ARCH_PPC64:
case SCMP_ARCH_PPC64LE:
case SCMP_ARCH_S390X:
filter_syscall = SCMP_SYS(mmap);
/* Note that shmat() isn't available, and the call is multiplexed through ipc().
* We ignore that here, which means there's still a way to get writable/executable
* memory, if an IPC key is mapped like this. That's a pity, but no total loss. */
/* shmat multiplexed, see above */
break;
case SCMP_ARCH_ARM:
@ -1619,8 +1621,7 @@ int seccomp_memory_deny_write_execute(void) {
case SCMP_ARCH_X86_64:
case SCMP_ARCH_X32:
case SCMP_ARCH_AARCH64:
case SCMP_ARCH_S390X:
filter_syscall = SCMP_SYS(mmap); /* amd64, x32, s390x, and arm64 have only mmap */
filter_syscall = SCMP_SYS(mmap); /* amd64, x32 and arm64 have only mmap */
shmat_syscall = SCMP_SYS(shmat);
break;
@ -1666,7 +1667,7 @@ int seccomp_memory_deny_write_execute(void) {
#endif
if (shmat_syscall > 0) {
r = add_seccomp_syscall_filter(seccomp, arch, SCMP_SYS(shmat),
r = add_seccomp_syscall_filter(seccomp, arch, shmat_syscall,
1,
SCMP_A2(SCMP_CMP_MASKED_EQ, SHM_EXEC, SHM_EXEC));
if (r < 0)
@ -1678,9 +1679,13 @@ int seccomp_memory_deny_write_execute(void) {
return r;
if (r < 0)
log_debug_errno(r, "Failed to install MemoryDenyWriteExecute= rule for architecture %s, skipping: %m", seccomp_arch_to_string(arch));
loaded++;
}
return 0;
if (loaded == 0)
log_debug_errno(r, "Failed to install any seccomp rules for MemoryDenyWriteExecute=");
return loaded;
}
int seccomp_restrict_archs(Set *archs) {

View File

@ -32,6 +32,7 @@
#include "cpu-set-util.h"
#include "dirent-util.h"
#include "dropin.h"
#include "efi-loader.h"
#include "efivars.h"
#include "env-util.h"
#include "escape.h"
@ -3514,8 +3515,13 @@ static int load_kexec_kernel(void) {
return log_error_errno(errno, KEXEC" is not available: %m");
r = boot_entries_load_config_auto(NULL, NULL, &config);
if (r == -ENOKEY) /* The call doesn't log about ENOKEY, let's do so here. */
return log_error_errno(r, "Cannot find the ESP partition mount point.");
if (r == -ENOKEY)
/* The call doesn't log about ENOKEY, let's do so here. */
return log_error_errno(r,
"No kexec kernel loaded and autodetection failed.\n%s",
is_efi_boot()
? "Cannot automatically load kernel: ESP partition mount point not found."
: "Automatic loading works only on systems booted with EFI.");
if (r < 0)
return r;
@ -7853,7 +7859,7 @@ static int systemctl_help(void) {
" isolate UNIT Start one unit and stop all others\n"
" kill UNIT... Send signal to processes of a unit\n"
" clean UNIT... Clean runtime, cache, state, logs or\n"
" or configuration of unit\n"
" configuration of unit\n"
" is-active PATTERN... Check whether units are active\n"
" is-failed PATTERN... Check whether units are failed\n"
" status [PATTERN...|PID...] Show runtime status of one or more units\n"

View File

@ -20,6 +20,7 @@
#include <net/ethernet.h>
#include <netinet/in.h>
#include <stdbool.h>
#include "sd-event.h"
@ -44,7 +45,7 @@ int sd_ipv4acd_set_mac(sd_ipv4acd *acd, const struct ether_addr *addr);
int sd_ipv4acd_set_ifindex(sd_ipv4acd *acd, int interface_index);
int sd_ipv4acd_set_address(sd_ipv4acd *acd, const struct in_addr *address);
int sd_ipv4acd_is_running(sd_ipv4acd *acd);
int sd_ipv4acd_start(sd_ipv4acd *acd);
int sd_ipv4acd_start(sd_ipv4acd *acd, bool reset_conflicts);
int sd_ipv4acd_stop(sd_ipv4acd *acd);
sd_ipv4acd *sd_ipv4acd_ref(sd_ipv4acd *acd);
sd_ipv4acd *sd_ipv4acd_unref(sd_ipv4acd *acd);

View File

@ -100,6 +100,9 @@ static void test_fstab_find_pri(void) {
assert_se(fstab_find_pri("pri=11", &pri) == 1);
assert_se(pri == 11);
assert_se(fstab_find_pri("pri=-2", &pri) == 1);
assert_se(pri == -2);
assert_se(fstab_find_pri("opt,pri=12,opt", &pri) == 1);
assert_se(pri == 12);

View File

@ -29,7 +29,7 @@
#include "virt.h"
/* __NR_socket may be invalid due to libseccomp */
#if !defined(__NR_socket) || __NR_socket <= 0 || defined(__i386__) || defined(__s390x__) || defined(__s390__)
#if !defined(__NR_socket) || __NR_socket < 0 || defined(__i386__) || defined(__s390x__) || defined(__s390__)
/* On these archs, socket() is implemented via the socketcall() syscall multiplexer,
* and we can't restrict it hence via seccomp. */
# define SECCOMP_RESTRICT_ADDRESS_FAMILIES_BROKEN 1
@ -305,14 +305,14 @@ static void test_protect_sysctl(void) {
assert_se(pid >= 0);
if (pid == 0) {
#if defined __NR__sysctl && __NR__sysctl > 0
#if defined __NR__sysctl && __NR__sysctl >= 0
assert_se(syscall(__NR__sysctl, NULL) < 0);
assert_se(errno == EFAULT);
#endif
assert_se(seccomp_protect_sysctl() >= 0);
#if defined __NR__sysctl && __NR__sysctl > 0
#if defined __NR__sysctl && __NR__sysctl >= 0
assert_se(syscall(__NR__sysctl, 0, 0, 0) < 0);
assert_se(errno == EPERM);
#endif
@ -347,14 +347,14 @@ static void test_protect_syslog(void) {
assert_se(pid >= 0);
if (pid == 0) {
#if defined __NR_syslog && __NR_syslog > 0
#if defined __NR_syslog && __NR_syslog >= 0
assert_se(syscall(__NR_syslog, -1, NULL, 0) < 0);
assert_se(errno == EINVAL);
#endif
assert_se(seccomp_protect_syslog() >= 0);
#if defined __NR_syslog && __NR_syslog > 0
#if defined __NR_syslog && __NR_syslog >= 0
assert_se(syscall(__NR_syslog, 0, 0, 0) < 0);
assert_se(errno == EPERM);
#endif
@ -535,10 +535,11 @@ static void test_memory_deny_write_execute_mmap(void) {
#if defined(__x86_64__) || defined(__i386__) || defined(__powerpc64__) || defined(__arm__) || defined(__aarch64__)
assert_se(p == MAP_FAILED);
assert_se(errno == EPERM);
#else /* unknown architectures */
assert_se(p != MAP_FAILED);
assert_se(munmap(p, page_size()) >= 0);
#endif
/* Depending on kernel, libseccomp, and glibc versions, other architectures
* might fail or not. Let's not assert success. */
if (p != MAP_FAILED)
assert_se(munmap(p, page_size()) == 0);
p = mmap(NULL, page_size(), PROT_WRITE|PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1,0);
assert_se(p != MAP_FAILED);
@ -683,7 +684,7 @@ static void test_load_syscall_filter_set_raw(void) {
assert_se(poll(NULL, 0, 0) == 0);
assert_se(s = hashmap_new(NULL));
#if defined __NR_access && __NR_access > 0
#if defined __NR_access && __NR_access >= 0
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_access + 1), INT_TO_PTR(-1)) >= 0);
#else
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_faccessat + 1), INT_TO_PTR(-1)) >= 0);
@ -699,7 +700,7 @@ static void test_load_syscall_filter_set_raw(void) {
s = hashmap_free(s);
assert_se(s = hashmap_new(NULL));
#if defined __NR_access && __NR_access > 0
#if defined __NR_access && __NR_access >= 0
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_access + 1), INT_TO_PTR(EILSEQ)) >= 0);
#else
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_faccessat + 1), INT_TO_PTR(EILSEQ)) >= 0);
@ -715,7 +716,7 @@ static void test_load_syscall_filter_set_raw(void) {
s = hashmap_free(s);
assert_se(s = hashmap_new(NULL));
#if defined __NR_poll && __NR_poll > 0
#if defined __NR_poll && __NR_poll >= 0
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_poll + 1), INT_TO_PTR(-1)) >= 0);
#else
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_ppoll + 1), INT_TO_PTR(-1)) >= 0);
@ -732,7 +733,7 @@ static void test_load_syscall_filter_set_raw(void) {
s = hashmap_free(s);
assert_se(s = hashmap_new(NULL));
#if defined __NR_poll && __NR_poll > 0
#if defined __NR_poll && __NR_poll >= 0
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_poll + 1), INT_TO_PTR(EILSEQ)) >= 0);
#else
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_ppoll + 1), INT_TO_PTR(EILSEQ)) >= 0);
@ -810,7 +811,7 @@ static int real_open(const char *path, int flags, mode_t mode) {
* testing purposes that calls the real syscall, on architectures where SYS_open is defined. On
* other architectures, let's just fall back to the glibc call. */
#if defined __NR_open && __NR_open > 0
#if defined __NR_open && __NR_open >= 0
return (int) syscall(__NR_open, path, flags, mode);
#else
return open(path, flags, mode);

View File

@ -7,3 +7,4 @@ IPv6AcceptRA=false
[DHCPv4]
RoutesToDNS=yes
SendOption=12:string:test