summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2005-01-18 22:10:11 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2005-01-18 22:10:11 +0000
commit67505306b1c19f13338224ae8a05aec14bdd5b7d (patch)
tree4d56576ae8f3472f04a136bc8dcd71211f9fac51 /sys
parentcef54d1b6b1947701403863687eec35892c39b28 (diff)
If there is no match in ifaof_ifpforaddr() return the first match -- main
interface address -- and not the last one -- some alias. Also handle point to point networks a bit more special. With some input from markus@ OK markus@ henning@ fgsch@
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 92e4462b9b6..94374a5ebe2 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.102 2005/01/14 12:04:02 grange Exp $ */
+/* $OpenBSD: if.c,v 1.103 2005/01/18 22:10:10 claudio Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -991,7 +991,7 @@ ifaof_ifpforaddr(addr, ifp)
struct ifaddr *ifa;
char *cp, *cp2, *cp3;
char *cplim;
- struct ifaddr *ifa_maybe = 0;
+ struct ifaddr *ifa_maybe = NULL;
u_int af = addr->sa_family;
if (af >= AF_MAX)
@@ -999,8 +999,9 @@ ifaof_ifpforaddr(addr, ifp)
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != af)
continue;
- ifa_maybe = ifa;
- if (ifa->ifa_netmask == 0) {
+ if (ifa_maybe == NULL)
+ ifa_maybe = ifa;
+ if (ifa->ifa_netmask == 0 || ifp->if_flags & IFF_POINTOPOINT) {
if (equal(addr, ifa->ifa_addr) ||
(ifa->ifa_dstaddr && equal(addr, ifa->ifa_dstaddr)))
return (ifa);