From 37bd2b301c48c7dcb00f1dfdfba81c0e040b4ed5 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Wed, 30 Oct 1996 06:13:10 +0000 Subject: [PATCH] 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. --- sys/netinet/in_pcb.c | 7 +++++-- sys/netinet/in_pcb.h | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index ceebbd94c77..e5da5fc54c2 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -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 @@ -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 diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 685c66d79de..723d4ecdbb0 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -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: */