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
This commit is contained in:
Thomas Haller
2021-01-14 14:15:27 +01:00
parent 7c05ff1632
commit a824f56441

View File

@@ -15372,6 +15372,15 @@ check_connection_available(NMDevice * self,
if (nm_device_is_master(self)) if (nm_device_is_master(self))
return TRUE; 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_set_literal(error,
NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
"device has no carrier"); "device has no carrier");