Compare commits

...

13 Commits

Author SHA1 Message Date
Yu Watanabe b9cbb08e0a sd-device: drop unwanted newline in netlink message 2020-11-18 05:32:44 +09:00
Zbigniew Jędrzejewski-Szmek d407638382 test/udev-test: gracefully exit when imports fail
In Fedora rawhide various perl modules are now available as separate
packages that are not pulled in by dependencies. If we don't have some
package, skip the tests.

This ugly code is apparently the way to do conditional imports:
https://www.cs.ait.ac.th/~on/O/oreilly/perl/cookbook/ch12_03.htm.
2020-11-18 03:50:17 +09:00
Roman Beranek 07e4a8dc23 Revert "resolve: check DNSSD service name template before assigning it"
This reverts commit 34136e1503.

Having the "%H" host name specifier in a DNSSD service name template
triggers a failed assertion during name template instantiation as
specifier_dnssd_host_name expects DnssdService in its userdata
pointer but finds NULL instead.
2020-11-18 03:16:57 +09:00
Zbigniew Jędrzejewski-Szmek 478f5aac07 hwdb/60-keyboard: untabify and move comments to the same column
Follow-up for b0a3a3ff5d.
2020-11-18 02:14:32 +09:00
Zbigniew Jędrzejewski-Szmek 1598b07da3
Merge pull request #17640 from keszybz/meson-test-c++20
Also test headers against c++20
2020-11-17 17:14:49 +01:00
Zbigniew Jędrzejewski-Szmek 485a9202ba
Merge pull request #17643 from keszybz/man-news-independent
NEWS and man page tweaks
2020-11-17 17:14:14 +01:00
Zbigniew Jędrzejewski-Szmek 905a03e71d NEWS,man: improve descriptions of Independent=
In NEWS, the new option was described twice, most likely because the first
description was tucked away in a paragraph about some other subject.

While at it, improve the descriptions in the man page to make it easier to grok
what that option really does.
2020-11-17 12:37:44 +01:00
Zbigniew Jędrzejewski-Szmek de70ff66dc man: drop misplaced phrase
I think it was added in 6c2b9c8da1 as c&p.
2020-11-17 11:46:50 +01:00
Zbigniew Jędrzejewski-Szmek dbc29e9175 network: use the common "cannot" form
Just for consistency.
2020-11-17 10:55:36 +01:00
Zbigniew Jędrzejewski-Szmek 7ad41997d1 man/systemd.netdev: remove bogus markup
There is no "Multicast" constant, and NULL doesn't make sense in the
context of addresses.
2020-11-17 10:55:12 +01:00
Zbigniew Jędrzejewski-Szmek e375ceb640 man/systemd.netdev: don't say "ranges" 2020-11-17 10:43:13 +01:00
Zbigniew Jędrzejewski-Szmek 2e5811521d test: let's start getting ready for 2020
It'll be a wonderful year, I'm sure.
2020-11-17 10:03:15 +01:00
Zbigniew Jędrzejewski-Szmek e318c2a444 meson: use proper variable for libudev.h path 2020-11-17 10:01:05 +01:00
13 changed files with 218 additions and 200 deletions

9
NEWS
View File

@ -457,9 +457,7 @@ CHANGES WITH 247 in spe:
discipline in the [FlowQueuePIE] sections.
* systemd-networkd's .netdev files may now be used to create "BareUDP"
tunnels, configured in the new [BareUDP] setting. VXLAN tunnels may
now be marked to be independent of any underlying network interface
via the new Independent= boolean setting.
tunnels, configured in the new [BareUDP] setting.
* systemd-networkd's Gateway= setting in .network files now accepts the
special values "_dhcp4" and "_ipv6ra" to configure additional,
@ -482,9 +480,8 @@ CHANGES WITH 247 in spe:
prefix will be announced through IPv6 router advertisement (IPv6 RA).
The setting is enabled by default.
* systemd-networkd's .netdev files gained the Independent= boolean
setting in [VXLAN] section. When enabled, the vxlan interface will be
created without underlying interfaces. Defaults to false.
* VXLAN tunnels may now be marked as independent of any underlying
network interface via the new Independent= boolean setting.
* systemctl gained support for two new verbs: "service-log-level" and
"service-log-target" may be used on services that implement the

