diff options
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/in_pcb.c | 47 | ||||
-rw-r--r-- | sys/netinet/in_pcb.h | 6 | ||||
-rw-r--r-- | sys/netinet/tcp_input.c | 8 | ||||
-rw-r--r-- | sys/netinet/tcp_usrreq.c | 6 | ||||
-rw-r--r-- | sys/netinet/udp_usrreq.c | 10 |
5 files changed, 50 insertions, 27 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 5d8e28ff09c..82c2c71ef96 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.69 2003/11/04 21:43:16 markus Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.70 2003/12/08 07:07:36 mcbride Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -1055,35 +1055,45 @@ in6_pcbhashlookup(table, faddr, fport_arg, laddr, lport_arg) * *.* <-> *.lport */ struct inpcb * -in_pcblookup_listen(table, laddr, lport_arg) +in_pcblookup_listen(table, laddr, lport_arg, reverse) struct inpcbtable *table; struct in_addr laddr; u_int lport_arg; + int reverse; { struct inpcbhead *head; + struct in_addr *key1, *key2; register struct inpcb *inp; u_int16_t lport = lport_arg; - head = INPCBHASH(table, &zeroin_addr, 0, &laddr, lport); + if (reverse) { + key1 = &zeroin_addr; + key2 = &laddr; + } else { + key1 = &laddr; + key2 = &zeroin_addr; + } + + head = INPCBHASH(table, &zeroin_addr, 0, key1, lport); LIST_FOREACH(inp, head, inp_hash) { #ifdef INET6 if (inp->inp_flags & INP_IPV6) continue; /*XXX*/ #endif if (inp->inp_lport == lport && inp->inp_fport == 0 && - inp->inp_laddr.s_addr == laddr.s_addr && + inp->inp_laddr.s_addr == key1->s_addr && inp->inp_faddr.s_addr == INADDR_ANY) break; } - if (inp == NULL && laddr.s_addr != INADDR_ANY) { - head = INPCBHASH(table, &zeroin_addr, 0, &zeroin_addr, lport); + if (inp == NULL && key1->s_addr != key2->s_addr) { + head = INPCBHASH(table, &zeroin_addr, 0, key2, lport); LIST_FOREACH(inp, head, inp_hash) { #ifdef INET6 if (inp->inp_flags & INP_IPV6) continue; /*XXX*/ #endif if (inp->inp_lport == lport && inp->inp_fport == 0 && - inp->inp_laddr.s_addr == INADDR_ANY && + inp->inp_laddr.s_addr == key2->s_addr && inp->inp_faddr.s_addr == INADDR_ANY) break; } @@ -1108,32 +1118,41 @@ in_pcblookup_listen(table, laddr, lport_arg) #ifdef INET6 struct inpcb * -in6_pcblookup_listen(table, laddr, lport_arg) +in6_pcblookup_listen(table, laddr, lport_arg, reverse) struct inpcbtable *table; struct in6_addr *laddr; u_int lport_arg; + int reverse; { struct inpcbhead *head; + struct in6_addr *key1, *key2; register struct inpcb *inp; u_int16_t lport = lport_arg; - head = IN6PCBHASH(table, &zeroin6_addr, 0, laddr, lport); + if (reverse) { + key1 = &zeroin6_addr; + key2 = laddr; + } else { + key1 = laddr; + key2 = &zeroin6_addr; + } + + head = IN6PCBHASH(table, &zeroin6_addr, 0, key1, lport); LIST_FOREACH(inp, head, inp_hash) { if (!(inp->inp_flags & INP_IPV6)) continue; if (inp->inp_lport == lport && inp->inp_fport == 0 && - IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, laddr) && + IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, key1) && IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6)) break; } - if (inp == NULL && !IN6_IS_ADDR_UNSPECIFIED(laddr)) { - head = IN6PCBHASH(table, &zeroin6_addr, 0, - &zeroin6_addr, lport); + if (inp == NULL && ! IN6_ARE_ADDR_EQUAL(key1, key2)) { + head = IN6PCBHASH(table, &zeroin6_addr, 0, key2, lport); LIST_FOREACH(inp, head, inp_hash) { if (!(inp->inp_flags & INP_IPV6)) continue; if (inp->inp_lport == lport && inp->inp_fport == 0 && - IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6) && + IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, key2) && IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6)) break; } diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 5f5ec71b589..27d411b4a5c 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.h,v 1.47 2003/11/04 21:43:16 markus Exp $ */ +/* $OpenBSD: in_pcb.h,v 1.48 2003/12/08 07:07:36 mcbride Exp $ */ /* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */ /* @@ -239,14 +239,14 @@ struct inpcb * in_pcbhashlookup(struct inpcbtable *, struct in_addr, u_int, struct in_addr, u_int); struct inpcb * - in_pcblookup_listen(struct inpcbtable *, struct in_addr, u_int); + in_pcblookup_listen(struct inpcbtable *, struct in_addr, u_int, int); #ifdef INET6 struct inpcb * in6_pcbhashlookup(struct inpcbtable *, struct in6_addr *, u_int, struct in6_addr *, u_int); struct inpcb * in6_pcblookup_listen(struct inpcbtable *, - struct in6_addr *, u_int); + struct in6_addr *, u_int, int); int in6_pcbbind(struct inpcb *, struct mbuf *); int in6_pcbconnect(struct inpcb *, struct mbuf *); int in6_setsockaddr(struct inpcb *, struct mbuf *); diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index a786851a75a..945076d1f62 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.134 2003/11/04 21:43:16 markus Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.135 2003/12/08 07:07:36 mcbride Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -671,12 +671,14 @@ findpcb: #ifdef INET6 case AF_INET6: inp = in6_pcblookup_listen(&tcbtable, - &ip6->ip6_dst, th->th_dport); + &ip6->ip6_dst, th->th_dport, m_tag_find(m, + PACKET_TAG_PF_TRANSLATE_LOCALHOST, NULL) != NULL); break; #endif /* INET6 */ case AF_INET: inp = in_pcblookup_listen(&tcbtable, - ip->ip_dst, th->th_dport); + ip->ip_dst, th->th_dport, m_tag_find(m, + PACKET_TAG_PF_TRANSLATE_LOCALHOST, NULL) != NULL); break; } /* diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index ff9983289b7..7512d1a99b0 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.72 2003/11/04 21:43:16 markus Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.73 2003/12/08 07:07:36 mcbride Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* @@ -835,12 +835,12 @@ tcp_ident(oldp, oldlenp, newp, newlen) #ifdef INET6 case AF_INET6: inp = in6_pcblookup_listen(&tcbtable, - &l6, lin6->sin6_port); + &l6, lin6->sin6_port, 0); break; #endif case AF_INET: inp = in_pcblookup_listen(&tcbtable, - lin->sin_addr, lin->sin_port); + lin->sin_addr, lin->sin_port, 0); break; } } diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 2d5aed4bbec..b5823ac6073 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.93 2003/12/02 23:16:29 markus Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.94 2003/12/08 07:07:36 mcbride Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -525,11 +525,13 @@ udp_input(struct mbuf *m, ...) #ifdef INET6 if (ip6) { inp = in6_pcblookup_listen(&udbtable, - &ip6->ip6_dst, uh->uh_dport); + &ip6->ip6_dst, uh->uh_dport, m_tag_find(m, + PACKET_TAG_PF_TRANSLATE_LOCALHOST, NULL) != NULL); } else #endif /* INET6 */ inp = in_pcblookup_listen(&udbtable, - ip->ip_dst, uh->uh_dport); + ip->ip_dst, uh->uh_dport, m_tag_find(m, + PACKET_TAG_PF_TRANSLATE_LOCALHOST, NULL) != NULL); if (inp == 0) { udpstat.udps_noport++; if (m->m_flags & (M_BCAST | M_MCAST)) { @@ -820,7 +822,7 @@ udp6_ctlinput(cmd, sa, d) * is really ours. */ else if (in6_pcblookup_listen(&udbtable, - &sa6_src.sin6_addr, uh.uh_sport)) + &sa6_src.sin6_addr, uh.uh_sport, 0); valid = 1; #endif |