diff options
author | 2015-09-22 09:34:38 +0000 | |
---|---|---|
committer | 2015-09-22 09:34:38 +0000 | |
commit | 7163a082540e7dd7e7da2baaf87ea9453053379f (patch) | |
tree | ac550ebf7a33889abb3bd8b3a365a3af4b1981f7 /sys/netinet6 | |
parent | regen (diff) | |
download | wireguard-openbsd-7163a082540e7dd7e7da2baaf87ea9453053379f.tar.xz wireguard-openbsd-7163a082540e7dd7e7da2baaf87ea9453053379f.zip |
Remove inpt_lastport from struct inpcbtable, use local variables
in in_pcbbind() and in6_pcbsetport()
ok claudio@, with input from David Hill
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/in6_pcb.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 77d252a575f..866fc9cf800 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_pcb.c,v 1.74 2015/09/11 15:29:47 deraadt Exp $ */ +/* $OpenBSD: in6_pcb.c,v 1.75 2015/09/22 09:34:39 vgross Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -294,7 +294,7 @@ in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct proc *p) struct socket *so = inp->inp_socket; struct inpcbtable *table = inp->inp_table; u_int16_t first, last; - u_int16_t *lastport = &inp->inp_table->inpt_lastport; + u_int16_t lastport = 0; u_int16_t lport = 0; int count; int wild = INPLOOKUP_IPV6; @@ -334,16 +334,16 @@ in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct proc *p) */ count = first - last; if (count) - *lastport = first - arc4random_uniform(count); + lastport = first - arc4random_uniform(count); do { if (count-- < 0) /* completely used? */ return (EADDRNOTAVAIL); - --*lastport; - if (*lastport > first || *lastport < last) - *lastport = first; - lport = htons(*lastport); - } while (in_baddynamic(*lastport, so->so_proto->pr_protocol) || + --lastport; + if (lastport > first || lastport < last) + lastport = first; + lport = htons(lastport); + } while (in_baddynamic(lastport, so->so_proto->pr_protocol) || in_pcblookup(table, &zeroin6_addr, 0, &inp->inp_laddr6, lport, wild, inp->inp_rtableid)); } else { @@ -352,16 +352,16 @@ in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct proc *p) */ count = last - first; if (count) - *lastport = first + arc4random_uniform(count); + lastport = first + arc4random_uniform(count); do { if (count-- < 0) /* completely used? */ return (EADDRNOTAVAIL); - ++*lastport; - if (*lastport < first || *lastport > last) - *lastport = first; - lport = htons(*lastport); - } while (in_baddynamic(*lastport, so->so_proto->pr_protocol) || + ++lastport; + if (lastport < first || lastport > last) + lastport = first; + lport = htons(lastport); + } while (in_baddynamic(lastport, so->so_proto->pr_protocol) || in_pcblookup(table, &zeroin6_addr, 0, &inp->inp_laddr6, lport, wild, inp->inp_rtableid)); } |