summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-10-16 09:23:10 -0500
committerThomas Haller <thaller@redhat.com>2015-04-29 11:07:11 +0200
commit1bd50fe64cafae467f9656b87b2a6189d527d403 (patch)
tree52a4e625df5560de432f5c220e4f61b021b67507
parentf70b9f675b5009db09b35e1d8cad0c26936dba3d (diff)
downloadNetworkManager-1bd50fe64cafae467f9656b87b2a6189d527d403.tar.gz
platform: ensure created interface matches requested type
If the caller requested that a bond be created, don't return success if there was an existing bridge with the same name.
-rw-r--r--src/platform/nm-linux-platform.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 4e6e65f8e6..8ccaf80953 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -2339,14 +2339,26 @@ build_rtnl_link (int ifindex, const char *name, NMLinkType type)
}
static gboolean
-link_get_by_name (NMPlatform *platform, const char *name, NMPlatformLink *out_link)
+link_get_by_name (NMPlatform *platform,
+ const char *name,
+ NMLinkType required_type,
+ NMPlatformLink *out_link)
{
int ifindex;
+ g_return_val_if_fail (name != NULL, FALSE);
+ g_return_val_if_fail (required_type > NM_LINK_TYPE_UNKNOWN, FALSE);
+
if (out_link) {
ifindex = nm_platform_link_get_ifindex (platform, name);
g_return_val_if_fail (ifindex > 0, FALSE);
- return _nm_platform_link_get (platform, ifindex, out_link);
+ if (_nm_platform_link_get (platform, ifindex, out_link)) {
+ if (out_link->type != required_type) {
+ memset (out_link, 0, sizeof (NMPlatformLink));
+ platform->error = NM_PLATFORM_ERROR_WRONG_TYPE;
+ return FALSE;
+ }
+ }
}
return TRUE;
}
@@ -2388,7 +2400,7 @@ link_add (NMPlatform *platform,
if (!add_object (platform, l))
return FALSE;
- return link_get_by_name (platform, name, out_link);
+ return link_get_by_name (platform, name, type, out_link);
}
static struct rtnl_link *
@@ -2899,7 +2911,7 @@ vlan_add (NMPlatform *platform,
if (!add_object (platform, object))
return FALSE;
- return link_get_by_name (platform, name, out_link);
+ return link_get_by_name (platform, name, NM_LINK_TYPE_VLAN, out_link);
}
static gboolean
@@ -3081,7 +3093,7 @@ infiniband_partition_add (NMPlatform *platform, int parent, int p_key, NMPlatfor
success = refresh_object (platform, (struct nl_object *) rtnllink, FALSE, NM_PLATFORM_REASON_INTERNAL);
if (success)
- success = link_get_by_name (platform, ifname, out_link);
+ success = link_get_by_name (platform, ifname, NM_LINK_TYPE_INFINIBAND, out_link);
}
return success;