View File

@ -84,7 +84,7 @@
</row></thead>
<tbody>
<row><entry><varname>bond</varname></entry>
<entry>A bond device is an aggregation of all its slave devices. See <ulink url="https://www.kernel.org/doc/Documentation/networking/bonding.txt">Linux Ethernet Bonding Driver HOWTO</ulink> for details.Local configuration</entry></row>
<entry>A bond device is an aggregation of all its slave devices. See <ulink url="https://www.kernel.org/doc/Documentation/networking/bonding.txt">Linux Ethernet Bonding Driver HOWTO</ulink> for details.</entry></row>
<row><entry><varname>bridge</varname></entry>
<entry>A bridge device is a software switch, and each of its slave devices and the bridge itself are ports of the switch.</entry></row>
@ -754,7 +754,8 @@
<varlistentry>
<term><varname>Id=</varname></term>
<listitem>
<para>Specifies the Virtual Network Identifier (VNI) to use. Ranges [0-16777215]. This field is mandatory.</para>
<para>Specifies the Virtual Network Identifier (VNI) to use, a number between 0 and 16777215. This
field is mandatory.</para>
</listitem>
</varlistentry>
<varlistentry>
@ -766,7 +767,7 @@
<varlistentry>
<term><varname>TOS=</varname></term>
<listitem>
<para>Specifies the TOS value to use in outgoing packets. Ranges [1-255].</para>
<para>Specifies the TOS value to use in outgoing packets. Takes a number between 1 and 255.</para>
</listitem>
</varlistentry>
<varlistentry>
@ -818,8 +819,9 @@
<varlistentry>
<term><varname>Independent=</varname></term>
<listitem>
<para>Takes a boolean. When true, the vxlan interface is created without underlying interfaces.
Defaults to <literal>false</literal>.</para>
<para>Takes a boolean. When true, the vxlan interface is created without any underlying network
interface. Defaults to false, which means that a .network file that requests this tunnel using
<varname>Tunnel=</varname> is required for the tunnel to be created.</para>
</listitem>
</varlistentry>
</variablelist>
@ -1276,9 +1278,10 @@
<varlistentry>
<term><varname>Independent=</varname></term>
<listitem>
<para>Takes a boolean. When true tunnel does not require .network file. Created as "tunnel@NONE".
Defaults to <literal>false</literal>.
</para>
<para>Takes a boolean. When false (the default), the tunnel is always created over some network
device, and a .network file that requests this tunnel using <varname>Tunnel=</varname> is required
for the tunnel to be created. When true, the tunnel is created independently of any network as
"tunnel@NONE".</para>
</listitem>
</varlistentry>
<varlistentry>
@ -1770,8 +1773,8 @@
<varlistentry>
<term><varname>AdActorSystem=</varname></term>
<listitem>
<para>Specifies the 802.3ad system mac address. This can not be either
<constant>NULL</constant> or <constant>Multicast</constant>.</para>
<para>Specifies the 802.3ad system MAC address. This cannot be a null or multicast address.
</para>
</listitem>
</varlistentry>
@ -1948,10 +1951,8 @@
<varlistentry>
<term><varname>Independent=</varname></term>
<listitem>
<para>Takes a boolean. If set to <literal>no</literal>, the xfrm interface should have an
underlying device which can be used for hardware offloading. Defaults to <literal>no</literal>.
See <citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>
for how to configure the underlying device.</para>
<para>Takes a boolean. If false (the default), the xfrm interface must have an underlying device
which can be used for hardware offloading.</para>
</listitem>
</varlistentry>
</variablelist>

