From 413ff5cddcb80254dca9b9d79133e357822f4f04 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 10 Oct 2007 17:30:18 -0700 Subject: [PATCH] --- yaml --- r: 67053 b: refs/heads/master c: 06393009000779b00a558fd2f280882cc7dc2008 h: refs/heads/master i: 67051: c9b490f4c0fd23e69125fcf43f2ed5ac6562e29e v: v3 --- [refs] | 2 +- trunk/include/net/sctp/structs.h | 2 -- trunk/net/sctp/protocol.c | 3 --- trunk/net/sctp/socket.c | 21 +++++---------------- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/[refs] b/[refs] index 09728f4cd13f..0b9fc005dd1a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3c0cfc135829b98f7a4894938652f9ef78e24237 +refs/heads/master: 06393009000779b00a558fd2f280882cc7dc2008 diff --git a/trunk/include/net/sctp/structs.h b/trunk/include/net/sctp/structs.h index 448f713a0205..ef892e00c833 100644 --- a/trunk/include/net/sctp/structs.h +++ b/trunk/include/net/sctp/structs.h @@ -197,8 +197,6 @@ extern struct sctp_globals { /* This is the sctp port control hash. */ int port_hashsize; - int port_rover; - spinlock_t port_alloc_lock; /* Protects port_rover. */ struct sctp_bind_hashbucket *port_hashtable; /* This is the global local address list. diff --git a/trunk/net/sctp/protocol.c b/trunk/net/sctp/protocol.c index 4e6b59e8b695..81b26c5ffd4b 100644 --- a/trunk/net/sctp/protocol.c +++ b/trunk/net/sctp/protocol.c @@ -1172,9 +1172,6 @@ SCTP_STATIC __init int sctp_init(void) sctp_port_hashtable[i].chain = NULL; } - spin_lock_init(&sctp_port_alloc_lock); - sctp_port_rover = sysctl_local_port_range[0] - 1; - printk(KERN_INFO "SCTP: Hash tables configured " "(established %d bind %d)\n", sctp_assoc_hashsize, sctp_port_hashsize); diff --git a/trunk/net/sctp/socket.c b/trunk/net/sctp/socket.c index f3e1a9c811ad..7cd58ef84eda 100644 --- a/trunk/net/sctp/socket.c +++ b/trunk/net/sctp/socket.c @@ -5314,22 +5314,13 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) sctp_local_bh_disable(); if (snum == 0) { - /* Search for an available port. - * - * 'sctp_port_rover' was the last port assigned, so - * we start to search from 'sctp_port_rover + - * 1'. What we do is first check if port 'rover' is - * already in the hash table; if not, we use that; if - * it is, we try next. - */ - int low = sysctl_local_port_range[0]; - int high = sysctl_local_port_range[1]; - int remaining = (high - low) + 1; - int rover; + /* Search for an available port. */ + unsigned int low = sysctl_local_port_range[0]; + unsigned int high = sysctl_local_port_range[1]; + unsigned int remaining = (high - low) + 1; + unsigned int rover = net_random() % remaining + low; int index; - sctp_spin_lock(&sctp_port_alloc_lock); - rover = sctp_port_rover; do { rover++; if ((rover < low) || (rover > high)) @@ -5344,8 +5335,6 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) next: sctp_spin_unlock(&head->lock); } while (--remaining > 0); - sctp_port_rover = rover; - sctp_spin_unlock(&sctp_port_alloc_lock); /* Exhausted local port range during search? */ ret = 1;