Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net ifa_ifwithnet(): for the netatalk case, don't blindl...



details:   https://anonhg.NetBSD.org/src/rev/73b677c5d3f1
branches:  trunk
changeset: 485369:73b677c5d3f1
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Wed Apr 26 13:38:13 2000 +0000

description:
ifa_ifwithnet(): for the netatalk case, don't blindly return the first match
but try to find a exact match first. Closes kern/9957.

diffstat:

 sys/net/if.c |  17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r eab0089d9582 -r 73b677c5d3f1 sys/net/if.c
--- a/sys/net/if.c      Wed Apr 26 12:31:27 2000 +0000
+++ b/sys/net/if.c      Wed Apr 26 13:38:13 2000 +0000
@@ -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 @@
        }
 #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;



Home | Main Index | Thread Index | Old Index