Compare commits

..

16 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek e6791b5522
Merge pull request #16497 from DaanDeMeyer/mkosi
mkosi: Keep mkosi.default out of the repository
2020-07-20 09:03:51 +02:00
Zbigniew Jędrzejewski-Szmek 7e8279c0a6
Merge pull request #16501 from yuwata/udev-fix-renaming
udev: fix issues in renaming interface vs alternative names
2020-07-20 09:00:02 +02:00
Franck Bui 0ef1adf512 vconsole-setup: downgrade log message when setting font fails on dummy console
Since commit 883eb9be98, vconsole-setup might be
called again to operate on dummy console where font operations are not
supported but where it's still important to have the correct keymap set [0][1].

vconsole-setup is mainly called by udev but can also be run via a dependency of
an early service. Both cases might end up calling vconsole-setup on the dummy
console.

The first case can happen during early boot even on systems that use (instead
of the dummy console) a "simple" video console driver supporting font
operations (such as vgacon) until a more specific driver (such as i915) takes
the console over. While this is happening vgacon is deactivated and temporarly
replaced by the dummy console [2].

There are also other cases where systemd-vconsole-setup might be called on
dummy console especially during (very) early boot. Indeed
systemd-vconsole-setup.service might be pulled in by early interactive services
such as 'dracut-cmdline-ask.service` which is run before udev.

If that happens on platforms with no grapical HWs (such as embedded ARM) or
with dummy console initially installed until a driver takes over (like Xen and
xen-fbfront) then setting font will fail.

Therefore this patch downgrades the log message emitted when setting font fails
to LOG_DEBUG and when font operations is not implemented like it's the case for
the dummy console.

Fixes: #16406.

[0] https://github.com/systemd/systemd/issues/10826
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1652473
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/vga/vgaarb.c?h=v5.7#n204
2020-07-20 08:15:50 +02:00
Yu Watanabe 628f08b66d sd-netlink: make timeout message sealed
When sd_netlink_call_async() timed out, then we reply the synthetic
error message, but it was not sealed. So, reading the message causes
the following assertion:

```
Assertion 'm->sealed' failed at src/libsystemd/sd-netlink/netlink-message.c:652, function netlink_message_read_internal(). Ignoring.
```
2020-07-20 07:49:55 +02:00
Zbigniew Jędrzejewski-Szmek d735e4f2d6
Merge pull request #16505 from yuwata/network-manage-foreign-routes-cleanups
network: do not enumerate foreign routes when ManageForeignRoutes=no, and tiny cleanups
2020-07-20 07:48:57 +02:00
Luca Boccassi ed4512d009 nspawn: set container_host env vars before user arguments
Allows users on the command line to seamlessly override
$container_host_* just like they can override $container_id and
$container
2020-07-20 07:28:22 +02:00
YmrDtnJu a9c9b18a95 networkd: Use NLM_F_ACK on the netlink message to add a neighbor.
sd_netlink_message_set_flags is called without NLM_F_ACK which results in
a timeout while networkd is waiting for an ACK that the kernel will never send.
2020-07-20 11:30:35 +09:00
Yu Watanabe a8c10331b4 network: replace NDISC -> NDisc in log messages 2020-07-18 05:51:41 +09:00
Yu Watanabe 5eec0a0810 network: introduce address_exists() helper function 2020-07-18 05:51:41 +09:00
Yu Watanabe d15818f227 network: update debug log when foreign routes are received with ManageForeignRoutes=no 2020-07-18 05:51:41 +09:00
Yu Watanabe 5ff1ef31f2 network: do not enumerate routes if ManageForeignRoutes=no 2020-07-18 05:51:32 +09:00
Yu Watanabe 97fdae33df udev: do not try to reassign alternative names
Setting alternative names may fail if some of them are already assigned.
2020-07-17 21:36:11 +09:00
Yu Watanabe 434a348380 netlink: do not fail when new interface name is already used as an alternative name
When renaming a network interface, the new name may be used as an
alternative name. In that case, let's swap the current name and the
alternative name. That is, first drop the new name from the list of
alternative names, then rename the interface, finally set the old name
as an alternative name.
2020-07-17 21:31:47 +09:00
Yu Watanabe 1498252614 netlink: introduce rtnl_get/delete_link_alternative_names() 2020-07-17 21:29:13 +09:00
Daan De Meyer e5f0010659 mkosi: Update help comment in settings files 2020-07-16 21:44:57 +01:00
Daan De Meyer 172ad053ff mkosi: Keep mkosi.default out of the repository.
Defaulting to fedora makes it a pain to override mkosi.default
point to one of the other mkosi settings files. Instead, have
every developer manually add the symlink to his distro
of choice and don't commit the symlink to the repository by
putting it in the .gitignore.
2020-07-16 21:44:02 +01:00
19 changed files with 163 additions and 70 deletions