View File

@ -1594,6 +1594,7 @@ generate_gperfs = find_program('tools/generate-gperfs.py')
subdir('po')
subdir('catalog')
subdir('src/libudev')
subdir('src/systemd')
subdir('src/basic')
subdir('src/libsystemd')
@ -1673,7 +1674,6 @@ update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
# usually, but not always, installed in /bin.
public_programs = []
subdir('src/libudev')
subdir('src/shared')
subdir('src/core')
subdir('src/shutdown')

View File

@ -468,6 +468,10 @@ int device_new_from_nulstr(sd_device **ret, uint8_t *nulstr, size_t len) {
i += end - key + 1;
/* netlink messages for some devices contain an unwanted newline at the end of value.
* Let's drop the newline and remaining characters after the newline. */
truncate_nl(key);
r = device_append(device, key, &major, &minor);
if (r < 0)
return r;

View File

@ -469,7 +469,7 @@ int config_parse_ad_actor_system(
}
if (ether_addr_is_null(&n) || (n.ether_addr_octet[0] & 0x01)) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Not a valid MAC address %s, can not be null or multicast. Ignoring assignment.",
"Not an appropriate MAC address %s, cannot be null or multicast. Ignoring assignment.",
rvalue);
return 0;
}

View File

@ -1795,6 +1795,7 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata,
_cleanup_(dnssd_service_freep) DnssdService *service = NULL;
_cleanup_(sd_bus_track_unrefp) sd_bus_track *bus_track = NULL;
_cleanup_free_ char *path = NULL;
_cleanup_free_ char *instance_name = NULL;
Manager *m = userdata;
DnssdService *s = NULL;
const char *name;
@ -1835,10 +1836,6 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata,
if (!dnssd_srv_type_is_valid(type))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "DNS-SD service type '%s' is invalid", type);
r = dnssd_render_instance_name(name_template, NULL);
if (r < 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "DNS-SD service name '%s' is invalid", name_template);
service->name = strdup(name);
if (!service->name)
return log_oom();
@ -1851,6 +1848,10 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata,
if (!service->type)
return log_oom();
r = dnssd_render_instance_name(service, &instance_name);
if (r < 0)
return r;
r = sd_bus_message_enter_container(message, SD_BUS_TYPE_ARRAY, "a{say}");
if (r < 0)
return r;

View File

