diff options
author | Thomas Haller <thaller@redhat.com> | 2018-08-17 22:18:17 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-08-28 22:27:54 +0200 |
commit | 72de0afa35c88d40eda87855aee4a80034bef765 (patch) | |
tree | e557f8e439c3b0a170f6a6b48ddf6a9682a12f45 /src/devices/nm-device-ip-tunnel.c | |
parent | 357edff198aa732e25073b84a4da3e53293e2602 (diff) | |
download | NetworkManager-72de0afa35c88d40eda87855aee4a80034bef765.tar.gz |
device: refactor setting parent in device's update_connection()
Add a helper function nm_device_parent_find_for_connection() to
unify implementations of setting the parent in update_connection().
There is some change in behavior, in particular for nm-device-vlan.c,
which no longer compares the link information from platform. But
update_connection() is anyway a questionable concept, only used
for external assumed connection (which itself, is questionable). Meaning,
update_connection() is a hack not science, and it's not at all clear
what the correct behavior is.
Also, note how vlan's implementation differs from all others. Why?
Should we always resort to also check the information from platform?
Either way, one of the two approaches should be used consistently and
nm_device_parent_find_for_connection() opts to not consult platform
cache.
Diffstat (limited to 'src/devices/nm-device-ip-tunnel.c')
-rw-r--r-- | src/devices/nm-device-ip-tunnel.c | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c index 642bb25447..568403c626 100644 --- a/src/devices/nm-device-ip-tunnel.c +++ b/src/devices/nm-device-ip-tunnel.c @@ -435,8 +435,6 @@ update_connection (NMDevice *device, NMConnection *connection) NMDeviceIPTunnel *self = NM_DEVICE_IP_TUNNEL (device); NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE (self); NMSettingIPTunnel *s_ip_tunnel = nm_connection_get_setting_ip_tunnel (connection); - NMDevice *parent = NULL; - const char *setting_parent, *new_parent; if (!s_ip_tunnel) { s_ip_tunnel = (NMSettingIPTunnel *) nm_setting_ip_tunnel_new (); @@ -446,25 +444,11 @@ 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); - parent = nm_device_parent_get_device (device); - - /* Update parent in the connection; default to parent's interface name */ - if (parent) { - new_parent = nm_device_get_iface (parent); - setting_parent = nm_setting_ip_tunnel_get_parent (s_ip_tunnel); - if (setting_parent && nm_utils_is_uuid (setting_parent)) { - NMConnection *parent_connection; - - /* Don't change a parent specified by UUID if it's still valid */ - parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device), - setting_parent); - if (parent_connection && nm_device_check_connection_compatible (parent, parent_connection, NULL)) - new_parent = NULL; - } - if (new_parent) - g_object_set (s_ip_tunnel, NM_SETTING_IP_TUNNEL_PARENT, new_parent, NULL); - } else - g_object_set (s_ip_tunnel, NM_SETTING_IP_TUNNEL_PARENT, NULL, NULL); + g_object_set (s_ip_tunnel, + NM_SETTING_IP_TUNNEL_PARENT, + nm_device_parent_find_for_connection (device, + nm_setting_ip_tunnel_get_parent (s_ip_tunnel)), + NULL); if (!address_equal_pp (priv->addr_family, nm_setting_ip_tunnel_get_local (s_ip_tunnel), |