summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-02-01 21:46:32 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-02-01 21:46:32 +0000
commit065ebf549910cdad4cbaeb26ba066fa562c53ab8 (patch)
tree225c9a2e6ceb6e2b317b01953d0426c3356ed157
parent86579f56153e9cbd716800bc46288df3075ed742 (diff)
undo wildcard loopback stuff; it was not checked by other developers
-rw-r--r--share/man/man4/lo.424
-rw-r--r--sys/netinet/in_pcb.c18
-rw-r--r--sys/netinet/ip_input.c54
-rw-r--r--sys/netinet/ip_var.h4
4 files changed, 33 insertions, 67 deletions
diff --git a/share/man/man4/lo.4 b/share/man/man4/lo.4
index c53e9cc7e27..0491936b493 100644
--- a/share/man/man4/lo.4
+++ b/share/man/man4/lo.4
@@ -1,4 +1,3 @@
-.\" $OpenBSD: lo.4,v 1.2 1998/02/01 18:31:57 mickey Exp $
.\" $NetBSD: lo.4,v 1.3 1994/11/30 16:22:23 jtc Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
@@ -41,7 +40,8 @@
.Nm lo
.Nd software loopback network interface
.Sh SYNOPSIS
-.Sy pseudo-device Nm loop Em <number>
+.Sy pseudo-device
+.Nm loop
.Sh DESCRIPTION
The
.Nm loop
@@ -60,14 +60,6 @@ The loopback should
.Em never
be configured first unless no hardware
interfaces exist.
-.Pp
-Configuring loopback interface for
-.Xr inet 4
-with
-.Em link1
-flag set you achieve a functionality such as equivalent to setting
-the whole set of addresses wich belongs to the sub/super-net of the
-address and netmask configured on the interface.
.Sh DIAGNOSTICS
.Bl -diag
.It lo%d: can't handle af%d.
@@ -75,25 +67,15 @@ The interface was handed
a message with addresses formatted in an unsuitable address
family; the packet was dropped.
.El
-.Sh EXAMPLES
-ifconfig lo1 inet 192.168.1.1 netmask 255.255.255.0 link1
-this would configure lo1 the way equivalent to:
-.Pp
-awk 'BEGIN {for(i=1;i<255;i++) \
-print "ifconfig lo1 inet 192.168.1."i" netmask 255.255.255.255"}'|sh
.Sh SEE ALSO
.Xr intro 4 ,
.Xr inet 4 ,
-.Xr ns 4 ,
-.Xr ifconfig 8
+.Xr ns 4
.Sh HISTORY
The
.Nm
device appeared in
.Bx 4.2 .
-.Pp
-The wildcard functionality first appeared in
-.Ox 2.2 .
.Sh BUGS
Previous versions of the system enabled the loopback interface
automatically, using a nonstandard Internet address (127.1).
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));