diff options
| author | Michael Brown | 2007-07-13 12:25:00 +0200 |
|---|---|---|
| committer | Michael Brown | 2007-07-13 12:25:00 +0200 |
| commit | d5735c631cf26d8e1bcf7b5e635623b52d6b48aa (patch) | |
| tree | 16161423ab69c241d08135c1ac8aaaac0c81b782 | |
| parent | Improve error reporting for strange length combinations reported by (diff) | |
| download | ipxe-d5735c631cf26d8e1bcf7b5e635623b52d6b48aa.tar.gz ipxe-d5735c631cf26d8e1bcf7b5e635623b52d6b48aa.tar.xz ipxe-d5735c631cf26d8e1bcf7b5e635623b52d6b48aa.zip | |
Avoid reusing auto-allocated ports after connection close.
| -rw-r--r-- | src/net/tcp.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/net/tcp.c b/src/net/tcp.c index a2908f54e..97d9dea17 100644 --- a/src/net/tcp.c +++ b/src/net/tcp.c @@ -160,11 +160,12 @@ tcp_dump_flags ( struct tcp_connection *tcp, unsigned int flags ) { */ static int tcp_bind ( struct tcp_connection *tcp, unsigned int port ) { struct tcp_connection *existing; - static uint16_t try_port = 1024; + static uint16_t try_port = 1023; /* If no port specified, find the first available port */ if ( ! port ) { - for ( ; try_port ; try_port++ ) { + while ( try_port ) { + try_port++; if ( try_port < 1024 ) continue; if ( tcp_bind ( tcp, htons ( try_port ) ) == 0 ) |
