reserve a port range for unprivileged servers
authorMike Karels <karels@ucbvax.Berkeley.EDU>
Sun, 2 Feb 1986 13:17:19 +0000 (05:17 -0800)
committerMike Karels <karels@ucbvax.Berkeley.EDU>
Sun, 2 Feb 1986 13:17:19 +0000 (05:17 -0800)
SCCS-vsn: sys/netinet/in.h 6.9
SCCS-vsn: sys/netinet/in_pcb.c 6.11

usr/src/sys/netinet/in.h
usr/src/sys/netinet/in_pcb.c

index 0853bff..2af66ff 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)in.h        6.8 (Berkeley) %G%
+ *     @(#)in.h        6.9 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
 /*
  * Ports < IPPORT_RESERVED are reserved for
  * privileged processes (e.g. root).
 /*
  * Ports < IPPORT_RESERVED are reserved for
  * privileged processes (e.g. root).
+ * Ports > IPPORT_USERRESERVED are reserved
+ * for servers, not necessarily privileged.
  */
 #define        IPPORT_RESERVED         1024
  */
 #define        IPPORT_RESERVED         1024
+#define        IPPORT_USERRESERVED     5000
 
 /*
  * Link numbers
 
 /*
  * Link numbers
index fd325b1..a901bb2 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)in_pcb.c    6.10 (Berkeley) %G%
+ *     @(#)in_pcb.c    6.11 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -89,7 +89,8 @@ in_pcbbind(inp, nam)
 noname:
        if (lport == 0)
                do {
 noname:
        if (lport == 0)
                do {
-                       if (head->inp_lport++ < IPPORT_RESERVED)
+                       if (head->inp_lport++ < IPPORT_RESERVED ||
+                           head->inp_lport > IPPORT_USERRESERVED)
                                head->inp_lport = IPPORT_RESERVED;
                        lport = htons(head->inp_lport);
                } while (in_pcblookup(head,
                                head->inp_lport = IPPORT_RESERVED;
                        lport = htons(head->inp_lport);
                } while (in_pcblookup(head,