veth: merge branch 'th/veth-fixes'

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/726
This commit is contained in:
Thomas Haller 2021-01-19 18:46:00 +01:00
commit d649a1f9cc
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
3 changed files with 63 additions and 29 deletions

View file

@ -1595,6 +1595,60 @@ complete_connection(NMDevice * device,
NMSettingWired *s_wired;
NMSettingPppoe *s_pppoe;
if (nm_streq0(nm_connection_get_connection_type(connection), NM_SETTING_VETH_SETTING_NAME)) {
NMSettingVeth *s_veth;
const char * peer_name = NULL;
const char * con_peer_name = NULL;
int ifindex;
nm_utils_complete_generic(nm_device_get_platform(device),
connection,
NM_SETTING_VETH_SETTING_NAME,
existing_connections,
NULL,
_("Veth connection"),
"veth",
NULL,
TRUE);
s_veth = _nm_connection_get_setting(connection, NM_TYPE_SETTING_VETH);
if (!s_veth) {
s_veth = (NMSettingVeth *) nm_setting_veth_new();
nm_connection_add_setting(connection, NM_SETTING(s_veth));
}
ifindex = nm_device_get_ip_ifindex(device);
if (ifindex > 0) {
const NMPlatformLink *pllink;
pllink = nm_platform_link_get(nm_device_get_platform(device), ifindex);
if (pllink && pllink->type == NM_LINK_TYPE_VETH && pllink->parent > 0) {
pllink = nm_platform_link_get(nm_device_get_platform(device), pllink->parent);
if (pllink && pllink->type == NM_LINK_TYPE_VETH) {
peer_name = pllink->name;
}
}
}
if (!peer_name) {
nm_utils_error_set(error, NM_UTILS_ERROR_UNKNOWN, "cannot find peer for veth device");
return FALSE;
}
con_peer_name = nm_setting_veth_get_peer(s_veth);
if (con_peer_name) {
nm_utils_error_set(error,
NM_UTILS_ERROR_UNKNOWN,
"mismatching veth peer \"%s\"",
con_peer_name);
return FALSE;
} else
g_object_set(s_veth, NM_SETTING_VETH_PEER, peer_name, NULL);
return TRUE;
}
s_pppoe = nm_connection_get_setting_pppoe(connection);
/* We can't telepathically figure out the service name or username, so if

View file

@ -121,34 +121,6 @@ get_generic_capabilities(NMDevice *device)
return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE;
}
static gboolean
complete_connection(NMDevice * device,
NMConnection * connection,
const char * specific_object,
NMConnection *const *existing_connections,
GError ** error)
{
NMSettingVeth *s_veth;
nm_utils_complete_generic(nm_device_get_platform(device),
connection,
NM_SETTING_VETH_SETTING_NAME,
existing_connections,
NULL,
_("Veth connection"),
"veth",
NULL,
TRUE);
s_veth = _nm_connection_get_setting(connection, NM_TYPE_SETTING_VETH);
if (!s_veth) {
s_veth = (NMSettingVeth *) nm_setting_veth_new();
nm_connection_add_setting(connection, NM_SETTING(s_veth));
}
return TRUE;
}
/*****************************************************************************/
static void
@ -215,7 +187,6 @@ nm_device_veth_class_init(NMDeviceVethClass *klass)
device_class->link_changed = link_changed;
device_class->parent_changed_notify = parent_changed_notify;
device_class->create_and_realize = create_and_realize;
device_class->complete_connection = complete_connection;
device_class->get_generic_capabilities = get_generic_capabilities;
obj_properties[PROP_PEER] = g_param_spec_string(NM_DEVICE_VETH_PEER,

View file

@ -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");