From a824f56441b75a94697bd59eba40ab54c8128310 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 14 Jan 2021 14:15:27 +0100 Subject: [PATCH] device: if a device is not IFF_UP assume that is has carrier A device that is not IFF_UP does not have carrier. So we don't know the real state before we bring it up. On the other hand, during `nmcli connection up` we check whether the device is available. So we are blocked. The solution is to optimistically assume that the device has carrier if it is down. We may fail later. $ nmcli connection add type veth con-name vv0 autoconnect no ifname vv0 peer vv1 ipv4.method shared ipv6.method shared $ nmcli connection up vv0 $ nmcli device connect vv1 Error: Failed to add/activate new connection: Connection 'vv1' is not available on device vv1 because device has no carrier --- src/devices/nm-device.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 59812ef0f..c6ec4e3bc 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -15372,6 +15372,15 @@ check_connection_available(NMDevice * self, if (nm_device_is_master(self)) return TRUE; + if (!priv->up) { + /* If the device is !IFF_UP it also has no carrier. But we assume that if we + * would start activating the device (and thereby set the device IFF_UP), + * that we would get a carrier. We only know after we set the device up, + * and we only set it up after we start activating it. So presumably, this + * profile would be available (but we just don't know). */ + return TRUE; + } + nm_utils_error_set_literal(error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY, "device has no carrier");