udev,network: use standard paths for .network and .link files
This centralizes the configuration to one header file. /usr/local/lib is now included in the search list, and documentation is updated accordingly.
This commit is contained in:
@@ -8,7 +8,9 @@
|
||||
|
||||
#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
|
||||
@@ -54,3 +56,5 @@ int deserialize_dhcp_routes(struct sd_dhcp_route **ret, size_t *ret_size, size_t
|
||||
|
||||
/* 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"))
|
||||
|
||||
@@ -661,7 +661,7 @@ int netdev_load_one(Manager *manager, const char *filename) {
|
||||
};
|
||||
|
||||
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);
|
||||
@@ -702,7 +702,7 @@ int netdev_load_one(Manager *manager, const char *filename) {
|
||||
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);
|
||||
@@ -802,7 +802,7 @@ int netdev_load(Manager *manager) {
|
||||
|
||||
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");
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#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"
|
||||
@@ -29,15 +30,6 @@
|
||||
/* 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;
|
||||
@@ -1485,7 +1477,7 @@ int manager_load_config(Manager *m) {
|
||||
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)
|
||||
@@ -1499,7 +1491,7 @@ int manager_load_config(Manager *m) {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
#include "networkd-link.h"
|
||||
#include "networkd-network.h"
|
||||
|
||||
extern const char* const network_dirs[];
|
||||
|
||||
struct Manager {
|
||||
sd_netlink *rtnl;
|
||||
/* lazy initialized */
|
||||
|
||||
@@ -211,7 +211,7 @@ int network_load_one(Manager *manager, const char *filename) {
|
||||
.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"
|
||||
@@ -291,7 +291,7 @@ int network_load(Manager *manager) {
|
||||
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");
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#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"
|
||||
@@ -36,18 +37,9 @@ struct link_config_ctx {
|
||||
|
||||
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;
|
||||
@@ -216,9 +208,9 @@ int link_config_load(link_config_ctx *ctx) {
|
||||
}
|
||||
|
||||
/* 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");
|
||||
|
||||
@@ -232,7 +224,7 @@ int link_config_load(link_config_ctx *ctx) {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user