Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jeff Layton and committed by
Linus Torvalds
713e00a3 a66c04b4

+2 -14
+2 -14
net/sctp/associola.c
··· 66 66 static void sctp_assoc_free_asconf_acks(struct sctp_association *asoc); 67 67 static void sctp_assoc_free_asconf_queue(struct sctp_association *asoc); 68 68 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 - 76 69 /* 1st Level Abstractions. */ 77 70 78 71 /* Initialize a new association from provided memory. */ ··· 1594 1601 if (preload) 1595 1602 idr_preload(gfp); 1596 1603 spin_lock_bh(&sctp_assocs_id_lock); 1597 - /* 0 is not a valid id, idr_low is always >= 1 */ 1598 - ret = idr_alloc(&sctp_assocs_id, asoc, idr_low, 0, GFP_NOWAIT); 1599 - if (ret >= 0) { 1600 - idr_low = ret + 1; 1601 - if (idr_low == INT_MAX) 1602 - idr_low = 1; 1603 - } 1604 + /* 0 is not a valid assoc_id, must be >= 1 */ 1605 + ret = idr_alloc_cyclic(&sctp_assocs_id, asoc, 1, 0, GFP_NOWAIT); 1604 1606 spin_unlock_bh(&sctp_assocs_id_lock); 1605 1607 if (preload) 1606 1608 idr_preload_end();