Compare commits
3 Commits
da4dd97405
...
ec34e7d1ab
Author | SHA1 | Date |
---|---|---|
Yu Watanabe | ec34e7d1ab | |
Yu Watanabe | bf331d8717 | |
Yu Watanabe | 26208d5b96 |
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "stat-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "udev-util.h"
|
||||
#include "util.h"
|
||||
|
||||
#define HOST_HASH_KEY SD_ID128_MAKE(1a,37,6f,c7,46,ec,45,0b,ad,a3,d5,31,06,60,5d,b1)
|
||||
|
@ -395,24 +396,33 @@ int remove_bridge(const char *bridge_name) {
|
|||
|
||||
static int parse_interface(const char *name) {
|
||||
_cleanup_(sd_device_unrefp) sd_device *d = NULL;
|
||||
char ifi_str[2 + DECIMAL_STR_MAX(int)];
|
||||
int ifi, r;
|
||||
|
||||
r = parse_ifindex_or_ifname(name, &ifi);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to resolve interface %s: %m", name);
|
||||
|
||||
if (path_is_read_only_fs("/sys") <= 0) {
|
||||
char ifi_str[2 + DECIMAL_STR_MAX(int)];
|
||||
|
||||
/* udev should be around. */
|
||||
|
||||
sprintf(ifi_str, "n%i", ifi);
|
||||
r = sd_device_new_from_device_id(&d, ifi_str);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get device for interface %s: %m", name);
|
||||
return log_error_errno(r, "Failed to get device %s: %m", name);
|
||||
|
||||
r = sd_device_get_is_initialized(d);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to determine whether interface %s is initialized or not: %m", name);
|
||||
if (r == 0) {
|
||||
log_error("Network interface %s is not initialized yet.", name);
|
||||
return -EBUSY;
|
||||
return log_error_errno(r, "Failed to determine whether interface %s is initialized: %m", name);
|
||||
if (r == 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EBUSY), "Network interface %s is not initialized yet.", name);
|
||||
|
||||
r = device_is_renaming(d);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to determine the interface %s is being renamed: %m", name);
|
||||
if (r > 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EBUSY), "Interface %s is being renamed.", name);
|
||||
}
|
||||
|
||||
return ifi;
|
||||
|
|
Loading…
Reference in New Issue