aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/sctp/protocol.c3
-rw-r--r--net/sctp/socket.c21
2 files changed, 5 insertions, 19 deletions
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 4e6b59e8b695..81b26c5ffd4b 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1172,9 +1172,6 @@ SCTP_STATIC __init int sctp_init(void)
1172 sctp_port_hashtable[i].chain = NULL; 1172 sctp_port_hashtable[i].chain = NULL;
1173 } 1173 }
1174 1174
1175 spin_lock_init(&sctp_port_alloc_lock);
1176 sctp_port_rover = sysctl_local_port_range[0] - 1;
1177
1178 printk(KERN_INFO "SCTP: Hash tables configured " 1175 printk(KERN_INFO "SCTP: Hash tables configured "
1179 "(established %d bind %d)\n", 1176 "(established %d bind %d)\n",
1180 sctp_assoc_hashsize, sctp_port_hashsize); 1177 sctp_assoc_hashsize, sctp_port_hashsize);
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;