aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r--net/sctp/socket.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index f3e1a9c811ad..7cd58ef84eda 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -5314,22 +5314,13 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
5314 sctp_local_bh_disable(); 5314 sctp_local_bh_disable();
5315 5315
5316 if (snum == 0) { 5316 if (snum == 0) {
5317 /* Search for an available port. 5317 /* Search for an available port. */
5318 * 5318 unsigned int low = sysctl_local_port_range[0];
5319 * 'sctp_port_rover' was the last port assigned, so 5319 unsigned int high = sysctl_local_port_range[1];
5320 * we start to search from 'sctp_port_rover + 5320 unsigned int remaining = (high - low) + 1;
5321 * 1'. What we do is first check if port 'rover' is 5321 unsigned int rover = net_random() % remaining + low;
5322 * already in the hash table; if not, we use that; if
5323 * it is, we try next.
5324 */
5325 int low = sysctl_local_port_range[0];
5326 int high = sysctl_local_port_range[1];
5327 int remaining = (high - low) + 1;
5328 int rover;
5329 int index; 5322 int index;
5330 5323
5331 sctp_spin_lock(&sctp_port_alloc_lock);
5332 rover = sctp_port_rover;
5333 do { 5324 do {
5334 rover++; 5325 rover++;
5335 if ((rover < low) || (rover > high)) 5326 if ((rover < low) || (rover > high))
@@ -5344,8 +5335,6 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
5344 next: 5335 next:
5345 sctp_spin_unlock(&head->lock); 5336 sctp_spin_unlock(&head->lock);
5346 } while (--remaining > 0); 5337 } while (--remaining > 0);
5347 sctp_port_rover = rover;
5348 sctp_spin_unlock(&sctp_port_alloc_lock);
5349 5338
5350 /* Exhausted local port range during search? */ 5339 /* Exhausted local port range during search? */
5351 ret = 1; 5340 ret = 1;