From 05a938f80760180ba512b01ca970c4fd19e6d94d Mon Sep 17 00:00:00 2001 From: Michael Shalayeff Date: Sun, 1 Feb 1998 18:09:24 +0000 Subject: support wildcard loopbacks. that is, setting up lo1 like: ifconfig lo1 inet 192.168.1.1 netmask 255.255.255.0 link1 would force it to act like all the addresses from net 192.168.1 were added to the interface. todo: man lo --- sys/netinet/ip_input.c | 54 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 19 deletions(-) (limited to 'sys/netinet/ip_input.c') diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 1863051f803..929f0b91b29 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.26 1997/08/09 23:36:29 millert Exp $ */ +/* $OpenBSD: ip_input.c,v 1.27 1998/02/01 18:09:23 mickey Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -196,7 +196,6 @@ 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; @@ -306,23 +305,9 @@ next: /* * Check our list of addresses, to see if the packet is for us. */ - 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_iawithaddr(ip->ip_dst, m)) + goto ours; + if (IN_MULTICAST(ip->ip_dst.s_addr)) { struct in_multi *inm; #ifdef MROUTING @@ -478,6 +463,37 @@ 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 -- cgit v1.2.3