Fix braino on my part. When we have three different port ranges (default,

"high" and "secure"), we can't use a single variable to track the most
recently used port in all three ranges.. :-]  This caused the next
transient port to be allocated from the start of the range more often than
it should.
This commit is contained in:
Peter Wemm 1996-10-30 06:13:10 +00:00
parent d700038439
commit 37bd2b301c
2 changed files with 8 additions and 3 deletions

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)in_pcb.c 8.4 (Berkeley) 5/24/95
* $Id: in_pcb.c,v 1.21 1996/08/23 18:59:05 phk Exp $
* $Id: in_pcb.c,v 1.22 1996/10/07 19:06:07 davidg Exp $
*/
#include <sys/param.h>
@ -140,7 +140,7 @@ in_pcbbind(inp, nam)
struct mbuf *nam;
{
register struct socket *so = inp->inp_socket;
unsigned short *lastport = &inp->inp_pcbinfo->lastport;
unsigned short *lastport;
struct sockaddr_in *sin;
struct proc *p = curproc; /* XXX */
u_short lport = 0;
@ -206,14 +206,17 @@ in_pcbbind(inp, nam)
if (inp->inp_flags & INP_HIGHPORT) {
first = ipport_hifirstauto; /* sysctl */
last = ipport_hilastauto;
lastport = &inp->inp_pcbinfo->lasthi;
} else if (inp->inp_flags & INP_LOWPORT) {
if (error = suser(p->p_ucred, &p->p_acflag))
return (EACCES);
first = ipport_lowfirstauto; /* 1023 */
last = ipport_lowlastauto; /* 600 */
lastport = &inp->inp_pcbinfo->lastlow;
} else {
first = ipport_firstauto; /* sysctl */
last = ipport_lastauto;
lastport = &inp->inp_pcbinfo->lastport;
}
/*
* Simple check to ensure all ports are not used up causing

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
* $Id: in_pcb.h,v 1.12 1996/08/23 18:59:07 phk Exp $
* $Id: in_pcb.h,v 1.13 1996/10/07 19:06:08 davidg Exp $
*/
#ifndef _NETINET_IN_PCB_H_
@ -70,6 +70,8 @@ struct inpcbinfo {
struct inpcbhead *hashbase;
unsigned long hashsize;
unsigned short lastport;
unsigned short lastlow;
unsigned short lasthi;
};
/* flags in inp_flags: */