mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-07 00:30:32 +01:00
device: set link type from all factories
This is, in particular, important for devices that support multiple link types which can not be changed once the platform device exists.
This commit is contained in:
parent
7dbf821cb2
commit
f72d0f6efb
13 changed files with 62 additions and 1 deletions
|
|
@ -523,6 +523,7 @@ create_device (NMDeviceFactory *factory,
|
|||
NM_DEVICE_DRIVER, "bonding",
|
||||
NM_DEVICE_TYPE_DESC, "Bond",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BOND,
|
||||
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_BOND,
|
||||
NM_DEVICE_IS_MASTER, TRUE,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -471,6 +471,7 @@ create_device (NMDeviceFactory *factory,
|
|||
NM_DEVICE_DRIVER, "bridge",
|
||||
NM_DEVICE_TYPE_DESC, "Bridge",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BRIDGE,
|
||||
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_BRIDGE,
|
||||
NM_DEVICE_IS_MASTER, TRUE,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1776,6 +1776,7 @@ create_device (NMDeviceFactory *factory,
|
|||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_TYPE_DESC, "Ethernet",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_ETHERNET,
|
||||
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_ETHERNET,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -385,6 +385,8 @@ create_device (NMDeviceFactory *factory,
|
|||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_TYPE_DESC, "InfiniBand",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_INFINIBAND,
|
||||
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_INFINIBAND,
|
||||
/* XXX: Partition should probably be a different link type! */
|
||||
NM_DEVICE_INFINIBAND_IS_PARTITION, is_partition,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -570,6 +570,24 @@ platform_link_to_tunnel_mode (const NMPlatformLink *link)
|
|||
}
|
||||
}
|
||||
|
||||
static NMLinkType
|
||||
tunnel_mode_to_link_type (NMIPTunnelMode tunnel_mode)
|
||||
{
|
||||
switch (tunnel_mode) {
|
||||
case NM_IP_TUNNEL_MODE_GRE:
|
||||
return NM_LINK_TYPE_GRE;
|
||||
case NM_IP_TUNNEL_MODE_IPIP6:
|
||||
case NM_IP_TUNNEL_MODE_IP6IP6:
|
||||
return NM_LINK_TYPE_IP6TNL;
|
||||
case NM_IP_TUNNEL_MODE_IPIP:
|
||||
return NM_LINK_TYPE_IPIP;
|
||||
case NM_IP_TUNNEL_MODE_SIT:
|
||||
return NM_LINK_TYPE_SIT;
|
||||
default:
|
||||
g_return_val_if_reached (NM_LINK_TYPE_UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -957,12 +975,16 @@ create_device (NMDeviceFactory *factory,
|
|||
{
|
||||
NMSettingIPTunnel *s_ip_tunnel;
|
||||
NMIPTunnelMode mode;
|
||||
NMLinkType link_type;
|
||||
|
||||
if (connection) {
|
||||
s_ip_tunnel = nm_connection_get_setting_ip_tunnel (connection);
|
||||
mode = nm_setting_ip_tunnel_get_mode (s_ip_tunnel);
|
||||
} else
|
||||
link_type = tunnel_mode_to_link_type (mode);
|
||||
} else {
|
||||
link_type = plink->type;
|
||||
mode = platform_link_to_tunnel_mode (plink);
|
||||
}
|
||||
|
||||
if (mode == NM_IP_TUNNEL_MODE_UKNOWN)
|
||||
return NULL;
|
||||
|
|
@ -971,6 +993,7 @@ create_device (NMDeviceFactory *factory,
|
|||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_TYPE_DESC, "IPTunnel",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_IP_TUNNEL,
|
||||
NM_DEVICE_LINK_TYPE, link_type,
|
||||
NM_DEVICE_IP_TUNNEL_MODE, mode,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,10 +189,13 @@ create_device (NMDeviceFactory *factory,
|
|||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
g_return_val_if_fail (plink, NULL);
|
||||
|
||||
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_MACVLAN,
|
||||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_TYPE_DESC, "Macvlan",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC,
|
||||
NM_DEVICE_LINK_TYPE, plink->type,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -449,10 +449,34 @@ create_device (NMDeviceFactory *factory,
|
|||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
NMSettingTun *s_tun;
|
||||
NMLinkType link_type = NM_LINK_TYPE_UNKNOWN;
|
||||
|
||||
if (plink) {
|
||||
link_type = plink->type;
|
||||
} else if (connection) {
|
||||
s_tun = nm_connection_get_setting_tun (connection);
|
||||
if (!s_tun)
|
||||
return NULL;
|
||||
switch (nm_setting_tun_get_mode (s_tun)) {
|
||||
case NM_SETTING_TUN_MODE_TUN:
|
||||
link_type = NM_LINK_TYPE_TUN;
|
||||
break;
|
||||
case NM_SETTING_TUN_MODE_TAP:
|
||||
link_type = NM_LINK_TYPE_TAP;
|
||||
break;
|
||||
case NM_SETTING_TUN_MODE_UNKNOWN:
|
||||
g_return_val_if_reached (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
g_return_val_if_fail (link_type != NM_LINK_TYPE_UNKNOWN, NULL);
|
||||
|
||||
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_TUN,
|
||||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_TYPE_DESC, "Tun",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_TUN,
|
||||
NM_DEVICE_LINK_TYPE, link_type,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -189,6 +189,7 @@ create_device (NMDeviceFactory *factory,
|
|||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_TYPE_DESC, "Veth",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_ETHERNET,
|
||||
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_VETH,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -727,6 +727,7 @@ create_device (NMDeviceFactory *factory,
|
|||
NM_DEVICE_DRIVER, "8021q",
|
||||
NM_DEVICE_TYPE_DESC, "VLAN",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_VLAN,
|
||||
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_VLAN,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -386,6 +386,7 @@ create_device (NMDeviceFactory *factory,
|
|||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_TYPE_DESC, "Vxlan",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC,
|
||||
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_VXLAN,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -702,6 +702,7 @@ nm_device_team_new (const char *iface)
|
|||
NM_DEVICE_DRIVER, "team",
|
||||
NM_DEVICE_TYPE_DESC, "Team",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_TEAM,
|
||||
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_TEAM,
|
||||
NM_DEVICE_IS_MASTER, TRUE,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -421,6 +421,7 @@ nm_device_olpc_mesh_new (const char *iface)
|
|||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_TYPE_DESC, "802.11 OLPC Mesh",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_OLPC_MESH,
|
||||
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_OLPC_MESH,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2927,6 +2927,7 @@ nm_device_wifi_new (const char *iface)
|
|||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_TYPE_DESC, "802.11 WiFi",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_WIFI,
|
||||
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_WIFI,
|
||||
NM_DEVICE_RFKILL_TYPE, RFKILL_TYPE_WLAN,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue