Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp158727ybx; Tue, 5 Nov 2019 21:41:44 -0800 (PST) X-Google-Smtp-Source: APXvYqxm1Xm2gafR7VB3oC064AVHzGtHxwbSS8vWf/dSWrlwFLo267O6orxwddDLDnq2vXQ8IDng X-Received: by 2002:a17:906:5151:: with SMTP id s17mr2045038ejl.230.1573018904519; Tue, 05 Nov 2019 21:41:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573018904; cv=none; d=google.com; s=arc-20160816; b=N9aIeMj7wD62sAsN1P2+K764bOc/po1TYljny6NojhCPCe67rvQuAXViuIbpkkaLb7 pYgxYYLRBrbkXlWdV4m6CwzfGGll2s0FB4Zi9EVlaz6xKcgZf8DfPAiceCaRgCcizlIA SLImYQayL4GkBV1LEW7MUyLfOj6cyQHifjxY+LNbYpgwmLQ6KceQHLzgGhM+Xa+5CzWh Les35VynLcLJPidvfeCBOIpBBl+xuDNN3prB0OyJ7RhMkfpCcA++cqAI6VSfZG9yetQg 2ORHlE8VLWbekcxXP0r+QosNbv+HQ03Kpau+2/I3BEjSKGKlkllaB2/AjXPGzu2SzkwG vxiQ== 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=qGTjy+zcT2e1yA2MRPN9kM8zQu04YAnRCawlHATxUEY=; b=YCL3u7llhTZ2A9kQiNhbPMUXnFjmrnCgkTbubz1zt6Ts3o4HJU80pNDjTklI9kEvJq dSdUsfgRFak+yTWsrfKmU/JyYfBHVrMwhvw0LChbEDxAUnIoBpnaSAC7kPO/lDTJSMGG Yzlnt9BCJlwJ90g42CrIdsFouBtDjAhsl6BBzF4m3DgbuoH0pzGtsSASNgM9TOMm0OaE rNDFmFAFv7XDLctv4pglpmlF6+oGLwpCpoWFlY2H+eMVt5opvbbTlZ7gpdIt84TDVA8K oiUhFM8yJGbQaUTg1/qk/nTnilkXzMXmUKvIZhu3kkDCCNZ1xgezZ38lTlEIJYfDZWK7 sSYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@norrbonn-se.20150623.gappssmtp.com header.s=20150623 header.b=iDxUcWfd; 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 e22si12554297ede.163.2019.11.05.21.41.21; Tue, 05 Nov 2019 21:41:44 -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=iDxUcWfd; 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 S1730804AbfKFFje (ORCPT + 99 others); Wed, 6 Nov 2019 00:39:34 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:34255 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726129AbfKFFjc (ORCPT ); Wed, 6 Nov 2019 00:39:32 -0500 Received: by mail-lf1-f65.google.com with SMTP id f5so17021536lfp.1 for ; Tue, 05 Nov 2019 21:39:31 -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=qGTjy+zcT2e1yA2MRPN9kM8zQu04YAnRCawlHATxUEY=; b=iDxUcWfdUHYZ/NBlpYtSpzwyYzs45fHX7CfDnHpADcUHV5bPMOnA5iRTSYFgvv6JVE yq1HLts+QnQdzuJcXZXV/VHM3l9sCKUpDiovdVazyxRaC5+k2D9Cx4gaghh61dB2+qLZ leW1hID+/RSS6eexexqstw+iUv9vp7lketEtgr2ExOw1RkNpcWiewNKPTBeLjn641k2G RZMZiLSNsYxXYduxF7cI184bLn58OzZFMlmJUokHMuL3YdxDX9VkgFe5MafgWnHOQ6aE YZFzf8lRKoZmRr+MnqiUuHD2j5jQc9/FytmCniiKWmvkjYz/YCd/Xlne1VDzJPcBGhGV NhXA== 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=qGTjy+zcT2e1yA2MRPN9kM8zQu04YAnRCawlHATxUEY=; b=P6OU9dxZJNjCSNRBh9I3NulcIudI3NHwpAdofkjlz4peaZvM4lT5t7lq+MqW4L2iyz 8QsfKl+SyX9pA8GUpkIETg76PmDwBbM8kEyesGyVqReTjDbwr/VDVb10fohiPdBHoV7o v/ALOSHCw+koiV4qKBjUJjr3TFjqfImY3co48D+tKoWfhE1np7ST7ucsvtLMNNVpzSFu hPIaMh8sQFesqkaqzar9DNXnMihA56cvL1Jcz4CfXKHQV9tg+8uMxGpPfPrLaDCKZnZE Ryar+n2F7OLB7wWENumGHIldsfqsC3LPMJNR6M3SnZXZJdIKhyUVOMLeVcDD4oEHGvMH IDCA== X-Gm-Message-State: APjAAAU41djSEF+VHKqjBRZBf5P/enoQUatB1kOfB+0WO3k2SKWrIbqU D6qyGMv38AsJUhupUKiaosGpUw== X-Received: by 2002:a19:a8b:: with SMTP id 133mr23468345lfk.136.1573018770875; Tue, 05 Nov 2019 21:39:30 -0800 (PST) Received: from mimer.lan (h-137-65.A159.priv.bahnhof.se. [81.170.137.65]) by smtp.gmail.com with ESMTPSA id c22sm754737ljk.43.2019.11.05.21.39.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 21:39:30 -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 v2 2/5] rtnetlink: skip namespace change if already effect Date: Wed, 6 Nov 2019 06:39:20 +0100 Message-Id: <20191106053923.10414-3-jonas@norrbonn.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191106053923.10414-1-jonas@norrbonn.se> References: <20191106053923.10414-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 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