mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 01:50:25 +01:00
core: check generated virtual interfaceplatform name
https://bugzilla.redhat.com/show_bug.cgi?id=1300755
This commit is contained in:
parent
f2399a6976
commit
944065c115
3 changed files with 48 additions and 22 deletions
|
|
@ -29,6 +29,7 @@
|
|||
#include "nm-device-factory.h"
|
||||
#include "nm-default.h"
|
||||
#include "nm-platform.h"
|
||||
#include "nm-utils.h"
|
||||
|
||||
const NMLinkType _nm_device_factory_no_default_links[] = { NM_LINK_TYPE_NONE };
|
||||
const char *_nm_device_factory_no_default_settings[] = { NULL };
|
||||
|
|
@ -174,17 +175,54 @@ get_virtual_iface_name (NMDeviceFactory *factory,
|
|||
char *
|
||||
nm_device_factory_get_virtual_iface_name (NMDeviceFactory *factory,
|
||||
NMConnection *connection,
|
||||
const char *parent_iface)
|
||||
const char *parent_iface,
|
||||
GError **error)
|
||||
{
|
||||
char *ifname;
|
||||
|
||||
g_return_val_if_fail (factory != NULL, NULL);
|
||||
g_return_val_if_fail (connection != NULL, NULL);
|
||||
g_return_val_if_fail (!error || !*error, NULL);
|
||||
|
||||
if (!nm_connection_is_virtual (connection))
|
||||
if (!nm_connection_is_virtual (connection)) {
|
||||
g_set_error (error,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_FAILED,
|
||||
"failed to determine virtual interface name: connection type '%s' is not a software device",
|
||||
nm_connection_get_connection_type (connection));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (NM_DEVICE_FACTORY_GET_INTERFACE (factory)->get_virtual_iface_name)
|
||||
return NM_DEVICE_FACTORY_GET_INTERFACE (factory)->get_virtual_iface_name (factory, connection, parent_iface);
|
||||
return NULL;
|
||||
if (!NM_DEVICE_FACTORY_GET_INTERFACE (factory)->get_virtual_iface_name) {
|
||||
g_set_error (error,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_FAILED,
|
||||
"failed to determine virtual interface name: cannot generate name for %s",
|
||||
nm_connection_get_connection_type (connection));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ifname = NM_DEVICE_FACTORY_GET_INTERFACE (factory)->get_virtual_iface_name (factory, connection, parent_iface);
|
||||
if (!ifname) {
|
||||
g_set_error (error,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_FAILED,
|
||||
"failed to determine virtual interface name: error generating name for %s",
|
||||
nm_connection_get_connection_type (connection));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!nm_utils_iface_valid_name (ifname)) {
|
||||
g_set_error (error,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_FAILED,
|
||||
"failed to determine virtual interface name: invalid name \"%s\" generated",
|
||||
ifname);
|
||||
g_free (ifname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ifname;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
|
|
|
|||
|
|
@ -177,7 +177,8 @@ const char *nm_device_factory_get_connection_parent (NMDeviceFactory *factory,
|
|||
|
||||
char * nm_device_factory_get_virtual_iface_name (NMDeviceFactory *factory,
|
||||
NMConnection *connection,
|
||||
const char *parent_iface);
|
||||
const char *parent_iface,
|
||||
GError **error);
|
||||
|
||||
void nm_device_factory_start (NMDeviceFactory *factory);
|
||||
|
||||
|
|
|
|||
|
|
@ -974,15 +974,6 @@ get_virtual_iface_name (NMManager *self,
|
|||
if (out_parent)
|
||||
*out_parent = NULL;
|
||||
|
||||
if (!nm_connection_is_virtual (connection)) {
|
||||
g_set_error (error,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_FAILED,
|
||||
"NetworkManager plugin for '%s' unavailable",
|
||||
nm_connection_get_connection_type (connection));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
factory = nm_device_factory_manager_find_factory_for_connection (connection);
|
||||
if (!factory) {
|
||||
g_set_error (error,
|
||||
|
|
@ -996,14 +987,10 @@ get_virtual_iface_name (NMManager *self,
|
|||
parent = find_parent_device_for_connection (self, connection);
|
||||
iface = nm_device_factory_get_virtual_iface_name (factory,
|
||||
connection,
|
||||
parent ? nm_device_get_ip_iface (parent) : NULL);
|
||||
if (!iface) {
|
||||
g_set_error_literal (error,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
||||
"failed to determine virtual interface name");
|
||||
parent ? nm_device_get_ip_iface (parent) : NULL,
|
||||
error);
|
||||
if (!iface)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (out_parent)
|
||||
*out_parent = parent;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue