[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191105081112.16656-3-jonas@norrbonn.se>
Date: Tue, 5 Nov 2019 09:11:09 +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 2/5] 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>
---
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
Powered by blists - more mailing lists