[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191107132755.8517-3-jonas@norrbonn.se>
Date: Thu, 7 Nov 2019 14:27:51 +0100
From: Jonas Bonn <jonas@...rbonn.se>
To: nicolas.dichtel@...nd.com, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: davem@...emloft.net, Jonas Bonn <jonas@...rbonn.se>
Subject: [PATCH v3 2/6] rtnetlink: skip namespace change if already effect
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 <jonas@...rbonn.se>
Acked-by: Nicolas Dichtel <nicolas.dichtel@...nd.com>
---
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
Powered by blists - more mailing lists