From: Yu Watanabe Date: Thu, 4 Mar 2021 07:48:57 +0000 (+0900) Subject: udev/net: make .link files support drop-in config X-Git-Tag: v248-rc3~54^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e406e8a29a42d7418188c883f4efea58a0c9727b;p=thirdparty%2Fsystemd.git udev/net: make .link files support drop-in config --- diff --git a/man/systemd.link.xml b/man/systemd.link.xml index 93f7191b332..5918a321898 100644 --- a/man/systemd.link.xml +++ b/man/systemd.link.xml @@ -32,23 +32,31 @@ systemd.syntax7 for a general description of the syntax. - The link files are read from the files located in the system - network directory /usr/lib/systemd/network, - the volatile runtime network directory - /run/systemd/network, and the local - administration network directory - /etc/systemd/network. Link files must have - the extension .link; 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 /etc/ have the highest priority, files in - /run/ take precedence over files with the same - name in /usr/lib/. 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 /dev/null disables the - configuration file entirely (it is "masked"). + The link files are read from the files located in the system network directory + /usr/lib/systemd/network, the volatile runtime network directory + /run/systemd/network, and the local administration network directory + /etc/systemd/network. Link files must have the extension + .link; 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 /etc/ have the highest + priority, files in /run/ take precedence over files with the same name in + /usr/lib/. 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 /dev/null disables the configuration file entirely (it is + "masked"). + + Along with the link file foo.link, a "drop-in" directory + foo.link.d/ may exist. All files with the suffix .conf + 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. + + In addition to /etc/systemd/network, drop-in .d + directories can be placed in /usr/lib/systemd/network or + /run/systemd/network directories. Drop-in files in /etc/ + take precedence over those in /run/ which in turn take precedence over those + in /usr/lib/. Drop-in files under any of these directories take precedence + over the main link file wherever located. 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 diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index 10d64d52608..79281887e0a 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -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;