diff options
author | Dan Williams <dcbw@redhat.com> | 2014-10-16 09:23:10 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-12-11 09:38:45 -0600 |
commit | d10acccf89da14fc019d14efed67985434bb26c0 (patch) | |
tree | 0f91b83a8c7832cb7cb817ab5d2b7685aa7ae5dd | |
parent | fe1e0c81cd8d4ae3cb2fbcaf411f5ed6ce3df005 (diff) | |
download | NetworkManager-d10acccf89da14fc019d14efed67985434bb26c0.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.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 96ab96390b..ebc94caafe 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -2250,14 +2250,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 (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; } @@ -2301,7 +2313,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 * @@ -2744,7 +2756,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 @@ -2926,7 +2938,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; |