device: cleanup get_connection_iface() callbacks
Some of them are wrong: they assert a connection has a particular setting even though this can be called on AddAndActivate against a connection that is not complete or normalized: impl_manager_add_and_activate_connection () validate_activation_request () nm_manager_get_best_device_for_connection () iface = nm_manager_get_connection_iface () find_parent_device_for_connection () nm_device_factory_get_connection_parent () nm_device_factory_get_connection_iface () <====== here find_device_by_iface (iface) nm_device_complete_connection () Fix those by removing the assertions. Some of them are also fall back to just calling nm_connection_get_interface_name() which is a pretty useless thing to do because nm_device_factory_get_connection_iface() only calls the device-specific routine if nm_device_factory_get_connection_iface() doesn't return anything, to give the factory a chance to make up a name (like <parent>.<vlan-id> for Vlan) on its own. Drop those.
This commit is contained in:
@@ -281,24 +281,6 @@ get_connection_parent(NMDeviceFactory *factory, NMConnection *connection)
|
||||
return nm_setting_6lowpan_get_parent(s_6lowpan);
|
||||
}
|
||||
|
||||
static char *
|
||||
get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface)
|
||||
{
|
||||
NMSetting6Lowpan *s_6lowpan;
|
||||
const char *ifname;
|
||||
|
||||
g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_6LOWPAN_SETTING_NAME), NULL);
|
||||
|
||||
s_6lowpan = NM_SETTING_6LOWPAN(nm_connection_get_setting(connection, NM_TYPE_SETTING_6LOWPAN));
|
||||
g_assert(s_6lowpan);
|
||||
|
||||
if (!parent_iface)
|
||||
return NULL;
|
||||
|
||||
ifname = nm_connection_get_interface_name(connection);
|
||||
return g_strdup(ifname);
|
||||
}
|
||||
|
||||
NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
6LOWPAN,
|
||||
6Lowpan,
|
||||
@@ -306,5 +288,4 @@ NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
NM_DEVICE_FACTORY_DECLARE_LINK_TYPES(NM_LINK_TYPE_6LOWPAN)
|
||||
NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES(NM_SETTING_6LOWPAN_SETTING_NAME),
|
||||
factory_class->create_device = create_device;
|
||||
factory_class->get_connection_parent = get_connection_parent;
|
||||
factory_class->get_connection_iface = get_connection_iface;);
|
||||
factory_class->get_connection_parent = get_connection_parent;);
|
||||
|
@@ -477,17 +477,19 @@ get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const c
|
||||
g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_INFINIBAND_SETTING_NAME),
|
||||
NULL);
|
||||
|
||||
s_infiniband = nm_connection_get_setting_infiniband(connection);
|
||||
g_assert(s_infiniband);
|
||||
|
||||
if (!parent_iface)
|
||||
return NULL;
|
||||
|
||||
s_infiniband = nm_connection_get_setting_infiniband(connection);
|
||||
if (s_infiniband) {
|
||||
g_return_val_if_fail(g_strcmp0(parent_iface, nm_setting_infiniband_get_parent(s_infiniband))
|
||||
== 0,
|
||||
NULL);
|
||||
|
||||
return g_strdup(nm_setting_infiniband_get_virtual_interface_name(s_infiniband));
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
|
@@ -1374,26 +1374,6 @@ get_connection_parent(NMDeviceFactory *factory, NMConnection *connection)
|
||||
return nm_setting_ip_tunnel_get_parent(s_ip_tunnel);
|
||||
}
|
||||
|
||||
static char *
|
||||
get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface)
|
||||
{
|
||||
const char *ifname;
|
||||
NMSettingIPTunnel *s_ip_tunnel;
|
||||
|
||||
g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_IP_TUNNEL_SETTING_NAME),
|
||||
NULL);
|
||||
|
||||
s_ip_tunnel = nm_connection_get_setting_ip_tunnel(connection);
|
||||
g_assert(s_ip_tunnel);
|
||||
|
||||
if (nm_setting_ip_tunnel_get_parent(s_ip_tunnel) && !parent_iface)
|
||||
return NULL;
|
||||
|
||||
ifname = nm_connection_get_interface_name(connection);
|
||||
|
||||
return g_strdup(ifname);
|
||||
}
|
||||
|
||||
NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
IP_TUNNEL,
|
||||
IPTunnel,
|
||||
@@ -1409,5 +1389,4 @@ NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
NM_LINK_TYPE_VTI6)
|
||||
NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES(NM_SETTING_IP_TUNNEL_SETTING_NAME),
|
||||
factory_class->create_device = create_device;
|
||||
factory_class->get_connection_parent = get_connection_parent;
|
||||
factory_class->get_connection_iface = get_connection_iface;);
|
||||
factory_class->get_connection_parent = get_connection_parent;);
|
||||
|
@@ -458,24 +458,6 @@ get_connection_parent(NMDeviceFactory *factory, NMConnection *connection)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface)
|
||||
{
|
||||
NMSettingIpvlan *s_ipvlan;
|
||||
const char *ifname;
|
||||
|
||||
g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_IPVLAN_SETTING_NAME), NULL);
|
||||
|
||||
s_ipvlan = _nm_connection_get_setting(connection, NM_TYPE_SETTING_IPVLAN);
|
||||
nm_assert(s_ipvlan);
|
||||
|
||||
if (!parent_iface)
|
||||
return NULL;
|
||||
|
||||
ifname = nm_connection_get_interface_name(connection);
|
||||
return g_strdup(ifname);
|
||||
}
|
||||
|
||||
NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
IPVLAN,
|
||||
Ipvlan,
|
||||
@@ -483,5 +465,4 @@ NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
NM_DEVICE_FACTORY_DECLARE_LINK_TYPES(NM_LINK_TYPE_IPVLAN)
|
||||
NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES(NM_SETTING_IPVLAN_SETTING_NAME),
|
||||
factory_class->create_device = create_device;
|
||||
factory_class->get_connection_parent = get_connection_parent;
|
||||
factory_class->get_connection_iface = get_connection_iface;);
|
||||
factory_class->get_connection_parent = get_connection_parent;);
|
||||
|
@@ -1036,24 +1036,6 @@ get_connection_parent(NMDeviceFactory *factory, NMConnection *connection)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface)
|
||||
{
|
||||
NMSettingMacsec *s_macsec;
|
||||
const char *ifname;
|
||||
|
||||
g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_MACSEC_SETTING_NAME), NULL);
|
||||
|
||||
s_macsec = nm_connection_get_setting_macsec(connection);
|
||||
g_assert(s_macsec);
|
||||
|
||||
if (!parent_iface)
|
||||
return NULL;
|
||||
|
||||
ifname = nm_connection_get_interface_name(connection);
|
||||
return g_strdup(ifname);
|
||||
}
|
||||
|
||||
NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
MACSEC,
|
||||
Macsec,
|
||||
@@ -1061,5 +1043,4 @@ NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
NM_DEVICE_FACTORY_DECLARE_LINK_TYPES(NM_LINK_TYPE_MACSEC)
|
||||
NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES(NM_SETTING_MACSEC_SETTING_NAME),
|
||||
factory_class->create_device = create_device;
|
||||
factory_class->get_connection_parent = get_connection_parent;
|
||||
factory_class->get_connection_iface = get_connection_iface;)
|
||||
factory_class->get_connection_parent = get_connection_parent;);
|
||||
|
@@ -604,24 +604,6 @@ get_connection_parent(NMDeviceFactory *factory, NMConnection *connection)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface)
|
||||
{
|
||||
NMSettingMacvlan *s_macvlan;
|
||||
const char *ifname;
|
||||
|
||||
g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_MACVLAN_SETTING_NAME), NULL);
|
||||
|
||||
s_macvlan = nm_connection_get_setting_macvlan(connection);
|
||||
g_assert(s_macvlan);
|
||||
|
||||
if (!parent_iface)
|
||||
return NULL;
|
||||
|
||||
ifname = nm_connection_get_interface_name(connection);
|
||||
return g_strdup(ifname);
|
||||
}
|
||||
|
||||
NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
MACVLAN,
|
||||
Macvlan,
|
||||
@@ -629,5 +611,4 @@ NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
NM_DEVICE_FACTORY_DECLARE_LINK_TYPES(NM_LINK_TYPE_MACVLAN, NM_LINK_TYPE_MACVTAP)
|
||||
NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES(NM_SETTING_MACVLAN_SETTING_NAME),
|
||||
factory_class->create_device = create_device;
|
||||
factory_class->get_connection_parent = get_connection_parent;
|
||||
factory_class->get_connection_iface = get_connection_iface;);
|
||||
factory_class->get_connection_parent = get_connection_parent;);
|
||||
|
@@ -385,17 +385,6 @@ get_connection_parent(NMDeviceFactory *factory, NMConnection *connection)
|
||||
return nm_setting_pppoe_get_parent(s_pppoe);
|
||||
}
|
||||
|
||||
static char *
|
||||
get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface)
|
||||
{
|
||||
nm_assert(nm_connection_is_type(connection, NM_SETTING_PPPOE_SETTING_NAME));
|
||||
|
||||
if (!parent_iface)
|
||||
return NULL;
|
||||
|
||||
return g_strdup(nm_connection_get_interface_name(connection));
|
||||
}
|
||||
|
||||
NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
PPP,
|
||||
Ppp,
|
||||
@@ -403,6 +392,5 @@ NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
NM_DEVICE_FACTORY_DECLARE_LINK_TYPES(NM_LINK_TYPE_PPP)
|
||||
NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES(NM_SETTING_PPPOE_SETTING_NAME),
|
||||
factory_class->get_connection_parent = get_connection_parent;
|
||||
factory_class->get_connection_iface = get_connection_iface;
|
||||
factory_class->create_device = create_device;
|
||||
factory_class->match_connection = match_connection;);
|
||||
|
@@ -635,26 +635,18 @@ get_connection_parent(NMDeviceFactory *factory, NMConnection *connection)
|
||||
static char *
|
||||
get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface)
|
||||
{
|
||||
const char *ifname;
|
||||
NMSettingVlan *s_vlan;
|
||||
|
||||
g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_VLAN_SETTING_NAME), NULL);
|
||||
|
||||
s_vlan = nm_connection_get_setting_vlan(connection);
|
||||
g_assert(s_vlan);
|
||||
|
||||
if (!parent_iface)
|
||||
return NULL;
|
||||
|
||||
ifname = nm_connection_get_interface_name(connection);
|
||||
if (ifname)
|
||||
return g_strdup(ifname);
|
||||
|
||||
/* If the connection doesn't specify the interface name for the VLAN
|
||||
* device, we create one for it using the VLAN ID and the parent
|
||||
* interface's name.
|
||||
*/
|
||||
s_vlan = nm_connection_get_setting_vlan(connection);
|
||||
if (s_vlan)
|
||||
return nmp_utils_new_vlan_name(parent_iface, nm_setting_vlan_get_id(s_vlan));
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
|
@@ -782,24 +782,6 @@ get_connection_parent(NMDeviceFactory *factory, NMConnection *connection)
|
||||
return nm_setting_vxlan_get_parent(s_vxlan);
|
||||
}
|
||||
|
||||
static char *
|
||||
get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface)
|
||||
{
|
||||
const char *ifname;
|
||||
NMSettingVxlan *s_vxlan;
|
||||
|
||||
g_return_val_if_fail(nm_connection_is_type(connection, NM_SETTING_VXLAN_SETTING_NAME), NULL);
|
||||
|
||||
s_vxlan = nm_connection_get_setting_vxlan(connection);
|
||||
g_assert(s_vxlan);
|
||||
|
||||
if (nm_setting_vxlan_get_parent(s_vxlan) && !parent_iface)
|
||||
return NULL;
|
||||
|
||||
ifname = nm_connection_get_interface_name(connection);
|
||||
return g_strdup(ifname);
|
||||
}
|
||||
|
||||
NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
VXLAN,
|
||||
Vxlan,
|
||||
@@ -807,5 +789,4 @@ NM_DEVICE_FACTORY_DEFINE_INTERNAL(
|
||||
NM_DEVICE_FACTORY_DECLARE_LINK_TYPES(NM_LINK_TYPE_VXLAN)
|
||||
NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES(NM_SETTING_VXLAN_SETTING_NAME),
|
||||
factory_class->create_device = create_device;
|
||||
factory_class->get_connection_parent = get_connection_parent;
|
||||
factory_class->get_connection_iface = get_connection_iface;);
|
||||
factory_class->get_connection_parent = get_connection_parent;);
|
||||
|
Reference in New Issue
Block a user