This centralizes the configuration to one header file.
/usr/local/lib is now included in the search list, and documentation is
updated accordingly.
<para>The main network file must have the extension <filename>.network</filename>; other
extensions are ignored. Networks are applied to links whenever the links appear.</para>
- <para>The <filename>.network</filename> 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>. All configuration 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
- configuration 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 <filename>.network</filename> files are read from the files located in the system network
+ directories <filename>/usr/lib/systemd/network</filename> and
+ <filename>/usr/local/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>. All configuration 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 under
+ <filename>/usr</filename>. This can be used to override a system-supplied configuration 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 network file <filename>foo.network</filename>, a "drop-in" directory
<filename>foo.network.d/</filename> may exist. All files with the suffix
<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 netdev file wherever located. (Of course, since
- <filename>/run</filename> is temporary and <filename>/usr/lib</filename> is for vendors, it is
- unlikely drop-ins should be used in either of those places.)</para>
+ directories take precedence over the main netdev file wherever located.</para>
<para>Note that an interface without any static IPv6 addresses configured, and neither DHCPv6
nor IPv6LL enabled, shall be considered to have no IPv6 support. IPv6 will be automatically
#include "condition.h"
#include "conf-parser.h"
+#include "def.h"
#include "set.h"
+#include "strv.h"
#define LINK_BRIDGE_PORT_PRIORITY_INVALID 128
#define LINK_BRIDGE_PORT_PRIORITY_MAX 63
/* It is not necessary to add deserialize_dhcp_option(). Use unhexmem() instead. */
int serialize_dhcp_option(FILE *f, const char *key, const void *data, size_t size);
+
+#define NETWORK_DIRS ((const char* const*) CONF_PATHS_STRV("systemd/network"))
};
dropin_dirname = strjoina(basename(filename), ".d");
- r = config_parse_many(filename, network_dirs, dropin_dirname,
+ r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
"Match\0NetDev\0",
config_item_perf_lookup, network_netdev_gperf_lookup,
CONFIG_PARSE_WARN|CONFIG_PARSE_RELAXED, netdev_raw);
if (NETDEV_VTABLE(netdev)->init)
NETDEV_VTABLE(netdev)->init(netdev);
- r = config_parse_many(filename, network_dirs, dropin_dirname,
+ r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
NETDEV_VTABLE(netdev)->sections,
config_item_perf_lookup, network_netdev_gperf_lookup,
CONFIG_PARSE_WARN, netdev);
hashmap_clear_with_destructor(manager->netdevs, netdev_unref);
- r = conf_files_list_strv(&files, ".netdev", NULL, 0, network_dirs);
+ r = conf_files_list_strv(&files, ".netdev", NULL, 0, NETWORK_DIRS);
if (r < 0)
return log_error_errno(r, "Failed to enumerate netdev files: %m");
#include "fileio.h"
#include "local-addresses.h"
#include "netlink-util.h"
+#include "network-internal.h"
#include "networkd-manager.h"
#include "ordered-set.h"
#include "path-util.h"
/* use 8 MB for receive socket kernel queue. */
#define RCVBUF_SIZE (8*1024*1024)
-const char* const network_dirs[] = {
- "/etc/systemd/network",
- "/run/systemd/network",
- "/usr/lib/systemd/network",
-#if HAVE_SPLIT_USR
- "/lib/systemd/network",
-#endif
- NULL};
-
static int setup_default_address_pool(Manager *m) {
AddressPool *p;
int r;
int r;
/* update timestamp */
- paths_check_timestamp(network_dirs, &m->network_dirs_ts_usec, true);
+ paths_check_timestamp(NETWORK_DIRS, &m->network_dirs_ts_usec, true);
r = netdev_load(m);
if (r < 0)
}
bool manager_should_reload(Manager *m) {
- return paths_check_timestamp(network_dirs, &m->network_dirs_ts_usec, false);
+ return paths_check_timestamp(NETWORK_DIRS, &m->network_dirs_ts_usec, false);
}
int manager_rtnl_enumerate_links(Manager *m) {
#include "networkd-link.h"
#include "networkd-network.h"
-extern const char* const network_dirs[];
-
struct Manager {
sd_netlink *rtnl;
/* lazy initialized */
.ipv6_accept_ra_route_table = RT_TABLE_MAIN,
};
- r = config_parse_many(filename, network_dirs, dropin_dirname,
+ r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
"Match\0"
"Link\0"
"Network\0"
while ((network = manager->networks))
network_free(network);
- r = conf_files_list_strv(&files, ".network", NULL, 0, network_dirs);
+ r = conf_files_list_strv(&files, ".network", NULL, 0, NETWORK_DIRS);
if (r < 0)
return log_error_errno(r, "Failed to enumerate network files: %m");
#include "alloc-util.h"
#include "conf-files.h"
#include "conf-parser.h"
+#include "def.h"
#include "device-util.h"
#include "ethtool-util.h"
#include "fd-util.h"
sd_netlink *rtnl;
- usec_t link_dirs_ts_usec;
+ usec_t network_dirs_ts_usec;
};
-static const char* const link_dirs[] = {
- "/etc/systemd/network",
- "/run/systemd/network",
- "/usr/lib/systemd/network",
-#if HAVE_SPLIT_USR
- "/lib/systemd/network",
-#endif
- NULL};
-
static void link_config_free(link_config *link) {
if (!link)
return;
}
/* update timestamp */
- paths_check_timestamp(link_dirs, &ctx->link_dirs_ts_usec, true);
+ paths_check_timestamp(NETWORK_DIRS, &ctx->network_dirs_ts_usec, true);
- r = conf_files_list_strv(&files, ".link", NULL, 0, link_dirs);
+ r = conf_files_list_strv(&files, ".link", NULL, 0, NETWORK_DIRS);
if (r < 0)
return log_error_errno(r, "failed to enumerate link files: %m");
}
bool link_config_should_reload(link_config_ctx *ctx) {
- return paths_check_timestamp(link_dirs, &ctx->link_dirs_ts_usec, false);
+ return paths_check_timestamp(NETWORK_DIRS, &ctx->network_dirs_ts_usec, false);
}
int link_config_get(link_config_ctx *ctx, sd_device *device, link_config **ret) {