Since rti_info[RTAX_IFP], when it is present, contains the sockaddr_dl
of a given interface, in the chunk below, ifa_ifwithnet() will return
its corresponding link-layer address.

But here we are interested in the ifp, not in its link-layer address!
So let's use if_get() directly.

ok?

Index: net/route.c
===================================================================
RCS file: /home/ncvs/src/sys/net/route.c,v
retrieving revision 1.157
diff -u -p -r1.157 route.c
--- net/route.c 27 Mar 2014 10:39:23 -0000      1.157
+++ net/route.c 27 Mar 2014 14:22:06 -0000
@@ -683,11 +683,12 @@ rt_getifa(struct rt_addrinfo *info, u_in
         * ifp may be specified by sockaddr_dl when protocol address
         * is ambiguous
         */
-       if (info->rti_ifp == NULL && info->rti_info[RTAX_IFP] != NULL
-           && info->rti_info[RTAX_IFP]->sa_family == AF_LINK &&
-           (ifa = ifa_ifwithnet((struct sockaddr *)info->rti_info[RTAX_IFP],
-           rtid)) != NULL)
-               info->rti_ifp = ifa->ifa_ifp;
+       if (info->rti_ifp == NULL && info->rti_info[RTAX_IFP] != NULL) {
+               struct sockaddr_dl *sdl;
+
+               sdl = (struct sockaddr_dl *)info->rti_info[RTAX_IFP];
+               info->rti_ifp = if_get(sdl->sdl_index);
+       }
 
        if (info->rti_ifa == NULL && info->rti_info[RTAX_IFA] != NULL)
                info->rti_ifa = ifa_ifwithaddr(info->rti_info[RTAX_IFA], rtid);

Reply via email to