1
.gitignore vendored
View File

@ -35,4 +35,5 @@ __pycache__/
/.mkosi-*
/mkosi.builddir/
/mkosi.output/
/mkosi.default
/tags

View File

@ -3,7 +3,7 @@
# Copyright © 2016 Zeal Jagannatha
# This is a settings file for OS image generation using mkosi (https://github.com/systemd/mkosi).
# Simply invoke "mkosi" in the project directory to build an OS image.
# Symlink this file to mkosi.default in the project root directory and invoke "mkosi" to build an OS image.
[Distribution]
Distribution=arch

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1+
# This is a settings file for OS image generation using mkosi (https://github.com/systemd/mkosi).
# Simply invoke "mkosi" in the project directory to build an OS image.
# Symlink this file to mkosi.default in the project root directory and invoke "mkosi" to build an OS image.
[Distribution]
Distribution=debian

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1+
# This is a settings file for OS image generation using mkosi (https://github.com/systemd/mkosi).
# Simply invoke "mkosi" in the project directory to build an OS image.
# Symlink this file to mkosi.default in the project root directory and invoke "mkosi" to build an OS image.
[Distribution]
Distribution=fedora

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1+
# This is a settings file for OS image generation using mkosi (https://github.com/systemd/mkosi).
# Simply invoke "mkosi" in the project directory to build an OS image.
# Symlink this file to mkosi.default in the project root directory and invoke "mkosi" to build an OS image.
[Distribution]
Distribution=opensuse

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1+
# This is a settings file for OS image generation using mkosi (https://github.com/systemd/mkosi).
# Simply invoke "mkosi" in the project directory to build an OS image.
# Symlink this file to mkosi.default in the project root directory and invoke "mkosi" to build an OS image.
[Distribution]
Distribution=ubuntu

View File

