diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-02-01 21:46:32 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-02-01 21:46:32 +0000 |
commit | 065ebf549910cdad4cbaeb26ba066fa562c53ab8 (patch) | |
tree | 225c9a2e6ceb6e2b317b01953d0426c3356ed157 /sys | |
parent | 86579f56153e9cbd716800bc46288df3075ed742 (diff) |
undo wildcard loopback stuff; it was not checked by other developers
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/in_pcb.c | 18 | ||||
-rw-r--r-- | sys/netinet/ip_input.c | 54 | ||||
-rw-r--r-- | sys/netinet/ip_var.h | 4 |
3 files changed, 30 insertions, 46 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index b3e4c49bc02..118074916a8 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.20 1998/02/01 18:09:22 mickey Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.21 1998/02/01 21:46:02 deraadt Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -189,7 +189,7 @@ in_pcbbind(v, nam) reuseport = SO_REUSEADDR|SO_REUSEPORT; } else if (sin->sin_addr.s_addr != INADDR_ANY) { sin->sin_port = 0; /* yech... */ - if (in_iawithaddr(sin->sin_addr, NULL) == 0) + if (ifa_ifwithaddr(sintosa(sin)) == 0) return (EADDRNOTAVAIL); } if (lport) { @@ -206,7 +206,7 @@ in_pcbbind(v, nam) return (EADDRINUSE); } t = in_pcblookup(table, zeroin_addr, 0, - sin->sin_addr, lport, wild); + sin->sin_addr, lport, wild); if (t && (reuseport & t->inp_socket->so_options) == 0) return (EADDRINUSE); } @@ -265,7 +265,7 @@ portloop: lport = htons(*lastport); } while (baddynamic(*lastport, so->so_proto->pr_protocol) || in_pcblookup(table, zeroin_addr, 0, - inp->inp_laddr, lport, wild)); + inp->inp_laddr, lport, wild)); } else { /* * counting up @@ -292,7 +292,7 @@ portloop: lport = htons(*lastport); } while (baddynamic(*lastport, so->so_proto->pr_protocol) || in_pcblookup(table, zeroin_addr, 0, - inp->inp_laddr, lport, wild)); + inp->inp_laddr, lport, wild)); } } inp->inp_lport = lport; @@ -656,10 +656,12 @@ in_pcblookup(table, faddr, fport_arg, laddr, lport_arg, flags) if (laddr.s_addr != INADDR_ANY) wildcard++; } - if ((!wildcard || (flags & INPLOOKUP_WILDCARD)) && - wildcard < matchwild) { + if (wildcard && (flags & INPLOOKUP_WILDCARD) == 0) + continue; + if (wildcard < matchwild) { match = inp; - if ((matchwild = wildcard) == 0) + matchwild = wildcard; + if (matchwild == 0) break; } } diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 929f0b91b29..72a00c38fa8 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.27 1998/02/01 18:09:23 mickey Exp $ */ +/* $OpenBSD: ip_input.c,v 1.28 1998/02/01 21:46:02 deraadt Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -196,6 +196,7 @@ ipintr() register struct ip *ip; register struct mbuf *m; register struct ipq *fp; + register struct in_ifaddr *ia; struct ipqent *ipqe; int hlen, mff, s; @@ -305,9 +306,23 @@ next: /* * Check our list of addresses, to see if the packet is for us. */ - if (in_iawithaddr(ip->ip_dst, m)) - goto ours; - + for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) { + if (ip->ip_dst.s_addr == ia->ia_addr.sin_addr.s_addr) + goto ours; + if (((ip_directedbcast == 0) || (ip_directedbcast && + ia->ia_ifp == m->m_pkthdr.rcvif)) && + (ia->ia_ifp->if_flags & IFF_BROADCAST)) { + if (ip->ip_dst.s_addr == ia->ia_broadaddr.sin_addr.s_addr || + ip->ip_dst.s_addr == ia->ia_netbroadcast.s_addr || + /* + * Look for all-0's host part (old broadcast addr), + * either for subnet or net. + */ + ip->ip_dst.s_addr == ia->ia_subnet || + ip->ip_dst.s_addr == ia->ia_net) + goto ours; + } + } if (IN_MULTICAST(ip->ip_dst.s_addr)) { struct in_multi *inm; #ifdef MROUTING @@ -463,37 +478,6 @@ bad: goto next; } -struct in_ifaddr * -in_iawithaddr(ina, m) - struct in_addr ina; - register struct mbuf *m; -{ - register struct in_ifaddr *ia; - - for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) { - if ((ina.s_addr == ia->ia_addr.sin_addr.s_addr) || - ((ia->ia_ifp->if_flags & (IFF_LOOPBACK|IFF_LINK1)) == - (IFF_LOOPBACK|IFF_LINK1) && - ia->ia_subnet == (ina.s_addr & ia->ia_subnetmask))) - return ia; - if (m && ((ip_directedbcast == 0) || (ip_directedbcast && - ia->ia_ifp == m->m_pkthdr.rcvif)) && - (ia->ia_ifp->if_flags & IFF_BROADCAST)) { - if (ina.s_addr == ia->ia_broadaddr.sin_addr.s_addr || - ina.s_addr == ia->ia_netbroadcast.s_addr || - /* - * Look for all-0's host part (old broadcast addr), - * either for subnet or net. - */ - ina.s_addr == ia->ia_subnet || - ina.s_addr == ia->ia_net) - return ia; - } - } - - return NULL; -} - /* * Take incoming datagram fragment and try to * reassemble it into whole datagram. If a chain for diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index 99ef2926aad..bb192317902 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_var.h,v 1.6 1998/02/01 18:09:23 mickey Exp $ */ +/* $OpenBSD: ip_var.h,v 1.7 1998/02/01 21:46:03 deraadt Exp $ */ /* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */ /* @@ -178,8 +178,6 @@ int ip_pcbopts __P((struct mbuf **, struct mbuf *)); struct ip * ip_reass __P((struct ipqent *, struct ipq *)); struct in_ifaddr * - in_iawithaddr __P((struct in_addr, struct mbuf *)); -struct in_ifaddr * ip_rtaddr __P((struct in_addr)); int ip_setmoptions __P((int, struct ip_moptions **, struct mbuf *)); void ip_slowtimo __P((void)); |