diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-06-01 15:14:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-01 15:14:13 +0200 |
commit | d06661ab664ac82f97b65e3ccb63c57c78a3b0dc (patch) | |
tree | f43dcba761c4d0998135f949c9fa536115c31025 | |
parent | 397288e3eb3bfb2c48d1a666754d2f0c7ac61ca0 (diff) | |
parent | 9f83091e3cceb646a66fa9df89de6d9a77c21d86 (diff) | |
download | systemd-d06661ab664ac82f97b65e3ccb63c57c78a3b0dc.tar.gz |
Merge pull request #16030 from yuwata/network-read-mtime-of-dropin-configs-15521
network: also read mtime of drop-in configs
-rw-r--r-- | src/network/netdev/netdev.c | 4 | ||||
-rw-r--r-- | src/network/networkd-network.c | 22 | ||||
-rw-r--r-- | src/resolve/resolved-dnssd.c | 2 | ||||
-rw-r--r-- | src/shared/conf-parser.c | 12 | ||||
-rw-r--r-- | src/shared/conf-parser.h | 3 |
5 files changed, 33 insertions, 10 deletions
diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c index 997dafa719..a990c64b55 100644 --- a/src/network/netdev/netdev.c +++ b/src/network/netdev/netdev.c @@ -689,7 +689,7 @@ int netdev_load_one(Manager *manager, const char *filename) { r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname, NETDEV_COMMON_SECTIONS NETDEV_OTHER_SECTIONS, config_item_perf_lookup, network_netdev_gperf_lookup, - CONFIG_PARSE_WARN, netdev_raw); + CONFIG_PARSE_WARN, netdev_raw, NULL); if (r < 0) return r; @@ -729,7 +729,7 @@ int netdev_load_one(Manager *manager, const char *filename) { 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); + CONFIG_PARSE_WARN, netdev, NULL); if (r < 0) return r; diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index e8419426f2..2e8cba4ae2 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -335,6 +335,7 @@ int network_verify(Network *network) { int network_load_one(Manager *manager, OrderedHashmap **networks, const char *filename) { _cleanup_free_ char *fname = NULL, *name = NULL; _cleanup_(network_unrefp) Network *network = NULL; + _cleanup_strv_free_ char **dropins = NULL; _cleanup_fclose_ FILE *file = NULL; const char *dropin_dirname; char *d; @@ -522,7 +523,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi "TokenBucketFilter\0" "TrivialLinkEqualizer\0", config_item_perf_lookup, network_network_gperf_lookup, - CONFIG_PARSE_WARN, network); + CONFIG_PARSE_WARN, network, &dropins); if (r < 0) return r; @@ -538,9 +539,22 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi network->filename); struct stat stats; - if (stat(filename, &stats) < 0) - return -errno; - network->timestamp = timespec_load(&stats.st_mtim); + if (stat(filename, &stats) >= 0) + network->timestamp = timespec_load(&stats.st_mtim); + + char **f; + STRV_FOREACH(f, dropins) { + usec_t t; + + if (stat(*f, &stats) < 0) { + network->timestamp = 0; + break; + } + + t = timespec_load(&stats.st_mtim); + if (t > network->timestamp) + network->timestamp = t; + } if (network_verify(network) < 0) /* Ignore .network files that do not match the conditions. */ diff --git a/src/resolve/resolved-dnssd.c b/src/resolve/resolved-dnssd.c index bc886fd0e0..c331b2d94c 100644 --- a/src/resolve/resolved-dnssd.c +++ b/src/resolve/resolved-dnssd.c @@ -89,7 +89,7 @@ static int dnssd_service_load(Manager *manager, const char *filename) { r = config_parse_many(filename, DNSSD_SERVICE_DIRS, dropin_dirname, "Service\0", config_item_perf_lookup, resolved_dnssd_gperf_lookup, - false, service); + false, service, NULL); if (r < 0) return r; diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index e685ecbff7..b04eb3912c 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -493,7 +493,8 @@ int config_parse_many( ConfigItemLookup lookup, const void *table, ConfigParseFlags flags, - void *userdata) { + void *userdata, + char ***ret_dropins) { _cleanup_strv_free_ char **dropin_dirs = NULL; _cleanup_strv_free_ char **files = NULL; @@ -509,7 +510,14 @@ int config_parse_many( if (r < 0) return r; - return config_parse_many_files(conf_file, files, sections, lookup, table, flags, userdata); + r = config_parse_many_files(conf_file, files, sections, lookup, table, flags, userdata); + if (r < 0) + return r; + + if (ret_dropins) + *ret_dropins = TAKE_PTR(files); + + return 0; } #define DEFINE_PARSER(type, vartype, conv_func) \ diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index 82c692af10..480988f392 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -107,7 +107,8 @@ int config_parse_many( ConfigItemLookup lookup, const void *table, ConfigParseFlags flags, - void *userdata); + void *userdata, + char ***ret_dropins); /* possibly NULL */ CONFIG_PARSER_PROTOTYPE(config_parse_int); CONFIG_PARSER_PROTOTYPE(config_parse_unsigned); |