summaryrefslogtreecommitdiff
path: root/src/network/netdev/netdev.c
diff options
context:
space:
mode:
authorRoelf Wichertjes <roelf@roelf.org>2017-04-30 13:12:32 +0200
committerLennart Poettering <lennart@poettering.net>2017-04-30 13:12:32 +0200
commit14b6bb776287e72887071dafae3d4c2c65ee926d (patch)
tree6f7369eec8143c0473674a44bdf234f494676e01 /src/network/netdev/netdev.c
parent2766d951c9385d91e504d968551247b115a77ef6 (diff)
networkd: Add check to ensure link is down before attempting to enslave (#5853)
netdev to bond. There are situations where a link can be in an "UP" state when systemd-networkd attempts to add the link to a bond device. This is a problem because the bonding driver will refuse to enslave a link if it is in the "UP" state. This check ensures systemd-networkd sets the link to "DOWN" before attempting to add the link to the bond. Fixes #5838.
Diffstat (limited to 'src/network/netdev/netdev.c')
-rw-r--r--src/network/netdev/netdev.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c
index 3848c863c5..43884581ca 100644
--- a/src/network/netdev/netdev.c
+++ b/src/network/netdev/netdev.c
@@ -28,6 +28,7 @@
#include "network-internal.h"
#include "netdev/netdev.h"
#include "networkd-manager.h"
+#include "networkd-link.h"
#include "siphash24.h"
#include "stat-util.h"
#include "string-table.h"
@@ -221,6 +222,13 @@ static int netdev_enslave_ready(NetDev *netdev, Link* link, sd_netlink_message_h
assert(link);
assert(callback);
+ if (link->flags & IFF_UP) {
+ log_netdev_debug(netdev, "Link '%s' was up when attempting to enslave it. Bringing link down.", link->ifname);
+ r = link_down(link);
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not bring link down: %m");
+ }
+
r = sd_rtnl_message_new_link(netdev->manager->rtnl, &req, RTM_SETLINK, link->ifindex);
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not allocate RTM_SETLINK message: %m");