@ -36,9 +36,12 @@ building clean OS images from an upstream distribution in combination with a
fresh build of the project in the local working directory. To make use of this,
please acquire `mkosi` from https://github.com/systemd/mkosi first, unless your
distribution has packaged it already and you can get it from there. After the
tool is installed it is sufficient to type `mkosi` in the systemd project
directory to generate a disk image `image.raw` you can boot either in
`systemd-nspawn` or in an UEFI-capable VM:
tool is installed, symlink the settings file for your distribution of choice from
.mkosi/ to mkosi.default in the project root directory (note that the package
manager for this distro needs to be installed on your host system). After doing
that, it is sufficient to type `mkosi` in the systemd project directory to
generate a disk image `image.raw` you can boot either in `systemd-nspawn` or in
an UEFI-capable VM:
```
# systemd-nspawn -bi image.raw
@ -80,6 +83,7 @@ $ vim src/core/main.c # or wherever you'd like to make your cha
$ meson build # configure the build
$ ninja -C build # build it locally, see if everything compiles fine
$ ninja -C build test # run some simple regression tests
$ ln -s .mkosi/mkosi.fedora mkosi.default # Configure mkosi to build a fedora image
$ (umask 077; echo 123 > mkosi.rootpw) # set root password used by mkosi
$ sudo mkosi # build a test image
$ sudo systemd-nspawn -bi image.raw # boot up the test image

View File

@ -1 +0,0 @@
.mkosi/mkosi.fedora

View File

@ -2,6 +2,7 @@
#include "sd-netlink.h"
#include "format-util.h"
#include "memory-util.h"
#include "netlink-internal.h"
#include "netlink-util.h"
@ -9,6 +10,8 @@
int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL;
_cleanup_strv_free_ char **alternative_names = NULL;
char old_name[IF_NAMESIZE + 1] = {};
int r;
assert(rtnl);
@ -18,10 +21,18 @@ int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name) {
if (!ifname_valid(name))
return -EINVAL;
if (!*rtnl) {
r = sd_netlink_open(rtnl);
r = rtnl_get_link_alternative_names(rtnl, ifindex, &alternative_names);
if (r < 0)
return r;
log_debug_errno(r, "Failed to get alternative names on network interface %i, ignoring: %m",
ifindex);
if (strv_contains(alternative_names, name)) {
r = rtnl_delete_link_alternative_names(rtnl, ifindex, STRV_MAKE(name));
if (r < 0)
return log_debug_errno(r, "Failed to remove '%s' from alternative names on network interface %i: %m",
name, ifindex);
format_ifname(ifindex, old_name);
}
r = sd_rtnl_message_new_link(*rtnl, &message, RTM_SETLINK, ifindex);
@ -36,6 +47,13 @@ int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name) {
if (r < 0)
return r;
if (!isempty(old_name)) {
r = rtnl_set_link_alternative_names(rtnl, ifindex, STRV_MAKE(old_name));
if (r < 0)
log_debug_errno(r, "Failed to set '%s' as an alternative name on network interface %i, ignoring: %m",
old_name, ifindex);
}
return 0;
}
@ -85,12 +103,45 @@ int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias,
return 0;
}
int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names) {
int rtnl_get_link_alternative_names(sd_netlink **rtnl, int ifindex, char ***ret) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL, *reply = NULL;
_cleanup_strv_free_ char **names = NULL;
int r;
assert(rtnl);
assert(ifindex > 0);
assert(ret);
if (!*rtnl) {
r = sd_netlink_open(rtnl);
if (r < 0)
return r;
}
r = sd_rtnl_message_new_link(*rtnl, &message, RTM_GETLINK, ifindex);
if (r < 0)
return r;
r = sd_netlink_call(*rtnl, message, 0, &reply);
if (r < 0)
return r;
r = sd_netlink_message_read_strv(reply, IFLA_PROP_LIST, IFLA_ALT_IFNAME, &names);
if (r < 0 && r != -ENODATA)
return r;
*ret = TAKE_PTR(names);
return 0;
}
static int rtnl_update_link_alternative_names(sd_netlink **rtnl, uint16_t nlmsg_type, int ifindex, char * const *alternative_names) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL;
int r;
assert(rtnl);
assert(ifindex > 0);
assert(IN_SET(nlmsg_type, RTM_NEWLINKPROP, RTM_DELLINKPROP));
if (strv_isempty(alternative_names))
return 0;
@ -101,7 +152,7 @@ int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const
return r;
}
r = sd_rtnl_message_new_link(*rtnl, &message, RTM_NEWLINKPROP, ifindex);
r = sd_rtnl_message_new_link(*rtnl, &message, nlmsg_type, ifindex);
if (r < 0)
return r;
@ -124,6 +175,14 @@ int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const
return 0;
}
int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names) {
return rtnl_update_link_alternative_names(rtnl, RTM_NEWLINKPROP, ifindex, alternative_names);
}
int rtnl_delete_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names) {
return rtnl_update_link_alternative_names(rtnl, RTM_DELLINKPROP, ifindex, alternative_names);
}
int rtnl_set_link_alternative_names_by_ifname(sd_netlink **rtnl, const char *ifname, char * const *alternative_names) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL;
int r;
@ -236,10 +295,10 @@ int rtnl_message_new_synthetic_error(sd_netlink *rtnl, int error, uint32_t seria
if (r < 0)
return r;
rtnl_message_seal(*ret);
(*ret)->hdr->nlmsg_seq = serial;
err = NLMSG_DATA((*ret)->hdr);
err->error = error;
return 0;

View File

@ -53,8 +53,10 @@ static inline bool rtnl_message_type_is_tclass(uint16_t type) {
int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name);
int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias, const struct ether_addr *mac, uint32_t mtu);
int rtnl_get_link_alternative_names(sd_netlink **rtnl, int ifindex, char ***ret);
int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names);
int rtnl_set_link_alternative_names_by_ifname(sd_netlink **rtnl, const char *ifname, char * const *alternative_names);
int rtnl_delete_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names);
int rtnl_resolve_link_alternative_name(sd_netlink **rtnl, const char *name);
int rtnl_get_link_iftype(sd_netlink **rtnl, int ifindex, unsigned short *ret);

View File

@ -431,6 +431,32 @@ int address_get(Link *link,
return -ENOENT;
}
static bool address_exists_internal(Set *addresses, int family, const union in_addr_union *in_addr) {
Address *address;
Iterator i;
SET_FOREACH(address, addresses, i) {
if (address->family != family)
continue;
if (in_addr_equal(address->family, &address->in_addr, in_addr))
return true;
}
return false;
}
bool address_exists(Link *link, int family, const union in_addr_union *in_addr) {
assert(link);
assert(IN_SET(family, AF_INET, AF_INET6));
assert(in_addr);
if (address_exists_internal(link->addresses, family, in_addr))
return true;
if (address_exists_internal(link->addresses_foreign, family, in_addr))
return true;
return false;
}
static int address_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
int r;

View File

@ -57,6 +57,7 @@ void address_free(Address *address);
int address_add_foreign(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
int address_add(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
int address_get(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
bool address_exists(Link *link, int family, const union in_addr_union *in_addr);
int address_update(Address *address, unsigned char flags, unsigned char scope, const struct ifa_cacheinfo *cinfo);
int address_drop(Address *address);
int address_configure(Address *address, Link *link, link_netlink_message_handler_t callback, bool update);

View File

@ -4229,7 +4229,7 @@ int link_save(Link *link) {
sd_dhcp6_lease_get_dns,
NULL);
/* Make sure to flush out old entries before we use the NDISC data */
/* Make sure to flush out old entries before we use the NDisc data */
ndisc_vacuum(link);
if (link->network->ipv6_accept_ra_use_dns && link->ndisc_rdnss) {

View File

@ -505,7 +505,8 @@ int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, vo
log_link_debug(link,
"%s route: dst: %s%s, src: %s, gw: %s, prefsrc: %s, scope: %s, table: %s, proto: %s, type: %s",
(!route && !link->manager->manage_foreign_routes) || type == RTM_DELROUTE ? "Forgetting" :
(!route && !link->manager->manage_foreign_routes) ? "Ignoring received foreign" :
type == RTM_DELROUTE ? "Forgetting" :
route ? "Received remembered" : "Remembering",
strna(buf_dst), strempty(buf_dst_prefixlen),
strna(buf_src), strna(buf_gw), strna(buf_prefsrc),
@ -2031,6 +2032,9 @@ int manager_rtnl_enumerate_routes(Manager *m) {
assert(m);
assert(m->rtnl);
if (!m->manage_foreign_routes)
return 0;
r = sd_rtnl_message_new_route(m->rtnl, &req, RTM_GETROUTE, 0, 0);
if (r < 0)
return r;

View File

@ -148,8 +148,6 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
unsigned preference;
uint32_t mtu;
usec_t time_now;
Address *address;
Iterator i;
int r;
assert(link);
@ -166,35 +164,16 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
if (r < 0)
return log_link_error_errno(link, r, "Failed to get gateway address from RA: %m");
SET_FOREACH(address, link->addresses, i) {
if (address->family != AF_INET6)
continue;
if (in_addr_equal(AF_INET6, &gateway, &address->in_addr)) {
if (address_exists(link, AF_INET6, &gateway)) {
if (DEBUG_LOGGING) {
_cleanup_free_ char *buffer = NULL;
(void) in_addr_to_string(AF_INET6, &address->in_addr, &buffer);
(void) in_addr_to_string(AF_INET6, &gateway, &buffer);
log_link_debug(link, "No NDisc route added, gateway %s matches local address",
strnull(buffer));
}
return 0;
}
}
SET_FOREACH(address, link->addresses_foreign, i) {
if (address->family != AF_INET6)
continue;
if (in_addr_equal(AF_INET6, &gateway, &address->in_addr)) {
if (DEBUG_LOGGING) {
_cleanup_free_ char *buffer = NULL;
(void) in_addr_to_string(AF_INET6, &address->in_addr, &buffer);
log_link_debug(link, "No NDisc route added, gateway %s matches local address",
strnull(buffer));
}
return 0;
}
}
r = sd_ndisc_router_get_preference(rt, &preference);
if (r < 0)
@ -836,14 +815,14 @@ static void ndisc_handler(sd_ndisc *nd, sd_ndisc_event event, sd_ndisc_router *r
break;
case SD_NDISC_EVENT_TIMEOUT:
log_link_debug(link, "NDISC handler get timeout event");
log_link_debug(link, "NDisc handler get timeout event");
link->ndisc_addresses_configured = true;
link->ndisc_routes_configured = true;
link_check_ready(link);
break;
default:
assert_not_reached("IPv6 Neighbor Discovery unknown event");
assert_not_reached("Unknown NDisc event");
}
}
@ -969,7 +948,7 @@ int config_parse_ndisc_deny_listed_prefix(
return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse NDISC deny-listed prefix, ignoring assignment: %s",
"Failed to parse NDisc deny-listed prefix, ignoring assignment: %s",
rvalue);
return 0;
}
@ -979,7 +958,7 @@ int config_parse_ndisc_deny_listed_prefix(
r = in_addr_from_string(AF_INET6, n, &ip);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"NDISC deny-listed prefix is invalid, ignoring assignment: %s", n);
"NDisc deny-listed prefix is invalid, ignoring assignment: %s", n);
continue;
}

View File

@ -132,7 +132,7 @@ int neighbor_configure(Neighbor *neighbor, Link *link, link_netlink_message_hand
if (r < 0)
return log_link_error_errno(link, r, "Could not set state: %m");
r = sd_netlink_message_set_flags(req, NLM_F_REQUEST | NLM_F_CREATE | NLM_F_REPLACE);
r = sd_netlink_message_set_flags(req, NLM_F_REQUEST | NLM_F_ACK | NLM_F_CREATE | NLM_F_REPLACE);
if (r < 0)
return log_link_error_errno(link, r, "Could not set flags: %m");

View File

@ -3191,7 +3191,7 @@ static int inner_child(
if (asprintf((char **)(envp + n_env++), "NOTIFY_SOCKET=%s", NSPAWN_NOTIFY_SOCKET_PATH) < 0)
return log_oom();
env_use = strv_env_merge(3, envp, arg_setenv, os_release_pairs);
env_use = strv_env_merge(3, envp, os_release_pairs, arg_setenv);
if (!env_use)
return log_oom();

View File

@ -358,7 +358,7 @@ static int get_mac(sd_device *device, MACAddressPolicy policy, struct ether_addr
int link_config_apply(link_config_ctx *ctx, link_config *config,
sd_device *device, const char **name) {
_cleanup_strv_free_ char **altnames = NULL;
_cleanup_strv_free_ char **altnames = NULL, **current_altnames = NULL;
struct ether_addr generated_mac;
struct ether_addr *mac = NULL;
const char *new_name = NULL;
@ -539,9 +539,17 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
if (new_name)
strv_remove(altnames, new_name);
strv_remove(altnames, old_name);
r = rtnl_get_link_alternative_names(&ctx->rtnl, ifindex, &current_altnames);
if (r < 0)
log_debug_errno(r, "Failed to get alternative names on %s, ignoring: %m", old_name);
char **p;
STRV_FOREACH(p, current_altnames)
strv_remove(altnames, *p);
strv_uniq(altnames);
strv_sort(altnames);
r = rtnl_set_link_alternative_names(&ctx->rtnl, ifindex, altnames);
if (r == -EOPNOTSUPP)
log_debug_errno(r, "Could not set AlternativeName= or apply AlternativeNamesPolicy= on %s, ignoring: %m", old_name);

View File

@ -226,6 +226,7 @@ static void setup_remaining_vcs(int src_fd, unsigned src_idx, bool utf8) {
_cleanup_free_ struct unipair* unipairs = NULL;
_cleanup_free_ void *fontbuf = NULL;
unsigned i;
int log_level;
int r;
unipairs = new(struct unipair, USHRT_MAX);
@ -234,11 +235,20 @@ static void setup_remaining_vcs(int src_fd, unsigned src_idx, bool utf8) {
return;
}
log_level = LOG_WARNING;
/* get metadata of the current font (width, height, count) */
r = ioctl(src_fd, KDFONTOP, &cfo);
if (r < 0)
log_warning_errno(errno, "KD_FONT_OP_GET failed while trying to get the font metadata: %m");
else {
if (r < 0) {
/* We might be called to operate on the dummy console (to setup keymap
* mainly) when fbcon deferred takeover is used for example. In such case,
* setting font is not supported and is expected to fail. */
if (errno == ENOSYS)
log_level = LOG_DEBUG;
log_full_errno(log_level, errno,
"KD_FONT_OP_GET failed while trying to get the font metadata: %m");
} else {
/* verify parameter sanity first */
if (cfo.width > 32 || cfo.height > 32 || cfo.charcount > 512)
log_warning("Invalid font metadata - width: %u (max 32), height: %u (max 32), count: %u (max 512)",
@ -273,7 +283,7 @@ static void setup_remaining_vcs(int src_fd, unsigned src_idx, bool utf8) {
}
if (cfo.op != KD_FONT_OP_SET)
log_warning("Fonts will not be copied to remaining consoles");
log_full(log_level, "Fonts will not be copied to remaining consoles");
for (i = 1; i <= 63; i++) {
char ttyname[sizeof("/dev/tty63")];