network: if /sys is rw, then udev should be around

This switches detect_container() to path_is_read_only_rw("/sys"), as if
systemd-udevd.service is conditionalized with that way.

This also updates the log message.
This commit is contained in:
Yu Watanabe
2019-12-05 08:22:52 +09:00
parent 26208d5b96
commit bf331d8717
+6 -6
View File
@@ -36,6 +36,7 @@
#include "qdisc.h"
#include "set.h"
#include "socket-util.h"
#include "stat-util.h"
#include "stdio-util.h"
#include "string-table.h"
#include "strv.h"
@@ -43,7 +44,6 @@
#include "tmpfile-util.h"
#include "udev-util.h"
#include "util.h"
#include "virt.h"
#include "vrf.h"
uint32_t link_get_vrf_table(Link *link) {
@@ -3292,8 +3292,8 @@ int link_add(Manager *m, sd_netlink_message *message, Link **ret) {
if (r < 0)
return r;
if (detect_container() <= 0) {
/* not in a container, udev will be around */
if (path_is_read_only_fs("/sys") <= 0) {
/* udev should be around */
sprintf(ifindex_str, "n%d", link->ifindex);
r = sd_device_new_from_device_id(&device, ifindex_str);
if (r < 0) {
@@ -3303,7 +3303,7 @@ int link_add(Manager *m, sd_netlink_message *message, Link **ret) {
r = sd_device_get_is_initialized(device);
if (r < 0) {
log_link_warning_errno(link, r, "Could not determine whether the device is initialized or not: %m");
log_link_warning_errno(link, r, "Could not determine whether the device is initialized: %m");
goto failed;
}
if (r == 0) {
@@ -3314,11 +3314,11 @@ int link_add(Manager *m, sd_netlink_message *message, Link **ret) {
r = device_is_renaming(device);
if (r < 0) {
log_link_warning_errno(link, r, "Failed to determine the device is renamed or not: %m");
log_link_warning_errno(link, r, "Failed to determine the device is being renamed: %m");
goto failed;
}
if (r > 0) {
log_link_debug(link, "Interface is under renaming, pending initialization.");
log_link_debug(link, "Interface is being renamed, pending initialization.");
return 0;
}