diff options
author | Dan Williams <dcbw@redhat.com> | 2014-10-16 09:23:10 -0500 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-06-17 16:19:19 +0200 |
commit | f8a9574f7e2a0c0cff839c2d3cd8fe7c9b7f81b9 (patch) | |
tree | 268b7912e2b14b13a29e6570f690d74707349868 | |
parent | 4b9f506bfd9eb45efea14d5cf797f755d8d2cc5c (diff) | |
download | NetworkManager-f8a9574f7e2a0c0cff839c2d3cd8fe7c9b7f81b9.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.
(cherry picked from commit 29ccb8851ce09855d227cdc5e58ebc31e25cb4c5)
-rw-r--r-- | src/platform/nm-linux-platform.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index e7bae6e4bb..24f69a84ea 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -1776,12 +1776,14 @@ refresh_object (NMPlatform *platform, struct nl_object *object, gboolean removed announce_object (platform, kernel_object, cached_object ? NM_PLATFORM_SIGNAL_CHANGED : NM_PLATFORM_SIGNAL_ADDED, reason); - /* Refresh the master device (even on enslave/release) */ if (type == OBJECT_TYPE_LINK) { int kernel_master = rtnl_link_get_master ((struct rtnl_link *) kernel_object); int cached_master = cached_object ? rtnl_link_get_master ((struct rtnl_link *) cached_object) : 0; + const char *orig_link_type = rtnl_link_get_type ((struct rtnl_link *) object); + const char *kernel_link_type = rtnl_link_get_type ((struct rtnl_link *) kernel_object); struct nl_object *master_object; + /* Refresh the master device (even on enslave/release) */ if (kernel_master) { master_object = build_rtnl_link (kernel_master, NULL, NM_LINK_TYPE_NONE); refresh_object (platform, master_object, FALSE, NM_PLATFORM_REASON_INTERNAL); @@ -1792,6 +1794,12 @@ refresh_object (NMPlatform *platform, struct nl_object *object, gboolean removed refresh_object (platform, master_object, FALSE, NM_PLATFORM_REASON_INTERNAL); nl_object_put (master_object); } + + /* Ensure the existing link type matches the refreshed link type */ + if (orig_link_type && kernel_link_type && strcmp (orig_link_type, kernel_link_type)) { + platform->error = NM_PLATFORM_ERROR_WRONG_TYPE; + return FALSE; + } } } @@ -2329,6 +2337,8 @@ link_get_by_name (NMPlatform *platform, const char *name, NMPlatformLink *out_li { int ifindex; + g_return_val_if_fail (name != NULL, FALSE); + if (out_link) { ifindex = nm_platform_link_get_ifindex (platform, name); g_return_val_if_fail (ifindex > 0, FALSE); @@ -3072,8 +3082,9 @@ infiniband_partition_add (NMPlatform *platform, int parent, int p_key, NMPlatfor if (success) { gs_free char *ifname = g_strdup_printf ("%s.%04x", parent_name, p_key); - auto_nl_object struct rtnl_link *rtnllink = _nm_rtnl_link_alloc (0, ifname); + auto_nl_object struct rtnl_link *rtnllink; + rtnllink = (struct rtnl_link *) build_rtnl_link (0, ifname, NM_LINK_TYPE_INFINIBAND); success = refresh_object (platform, (struct nl_object *) rtnllink, FALSE, NM_PLATFORM_REASON_INTERNAL); if (success) success = link_get_by_name (platform, ifname, out_link); |