Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 713e00a3 authored by Jeff Layton's avatar Jeff Layton Committed by Linus Torvalds
Browse files

sctp: convert sctp_assoc_set_id() to use idr_alloc_cyclic()



Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Cc: Vlad Yasevich <vyasevich@gmail.com>
Cc: Sridhar Samudrala <sri@us.ibm.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a66c04b4
Loading
Loading
Loading
Loading
+2 −14
Original line number Original line Diff line number Diff line
@@ -66,13 +66,6 @@ static void sctp_assoc_bh_rcv(struct work_struct *work);
static void sctp_assoc_free_asconf_acks(struct sctp_association *asoc);
static void sctp_assoc_free_asconf_acks(struct sctp_association *asoc);
static void sctp_assoc_free_asconf_queue(struct sctp_association *asoc);
static void sctp_assoc_free_asconf_queue(struct sctp_association *asoc);


/* Keep track of the new idr low so that we don't re-use association id
 * numbers too fast.  It is protected by they idr spin lock is in the
 * range of 1 - INT_MAX.
 */
static u32 idr_low = 1;


/* 1st Level Abstractions. */
/* 1st Level Abstractions. */


/* Initialize a new association from provided memory. */
/* Initialize a new association from provided memory. */
@@ -1601,13 +1594,8 @@ int sctp_assoc_set_id(struct sctp_association *asoc, gfp_t gfp)
	if (preload)
	if (preload)
		idr_preload(gfp);
		idr_preload(gfp);
	spin_lock_bh(&sctp_assocs_id_lock);
	spin_lock_bh(&sctp_assocs_id_lock);
	/* 0 is not a valid id, idr_low is always >= 1 */
	/* 0 is not a valid assoc_id, must be >= 1 */
	ret = idr_alloc(&sctp_assocs_id, asoc, idr_low, 0, GFP_NOWAIT);
	ret = idr_alloc_cyclic(&sctp_assocs_id, asoc, 1, 0, GFP_NOWAIT);
	if (ret >= 0) {
		idr_low = ret + 1;
		if (idr_low == INT_MAX)
			idr_low = 1;
	}
	spin_unlock_bh(&sctp_assocs_id_lock);
	spin_unlock_bh(&sctp_assocs_id_lock);
	if (preload)
	if (preload)
		idr_preload_end();
		idr_preload_end();