summaryrefslogtreecommitdiff
path: root/net/core/net_namespace.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/net_namespace.c')
-rw-r--r--net/core/net_namespace.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 300322bcf8d7..217021eeab13 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -270,14 +270,19 @@ static void ops_undo_single(struct pernet_operations *ops,
/* should be called with nsid_lock held */
static int alloc_netid(struct net *net, struct net *peer, int reqid)
{
- int min = 0, max = 0;
+ int ret;
+ u32 id;
if (reqid >= 0) {
- min = reqid;
- max = reqid + 1;
+ id = reqid;
+ ret = idr_alloc_u32(&net->netns_ids, peer, &id, id,
+ GFP_ATOMIC);
+ if (ret)
+ return ret;
+ return id;
}
- return idr_alloc(&net->netns_ids, peer, min, max, GFP_ATOMIC);
+ return idr_alloc(&net->netns_ids, peer, 0, 0, GFP_ATOMIC);
}
/* This function is used by idr_for_each(). If net is equal to peer, the
@@ -639,10 +644,10 @@ static void unhash_nsid(struct net *last)
* use for_each_net_rcu() or net_rwsem.
*/
for_each_net(tmp) {
- int id = 0;
+ unsigned long id = 0;
spin_lock(&tmp->nsid_lock);
- while ((peer = idr_get_next(&tmp->netns_ids, &id))) {
+ while ((peer = idr_get_next_ul(&tmp->netns_ids, &id))) {
int curr_id = id;
id++;