- ro->ro_dest.sin_addr = ip->ip_dst;
- ro->ro_dest.sin_family = AF_INET;
- direct = allocroute(ro);
+ ro->ro_dst.sa_family = AF_INET;
+ ((struct sockaddr_in *)&ro->ro_dst)->sin_addr = ip->ip_dst;
+ /*
+ * If routing to interface only, short circuit routing lookup.
+ */
+ if (ro == &routetoif) {
+ /* check ifp is AF_INET??? */
+ ifp = if_ifonnetof(IN_NETOF(ip->ip_dst));
+ if (ifp == 0)
+ goto unreachable;
+ goto gotif;
+ }
+ rtalloc(ro);