summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-12-15 13:32:14 +0100
committerThomas Haller <thaller@redhat.com>2015-12-16 20:14:16 +0100
commita5660ca6157426769603cf1f4303f7c05690ce3c (patch)
treebdd8b6442dc270077418eeaa5752001dadcbf14a
parentf87f7af3001ee34c2363092fb098acf3f3b9de3b (diff)
downloadNetworkManager-a5660ca6157426769603cf1f4303f7c05690ce3c.tar.gz
platform: check for existing link in do_add_link_with_lookup()
When adding a link, that can only make sense if no such link exists yet. Check for that condition first, to properly return an error.
-rw-r--r--src/platform/nm-linux-platform.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 0dffb09e70..d345224d7a 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -3631,6 +3631,20 @@ do_add_link_with_lookup (NMPlatform *platform,
event_handler_read_netlink (platform, FALSE);
+ if (nmp_cache_lookup_link_full (priv->cache, 0, name, FALSE, NM_LINK_TYPE_NONE, NULL, NULL)) {
+ /* hm, a link with such a name already exists. Try reloading first. */
+ do_request_link (platform, 0, name);
+
+ obj = nmp_cache_lookup_link_full (priv->cache, 0, name, FALSE, NM_LINK_TYPE_NONE, NULL, NULL);
+ if (obj) {
+ _LOGE ("do-add-link[%s/%s]: link already exists: %s",
+ name,
+ nm_link_type_to_string (link_type),
+ nmp_object_to_string (obj, NMP_OBJECT_TO_STRING_ID, NULL, 0));
+ return FALSE;
+ }
+ }
+
nle = _nl_send_auto_with_seq (platform, nlmsg, &seq_result);
if (nle < 0) {
_LOGE ("do-add-link[%s/%s]: failed sending netlink request \"%s\" (%d)",