1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

network: do not abort execution when NetDev.Name= conflicts

This also changes that .netdev files are loaded in ascending order.
Otherwise, when NetDev.ifname= setting conflicts with other .netdev file,
then .netdev file with large prefix number wins.
This commit is contained in:
Yu Watanabe 2019-04-01 00:24:25 +09:00
parent 5a0bd90b82
commit b519908cac

View File

@ -738,6 +738,19 @@ int netdev_load_one(Manager *manager, const char *filename) {
return r;
r = hashmap_put(netdev->manager->netdevs, netdev->ifname, netdev);
if (r == -EEXIST) {
NetDev *n = hashmap_get(netdev->manager->netdevs, netdev->ifname);
assert(n);
log_netdev_warning_errno(netdev, r,
"The setting Name=%s in %s conflicts with the one in %s, ignoring",
netdev->ifname, netdev->filename, n->filename);
/* Clear ifname before netdev_free() is called. Otherwise, the NetDev object 'n' is
* removed from the hashmap 'manager->netdevs'. */
netdev->ifname = mfree(netdev->ifname);
return 0;
}
if (r < 0)
return r;
@ -810,7 +823,7 @@ int netdev_load(Manager *manager) {
if (r < 0)
return log_error_errno(r, "Failed to enumerate netdev files: %m");
STRV_FOREACH_BACKWARDS(f, files) {
STRV_FOREACH(f, files) {
r = netdev_load_one(manager, *f);
if (r < 0)
return r;