diff options
Diffstat (limited to 'src/devices/nm-device-ip-tunnel.c')
| -rw-r--r-- | src/devices/nm-device-ip-tunnel.c | 395 |
1 files changed, 187 insertions, 208 deletions
diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c index 72a13893..58544377 100644 --- a/src/devices/nm-device-ip-tunnel.c +++ b/src/devices/nm-device-ip-tunnel.c @@ -30,26 +30,35 @@ #include "nm-device-private.h" #include "nm-manager.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-core-internal.h" -#include "nm-settings.h" -#include "nm-activation-request.h" +#include "settings/nm-settings.h" +#include "nm-act-request.h" #include "nm-ip4-config.h" -#include "nmdbus-device-ip-tunnel.h" +#include "introspection/org.freedesktop.NetworkManager.Device.IPTunnel.h" #include "nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceIPTunnel); -G_DEFINE_TYPE (NMDeviceIPTunnel, nm_device_ip_tunnel, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_IP_TUNNEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_IP_TUNNEL, NMDeviceIPTunnelPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceIPTunnel, + PROP_MODE, + PROP_LOCAL, + PROP_REMOTE, + PROP_TTL, + PROP_TOS, + PROP_PATH_MTU_DISCOVERY, + PROP_INPUT_KEY, + PROP_OUTPUT_KEY, + PROP_ENCAPSULATION_LIMIT, + PROP_FLOW_LABEL, +); typedef struct { NMIPTunnelMode mode; - NMDevice *parent; - int parent_ifindex; char *local; char *remote; guint8 ttl; @@ -62,24 +71,20 @@ typedef struct { guint32 flow_label; } NMDeviceIPTunnelPrivate; -enum { - PROP_0, - PROP_MODE, - PROP_PARENT, - PROP_LOCAL, - PROP_REMOTE, - PROP_TTL, - PROP_TOS, - PROP_PATH_MTU_DISCOVERY, - PROP_INPUT_KEY, - PROP_OUTPUT_KEY, - PROP_ENCAPSULATION_LIMIT, - PROP_FLOW_LABEL, +struct _NMDeviceIPTunnel { + NMDevice parent; + NMDeviceIPTunnelPrivate _priv; +}; - LAST_PROP +struct _NMDeviceIPTunnelClass { + NMDeviceClass parent; }; -/**************************************************************/ +G_DEFINE_TYPE (NMDeviceIPTunnel, nm_device_ip_tunnel, NM_TYPE_DEVICE) + +#define NM_DEVICE_IP_TUNNEL_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceIPTunnel, NM_IS_DEVICE_IP_TUNNEL) + +/*****************************************************************************/ static gboolean address_equal_pp (int family, const char *a, const char *b) @@ -118,9 +123,7 @@ update_properties_from_ifindex (NMDevice *device, int ifindex) { NMDeviceIPTunnel *self = NM_DEVICE_IP_TUNNEL (device); NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE (self); - GObject *object = G_OBJECT (device); - NMDevice *parent; - int parent_ifindex; + int parent_ifindex = 0; in_addr_t local4, remote4; struct in6_addr local6, remote6; guint8 ttl = 0, tos = 0, encap_limit = 0; @@ -130,26 +133,22 @@ update_properties_from_ifindex (NMDevice *device, int ifindex) if (ifindex <= 0) { clear: - if (priv->parent || priv->parent_ifindex) { - g_clear_object (&priv->parent); - priv->parent_ifindex = 0; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_PARENT); - } + nm_device_parent_set_ifindex (device, 0); if (priv->local) { g_clear_pointer (&priv->local, g_free); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_LOCAL); + _notify (self, PROP_LOCAL); } if (priv->remote) { g_clear_pointer (&priv->remote, g_free); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_REMOTE); + _notify (self, PROP_REMOTE); } if (priv->input_key) { g_clear_pointer (&priv->input_key, g_free); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_INPUT_KEY); + _notify (self, PROP_INPUT_KEY); } if (priv->output_key) { g_clear_pointer (&priv->output_key, g_free); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_OUTPUT_KEY); + _notify (self, PROP_OUTPUT_KEY); } goto out; @@ -176,13 +175,13 @@ clear: if (g_strcmp0 (priv->input_key, key)) { g_free (priv->input_key); priv->input_key = key; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_INPUT_KEY); + _notify (self, PROP_INPUT_KEY); } else g_free (key); } else { if (priv->input_key) { g_clear_pointer (&priv->input_key, g_free); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_INPUT_KEY); + _notify (self, PROP_INPUT_KEY); } } @@ -191,13 +190,13 @@ clear: if (g_strcmp0 (priv->output_key, key)) { g_free (priv->output_key); priv->output_key = key; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_OUTPUT_KEY); + _notify (self, PROP_OUTPUT_KEY); } else g_free (key); } else { if (priv->output_key) { g_clear_pointer (&priv->output_key, g_free); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_OUTPUT_KEY); + _notify (self, PROP_OUTPUT_KEY); } } } else if (priv->mode == NM_IP_TUNNEL_MODE_SIT) { @@ -250,42 +249,35 @@ clear: } else g_return_if_reached (); - if (priv->parent_ifindex != parent_ifindex) { - g_clear_object (&priv->parent); - priv->parent_ifindex = parent_ifindex; - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), parent_ifindex); - if (parent) - priv->parent = g_object_ref (parent); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_PARENT); - } + nm_device_parent_set_ifindex (device, parent_ifindex); if (priv->addr_family == AF_INET) { if (!address_equal_pn (AF_INET, priv->local, &local4)) { g_clear_pointer (&priv->local, g_free); if (local4) priv->local = g_strdup (nm_utils_inet4_ntop (local4, NULL)); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_LOCAL); + _notify (self, PROP_LOCAL); } if (!address_equal_pn (AF_INET, priv->remote, &remote4)) { g_clear_pointer (&priv->remote, g_free); if (remote4) priv->remote = g_strdup (nm_utils_inet4_ntop (remote4, NULL)); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_REMOTE); + _notify (self, PROP_REMOTE); } } else { if (!address_equal_pn (AF_INET6, priv->local, &local6)) { g_clear_pointer (&priv->local, g_free); if (memcmp (&local6, &in6addr_any, sizeof (in6addr_any))) priv->local = g_strdup (nm_utils_inet6_ntop (&local6, NULL)); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_LOCAL); + _notify (self, PROP_LOCAL); } if (!address_equal_pn (AF_INET6, priv->remote, &remote6)) { g_clear_pointer (&priv->remote, g_free); if (memcmp (&remote6, &in6addr_any, sizeof (in6addr_any))) priv->remote = g_strdup (nm_utils_inet6_ntop (&remote6, NULL)); - g_object_notify (object, NM_DEVICE_IP_TUNNEL_REMOTE); + _notify (self, PROP_REMOTE); } } @@ -293,27 +285,27 @@ out: if (priv->ttl != ttl) { priv->ttl = ttl; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_TTL); + _notify (self, PROP_TTL); } if (priv->tos != tos) { priv->tos = tos; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_TOS); + _notify (self, PROP_TOS); } if (priv->path_mtu_discovery != pmtud) { priv->path_mtu_discovery = pmtud; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_PATH_MTU_DISCOVERY); + _notify (self, PROP_PATH_MTU_DISCOVERY); } if (priv->encap_limit != encap_limit) { priv->encap_limit = encap_limit; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_ENCAPSULATION_LIMIT); + _notify (self, PROP_ENCAPSULATION_LIMIT); } if (priv->flow_label != flow_label) { priv->flow_label = flow_label; - g_object_notify (object, NM_DEVICE_IP_TUNNEL_FLOW_LABEL); + _notify (self, PROP_FLOW_LABEL); } } @@ -324,9 +316,10 @@ update_properties (NMDevice *device) } static void -link_changed (NMDevice *device, NMPlatformLink *info) +link_changed (NMDevice *device, + const NMPlatformLink *pllink) { - NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->link_changed (device, info); + NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->link_changed (device, pllink); update_properties (device); } @@ -375,8 +368,7 @@ update_connection (NMDevice *device, NMConnection *connection) if (nm_setting_ip_tunnel_get_mode (s_ip_tunnel) != priv->mode) g_object_set (G_OBJECT (s_ip_tunnel), NM_SETTING_IP_TUNNEL_MODE, priv->mode, NULL); - if (priv->parent_ifindex > 0) - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->parent_ifindex); + parent = nm_device_parent_get_device (device); /* Update parent in the connection; default to parent's interface name */ if (parent) { @@ -505,7 +497,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) /* Check parent interface; could be an interface name or a UUID */ parent = nm_setting_ip_tunnel_get_parent (s_ip_tunnel); if (parent) { - if (!match_parent (priv->parent, parent)) + if (!match_parent (nm_device_parent_get_device (device), parent)) return FALSE; } @@ -550,12 +542,13 @@ platform_link_to_tunnel_mode (const NMPlatformLink *link) return NM_IP_TUNNEL_MODE_GRE; case NM_LINK_TYPE_IP6TNL: lnk = nm_platform_link_get_lnk_ip6tnl (NM_PLATFORM_GET, link->ifindex, NULL); - if (lnk->proto == IPPROTO_IPIP) - return NM_IP_TUNNEL_MODE_IPIP6; - else if (lnk->proto == IPPROTO_IPV6) - return NM_IP_TUNNEL_MODE_IP6IP6; - else - return NM_IP_TUNNEL_MODE_UNKNOWN; + if (lnk) { + if (lnk->proto == IPPROTO_IPIP) + return NM_IP_TUNNEL_MODE_IPIP6; + if (lnk->proto == IPPROTO_IPV6) + return NM_IP_TUNNEL_MODE_IP6IP6; + } + return NM_IP_TUNNEL_MODE_UNKNOWN; case NM_LINK_TYPE_IPIP: return NM_IP_TUNNEL_MODE_IPIP; case NM_LINK_TYPE_SIT: @@ -578,31 +571,18 @@ tunnel_mode_to_link_type (NMIPTunnelMode tunnel_mode) 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); + case NM_IP_TUNNEL_MODE_VTI: + case NM_IP_TUNNEL_MODE_IP6GRE: + case NM_IP_TUNNEL_MODE_VTI6: + case NM_IP_TUNNEL_MODE_ISATAP: + return NM_LINK_TYPE_UNKNOWN; + case NM_IP_TUNNEL_MODE_UNKNOWN: + break; } + g_return_val_if_reached (NM_LINK_TYPE_UNKNOWN); } -/**************************************************************/ - -static void -nm_device_ip_tunnel_init (NMDeviceIPTunnel *self) -{ -} - -static void -constructed (GObject *object) -{ - NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE (object); - - if ( priv->mode == NM_IP_TUNNEL_MODE_IPIP6 - || priv->mode == NM_IP_TUNNEL_MODE_IP6IP6) - priv->addr_family = AF_INET6; - else - priv->addr_family = AF_INET; - - G_OBJECT_CLASS (nm_device_ip_tunnel_parent_class)->constructed (object); -} +/*****************************************************************************/ static gboolean create_and_realize (NMDevice *device, @@ -764,30 +744,30 @@ create_and_realize (NMDevice *device, return TRUE; } -static void -realize_start_notify (NMDevice *device, const NMPlatformLink *plink) +static guint32 +get_configured_mtu (NMDevice *self, gboolean *out_is_user_config) { - NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->realize_start_notify (device, plink); - - update_properties (device); -} - -static void -ip4_config_pre_commit (NMDevice *device, NMIP4Config *config) -{ - NMConnection *connection; - NMSettingIPTunnel *s_ip_tunnel; + NMSettingIPTunnel *setting; + gint64 mtu_default; guint32 mtu; - connection = nm_device_get_applied_connection (device); - g_assert (connection); - s_ip_tunnel = nm_connection_get_setting_ip_tunnel (connection); - g_assert (s_ip_tunnel); + nm_assert (NM_IS_DEVICE (self)); + nm_assert (out_is_user_config); - /* MTU override */ - mtu = nm_setting_ip_tunnel_get_mtu (s_ip_tunnel); - if (mtu) - nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER); + setting = NM_SETTING_IP_TUNNEL (nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP_TUNNEL)); + if (!setting) + g_return_val_if_reached (0); + + mtu = nm_setting_ip_tunnel_get_mtu (setting); + if (mtu == 0) { + mtu_default = nm_device_get_configured_mtu_from_connection_default (self, "ip-tunnel.mtu"); + if (mtu_default >= 0) { + *out_is_user_config = TRUE; + return (guint32) mtu_default; + } + } + *out_is_user_config = (mtu != 0); + return mtu ?: NM_DEVICE_DEFAULT_MTU_WIRED; } static NMDeviceCapabilities @@ -804,21 +784,18 @@ unrealize_notify (NMDevice *device) update_properties_from_ifindex (device, 0); } +/*****************************************************************************/ + static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE (object); - NMDevice *parent; + NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE ((NMDeviceIPTunnel *) object); switch (prop_id) { case PROP_MODE: g_value_set_uint (value, priv->mode); break; - case PROP_PARENT: - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->parent_ifindex); - nm_utils_g_value_set_object_path (value, parent); - break; case PROP_LOCAL: g_value_set_string (value, priv->local); break; @@ -854,9 +831,9 @@ get_property (GObject *object, guint prop_id, static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) + const GValue *value, GParamSpec *pspec) { - NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE (object); + NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE ((NMDeviceIPTunnel *) object); switch (prop_id) { case PROP_MODE: @@ -867,14 +844,33 @@ set_property (GObject *object, guint prop_id, } } +/*****************************************************************************/ + +static void +nm_device_ip_tunnel_init (NMDeviceIPTunnel *self) +{ +} + +static void +constructed (GObject *object) +{ + NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE ((NMDeviceIPTunnel *) object); + + if ( priv->mode == NM_IP_TUNNEL_MODE_IPIP6 + || priv->mode == NM_IP_TUNNEL_MODE_IP6IP6) + priv->addr_family = AF_INET6; + else + priv->addr_family = AF_INET; + + G_OBJECT_CLASS (nm_device_ip_tunnel_parent_class)->constructed (object); +} + static void nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMDeviceIPTunnelPrivate)); - object_class->constructed = constructed; object_class->get_property = get_property; object_class->set_property = set_property; @@ -885,8 +881,7 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass) device_class->check_connection_compatible = check_connection_compatible; device_class->create_and_realize = create_and_realize; device_class->get_generic_capabilities = get_generic_capabilities; - device_class->ip4_config_pre_commit = ip4_config_pre_commit; - device_class->realize_start_notify = realize_start_notify; + device_class->get_configured_mtu = get_configured_mtu; device_class->unrealize_notify = unrealize_notify; NM_DEVICE_CLASS_DECLARE_TYPES (klass, @@ -896,94 +891,78 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass) NM_LINK_TYPE_IPIP, NM_LINK_TYPE_SIT); - /* properties */ - g_object_class_install_property - (object_class, PROP_MODE, - g_param_spec_uint (NM_DEVICE_IP_TUNNEL_MODE, "", "", - 0, G_MAXUINT, 0, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - /* properties */ - g_object_class_install_property - (object_class, PROP_PARENT, - g_param_spec_string (NM_DEVICE_IP_TUNNEL_PARENT, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_LOCAL, - g_param_spec_string (NM_DEVICE_IP_TUNNEL_LOCAL, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_REMOTE, - g_param_spec_string (NM_DEVICE_IP_TUNNEL_REMOTE, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_TTL, - g_param_spec_uchar (NM_DEVICE_IP_TUNNEL_TTL, "", "", - 0, 255, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_TOS, - g_param_spec_uchar (NM_DEVICE_IP_TUNNEL_TOS, "", "", - 0, 255, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_PATH_MTU_DISCOVERY, - g_param_spec_boolean (NM_DEVICE_IP_TUNNEL_PATH_MTU_DISCOVERY, "", "", - FALSE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_INPUT_KEY, - g_param_spec_string (NM_DEVICE_IP_TUNNEL_INPUT_KEY, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_OUTPUT_KEY, - g_param_spec_string (NM_DEVICE_IP_TUNNEL_OUTPUT_KEY, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_ENCAPSULATION_LIMIT, - g_param_spec_uchar (NM_DEVICE_IP_TUNNEL_ENCAPSULATION_LIMIT, "", "", - 0, 255, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_FLOW_LABEL, - g_param_spec_uint (NM_DEVICE_IP_TUNNEL_FLOW_LABEL, "", "", - 0, (1 << 20) - 1, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_MODE] = + g_param_spec_uint (NM_DEVICE_IP_TUNNEL_MODE, "", "", + 0, G_MAXUINT, 0, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_LOCAL] = + g_param_spec_string (NM_DEVICE_IP_TUNNEL_LOCAL, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_REMOTE] = + g_param_spec_string (NM_DEVICE_IP_TUNNEL_REMOTE, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_TTL] = + g_param_spec_uchar (NM_DEVICE_IP_TUNNEL_TTL, "", "", + 0, 255, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_TOS] = + g_param_spec_uchar (NM_DEVICE_IP_TUNNEL_TOS, "", "", + 0, 255, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_PATH_MTU_DISCOVERY] = + g_param_spec_boolean (NM_DEVICE_IP_TUNNEL_PATH_MTU_DISCOVERY, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_INPUT_KEY] = + g_param_spec_string (NM_DEVICE_IP_TUNNEL_INPUT_KEY, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_OUTPUT_KEY] = + g_param_spec_string (NM_DEVICE_IP_TUNNEL_OUTPUT_KEY, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_ENCAPSULATION_LIMIT] = + g_param_spec_uchar (NM_DEVICE_IP_TUNNEL_ENCAPSULATION_LIMIT, "", "", + 0, 255, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_FLOW_LABEL] = + g_param_spec_uint (NM_DEVICE_IP_TUNNEL_FLOW_LABEL, "", "", + 0, (1 << 20) - 1, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), NMDBUS_TYPE_DEVICE_IPTUNNEL_SKELETON, NULL); } -/*************************************************************/ -#define NM_TYPE_IP_TUNNEL_FACTORY (nm_ip_tunnel_factory_get_type ()) -#define NM_IP_TUNNEL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP_TUNNEL_FACTORY, NMIPTunnelFactory)) +/*****************************************************************************/ + +#define NM_TYPE_IP_TUNNEL_DEVICE_FACTORY (nm_ip_tunnel_device_factory_get_type ()) +#define NM_IP_TUNNEL_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP_TUNNEL_DEVICE_FACTORY, NMIPTunnelDeviceFactory)) static NMDevice * create_device (NMDeviceFactory *factory, @@ -1005,7 +984,7 @@ create_device (NMDeviceFactory *factory, mode = platform_link_to_tunnel_mode (plink); } - if (mode == NM_IP_TUNNEL_MODE_UNKNOWN) + if (mode == NM_IP_TUNNEL_MODE_UNKNOWN || link_type == NM_LINK_TYPE_UNKNOWN) return NULL; return (NMDevice *) g_object_new (NM_TYPE_DEVICE_IP_TUNNEL, @@ -1054,7 +1033,7 @@ get_connection_iface (NMDeviceFactory *factory, NM_DEVICE_FACTORY_DEFINE_INTERNAL (IP_TUNNEL, IPTunnel, ip_tunnel, NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_GRE, NM_LINK_TYPE_SIT, NM_LINK_TYPE_IPIP) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_IP_TUNNEL_SETTING_NAME), - factory_iface->create_device = create_device; - factory_iface->get_connection_parent = get_connection_parent; - factory_iface->get_connection_iface = get_connection_iface; -) + factory_class->create_device = create_device; + factory_class->get_connection_parent = get_connection_parent; + factory_class->get_connection_iface = get_connection_iface; +); |