diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-07-27 08:11:11 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-07-27 08:11:11 +0000 |
commit | db8da3d4df48f8d02c58f033fc5f6ecea949c049 (patch) | |
tree | a005a27fd06209637c9cea1a1204240f4b69347e | |
parent | f0244dfb726fb9a6f5591409663e8deafacb94c4 (diff) |
hardcode list of ports to not randomly allocate; will add configuration later
-rw-r--r-- | sys/netinet/in_pcb.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index b5a5690d493..086fd79b3f9 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.16 1997/04/17 02:02:26 deraadt Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.17 1997/07/27 08:11:10 deraadt Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -77,6 +77,8 @@ int ipport_hilastauto = IPPORT_HILASTAUTO; /* 44999 */ #define INPCBHASH(table, faddr, fport, laddr, lport) \ &(table)->inpt_hashtbl[(ntohl((faddr)->s_addr) + ntohs((fport)) + ntohs((lport))) & (table->inpt_hash)] +static int baddynamic __P((u_int16_t)); + void in_pcbinit(table, hashsize) struct inpcbtable *table; @@ -88,6 +90,30 @@ in_pcbinit(table, hashsize) table->inpt_lastport = 0; } +/* + * List of standard locked-down reserved ports. + * XXX need to be able to modify this from userland. + */ +static u_int16_t baddynamicports[] = { + 765, 749, 750, 751, 760, 761, 871, + 0 /* terminator */ +}; + +/* + * Check if the specified port is invalid for dynamic allocation. + */ +static int +baddynamic(port) + u_int16_t port; +{ + int i; + + for (i = 0; baddynamicports[i] != 0; i++) + if (baddynamicports[i] == port) + return (1); + return (0); +} + int in_pcballoc(so, v) struct socket *so; @@ -237,7 +263,8 @@ portloop: if (*lastport > first || *lastport < last) *lastport = first; lport = htons(*lastport); - } while (in_pcblookup(table, zeroin_addr, 0, + } while (baddynamic(*lastport) || + in_pcblookup(table, zeroin_addr, 0, inp->inp_laddr, lport, wild)); } else { /* @@ -263,7 +290,8 @@ portloop: if (*lastport < first || *lastport > last) *lastport = first; lport = htons(*lastport); - } while (in_pcblookup(table, zeroin_addr, 0, + } while (baddynamic(*lastport) || + in_pcblookup(table, zeroin_addr, 0, inp->inp_laddr, lport, wild)); } } |