diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2015-12-08 14:51:12 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2015-12-08 18:11:53 +0100 |
commit | f72d0f6efbdbf533ed2796318743e906249ce46d (patch) | |
tree | fbf1707c7231cf1c8ec998780251efa5c7697f5a | |
parent | 7dbf821cb2982672dc5bc1e0088f6a113ed81f87 (diff) | |
download | NetworkManager-f72d0f6efbdbf533ed2796318743e906249ce46d.tar.gz |
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.
-rw-r--r-- | src/devices/nm-device-bond.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-bridge.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-ethernet.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-infiniband.c | 2 | ||||
-rw-r--r-- | src/devices/nm-device-ip-tunnel.c | 25 | ||||
-rw-r--r-- | src/devices/nm-device-macvlan.c | 3 | ||||
-rw-r--r-- | src/devices/nm-device-tun.c | 24 | ||||
-rw-r--r-- | src/devices/nm-device-veth.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-vlan.c | 1 | ||||
-rw-r--r-- | src/devices/nm-device-vxlan.c | 1 | ||||
-rw-r--r-- | src/devices/team/nm-device-team.c | 1 | ||||
-rw-r--r-- | src/devices/wifi/nm-device-olpc-mesh.c | 1 | ||||
-rw-r--r-- | src/devices/wifi/nm-device-wifi.c | 1 |
13 files changed, 62 insertions, 1 deletions
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 6510065d55..6471d3e4a2 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -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); } diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index e43ce858b6..39d41ae4d4 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -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); } diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 68e16f20b2..9aec4ca66f 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -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); } diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index 95f69c93c3..50b7f1bb8f 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -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); } diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c index 84ab7cd69d..0e3e53d877 100644 --- a/src/devices/nm-device-ip-tunnel.c +++ b/src/devices/nm-device-ip-tunnel.c @@ -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); } diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index aed28816ff..ab650acab7 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -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); } diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index 60d9d7bba2..a170fe6533 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -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); } diff --git a/src/devices/nm-device-veth.c b/src/devices/nm-device-veth.c index 1fd2a5a834..07187205fb 100644 --- a/src/devices/nm-device-veth.c +++ b/src/devices/nm-device-veth.c @@ -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); } diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 7861cf2b4d..63938c8968 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -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); } diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index ad2f2ba44f..beee9f2c6c 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -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); } diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index 9ab848dedf..c91e2c404b 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -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); } diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c index 585c7022ad..9642e0955a 100644 --- a/src/devices/wifi/nm-device-olpc-mesh.c +++ b/src/devices/wifi/nm-device-olpc-mesh.c @@ -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); } diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 8f3630c84a..6febd10b55 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -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); } |