Compare commits

..

3 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek d06661ab66
Merge pull request #16030 from yuwata/network-read-mtime-of-dropin-configs-15521
network: also read mtime of drop-in configs
2020-06-01 15:14:13 +02:00
Yu Watanabe 9f83091e3c network: also read mtime of drop-in configs
Fixes #15521.
2020-06-01 17:03:40 +09:00
Yu Watanabe c4473dec34 network: do not propagte error on stat() 2020-06-01 17:03:40 +09:00
5 changed files with 33 additions and 10 deletions

View File

@ -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;

View File

@ -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,10 +539,23 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
network->filename);
struct stat stats;
if (stat(filename, &stats) < 0)
return -errno;
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. */
return 0;

View File

@ -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;

View File

@ -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) \

View File

@ -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);