Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp978039ybx; Thu, 7 Nov 2019 05:32:35 -0800 (PST) X-Google-Smtp-Source: APXvYqyn6ASkPuyzmKd9PHHYZQgi0xCfrM2U2tfkfLKeLoOrzPXmKGHlVdZ3f6NCb9XvyFe69XBr X-Received: by 2002:a50:b4e4:: with SMTP id x33mr3591688edd.222.1573133555560; Thu, 07 Nov 2019 05:32:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573133555; cv=none; d=google.com; s=arc-20160816; b=NeG/HeijYsE/S3AGO8b787+8M0FmuMZymk7LDFcuRAqF/fSXlzzULNVuhNb7raSx5J 7MseP7WOlhqvrWEgzb24gy6JVYvm9JK2o34vhstIB0F2ekYNescMCIUyzN2pP+ksCDqU AXeLY5t+saYDRnOFDAtWDOUiA7G6PmGXhInNtYx+5hT+eJsP0a5C6RkZHWn96/Xnm3l6 rk0D3PK3PpFUrFpH7RhLJ96AYUhHIvXqrwFYxWFfEZ/CgD1MEXqkNRxrDwUNtlJLc6FL flHukHfiYNHqgUXp4INNxctg0h0jLpdZcXUn2hU5WR06lOgB/bnYSru2AOHzXulqpPmi NvyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E+91P1B4I9nUdKLz0FwOjZwRdttTAkpiPZ4BDPYb2xA=; b=ViziYPhD/0+EUX7mjZKQwdUCOL2akJsrW/TJm+WGRemWdDaxVa9+CGKhWORu2FLOx6 LKriSyfmP7ZJMZdsmy5hPDWHo+E6vl3wlwlBGHrCetLaephPkOxbB2nZHSEb260N22j6 WEe5fsI+3u0gyZurVIbxBkvaie9drgof2EUKtpNit5EfbK7YOs7iirRFyt4vvLwIw6My nzCGB1/O2YpFJFGlJY1Q4Wn764VohHtAlWUTPap033iSaMapide8r+Wmm+xdG6hz/Rg1 RsH1J2Z3ovHLmiw0bNi38ws9SpWZ58RtE2CYicKQKeGbbZ2eN5PQNpyw/JjzYpROazvn r8lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@norrbonn-se.20150623.gappssmtp.com header.s=20150623 header.b=g5WpoUbS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w20si1541108edc.397.2019.11.07.05.32.11; Thu, 07 Nov 2019 05:32:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@norrbonn-se.20150623.gappssmtp.com header.s=20150623 header.b=g5WpoUbS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389003AbfKGN21 (ORCPT + 99 others); Thu, 7 Nov 2019 08:28:27 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:33063 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389004AbfKGN2D (ORCPT ); Thu, 7 Nov 2019 08:28:03 -0500 Received: by mail-lj1-f194.google.com with SMTP id t5so2296411ljk.0 for ; Thu, 07 Nov 2019 05:28:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=norrbonn-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E+91P1B4I9nUdKLz0FwOjZwRdttTAkpiPZ4BDPYb2xA=; b=g5WpoUbS7tBcQdvpARR9AGtrAIvtk6MXU53yoZ8VIwHDb1Ya/JtCWE1CNjVHPMPlav ltgeX4wpZTM5XFSYSZn1DAfKp8WCSoRDGSj1qcnA86GHrcU0GJQP4uVr18ptoVzAhY+5 KwQb8Sw+D9Pu5VkMKBgfSFf2Iqluzs6RfNO5LNQuq/l1/Ttwxexb2mY4Mg5wWyYjE9wQ 0XSY/Q7ikoNUCAr5aH3PGRGrluOQ5dHF+WNTEgLkDWY112pEjzJ1mrYRkCmI0jVLCGTl wD8YlD01Ep2FJQmBGBAr6Mh6f4t/TWfMr+2TZyBk5D9JCEbIQ5eAPEl8+PMGp9nbwh0i m5Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E+91P1B4I9nUdKLz0FwOjZwRdttTAkpiPZ4BDPYb2xA=; b=ty1sZ+q4Rx1r2bKNiYIUIace7KJeWe7a5hw2nxQaBViHk9T4KHJWE3azHp3idrux2j Is9Phk/M7C9kc9Kar9uzDtFYHEdczf7V1kEoCXeyHTJA5cGLfbaMHlbvHfefyGdnIwnZ hEd0xjU4zhc+ujTDZfH6yl/hyxfNs7mV+KSogGGBDoPBBpkqzg8jQBYz0kLG22NJfQb3 qZT4Po7ZkIQbTlYMw7LkhtoBWWU4HPwRUAZbzwmcQn2FWBT3aTIamaihNsLAHeXfqRq6 n/8Xsn6CZNszVTmiF5znBg4/iSICJT0riybbfZbX3+CJHWhIGrUbYXn/h8JQdvVisMUr 7pTQ== X-Gm-Message-State: APjAAAVsgL3VI7wIOJo2IEA4tuDaBqMYL/nYzXKAUdtznDhPK2JnnpMi 3g8YXwqZ3L1rDsSdBg3zl3xuUw== X-Received: by 2002:a2e:8608:: with SMTP id a8mr2576547lji.172.1573133281587; Thu, 07 Nov 2019 05:28:01 -0800 (PST) Received: from mimer.lan (h-137-65.A159.priv.bahnhof.se. [81.170.137.65]) by smtp.gmail.com with ESMTPSA id y20sm3151507ljd.99.2019.11.07.05.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2019 05:28:00 -0800 (PST) From: Jonas Bonn To: nicolas.dichtel@6wind.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: davem@davemloft.net, Jonas Bonn Subject: [PATCH v3 2/6] rtnetlink: skip namespace change if already effect Date: Thu, 7 Nov 2019 14:27:51 +0100 Message-Id: <20191107132755.8517-3-jonas@norrbonn.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191107132755.8517-1-jonas@norrbonn.se> References: <20191107132755.8517-1-jonas@norrbonn.se> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org RTM_SETLINK uses IFA_TARGET_NETNSID both as a selector for the device to act upon and as a selection of the namespace to move a device in the current namespace to. As such, one ends up in the code path for setting the namespace every time one calls setlink on a device outside the current namespace. This has the unfortunate side effect of setting the 'modified' flag on the device for every pass, resulting in Netlink notifications even when nothing was changed. This patch just makes the namespace switch dependent upon the namespace the device currently resides in. Signed-off-by: Jonas Bonn Acked-by: Nicolas Dichtel --- net/core/rtnetlink.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index aa3924c9813c..a21e7d47135b 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -2394,11 +2394,15 @@ static int do_setlink(const struct sk_buff *skb, goto errout; } - err = dev_change_net_namespace(dev, net, ifname); - put_net(net); - if (err) - goto errout; - status |= DO_SETLINK_MODIFIED; + if (!net_eq(dev_net(dev), net)) { + err = dev_change_net_namespace(dev, net, ifname); + put_net(net); + if (err) + goto errout; + status |= DO_SETLINK_MODIFIED; + } else { + put_net(net); + } } if (tb[IFLA_MAP]) { -- 2.20.1