]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev/net: make .link files support drop-in config
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 4 Mar 2021 07:48:57 +0000 (16:48 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 4 Mar 2021 23:09:01 +0000 (08:09 +0900)
man/systemd.link.xml
src/udev/net/link-config.c

index 93f7191b3321109aad8f875d0280e3fb9d8abce9..5918a32189810c54190d92e19aa6343ce3ad519a 100644 (file)
     <citerefentry><refentrytitle>systemd.syntax</refentrytitle><manvolnum>7</manvolnum></citerefentry> for a
     general description of the syntax.</para>
 
-    <para>The link files are read from the files located in the system
-    network directory <filename>/usr/lib/systemd/network</filename>,
-    the volatile runtime network directory
-    <filename>/run/systemd/network</filename>, and the local
-    administration network directory
-    <filename>/etc/systemd/network</filename>. Link files must have
-    the extension <filename>.link</filename>; other extensions are
-    ignored. All link files are collectively sorted and processed in
-    lexical order, regardless of the directories in which they live.
-    However, files with identical filenames replace each other. Files
-    in <filename>/etc/</filename> have the highest priority, files in
-    <filename>/run/</filename> take precedence over files with the same
-    name in <filename>/usr/lib/</filename>. This can be used to
-    override a system-supplied link file with a local file if needed.
-    As a special case, an empty file (file size 0) or symlink with the
-    same name pointing to <filename>/dev/null</filename> disables the
-    configuration file entirely (it is "masked").</para>
+    <para>The link files are read from the files located in the system network directory
+    <filename>/usr/lib/systemd/network</filename>, the volatile runtime network directory
+    <filename>/run/systemd/network</filename>, and the local administration network directory
+    <filename>/etc/systemd/network</filename>. Link files must have the extension
+    <filename>.link</filename>; other extensions are ignored. All link files are collectively sorted
+    and processed in lexical order, regardless of the directories in which they live. However, files
+    with identical filenames replace each other. Files in <filename>/etc/</filename> have the highest
+    priority, files in <filename>/run/</filename> take precedence over files with the same name in
+    <filename>/usr/lib/</filename>. This can be used to override a system-supplied link file with a
+    local file if needed. As a special case, an empty file (file size 0) or symlink with the same name
+    pointing to <filename>/dev/null</filename> disables the configuration file entirely (it is
+    "masked").</para>
+
+    <para>Along with the link file <filename>foo.link</filename>, a "drop-in" directory
+    <filename>foo.link.d/</filename> may exist. All files with the suffix <literal>.conf</literal>
+    from this directory will be parsed after the file itself is parsed. This is useful to alter or add
+    configuration settings, without having to modify the main configuration file. Each drop-in file
+    must have appropriate section headers.</para>
+
+    <para>In addition to <filename>/etc/systemd/network</filename>, drop-in <literal>.d</literal>
+    directories can be placed in <filename>/usr/lib/systemd/network</filename> or
+    <filename>/run/systemd/network</filename> directories. Drop-in files in <filename>/etc/</filename>
+    take precedence over those in <filename>/run/</filename> which in turn take precedence over those
+    in <filename>/usr/lib/</filename>. Drop-in files under any of these directories take precedence
+    over the main link file wherever located.</para>
 
     <para>The link file contains a [Match] section, which determines if a given link file may be applied to a
     given device, as well as a [Link] section specifying how the device should be configured. The first (in
index 10d64d526085302aa3489c1107bc07d083e08a3b..79281887e0a703b8d0dba923679e2160ea8f0763 100644 (file)
@@ -112,6 +112,7 @@ int link_load_one(link_config_ctx *ctx, const char *filename) {
         _cleanup_(link_config_freep) link_config *link = NULL;
         _cleanup_fclose_ FILE *file = NULL;
         _cleanup_free_ char *name = NULL;
+        const char *dropin_dirname;
         size_t i;
         int r;
 
@@ -151,11 +152,14 @@ int link_load_one(link_config_ctx *ctx, const char *filename) {
         for (i = 0; i < ELEMENTSOF(link->features); i++)
                 link->features[i] = -1;
 
-        r = config_parse(NULL, filename, file,
-                         "Match\0Link\0",
-                         config_item_perf_lookup, link_config_gperf_lookup,
-                         CONFIG_PARSE_WARN, link,
-                         NULL);
+        dropin_dirname = strjoina(basename(filename), ".d");
+        r = config_parse_many(
+                        STRV_MAKE_CONST(filename),
+                        (const char* const*) CONF_PATHS_STRV("systemd/network"),
+                        dropin_dirname,
+                        "Match\0Link\0",
+                        config_item_perf_lookup, link_config_gperf_lookup,
+                        CONFIG_PARSE_WARN, link, NULL);
         if (r < 0)
                 return r;