Skip to content

Commit 713e00a

Browse files
jtlaytontorvalds
authored andcommitted
sctp: convert sctp_assoc_set_id() to use idr_alloc_cyclic()
Signed-off-by: Jeff 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a66c04b commit 713e00a

1 file changed

Lines changed: 2 additions & 14 deletions

File tree

‎net/sctp/associola.c‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,6 @@ static void sctp_assoc_bh_rcv(struct work_struct *work);
6666
static void sctp_assoc_free_asconf_acks(struct sctp_association *asoc);
6767
static void sctp_assoc_free_asconf_queue(struct sctp_association *asoc);
6868

69-
/* Keep track of the new idr low so that we don't re-use association id
70-
* numbers too fast. It is protected by they idr spin lock is in the
71-
* range of 1 - INT_MAX.
72-
*/
73-
static u32 idr_low = 1;
74-
75-
7669
/* 1st Level Abstractions. */
7770

7871
/* Initialize a new association from provided memory. */
@@ -1601,13 +1594,8 @@ int sctp_assoc_set_id(struct sctp_association *asoc, gfp_t gfp)
16011594
if (preload)
16021595
idr_preload(gfp);
16031596
spin_lock_bh(&sctp_assocs_id_lock);
1604-
/* 0 is not a valid id, idr_low is always >= 1 */
1605-
ret = idr_alloc(&sctp_assocs_id, asoc, idr_low, 0, GFP_NOWAIT);
1606-
if (ret >= 0) {
1607-
idr_low = ret + 1;
1608-
if (idr_low == INT_MAX)
1609-
idr_low = 1;
1610-
}
1597+
/* 0 is not a valid assoc_id, must be >= 1 */
1598+
ret = idr_alloc_cyclic(&sctp_assocs_id, asoc, 1, 0, GFP_NOWAIT);
16111599
spin_unlock_bh(&sctp_assocs_id_lock);
16121600
if (preload)
16131601
idr_preload_end();

0 commit comments

Comments
 (0)