public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Flavio Leitner <fbl@sysclose•org>
To: netdev@vger•kernel.org
Cc: Flavio Leitner <fbl@sysclose•org>
Subject: [PATCH net-next] netlink: include netnsid only when netns differs.
Date: Tue, 30 May 2017 18:33:25 -0300	[thread overview]
Message-ID: <20170530213325.21652-1-fbl@sysclose.org> (raw)

Don't include netns id for notifications broadcasts when the
socket and the skb are in the same netns because it will be
an error which can't be distinguished from a peer netns failing
to allocate an id.

Signed-off-by: Flavio Leitner <fbl@sysclose•org>
---
 net/netlink/af_netlink.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index ee841f0..b9f1392 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1414,8 +1414,10 @@ static void do_one_broadcast(struct sock *sk,
 		p->skb2 = NULL;
 		goto out;
 	}
-	NETLINK_CB(p->skb2).nsid = peernet2id(sock_net(sk), p->net);
-	NETLINK_CB(p->skb2).nsid_is_set = true;
+	if (!net_eq(sock_net(sk), p->net)) {
+		NETLINK_CB(p->skb2).nsid = peernet2id(sock_net(sk), p->net);
+		NETLINK_CB(p->skb2).nsid_is_set = true;
+	}
 	val = netlink_broadcast_deliver(sk, p->skb2);
 	if (val < 0) {
 		netlink_overrun(sk);
-- 
2.9.4

             reply	other threads:[~2017-05-30 21:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-30 21:33 Flavio Leitner [this message]
2017-05-31  8:38 ` [PATCH net-next] netlink: include netnsid only when netns differs Nicolas Dichtel
2017-05-31 12:28   ` Flavio Leitner
2017-05-31 13:48     ` Nicolas Dichtel
2017-05-31 18:34       ` Flavio Leitner
2017-06-01  7:57         ` Nicolas Dichtel
2017-06-01  8:00           ` [PATCH net] netlink: don't send unknown nsid Nicolas Dichtel
2017-06-01 15:50             ` David Miller
2017-06-01 17:02             ` Flavio Leitner
2017-06-01 20:42               ` Nicolas Dichtel
2017-06-01 22:44                 ` Flavio Leitner
2017-06-05  8:40                   ` Nicolas Dichtel
2017-06-07 18:40                     ` Flavio Leitner
2017-06-08  8:31                       ` Nicolas Dichtel
2017-06-09 17:33                         ` Flavio Leitner

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=20170530213325.21652-1-fbl@sysclose.org \
    --to=fbl@sysclose$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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