mirror of
https://github.com/systemd/systemd
synced 2026-04-10 17:15:03 +02:00
Compare commits
18 Commits
58f62d7079
...
4bb3437cad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4bb3437cad | ||
|
|
97b6ed3295 | ||
|
|
0c0bb433db | ||
|
|
357376d0bb | ||
|
|
1c9b72f38e | ||
|
|
bd1660c4fa | ||
|
|
7b3a1af063 | ||
|
|
67cb0d4725 | ||
|
|
79463de533 | ||
|
|
a4c9bf2e51 | ||
|
|
ff516b4341 | ||
|
|
eb3e86ae2c | ||
|
|
987dd89c77 | ||
|
|
85e8650827 | ||
|
|
447a822f8e | ||
|
|
0ad4efb14b | ||
|
|
9d84fdec28 | ||
|
|
af45251e4c |
113
NEWS
113
NEWS
@ -237,6 +237,9 @@ CHANGES WITH 250 in spe:
|
||||
* sd-boot will now build with SBAT by default in order to facilitate
|
||||
working with recent versions of Shim that require it to be present.
|
||||
|
||||
* sd-boot can now parse Microsoft Windows' Boot Configuration Data.
|
||||
This is used to robustly generate boot entry titles for Windows.
|
||||
|
||||
* A new generic target unit factory-reset.target has been added. It is
|
||||
hooked into systemd-logind similar in fashion to
|
||||
reboot/poweroff/suspend/hibernate, and is supposed to be used to
|
||||
@ -345,6 +348,11 @@ CHANGES WITH 250 in spe:
|
||||
interfaces. The Kind= setting in .netdev file accepts "ipoib". And
|
||||
systemd.netdev files gained the [IPoIB] section.
|
||||
|
||||
* systemd-networkd and systemd-udevd now support net.ifname-policy=
|
||||
option on the kernel command-line. This is implemented through the
|
||||
systemd-network-generator service that automatically generates
|
||||
appropriate .link, .network, and .netdev files.
|
||||
|
||||
* systemd-networkd's handling of Endpoint= resolution for WireGuard
|
||||
interfaces has been improved.
|
||||
|
||||
@ -482,14 +490,17 @@ CHANGES WITH 250 in spe:
|
||||
".dtb" and apply it before invoking the kernel.
|
||||
|
||||
* sd-stub (the EFI stub that can be glued in front of a Linux kernel)
|
||||
gained the ability to pick up credentials and sysext files placed
|
||||
next to the kernel image file, wrap them in a cpio archive and pass
|
||||
as an additional initrd to the invoked Linux kernel, in effect
|
||||
placing those files in the /.extra/ directory of the initrd
|
||||
environment. This is useful to implement trusted initrd environments
|
||||
which are fully authenticated but still can be extended (via sysexts)
|
||||
and parameterized (via encrypted/authenticated credentials, see
|
||||
above).
|
||||
gained the ability to pick up credentials and sysext files, wrap them
|
||||
in a cpio archive, and pass as an additional initrd to the invoked
|
||||
Linux kernel, in effect placing those files in the /.extra/ directory
|
||||
of the initrd environment. This is useful to implement trusted initrd
|
||||
environments which are fully authenticated but still can be extended
|
||||
(via sysexts) and parameterized (via encrypted/authenticated
|
||||
credentials, see above).
|
||||
|
||||
Credentials can be located next to the kernel image file (credentials
|
||||
specific to a single boot entry), or in one of the shared directories
|
||||
(credentials applicable to multiple boot entries).
|
||||
|
||||
* sd-stub now comes with a full man page, that explains its feature set
|
||||
and how to combine a kernel image, an initrd and the stub to build a
|
||||
@ -504,6 +515,8 @@ CHANGES WITH 250 in spe:
|
||||
may be used to set the boot menu time-out of the boot loader (for all
|
||||
or just the subsequent boot).
|
||||
|
||||
* bootctl and systemd-bless-boot can now be linked statically.
|
||||
|
||||
* systemd-sysext now optionally doesn't insist on extension-release.d/
|
||||
files being placed in the image under the image's file name. If the
|
||||
file system xattr user.extension-release.strict is set on the
|
||||
@ -530,6 +543,9 @@ CHANGES WITH 250 in spe:
|
||||
* A new rule to allow console users access to rfkill by default has been
|
||||
added to hwdb.
|
||||
|
||||
* Device nodes for the Software Guard eXtension enclaves (sgx_vepc) are
|
||||
now also owned by the system group "sgx".
|
||||
|
||||
* A new build-time meson option "extra-net-naming-schemes=" has been
|
||||
added to define additional naming schemes schemes for udev's network
|
||||
interface naming logic. This is useful for enterprise distributions
|
||||
@ -668,6 +684,14 @@ CHANGES WITH 250 in spe:
|
||||
* The x-systemd.makefs option in /etc/fstab now explicitly supports
|
||||
ext2, ext3, and f2fs file systems.
|
||||
|
||||
* Mount units and units generated from /etc/fstab entries with 'noauto'
|
||||
are now ordered the same as other units. Effectively, they will be
|
||||
started earlier (if something actually pulled them in) and stopped
|
||||
later, similarly to normal mount units that are part of
|
||||
fs-local.target. This change should be invisibile to users, but
|
||||
should prevent those units from being stopped too early during
|
||||
shutdown.
|
||||
|
||||
* The systemd-getty-generator now honors a new kernel command line
|
||||
argument systemd.getty_auto= and a new environment variable
|
||||
$SYSTEMD_GETTY_AUTO that allows turning it off at boot. This is for
|
||||
@ -741,41 +765,43 @@ CHANGES WITH 250 in spe:
|
||||
this repository. It also contains the text of all applicable
|
||||
licenses as they appear on spdx.org.
|
||||
|
||||
Contributions from: Aakash Singh, Adolfo Jayme Barrientos, Albert Brox,
|
||||
Alberto Mardegan, Alexander Kanavin, alexlzhu, Alfonso Sánchez-Beato,
|
||||
Alvin Šipraga, Alyssa Ross, Amir Omidi, Anatol Pomozov,
|
||||
Andika Triwidada, Andreas Rammhold, Andreas Valder, Andrej Lajovic,
|
||||
Andrew Soutar, Andrew Stone, Andy Chi, Anita Zhang, Anssi Hannula,
|
||||
Antonio Alvarez Feijoo, Antony Deepak Thomas, Arnaud Ferraris,
|
||||
Arvid E. Picciani, Bastien Nocera, Benjamin Berg,
|
||||
Benjamin Herrenschmidt, Ben Stockett, Bogdan Seniuc, Boqun Feng,
|
||||
Carl Lei, chlorophyll-zz, Chris Packham, Christian Brauner,
|
||||
Christian Göttsche, Christian Wehrli, Christoph Anton Mitterer,
|
||||
Cristian Rodríguez, Daan De Meyer, Daniel Maixner, Dann Frazier,
|
||||
Dan Streetman, David Seifert, David Tardon, dependabot[bot],
|
||||
Dimitri John Ledkov, Dimitri Papadopoulos, Dimitry Ishenko,
|
||||
Dmitry Khlebnikov, Dominique Martinet, duament, Egor, Egor Ignatov,
|
||||
Emil Renner Berthing, Emily Gonyer, Ettore Atalan, Evgeny Vereshchagin,
|
||||
Florian Klink, Franck Bui, Frantisek Sumsal, Geass-LL, Gibeom Gwon,
|
||||
GnunuX, Gogo Gogsi, gregzuro, Greg Zuro, Gustavo Costa, Hans de Goede,
|
||||
Contributions from: Aakash Singh, acsfer, Adolfo Jayme Barrientos,
|
||||
Adrian Vovk, Albert Brox, Alberto Mardegan, Alexander Kanavin,
|
||||
alexlzhu, Alfonso Sánchez-Beato, Alvin Šipraga, Alyssa Ross,
|
||||
Amir Omidi, Anatol Pomozov, Andika Triwidada, Andreas Rammhold,
|
||||
Andreas Valder, Andrej Lajovic, Andrew Soutar, Andrew Stone, Andy Chi,
|
||||
Anita Zhang, Anssi Hannula, Antonio Alvarez Feijoo,
|
||||
Antony Deepak Thomas, Arnaud Ferraris, Arvid E. Picciani,
|
||||
Bastien Nocera, Benjamin Berg, Benjamin Herrenschmidt, Ben Stockett,
|
||||
Bogdan Seniuc, Boqun Feng, Carl Lei, chlorophyll-zz, Chris Packham,
|
||||
Christian Brauner, Christian Göttsche, Christian Wehrli,
|
||||
Christoph Anton Mitterer, Cristian Rodríguez, Daan De Meyer,
|
||||
Daniel Maixner, Dann Frazier, Dan Streetman, Davide Cavalca,
|
||||
David Seifert, David Tardon, dependabot[bot], Dimitri John Ledkov,
|
||||
Dimitri Papadopoulos, Dimitry Ishenko, Dmitry Khlebnikov,
|
||||
Dominique Martinet, duament, Egor, Egor Ignatov, Emil Renner Berthing,
|
||||
Emily Gonyer, Ettore Atalan, Evgeny Vereshchagin, Florian Klink,
|
||||
Franck Bui, Frantisek Sumsal, Geass-LL, Gibeom Gwon, GnunuX,
|
||||
Gogo Gogsi, gregzuro, Greg Zuro, Gustavo Costa, Hans de Goede,
|
||||
Hela Basa, Henri Chain, hikigaya58, Hugo Carvalho,
|
||||
Hugo Osvaldo Barrera, Iago Lopez Galeiras, Iago López Galeiras,
|
||||
I-dont-need-name, Jack Dähn, James Hilliard, Jan Janssen,
|
||||
Jan Kuparinen, Jan Macku, Jan Palus, jiangchuangang, jlempen,
|
||||
John Lindgren, Jonas Dreßler, Jonas Witschel, Joris Hartog,
|
||||
José Expósito, Julia Kartseva, Kai-Heng Feng, Kai Wohlfahrt,
|
||||
Kay Siver Bø, KennthStailey, Kevin Kuehler, Kevin Orr, Khem Raj,
|
||||
Kristian Klausen, Kyle Laker, lainahai, Lennart Poettering,
|
||||
Lia Lenckowski, longpanda, Luca Boccassi, Luca BRUNO, Ludwig Nussel,
|
||||
Lukas Senionis, Maanya Goenka, Maciek Borzecki, Marcel Menzel,
|
||||
Marco Scardovi, Marcus Harrison, Mark Boudreau, Matthijs van Duin,
|
||||
Mauricio Vásquez, Maxime de Roucy, Max Resch, MertsA, Michael Biebl,
|
||||
Michael Catanzaro, Michal Koutný, Michal Sekletár, Miika Karanki,
|
||||
Mike Gilbert, Milo Turner, ml, monosans, Nacho Barrientos, nassir90,
|
||||
I-dont-need-name, igo95862, Jack Dähn, James Hilliard, Jan Janssen,
|
||||
Jan Kuparinen, Jan Macku, Jan Palus, Jarkko Sakkinen, Jayce Fayne,
|
||||
jiangchuangang, jlempen, John Lindgren, Jonas Dreßler, Jonas Jelten,
|
||||
Jonas Witschel, Joris Hartog, José Expósito, Julia Kartseva,
|
||||
Kai-Heng Feng, Kai Wohlfahrt, Kay Siver Bø, KennthStailey,
|
||||
Kevin Kuehler, Kevin Orr, Khem Raj, Kristian Klausen, Kyle Laker,
|
||||
lainahai, LaserEyess, Lennart Poettering, Lia Lenckowski, longpanda,
|
||||
Luca Boccassi, Luca BRUNO, Ludwig Nussel, Lukas Senionis,
|
||||
Maanya Goenka, Maciek Borzecki, Marcel Menzel, Marco Scardovi,
|
||||
Marcus Harrison, Mark Boudreau, Matthijs van Duin, Mauricio Vásquez,
|
||||
Maxime de Roucy, Max Resch, MertsA, Michael Biebl, Michael Catanzaro,
|
||||
Michal Koutný, Michal Sekletár, Miika Karanki, Mike Gilbert,
|
||||
Milo Turner, ml, monosans, Nacho Barrientos, nassir90, Nishal Kulkarni,
|
||||
nl6720, Ondrej Kozina, Paulo Neves, Pavel Březina, pedro martelletto,
|
||||
Peter Hutterer, Peter Morrow, Piotr Drąg, Rasmus Villemoes, ratijas,
|
||||
Raul Tambre, rene, Riccardo Schirone, Robert-L-Turner, Ross Jennings,
|
||||
saikat0511, Scott Lamb, Sergei Trofimovich, Sho Iizuka,
|
||||
Raul Tambre, rene, Riccardo Schirone, Robert-L-Turner, Robert Scheck,
|
||||
Ross Jennings, saikat0511, Scott Lamb, Sergei Trofimovich, Sho Iizuka,
|
||||
Slava Bacherikov, Slimane Selyan Amiri, StefanBruens, Steven Siloti,
|
||||
svonohr, Taiki Sugawara, Takashi Sakamoto, Takuro Onoue, Thomas Blume,
|
||||
Thomas Haller, Thomas Mühlbacher, Tianlu Shao, Toke Høiland-Jørgensen,
|
||||
@ -6401,6 +6427,15 @@ CHANGES WITH 234:
|
||||
temporary directory is passed as the entry directory and removed
|
||||
after all the plugins exit.
|
||||
|
||||
* If KERNEL_INSTALL_MACHINE_ID is set in /etc/machine-info, kernel-install
|
||||
will now use its value as the machine ID instead of the machine ID
|
||||
from /etc/machine-id. If KERNEL_INSTALL_MACHINE_ID isn't set in
|
||||
/etc/machine-info and no machine ID is set in /etc/machine-id,
|
||||
kernel-install will try to store the current machine ID there as
|
||||
KERNEL_INSTALL_MACHINE_ID. If there is no machine ID, kernel-install
|
||||
will generate a new UUID, store it in /etc/machine-info as
|
||||
KERNEL_INSTALL_MACHINE_ID and use it as the machine ID.
|
||||
|
||||
Contributions from: Adrian Heine né Lang, Aggelos Avgerinos, Alexander
|
||||
Kurtz, Alexandros Frantzis, Alexey Brodkin, Alex Lu, Amir Pakdel, Amir
|
||||
Yalon, Anchor Cat, Anthony Parsons, Bastien Nocera, Benjamin Gilbert,
|
||||
|
||||
@ -228,6 +228,18 @@
|
||||
<command>kernel-install</command> will use <literal>Default</literal> instead.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/etc/machine-info</filename>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>If this file contains the <varname>KERNEL_INSTALL_MACHINE_ID</varname> variable,
|
||||
<command>kernel-install</command> will use it as <replaceable>MACHINE-ID</replaceable> instead of
|
||||
the contents of <filename>/etc/machine-id</filename>. If the variable is not found in
|
||||
<filename>/etc/machine-info</filename>, <command>kernel-install</command> will try to save the
|
||||
machine ID it uses to install to <varname>$BOOT</varname> to this file.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/etc/os-release</filename>
|
||||
|
||||
@ -128,6 +128,16 @@
|
||||
specific as <literal>Left Rack, 2nd Shelf</literal>.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>KERNEL_INSTALL_MACHINE_ID=</varname></term>
|
||||
|
||||
<listitem><para>Specifies the installation-specific installation directory
|
||||
<command>kernel-install</command> should use. The value must be a valid machine ID (32 hexadecimal
|
||||
characters). This would generally be the original machine-id that was used when the boot loader
|
||||
entries for this installation were first added. When not set, the current value of
|
||||
<cite>machine-id(5)</cite> will be used.</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
||||
@ -929,10 +929,7 @@ manpages = [
|
||||
''],
|
||||
['systemd-modules-load.service', '8', ['systemd-modules-load'], 'HAVE_KMOD'],
|
||||
['systemd-mount', '1', ['systemd-umount'], ''],
|
||||
['systemd-network-generator.service',
|
||||
'8',
|
||||
['systemd-network-generator'],
|
||||
'ENABLE_NETWORKD'],
|
||||
['systemd-network-generator.service', '8', ['systemd-network-generator'], ''],
|
||||
['systemd-networkd-wait-online.service',
|
||||
'8',
|
||||
['systemd-networkd-wait-online'],
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
||||
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
|
||||
|
||||
<refentry id="systemd-network-generator.service" conditional='ENABLE_NETWORKD'>
|
||||
<refentry id="systemd-network-generator.service">
|
||||
|
||||
<refentryinfo>
|
||||
<title>systemd-network-generator.service</title>
|
||||
@ -59,6 +59,7 @@
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>ifname=</varname></term>
|
||||
<term><varname>net.ifname-policy=</varname></term>
|
||||
<listitem>
|
||||
<para>— translated into
|
||||
<citerefentry><refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum></citerefentry> files.</para>
|
||||
@ -88,6 +89,8 @@
|
||||
|
||||
<para>See
|
||||
<citerefentry project='man-pages'><refentrytitle>dracut.kernel</refentrytitle><manvolnum>7</manvolnum></citerefentry>
|
||||
and
|
||||
<citerefentry><refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
||||
for option syntax and details.</para>
|
||||
</refsect1>
|
||||
|
||||
|
||||
@ -224,6 +224,45 @@
|
||||
appear, which affects older name derivation algorithms, too.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>net.ifname-policy=<replaceable>policy1</replaceable>[,<replaceable>policy2</replaceable>,…][,<replaceable>MAC</replaceable>]</varname></term>
|
||||
<listitem>
|
||||
<para>Specifies naming policies applied when renaming network interfaces. Takes a list of
|
||||
policies and an optional MAC address separated with comma. Each policy value must be one of
|
||||
the policies understood by the <varname>NamePolicy=</varname> setting in .link files, e.g.
|
||||
<literal>onboard</literal> or <literal>path</literal>. See
|
||||
<citerefentry><refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
||||
for more details. When the MAC address is specified, the policies are applied to the
|
||||
interface which has the address. When no MAC address is specified, the policies are applied
|
||||
to all interfaces. This kernel command line argument can be specified multiple times. This
|
||||
argument is not directly read from <command>systemd-udevd</command>, but read and converted
|
||||
to a .link file by <command>systemd-network-generator</command>. So, to make this argument
|
||||
take effect, <filename>systemd-network-generator.service</filename> must be enabled and
|
||||
started before starting <filename>systemd-udevd.service</filename>. See
|
||||
<citerefentry><refentrytitle>systemd-network-generator.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
||||
for more details about the service.</para>
|
||||
<para>Example:
|
||||
<programlisting>net.ifname-policy=keep,kernel,path,slot,onboard,01:23:45:67:89:ab
|
||||
net.ifname-policy=keep,kernel,path,slot,onboard,mac</programlisting>
|
||||
This is mostly equivalent to creating the following .link files:
|
||||
<programlisting># 91-name-policy-with-mac.link
|
||||
[Match]
|
||||
MACAddress=01:23:45:67:89:ab
|
||||
|
||||
[Link]
|
||||
NamePolicy=keep kernel path slot onboard
|
||||
AlternativeNamePolicy=path slot onboard</programlisting>
|
||||
and
|
||||
<programlisting># 92-name-policy-for-all.link
|
||||
[Match]
|
||||
OriginalName=*
|
||||
|
||||
[Link]
|
||||
NamePolicy=keep kernel path slot onboard mac
|
||||
AlternativeNamePolicy=path slot onboard mac</programlisting>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
<!-- when adding entries here, consider also adding them in kernel-command-line.xml -->
|
||||
</refsect1>
|
||||
|
||||
28
meson.build
28
meson.build
@ -3467,22 +3467,22 @@ if conf.get('ENABLE_NETWORKD') == 1
|
||||
install_rpath : rootlibexecdir,
|
||||
install : true,
|
||||
install_dir : rootbindir)
|
||||
endif
|
||||
|
||||
exe = executable(
|
||||
'systemd-network-generator',
|
||||
network_generator_sources,
|
||||
include_directories : includes,
|
||||
link_with : [networkd_link_with],
|
||||
install_rpath : rootlibexecdir,
|
||||
install : true,
|
||||
install_dir : rootlibexecdir)
|
||||
exe = executable(
|
||||
'systemd-network-generator',
|
||||
network_generator_sources,
|
||||
include_directories : includes,
|
||||
link_with : [networkd_link_with],
|
||||
install_rpath : rootlibexecdir,
|
||||
install : true,
|
||||
install_dir : rootlibexecdir)
|
||||
|
||||
if want_tests != 'false'
|
||||
test('test-network-generator-conversion',
|
||||
test_network_generator_conversion_sh,
|
||||
# https://github.com/mesonbuild/meson/issues/2681
|
||||
args : exe.full_path())
|
||||
endif
|
||||
if want_tests != 'false'
|
||||
test('test-network-generator-conversion',
|
||||
test_network_generator_conversion_sh,
|
||||
# https://github.com/mesonbuild/meson/issues/2681
|
||||
args : exe.full_path())
|
||||
endif
|
||||
|
||||
executable(
|
||||
|
||||
@ -90,10 +90,18 @@ if [[ ! $COMMAND ]] || [[ ! $KERNEL_VERSION ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[ -z "$MACHINE_ID" ] && [ -f /etc/machine-id ] && [ "$(stat -fc %T /etc/machine-id)" != "tmpfs" ] && read -r MACHINE_ID < /etc/machine-id
|
||||
# Prefer to use an existing machine ID from /etc/machine-info or /etc/machine-id. If we're using the machine
|
||||
# ID /etc/machine-id, try to persist it in /etc/machine-info. If no machine ID is found, try to generate
|
||||
# a new machine ID in /etc/machine-info. If that fails, use "Default".
|
||||
|
||||
[ -z "$MACHINE_ID" ] && [ -f /etc/machine-info ] && source /etc/machine-info && MACHINE_ID="$KERNEL_INSTALL_MACHINE_ID"
|
||||
[ -z "$MACHINE_ID" ] && [ -f /etc/machine-id ] && read -r MACHINE_ID </etc/machine-id
|
||||
[ -n "$MACHINE_ID" ] && [ -z "$KERNEL_INSTALL_MACHINE_ID" ] && echo "KERNEL_INSTALL_MACHINE_ID=$MACHINE_ID" >>/etc/machine-info
|
||||
[ -z "$MACHINE_ID" ] && NEW_MACHINE_ID="$(systemd-id128 new)" && echo "KERNEL_INSTALL_MACHINE_ID=$NEW_MACHINE_ID" >>/etc/machine-info
|
||||
[ -z "$MACHINE_ID" ] && [ -f /etc/machine-info ] && source /etc/machine-info && MACHINE_ID="$KERNEL_INSTALL_MACHINE_ID"
|
||||
[ -z "$MACHINE_ID" ] && MACHINE_ID="Default"
|
||||
|
||||
[ -z "$BOOT_ROOT" ] && for suff in "$MACHINE_ID" "Default" "loader/entries"; do
|
||||
[ -z "$BOOT_ROOT" ] && for suff in "$MACHINE_ID" "loader/entries"; do
|
||||
for pref in "/efi" "/boot/efi" "/boot"; do
|
||||
if [ -d "$pref/$suff" ]; then
|
||||
BOOT_ROOT="$pref"
|
||||
|
||||
@ -65,9 +65,10 @@ static int link_save(Link *link, const char *dest_dir) {
|
||||
|
||||
assert(link);
|
||||
|
||||
r = asprintf(&filename, "90-%s.link",
|
||||
link->ifname);
|
||||
if (r < 0)
|
||||
filename = strjoin(!isempty(link->ifname) ? "90" :
|
||||
!hw_addr_is_null(&link->mac) ? "91" : "92",
|
||||
"-", link->filename, ".link");
|
||||
if (!filename)
|
||||
return log_oom();
|
||||
|
||||
r = generator_open_unit_file(dest_dir, "kernel command line", filename, &f);
|
||||
@ -104,7 +105,7 @@ static int context_save(Context *context) {
|
||||
r = k;
|
||||
}
|
||||
|
||||
HASHMAP_FOREACH(link, context->links_by_name) {
|
||||
HASHMAP_FOREACH(link, context->links_by_filename) {
|
||||
k = link_save(link, p);
|
||||
if (k < 0 && r >= 0)
|
||||
r = k;
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "ether-addr-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "hostname-util.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
#include "netif-naming-scheme.h"
|
||||
#include "network-generator.h"
|
||||
#include "parse-util.h"
|
||||
#include "proc-cmdline.h"
|
||||
@ -26,6 +26,7 @@
|
||||
|
||||
# .link
|
||||
ifname=<interface>:<MAC>
|
||||
net.ifname-policy=policy1[,policy2,...][,<MAC>] # This is an original rule, not supported by other tools.
|
||||
|
||||
# .netdev
|
||||
vlan=<vlanname>:<phydevice>
|
||||
@ -264,36 +265,59 @@ static Link *link_free(Link *link) {
|
||||
if (!link)
|
||||
return NULL;
|
||||
|
||||
free(link->filename);
|
||||
free(link->ifname);
|
||||
strv_free(link->policies);
|
||||
strv_free(link->alt_policies);
|
||||
return mfree(link);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free);
|
||||
|
||||
static int link_new(Context *context, const char *name, struct ether_addr *mac, Link **ret) {
|
||||
static int link_new(
|
||||
Context *context,
|
||||
const char *name,
|
||||
const struct hw_addr_data *mac,
|
||||
Link **ret) {
|
||||
|
||||
_cleanup_(link_freep) Link *link = NULL;
|
||||
_cleanup_free_ char *ifname = NULL;
|
||||
_cleanup_free_ char *ifname = NULL, *filename = NULL;
|
||||
int r;
|
||||
|
||||
assert(context);
|
||||
assert(mac);
|
||||
|
||||
if (!ifname_valid(name))
|
||||
return -EINVAL;
|
||||
if (name) {
|
||||
if (!ifname_valid(name))
|
||||
return -EINVAL;
|
||||
|
||||
ifname = strdup(name);
|
||||
if (!ifname)
|
||||
return -ENOMEM;
|
||||
ifname = strdup(name);
|
||||
if (!ifname)
|
||||
return -ENOMEM;
|
||||
|
||||
filename = strdup(name);
|
||||
if (!filename)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (!filename) {
|
||||
filename = strdup(hw_addr_is_null(mac) ? "default" :
|
||||
HW_ADDR_TO_STR_FULL(mac, HW_ADDR_TO_STRING_NO_COLON));
|
||||
if (!filename)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
link = new(Link, 1);
|
||||
if (!link)
|
||||
return -ENOMEM;
|
||||
|
||||
*link = (Link) {
|
||||
.filename = TAKE_PTR(filename),
|
||||
.ifname = TAKE_PTR(ifname),
|
||||
.mac = *mac,
|
||||
};
|
||||
|
||||
r = hashmap_ensure_put(&context->links_by_name, &string_hash_ops, link->ifname, link);
|
||||
r = hashmap_ensure_put(&context->links_by_filename, &string_hash_ops, link->filename, link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -304,8 +328,10 @@ static int link_new(Context *context, const char *name, struct ether_addr *mac,
|
||||
return 0;
|
||||
}
|
||||
|
||||
Link *link_get(Context *context, const char *ifname) {
|
||||
return hashmap_get(context->links_by_name, ifname);
|
||||
Link *link_get(Context *context, const char *filename) {
|
||||
assert(context);
|
||||
assert(filename);
|
||||
return hashmap_get(context->links_by_filename, filename);
|
||||
}
|
||||
|
||||
static int network_set_dhcp_type(Context *context, const char *ifname, const char *dhcp_type) {
|
||||
@ -896,7 +922,7 @@ static int parse_cmdline_bond(Context *context, const char *key, const char *val
|
||||
}
|
||||
|
||||
static int parse_cmdline_ifname(Context *context, const char *key, const char *value) {
|
||||
struct ether_addr mac;
|
||||
struct hw_addr_data mac;
|
||||
const char *name, *p;
|
||||
int r;
|
||||
|
||||
@ -911,13 +937,72 @@ static int parse_cmdline_ifname(Context *context, const char *key, const char *v
|
||||
|
||||
name = strndupa_safe(value, p - value);
|
||||
|
||||
r = parse_ether_addr(p + 1, &mac);
|
||||
r = parse_hw_addr(p + 1, &mac);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return link_new(context, name, &mac, NULL);
|
||||
}
|
||||
|
||||
static int parse_cmdline_ifname_policy(Context *context, const char *key, const char *value) {
|
||||
_cleanup_strv_free_ char **policies = NULL, **alt_policies = NULL;
|
||||
struct hw_addr_data mac = HW_ADDR_NULL;
|
||||
Link *link;
|
||||
int r;
|
||||
|
||||
/* net.ifname-policy=policy1[,policy2,...][,<MAC>] */
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return -EINVAL;
|
||||
|
||||
for (const char *q = value; ; ) {
|
||||
_cleanup_free_ char *word = NULL;
|
||||
NamePolicy p;
|
||||
|
||||
r = extract_first_word(&q, &word, ",", 0);
|
||||
if (r == 0)
|
||||
break;
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
p = name_policy_from_string(word);
|
||||
if (p < 0) {
|
||||
r = parse_hw_addr(word, &mac);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (hw_addr_is_null(&mac))
|
||||
return -EINVAL;
|
||||
|
||||
if (!isempty(q))
|
||||
return -EINVAL;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (alternative_names_policy_from_string(word) >= 0) {
|
||||
r = strv_extend(&alt_policies, word);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = strv_consume(&policies, TAKE_PTR(word));
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (strv_isempty(policies))
|
||||
return -EINVAL;
|
||||
|
||||
r = link_new(context, NULL, &mac, &link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
link->policies = TAKE_PTR(policies);
|
||||
link->alt_policies = TAKE_PTR(alt_policies);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int parse_cmdline_item(const char *key, const char *value, void *data) {
|
||||
Context *context = data;
|
||||
|
||||
@ -940,6 +1025,8 @@ int parse_cmdline_item(const char *key, const char *value, void *data) {
|
||||
return parse_cmdline_bond(context, key, value);
|
||||
if (streq(key, "ifname"))
|
||||
return parse_cmdline_ifname(context, key, value);
|
||||
if (streq(key, "net.ifname-policy"))
|
||||
return parse_cmdline_ifname_policy(context, key, value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -991,7 +1078,7 @@ void context_clear(Context *context) {
|
||||
|
||||
hashmap_free_with_destructor(context->networks_by_name, network_free);
|
||||
hashmap_free_with_destructor(context->netdevs_by_name, netdev_free);
|
||||
hashmap_free_with_destructor(context->links_by_name, link_free);
|
||||
hashmap_free_with_destructor(context->links_by_filename, link_free);
|
||||
}
|
||||
|
||||
static int address_dump(Address *address, FILE *f) {
|
||||
@ -1117,13 +1204,27 @@ void link_dump(Link *link, FILE *f) {
|
||||
|
||||
fputs("[Match]\n", f);
|
||||
|
||||
if (!ether_addr_is_null(&link->mac))
|
||||
fprintf(f, "MACAddress=%s\n", ETHER_ADDR_TO_STR(&link->mac));
|
||||
if (!hw_addr_is_null(&link->mac))
|
||||
fprintf(f, "MACAddress=%s\n", HW_ADDR_TO_STR(&link->mac));
|
||||
else
|
||||
fputs("OriginalName=*\n", f);
|
||||
|
||||
fprintf(f,
|
||||
"\n[Link]\n"
|
||||
"Name=%s\n",
|
||||
link->ifname);
|
||||
fputs("\n[Link]\n", f);
|
||||
|
||||
if (!isempty(link->ifname))
|
||||
fprintf(f, "Name=%s\n", link->ifname);
|
||||
|
||||
if (!strv_isempty(link->policies)) {
|
||||
fputs("NamePolicy=", f);
|
||||
fputstrv(f, link->policies, " ", NULL);
|
||||
fputc('\n', f);
|
||||
}
|
||||
|
||||
if (!strv_isempty(link->alt_policies)) {
|
||||
fputs("AlternativeNamesPolicy=", f);
|
||||
fputstrv(f, link->alt_policies, " ", NULL);
|
||||
fputc('\n', f);
|
||||
}
|
||||
}
|
||||
|
||||
int network_format(Network *network, char **ret) {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <net/ethernet.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ether-addr-util.h"
|
||||
#include "hashmap.h"
|
||||
#include "in-addr-util.h"
|
||||
#include "list.h"
|
||||
@ -81,15 +81,21 @@ struct NetDev {
|
||||
};
|
||||
|
||||
struct Link {
|
||||
char *filename;
|
||||
|
||||
/* [Match] */
|
||||
struct hw_addr_data mac;
|
||||
|
||||
/* [Link] */
|
||||
char *ifname;
|
||||
struct ether_addr mac;
|
||||
char **policies;
|
||||
char **alt_policies;
|
||||
};
|
||||
|
||||
typedef struct Context {
|
||||
Hashmap *networks_by_name;
|
||||
Hashmap *netdevs_by_name;
|
||||
Hashmap *links_by_name;
|
||||
Hashmap *links_by_filename;
|
||||
} Context;
|
||||
|
||||
int parse_cmdline_item(const char *key, const char *value, void *data);
|
||||
@ -104,6 +110,6 @@ NetDev *netdev_get(Context *context, const char *ifname);
|
||||
void netdev_dump(NetDev *netdev, FILE *f);
|
||||
int netdev_format(NetDev *netdev, char **ret);
|
||||
|
||||
Link *link_get(Context *context, const char *ifname);
|
||||
Link *link_get(Context *context, const char *filename);
|
||||
void link_dump(Link *link, FILE *f);
|
||||
int link_format(Link *link, char **ret);
|
||||
|
||||
@ -49,14 +49,14 @@ static void test_netdev_one(const char *ifname, const char *key, const char *val
|
||||
assert_se(streq(output, expected));
|
||||
}
|
||||
|
||||
static void test_link_one(const char *ifname, const char *key, const char *value, const char *expected) {
|
||||
static void test_link_one(const char *filename, const char *key, const char *value, const char *expected) {
|
||||
_cleanup_(context_clear) Context context = {};
|
||||
_cleanup_free_ char *output = NULL;
|
||||
Link *link;
|
||||
|
||||
printf("# %s=%s\n", key, value);
|
||||
assert_se(parse_cmdline_item(key, value, &context) >= 0);
|
||||
assert_se(link = link_get(&context, ifname));
|
||||
assert_se(link = link_get(&context, filename));
|
||||
assert_se(link_format(link, &output) >= 0);
|
||||
puts(output);
|
||||
assert_se(streq(output, expected));
|
||||
@ -334,6 +334,22 @@ int main(int argc, char *argv[]) {
|
||||
"Name=hogehoge\n"
|
||||
);
|
||||
|
||||
test_link_one("001122334455", "net.ifname-policy", "keep,kernel,database,onboard,slot,path,mac,00:11:22:33:44:55",
|
||||
"[Match]\n"
|
||||
"MACAddress=00:11:22:33:44:55\n"
|
||||
"\n[Link]\n"
|
||||
"NamePolicy=keep kernel database onboard slot path mac\n"
|
||||
"AlternativeNamesPolicy=database onboard slot path mac\n"
|
||||
);
|
||||
|
||||
test_link_one("default", "net.ifname-policy", "keep,kernel,database,onboard,slot,path,mac",
|
||||
"[Match]\n"
|
||||
"OriginalName=*\n"
|
||||
"\n[Link]\n"
|
||||
"NamePolicy=keep kernel database onboard slot path mac\n"
|
||||
"AlternativeNamesPolicy=database onboard slot path mac\n"
|
||||
);
|
||||
|
||||
test_network_two("eth0",
|
||||
"ip", "192.168.0.10:192.168.0.2:192.168.0.1:255.255.255.0:hogehoge:eth0:on:10.10.10.10:10.10.10.11",
|
||||
"rd.route", "10.1.2.3/16:10.0.2.3",
|
||||
|
||||
@ -35,15 +35,16 @@ static int manager_add_dns_server_by_string(Manager *m, DnsServerType type, cons
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* Silently filter out 0.0.0.0, 127.0.0.53, 127.0.0.54 (our own stub DNS listener) */
|
||||
if (!dns_server_address_valid(family, &address))
|
||||
return 0;
|
||||
|
||||
/* By default, the port number is determined with the transaction feature level.
|
||||
/* By default, the port number is determined by the transaction feature level.
|
||||
* See dns_transaction_port() and dns_server_port(). */
|
||||
if (IN_SET(port, 53, 853))
|
||||
port = 0;
|
||||
|
||||
/* Refuse 0.0.0.0, 127.0.0.53, 127.0.0.54 and the rest of our own stub DNS listeners. */
|
||||
if (!dns_server_address_valid(family, &address) ||
|
||||
manager_server_address_is_stub(m, family, &address, port ?: 53))
|
||||
return -ELOOP;
|
||||
|
||||
/* Filter out duplicates */
|
||||
s = dns_server_find(manager_get_first_dns_server(m, type), family, &address, port, ifindex, server_name);
|
||||
if (s) {
|
||||
@ -56,7 +57,7 @@ static int manager_add_dns_server_by_string(Manager *m, DnsServerType type, cons
|
||||
return dns_server_new(m, NULL, type, NULL, family, &address, port, ifindex, server_name);
|
||||
}
|
||||
|
||||
int manager_parse_dns_server_string_and_warn(Manager *m, DnsServerType type, const char *string) {
|
||||
int manager_parse_dns_server_string_and_warn(Manager *m, DnsServerType type, const char *string, bool ignore_self_quietly) {
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
@ -66,17 +67,16 @@ int manager_parse_dns_server_string_and_warn(Manager *m, DnsServerType type, con
|
||||
_cleanup_free_ char *word = NULL;
|
||||
|
||||
r = extract_first_word(&string, &word, NULL, 0);
|
||||
if (r < 0)
|
||||
if (r <= 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
break;
|
||||
|
||||
r = manager_add_dns_server_by_string(m, type, word);
|
||||
if (r < 0)
|
||||
if (r == -ELOOP)
|
||||
log_full(ignore_self_quietly ? LOG_DEBUG : LOG_INFO,
|
||||
"DNS server string '%s' points to our own listener, ignoring.", word);
|
||||
else if (r < 0)
|
||||
log_warning_errno(r, "Failed to add DNS server address '%s', ignoring: %m", word);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int manager_add_search_domain_by_string(Manager *m, const char *domain) {
|
||||
@ -121,17 +121,13 @@ int manager_parse_search_domains_and_warn(Manager *m, const char *string) {
|
||||
_cleanup_free_ char *word = NULL;
|
||||
|
||||
r = extract_first_word(&string, &word, NULL, EXTRACT_UNQUOTE);
|
||||
if (r < 0)
|
||||
if (r <= 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
break;
|
||||
|
||||
r = manager_add_search_domain_by_string(m, word);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to add search domain '%s', ignoring: %m", word);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_dns_servers(
|
||||
@ -159,7 +155,7 @@ int config_parse_dns_servers(
|
||||
dns_server_unlink_all(manager_get_first_dns_server(m, ltype));
|
||||
else {
|
||||
/* Otherwise, add to the list */
|
||||
r = manager_parse_dns_server_string_and_warn(m, ltype, rvalue);
|
||||
r = manager_parse_dns_server_string_and_warn(m, ltype, rvalue, false);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to parse DNS server string '%s', ignoring.", rvalue);
|
||||
@ -167,8 +163,7 @@ int config_parse_dns_servers(
|
||||
}
|
||||
}
|
||||
|
||||
/* If we have a manual setting, then we stop reading
|
||||
* /etc/resolv.conf */
|
||||
/* If we have a manual setting, then we stop reading /etc/resolv.conf */
|
||||
if (ltype == DNS_SERVER_SYSTEM)
|
||||
m->read_resolv_conf = false;
|
||||
if (ltype == DNS_SERVER_FALLBACK)
|
||||
@ -210,8 +205,7 @@ int config_parse_search_domains(
|
||||
}
|
||||
}
|
||||
|
||||
/* If we have a manual setting, then we stop reading
|
||||
* /etc/resolv.conf */
|
||||
/* If we have a manual setting, then we stop reading /etc/resolv.conf */
|
||||
m->read_resolv_conf = false;
|
||||
|
||||
return 0;
|
||||
@ -493,7 +487,7 @@ int manager_parse_config_file(Manager *m) {
|
||||
return r;
|
||||
|
||||
if (m->need_builtin_fallbacks) {
|
||||
r = manager_parse_dns_server_string_and_warn(m, DNS_SERVER_FALLBACK, DNS_SERVERS);
|
||||
r = manager_parse_dns_server_string_and_warn(m, DNS_SERVER_FALLBACK, DNS_SERVERS, false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
int manager_parse_config_file(Manager *m);
|
||||
|
||||
int manager_parse_search_domains_and_warn(Manager *m, const char *string);
|
||||
int manager_parse_dns_server_string_and_warn(Manager *m, DnsServerType type, const char *string);
|
||||
int manager_parse_dns_server_string_and_warn(Manager *m, DnsServerType type, const char *string, bool ignore_self_quietly);
|
||||
|
||||
const struct ConfigPerfItem* resolved_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
|
||||
const struct ConfigPerfItem* resolved_dnssd_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
|
||||
|
||||
@ -875,9 +875,18 @@ DnsServer *manager_get_dns_server(Manager *m) {
|
||||
manager_read_resolv_conf(m);
|
||||
|
||||
/* If no DNS server was chosen so far, pick the first one */
|
||||
if (!m->current_dns_server)
|
||||
if (!m->current_dns_server ||
|
||||
/* In case m->current_dns_server != m->dns_servers */
|
||||
manager_server_is_stub(m, m->current_dns_server))
|
||||
manager_set_dns_server(m, m->dns_servers);
|
||||
|
||||
while (m->current_dns_server &&
|
||||
manager_server_is_stub(m, m->current_dns_server)) {
|
||||
manager_next_dns_server(m, NULL);
|
||||
if (m->current_dns_server == m->dns_servers)
|
||||
manager_set_dns_server(m, NULL);
|
||||
}
|
||||
|
||||
if (!m->current_dns_server) {
|
||||
bool found = false;
|
||||
|
||||
|
||||
@ -1620,30 +1620,37 @@ bool manager_next_dnssd_names(Manager *m) {
|
||||
return tried;
|
||||
}
|
||||
|
||||
bool manager_server_is_stub(Manager *m, DnsServer *s) {
|
||||
bool manager_server_address_is_stub(Manager *m, int family, const union in_addr_union *address, uint16_t port) {
|
||||
DnsStubListenerExtra *l;
|
||||
|
||||
assert(m);
|
||||
assert(s);
|
||||
assert(address);
|
||||
|
||||
/* Safety check: we generally already skip the main stub when parsing configuration. But let's be
|
||||
* extra careful, and check here again */
|
||||
if (s->family == AF_INET &&
|
||||
s->address.in.s_addr == htobe32(INADDR_DNS_STUB) &&
|
||||
dns_server_port(s) == 53)
|
||||
if (family == AF_INET &&
|
||||
address->in.s_addr == htobe32(INADDR_DNS_STUB) &&
|
||||
port == 53)
|
||||
return true;
|
||||
|
||||
/* Main reason to call this is to check server data against the extra listeners, and filter things
|
||||
* out. */
|
||||
ORDERED_SET_FOREACH(l, m->dns_extra_stub_listeners)
|
||||
if (s->family == l->family &&
|
||||
in_addr_equal(s->family, &s->address, &l->address) &&
|
||||
dns_server_port(s) == dns_stub_listener_extra_port(l))
|
||||
if (family == l->family &&
|
||||
in_addr_equal(family, address, &l->address) &&
|
||||
port == dns_stub_listener_extra_port(l))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool manager_server_is_stub(Manager *m, DnsServer *s) {
|
||||
assert(m);
|
||||
assert(s);
|
||||
|
||||
return manager_server_address_is_stub(m, s->family, &s->address, dns_server_port(s));
|
||||
}
|
||||
|
||||
int socket_disable_pmtud(int fd, int af) {
|
||||
int r;
|
||||
|
||||
|
||||
@ -207,6 +207,7 @@ void manager_cleanup_saved_user(Manager *m);
|
||||
|
||||
bool manager_next_dnssd_names(Manager *m);
|
||||
|
||||
bool manager_server_address_is_stub(Manager *m, int family, const union in_addr_union *address, uint16_t port);
|
||||
bool manager_server_is_stub(Manager *m, DnsServer *s);
|
||||
|
||||
int socket_disable_pmtud(int fd, int af);
|
||||
|
||||
@ -143,7 +143,8 @@ int manager_read_resolv_conf(Manager *m) {
|
||||
|
||||
a = first_word(l, "nameserver");
|
||||
if (a) {
|
||||
r = manager_parse_dns_server_string_and_warn(m, DNS_SERVER_SYSTEM, a);
|
||||
r = manager_parse_dns_server_string_and_warn(m, DNS_SERVER_SYSTEM, a,
|
||||
true /* don't warn about loops to our own stub listeners */);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to parse DNS server address '%s', ignoring.", a);
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "netif-naming-scheme.h"
|
||||
#include "proc-cmdline.h"
|
||||
#include "string-util.h"
|
||||
#include "string-table.h"
|
||||
|
||||
#ifdef _DEFAULT_NET_NAMING_SCHEME_TEST
|
||||
/* The primary purpose of this check is to verify that _DEFAULT_NET_NAMING_SCHEME_TEST
|
||||
@ -80,3 +81,25 @@ const NamingScheme* naming_scheme(void) {
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
static const char* const name_policy_table[_NAMEPOLICY_MAX] = {
|
||||
[NAMEPOLICY_KERNEL] = "kernel",
|
||||
[NAMEPOLICY_KEEP] = "keep",
|
||||
[NAMEPOLICY_DATABASE] = "database",
|
||||
[NAMEPOLICY_ONBOARD] = "onboard",
|
||||
[NAMEPOLICY_SLOT] = "slot",
|
||||
[NAMEPOLICY_PATH] = "path",
|
||||
[NAMEPOLICY_MAC] = "mac",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(name_policy, NamePolicy);
|
||||
|
||||
static const char* const alternative_names_policy_table[_NAMEPOLICY_MAX] = {
|
||||
[NAMEPOLICY_DATABASE] = "database",
|
||||
[NAMEPOLICY_ONBOARD] = "onboard",
|
||||
[NAMEPOLICY_SLOT] = "slot",
|
||||
[NAMEPOLICY_PATH] = "path",
|
||||
[NAMEPOLICY_MAC] = "mac",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(alternative_names_policy, NamePolicy);
|
||||
|
||||
@ -64,3 +64,21 @@ const NamingScheme* naming_scheme(void);
|
||||
static inline bool naming_scheme_has(NamingSchemeFlags flags) {
|
||||
return FLAGS_SET(naming_scheme()->flags, flags);
|
||||
}
|
||||
|
||||
typedef enum NamePolicy {
|
||||
NAMEPOLICY_KERNEL,
|
||||
NAMEPOLICY_KEEP,
|
||||
NAMEPOLICY_DATABASE,
|
||||
NAMEPOLICY_ONBOARD,
|
||||
NAMEPOLICY_SLOT,
|
||||
NAMEPOLICY_PATH,
|
||||
NAMEPOLICY_MAC,
|
||||
_NAMEPOLICY_MAX,
|
||||
_NAMEPOLICY_INVALID = -EINVAL,
|
||||
} NamePolicy;
|
||||
|
||||
const char *name_policy_to_string(NamePolicy p) _const_;
|
||||
NamePolicy name_policy_from_string(const char *p) _pure_;
|
||||
|
||||
const char *alternative_names_policy_to_string(NamePolicy p) _const_;
|
||||
NamePolicy alternative_names_policy_from_string(const char *p) _pure_;
|
||||
|
||||
@ -22,7 +22,6 @@
|
||||
#include "log-link.h"
|
||||
#include "memory-util.h"
|
||||
#include "net-condition.h"
|
||||
#include "netif-naming-scheme.h"
|
||||
#include "netif-util.h"
|
||||
#include "netlink-util.h"
|
||||
#include "parse-util.h"
|
||||
@ -1032,30 +1031,10 @@ DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(
|
||||
MAC_ADDRESS_POLICY_NONE,
|
||||
"Failed to parse MAC address policy");
|
||||
|
||||
static const char* const name_policy_table[_NAMEPOLICY_MAX] = {
|
||||
[NAMEPOLICY_KERNEL] = "kernel",
|
||||
[NAMEPOLICY_KEEP] = "keep",
|
||||
[NAMEPOLICY_DATABASE] = "database",
|
||||
[NAMEPOLICY_ONBOARD] = "onboard",
|
||||
[NAMEPOLICY_SLOT] = "slot",
|
||||
[NAMEPOLICY_PATH] = "path",
|
||||
[NAMEPOLICY_MAC] = "mac",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(name_policy, NamePolicy);
|
||||
DEFINE_CONFIG_PARSE_ENUMV(config_parse_name_policy, name_policy, NamePolicy,
|
||||
_NAMEPOLICY_INVALID,
|
||||
"Failed to parse interface name policy");
|
||||
|
||||
static const char* const alternative_names_policy_table[_NAMEPOLICY_MAX] = {
|
||||
[NAMEPOLICY_DATABASE] = "database",
|
||||
[NAMEPOLICY_ONBOARD] = "onboard",
|
||||
[NAMEPOLICY_SLOT] = "slot",
|
||||
[NAMEPOLICY_PATH] = "path",
|
||||
[NAMEPOLICY_MAC] = "mac",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(alternative_names_policy, NamePolicy);
|
||||
DEFINE_CONFIG_PARSE_ENUMV(config_parse_alternative_names_policy, alternative_names_policy, NamePolicy,
|
||||
_NAMEPOLICY_INVALID,
|
||||
"Failed to parse alternative names policy");
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include "ethtool-util.h"
|
||||
#include "list.h"
|
||||
#include "net-condition.h"
|
||||
#include "netif-naming-scheme.h"
|
||||
|
||||
typedef struct LinkConfigContext LinkConfigContext;
|
||||
typedef struct LinkConfig LinkConfig;
|
||||
@ -21,18 +22,6 @@ typedef enum MACAddressPolicy {
|
||||
_MAC_ADDRESS_POLICY_INVALID = -EINVAL,
|
||||
} MACAddressPolicy;
|
||||
|
||||
typedef enum NamePolicy {
|
||||
NAMEPOLICY_KERNEL,
|
||||
NAMEPOLICY_KEEP,
|
||||
NAMEPOLICY_DATABASE,
|
||||
NAMEPOLICY_ONBOARD,
|
||||
NAMEPOLICY_SLOT,
|
||||
NAMEPOLICY_PATH,
|
||||
NAMEPOLICY_MAC,
|
||||
_NAMEPOLICY_MAX,
|
||||
_NAMEPOLICY_INVALID = -EINVAL,
|
||||
} NamePolicy;
|
||||
|
||||
typedef struct Link {
|
||||
int ifindex;
|
||||
const char *ifname;
|
||||
@ -105,12 +94,6 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free);
|
||||
int link_get_config(LinkConfigContext *ctx, Link *link);
|
||||
int link_apply_config(LinkConfigContext *ctx, sd_netlink **rtnl, Link *link);
|
||||
|
||||
const char *name_policy_to_string(NamePolicy p) _const_;
|
||||
NamePolicy name_policy_from_string(const char *p) _pure_;
|
||||
|
||||
const char *alternative_names_policy_to_string(NamePolicy p) _const_;
|
||||
NamePolicy alternative_names_policy_from_string(const char *p) _pure_;
|
||||
|
||||
const char *mac_address_policy_to_string(MACAddressPolicy p) _const_;
|
||||
MACAddressPolicy mac_address_policy_from_string(const char *p) _pure_;
|
||||
|
||||
|
||||
@ -215,7 +215,7 @@ testcase_virtio_scsi_identically_named_partitions() {
|
||||
# and attach them to a virtio-scsi controller
|
||||
local qemu_opts=("-device virtio-scsi-pci,id=scsi0,num_queues=4")
|
||||
local diskpath="${TESTDIR:?}/namedpart0.img"
|
||||
local lodev
|
||||
local lodev qemu_timeout
|
||||
|
||||
dd if=/dev/zero of="$diskpath" bs=1M count=18
|
||||
lodev="$(losetup --show -f -P "$diskpath")"
|
||||
@ -245,10 +245,14 @@ EOF
|
||||
)
|
||||
done
|
||||
|
||||
# Bump the timeout when collecting test coverage, since the test is a bit
|
||||
# slower in that case
|
||||
is_built_with_coverage && qemu_timeout=120 || qemu_timeout=60
|
||||
|
||||
KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}"
|
||||
# Limit the number of VCPUs and set a timeout to make sure we trigger the issue
|
||||
QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}"
|
||||
QEMU_SMP=1 QEMU_TIMEOUT=60 test_run_one "${1:?}" || return $?
|
||||
QEMU_SMP=1 QEMU_TIMEOUT=$qemu_timeout test_run_one "${1:?}" || return $?
|
||||
|
||||
rm -f "${TESTDIR:?}"/namedpart*.img
|
||||
}
|
||||
|
||||
@ -673,6 +673,8 @@ testcase_long_sysfs_path() {
|
||||
swapon -v -L swap_vol
|
||||
swapoff -v -L swap_vol
|
||||
|
||||
udevadm settle
|
||||
|
||||
logfile="$(mktemp)"
|
||||
journalctl -b -q --no-pager -o short-monotonic -p info --grep "Device path.*vda.?' too long to fit into unit name"
|
||||
# Make sure we don't unnecessarily spam the log
|
||||
|
||||
@ -217,7 +217,7 @@ in_units = [
|
||||
'dbus-org.freedesktop.machine1.service'],
|
||||
['systemd-modules-load.service', 'HAVE_KMOD',
|
||||
'sysinit.target.wants/'],
|
||||
['systemd-network-generator.service', 'ENABLE_NETWORKD'],
|
||||
['systemd-network-generator.service', ''],
|
||||
['systemd-networkd.service', 'ENABLE_NETWORKD'],
|
||||
['systemd-networkd-wait-online.service', 'ENABLE_NETWORKD'],
|
||||
['systemd-nspawn@.service', ''],
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
Description=Generate network units from Kernel command line
|
||||
Documentation=man:systemd-network-generator.service(8)
|
||||
DefaultDependencies=no
|
||||
Before=network-pre.target
|
||||
Before=network-pre.target systemd-udevd.service
|
||||
Wants=network-pre.target
|
||||
|
||||
[Service]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user