From 4e9473a1e75838acfc9b7f053e3de2af98f3149c Mon Sep 17 00:00:00 2001 From: bouyer Date: Wed, 26 Apr 2000 13:38:13 +0000 Subject: [PATCH] ifa_ifwithnet(): for the netatalk case, don't blindly return the first match but try to find a exact match first. Closes kern/9957. --- sys/net/if.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 34a6bf66c43a..11bc9b84810c 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.61 2000/03/30 09:45:34 augustss Exp $ */ +/* $NetBSD: if.c,v 1.62 2000/04/26 13:38:13 bouyer Exp $ */ /*- * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. @@ -567,15 +567,24 @@ ifa_ifwithnet(addr) } #ifdef NETATALK if (af == AF_APPLETALK) { + struct sockaddr_at *sat, *sat2; + sat = (struct sockaddr_at *)addr; for (ifp = TAILQ_FIRST(&ifnet); ifp != NULL; ifp = TAILQ_NEXT(ifp, if_list)) { if (ifp->if_output == if_nulloutput) continue; ifa = at_ifawithnet((struct sockaddr_at *)addr, ifp); - if (ifa) - return (ifa); + if (ifa == NULL) + continue; + sat2 = (struct sockaddr_at *)ifa->ifa_addr; + if (sat2->sat_addr.s_net == sat->sat_addr.s_net) + return (ifa); /* exact match */ + if (ifa_maybe == NULL) { + /* else keep the if with the rigth range */ + ifa_maybe = ifa; + } } - return (NULL); + return (ifa_maybe); } #endif for (ifp = TAILQ_FIRST(&ifnet); ifp != NULL;