@ -217,19 +217,21 @@ int config_parse_search_domains(
return 0;
}
int config_parse_dnssd_service_name(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int config_parse_dnssd_service_name(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata) {
static const Specifier specifier_table[] = {
{ 'm', specifier_machine_id, NULL },
{ 'b', specifier_boot_id, NULL },
{ 'H', specifier_host_name, NULL },
{ 'v', specifier_kernel_release, NULL },
{ 'a', specifier_architecture, NULL },
{ 'o', specifier_os_id, NULL },
{ 'w', specifier_os_version_id, NULL },
{ 'B', specifier_os_build_id, NULL },
{ 'W', specifier_os_variant_id, NULL },
{}
};
DnssdService *s = userdata;
_cleanup_free_ char *name = NULL;
int r;
assert(filename);
@ -238,23 +240,23 @@ int config_parse_dnssd_service_name(
assert(s);
if (isempty(rvalue)) {
s->name_template = mfree(s->name_template);
return 0;
}
r = dnssd_render_instance_name(rvalue, NULL);
if (r == -ENOMEM)
return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid service instance name template '%s', ignoring: %m", rvalue);
return 0;
log_syntax(unit, LOG_ERR, filename, line, 0, "Service instance name can't be empty. Ignoring.");
return -EINVAL;
}
r = free_and_strdup(&s->name_template, rvalue);
if (r < 0)
return log_oom();
r = specifier_printf(s->name_template, specifier_table, NULL, &name);
if (r < 0)
return log_debug_errno(r, "Failed to replace specifiers: %m");
if (!dns_service_name_is_valid(name)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Service instance name template renders to invalid name '%s'. Ignoring.", name);
return -EINVAL;
}
return 0;
}

View File

@ -155,7 +155,7 @@ static int specifier_dnssd_host_name(char specifier, const void *data, const voi
return 0;
}
int dnssd_render_instance_name(const char *name_template, char **ret_name) {
int dnssd_render_instance_name(DnssdService *s, char **ret_name) {
static const Specifier specifier_table[] = {
{ 'm', specifier_machine_id, NULL },
{ 'b', specifier_boot_id, NULL },
@ -171,16 +171,18 @@ int dnssd_render_instance_name(const char *name_template, char **ret_name) {
_cleanup_free_ char *name = NULL;
int r;
assert(name_template);
assert(s);
assert(s->name_template);
r = specifier_printf(name_template, specifier_table, NULL, &name);
r = specifier_printf(s->name_template, specifier_table, s, &name);
if (r < 0)
return r;
return log_debug_errno(r, "Failed to replace specifiers: %m");
if (!dns_service_name_is_valid(name))
return -EINVAL;
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
"Service instance name '%s' is invalid.",
name);
if (ret_name)
*ret_name = TAKE_PTR(name);
return 0;
@ -225,7 +227,7 @@ int dnssd_update_rrs(DnssdService *s) {
LIST_FOREACH(items, txt_data, s->txt_data_items)
txt_data->rr = dns_resource_record_unref(txt_data->rr);
r = dnssd_render_instance_name(s->name_template, &n);
r = dnssd_render_instance_name(s, &n);
if (r < 0)
return r;

View File

@ -53,7 +53,7 @@ DnssdTxtData *dnssd_txtdata_free_all(DnssdTxtData *txt_data);
DEFINE_TRIVIAL_CLEANUP_FUNC(DnssdService*, dnssd_service_free);
DEFINE_TRIVIAL_CLEANUP_FUNC(DnssdTxtData*, dnssd_txtdata_free);
int dnssd_render_instance_name(const char *name_template, char **ret_name);
int dnssd_render_instance_name(DnssdService *s, char **ret_name);
int dnssd_load(Manager *manager);
int dnssd_txt_item_new_from_string(const char *key, const char *value, DnsTxtItem **ret_item);
int dnssd_txt_item_new_from_data(const char *key, const void *value, const size_t size, DnsTxtItem **ret_item);

View File

@ -64,9 +64,12 @@ if add_languages('cpp', required : false)
if cxx.has_argument('-std=c++17')
opts += [['c++', '-std=c++17']]
endif
if cxx.has_argument('-std=c++20')
opts += [['c++', '-std=c++20']]
endif
endif
foreach header : _systemd_headers + _not_installed_headers + ['../libudev/libudev.h']
foreach header : _systemd_headers + _not_installed_headers + [libudev_h_path]
foreach opt : opts
std_name = opt.length() == 2 ? '_'.join(opt[1].split(':')) : ''
name = ''.join(['cc-', header.split('/')[-1], '_', opt[0], std_name])

View File

@ -18,11 +18,19 @@
use warnings;
use strict;
use POSIX qw(WIFEXITED WEXITSTATUS);
use IPC::SysV qw(IPC_PRIVATE S_IRUSR S_IWUSR IPC_CREAT);
use IPC::Semaphore;
use Time::HiRes qw(usleep);
BEGIN {
my $EXIT_TEST_SKIP = 77;
unless (eval "use POSIX qw(WIFEXITED WEXITSTATUS);
use Cwd qw(getcwd abs_path);
use IPC::Semaphore;
use IPC::SysV qw(IPC_PRIVATE S_IRUSR S_IWUSR IPC_CREAT);
use Time::HiRes qw(usleep); 1") {
warn "Failed to import dependencies, skipping the test: $@";
exit($EXIT_TEST_SKIP);
}
}
my $udev_bin = "./test-udev";
my $valgrind = 0;