From: Jonas Bonn <jonas@norrbonn.se>
To: nicolas.dichtel@6wind.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: davem@davemloft.net, Jonas Bonn <jonas@norrbonn.se>
Subject: [PATCH 2/5] rtnetlink: skip namespace change if already effect
Date: Tue, 5 Nov 2019 09:11:09 +0100 [thread overview]
Message-ID: <20191105081112.16656-3-jonas@norrbonn.se> (raw)
In-Reply-To: <20191105081112.16656-1-jonas@norrbonn.se>
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@norrbonn.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
next prev parent reply other threads:[~2019-11-05 8:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-05 8:11 [PATCH 0/5] Add namespace awareness to Netlink methods Jonas Bonn
2019-11-05 8:11 ` [PATCH 1/5] rtnetlink: allow RTM_SETLINK to reference other namespaces Jonas Bonn
2019-11-05 15:41 ` Nicolas Dichtel
2019-11-05 8:11 ` Jonas Bonn [this message]
2019-11-05 15:42 ` [PATCH 2/5] rtnetlink: skip namespace change if already effect Nicolas Dichtel
2019-11-05 8:11 ` [PATCH 3/5] rtnetlink: allow RTM_NEWLINK to act upon interfaces in arbitrary namespaces Jonas Bonn
2019-11-05 15:43 ` Nicolas Dichtel
2019-11-05 8:11 ` [PATCH 4/5] net: ipv4: allow setting address on interface outside current namespace Jonas Bonn
2019-11-05 15:47 ` Nicolas Dichtel
2019-11-05 8:11 ` [PATCH 5/5] net: namespace: allow setting NSIDs " Jonas Bonn
2019-11-05 15:49 ` Nicolas Dichtel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191105081112.16656-3-jonas@norrbonn.se \
--to=jonas@norrbonn.se \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.dichtel@6wind.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®