Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp473231ybx; Tue, 5 Nov 2019 00:12:37 -0800 (PST) X-Google-Smtp-Source: APXvYqxkqA22DENrFSw/+9FJtJYNRQjDVasSKb+waMJVJEIcf990IyQA4gyf3DZI7JhinKTto1Ld X-Received: by 2002:a17:906:4e53:: with SMTP id g19mr23858396ejw.286.1572941557778; Tue, 05 Nov 2019 00:12:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572941557; cv=none; d=google.com; s=arc-20160816; b=MCaVjzEWSmkUu0VvBdn2AdYvriiQMpiMC54DWO30+LojjMIRwVgZkHSgscKRn31TpV U/K7Yrd5lalOVc35agruCYzjKgqn2cnYVW/yZVRqntyr2ljp8bmDGGlrjVBsbEDxBy0X SKQ4Lo6X2gZkzE7dfwyQ7Jpi8+tth5U3E42hsPUURSI1jenRbu/nUJcS9JBi9Def5g7H JkhgvRmRgnJQUQdvwSTjfVMj5ljDjfwdU5gM+KK7rQPJ7EO+wUvRFxc1qIa2YpW6KiXh Dri3uLvbN/uJfXAQQgNl84wpogRDeYcKnnWDEKJEDSziCSxrZFV1DpGUgRllf+J3dMiH ciFQ== 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=nnPxUgcY+eJznzWuRNBGSFKsUKuKOJYTW/84Xz2aVtI=; b=IY4LPmwV21csWzeHhkD8iqTvNLQRQJLH1F2qvioIsnA2qu2UyMOC7v2GvgtTTU8eOX rWWbgrctnFw5qvx6tTkiA7Pb5wG9f7J5sePeueXxQtGCuxXrhB8OdTgLEmidXS/pPolg UzyuM+afQQiRh1nSL1DGMPF2c/J3wLf8c7xVAObsnx0xcNks7D3DICnXa0YJNkZQTSBX VteF3p8uX8m9sw3Do8U00oNpHHcwWwPRa6+YqXquNvmWDLVHXq7x5kf4RBMvp5yfZuLh fOCkGHJlDAbOUG/ivHVgSKzvZajMumFsQ5B9NVCExRLZ2luisCn1BLGFd5uzCkrdQFIK jhzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@norrbonn-se.20150623.gappssmtp.com header.s=20150623 header.b=ALbnm26q; 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 35si10150560edl.409.2019.11.05.00.12.13; Tue, 05 Nov 2019 00:12:37 -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=ALbnm26q; 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 S2388030AbfKEIL2 (ORCPT + 99 others); Tue, 5 Nov 2019 03:11:28 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:38212 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388182AbfKEIL1 (ORCPT ); Tue, 5 Nov 2019 03:11:27 -0500 Received: by mail-lj1-f196.google.com with SMTP id v8so5049822ljh.5 for ; Tue, 05 Nov 2019 00:11:26 -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=nnPxUgcY+eJznzWuRNBGSFKsUKuKOJYTW/84Xz2aVtI=; b=ALbnm26qSw3qBI6lwMVbfQgweiwJhyxCdMHw/LwqnaCS272kbxVvPcR76yPD8jg8vn uPMaImK/pL75XFyu5TLMoTandyhlAIQR293BUbWt7WAA3r1AqUDNAp2G3BrXsBHs/Vlz Mx/SRmaZ1ZhCSjuuLMu/Oa/arJ/oaQdFsPYWvCnXadICxJEeVFugRYJnL+aweXDefKd7 b9ne6Wx5s0X5ASMeij7ukUWXVRVSQ+9d0XmlnwlzIgdVZ0+5SBKoQbj1AI3yZa8AJLXX +C4U2A21AKXVI4ClSgnbd3Ve8hiRCGOtd2IS6CHBNFlVYQFshSd5Tpo6TkAEQ0vgwfKk OIeQ== 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=nnPxUgcY+eJznzWuRNBGSFKsUKuKOJYTW/84Xz2aVtI=; b=M3cVSmwSos2NF0YVieD/EUaizveZkiEkb0QTV/dbJbK8+vfgzF9I+0sQkb5UDF3THU HtCGKkGHzj0OguLVSgxPmOPVKTRSRtNMwVld8SZYRNPzxQBQQYeo9kxMlsZvNA10uMj2 E2tfb85Zeo+YHeU2je8tg4bPi2UbF3K8614BCmaD9OtKh4hzu0pXadjGLBuID4ibp0PS 59XRkxbomDGVTG0Sh6xSphpaSOiyUK6Jlb9XwTTm3oyaDmtpuaHmzJDrgBHoriJmplw/ n/bGG0RHkcQvjkE/lvhhoLVr6I7pyvqPu2lKH4P3xlSGXcpeH1TBuZdSYMHCJ6/FZGQ1 xeog== X-Gm-Message-State: APjAAAWkouGylwK3t9owMC61zkLTvJGpudaBd4kBdG79evhhFbFPUDPS obl6uByySpMol3+Hqp27PRj+iA== X-Received: by 2002:a2e:b5a2:: with SMTP id f2mr21485342ljn.108.1572941485453; Tue, 05 Nov 2019 00:11:25 -0800 (PST) Received: from mimer.lulea.netrounds.lan ([195.22.87.57]) by smtp.gmail.com with ESMTPSA id m7sm7275986lfp.22.2019.11.05.00.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 00:11:24 -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 2/5] rtnetlink: skip namespace change if already effect Date: Tue, 5 Nov 2019 09:11:09 +0100 Message-Id: <20191105081112.16656-3-jonas@norrbonn.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191105081112.16656-1-jonas@norrbonn.se> References: <20191105081112.16656-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 --- 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 269d1afefceb..a6ec1b4ff7cd 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -2393,11 +2393,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