From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org,
Nicolas Dichtel <nicolas.dichtel@6wind.com>,
Jamal Hadi Salim <jhs@mojatatu.com>
Subject: [PATCH net-next 2/2] netns: fix error code when the nsid is already used
Date: Fri, 9 Jun 2017 14:41:57 +0200 [thread overview]
Message-ID: <1497012117-1344-2-git-send-email-nicolas.dichtel@6wind.com> (raw)
In-Reply-To: <1497012117-1344-1-git-send-email-nicolas.dichtel@6wind.com>
When the user tries to assign a specific nsid, idr_alloc() is called with
the range [nsid, nsid+1]. If this nsid is already used, idr_alloc() returns
ENOSPC (No space left on device). In our case, it's better to return
EEXIST to make it clear that the nsid is not available.
CC: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
net/core/net_namespace.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 1f60c180e2de..2178db8e47cd 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -642,6 +642,7 @@ static int rtnl_net_newid(struct sk_buff *skb, struct nlmsghdr *nlh,
rtnl_net_notifyid(net, RTM_NEWNSID, err);
err = 0;
} else if (err == -ENOSPC && nsid >= 0) {
+ err = -EEXIST;
NL_SET_BAD_ATTR(extack, tb[NETNSA_NSID]);
NL_SET_ERR_MSG(extack, "The specified nsid is already used");
}
--
2.8.1
next prev parent reply other threads:[~2017-06-09 13:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-09 12:41 [PATCH net-next 1/2] netns: define extack error msg for nsis cmds Nicolas Dichtel
2017-06-09 12:41 ` Nicolas Dichtel [this message]
2017-06-10 19:59 ` [PATCH net-next 2/2] netns: fix error code when the nsid is already used David Miller
2017-06-10 19:59 ` [PATCH net-next 1/2] netns: define extack error msg for nsis cmds David Miller
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=1497012117-1344-2-git-send-email-nicolas.dichtel@6wind.com \
--to=nicolas.dichtel@6wind.com \
--cc=davem@davemloft.net \
--cc=jhs@mojatatu.com \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).