From: mpi Date: Sat, 6 Jun 2015 09:31:53 +0000 (+0000) Subject: Put the link-layer address back into the gateway field of RTF_LOCAL X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=42e6235160e3a6bfbaf8ae5825086c9142278a3c;p=openbsd Put the link-layer address back into the gateway field of RTF_LOCAL routes. Since such routes are also flagged with RTF_LLINFO various code path assume correctly that they contain valid ARP or ND information. This fixes the "arpresolve: unresolved and rt_expire == 0" issue reported on tech@ by mxb . ok claudio@, phessler@ --- diff --git a/sys/net/route.c b/sys/net/route.c index dc510860670..88e8134dc2e 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.212 2015/05/26 12:19:51 mpi Exp $ */ +/* $OpenBSD: route.c,v 1.213 2015/06/06 09:31:53 mpi Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -1121,27 +1121,23 @@ rt_maskedcopy(struct sockaddr *src, struct sockaddr *dst, int rt_ifa_add(struct ifaddr *ifa, int flags, struct sockaddr *dst) { + struct ifnet *ifp = ifa->ifa_ifp; struct rtentry *rt, *nrt = NULL; struct sockaddr_rtlabel sa_rl; - struct sockaddr_dl sa_dl = { sizeof(sa_dl), AF_LINK }; struct rt_addrinfo info; - u_short rtableid = ifa->ifa_ifp->if_rdomain; - u_int8_t prio = ifa->ifa_ifp->if_priority + RTP_STATIC; + u_short rtableid = ifp->if_rdomain; + u_int8_t prio = ifp->if_priority + RTP_STATIC; int error; - sa_dl.sdl_type = ifa->ifa_ifp->if_type; - sa_dl.sdl_index = ifa->ifa_ifp->if_index; - memset(&info, 0, sizeof(info)); info.rti_ifa = ifa; info.rti_flags = flags | RTF_MPATH; info.rti_info[RTAX_DST] = dst; if (flags & RTF_LLINFO) - info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&sa_dl; + info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)ifp->if_sadl; else info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr; - info.rti_info[RTAX_LABEL] = - rtlabel_id2sa(ifa->ifa_ifp->if_rtlabelid, &sa_rl); + info.rti_info[RTAX_LABEL] = rtlabel_id2sa(ifp->if_rtlabelid, &sa_rl); #ifdef MPLS if ((flags & RTF_MPLS) == RTF_MPLS) { @@ -1189,14 +1185,14 @@ rt_ifa_add(struct ifaddr *ifa, int flags, struct sockaddr *dst) int rt_ifa_del(struct ifaddr *ifa, int flags, struct sockaddr *dst) { + struct ifnet *ifp = ifa->ifa_ifp; struct rtentry *rt, *nrt = NULL; struct mbuf *m = NULL; struct sockaddr *deldst; struct rt_addrinfo info; struct sockaddr_rtlabel sa_rl; - struct sockaddr_dl sa_dl = { sizeof(sa_dl), AF_LINK }; - u_short rtableid = ifa->ifa_ifp->if_rdomain; - u_int8_t prio = ifa->ifa_ifp->if_priority + RTP_STATIC; + u_short rtableid = ifp->if_rdomain; + u_int8_t prio = ifp->if_priority + RTP_STATIC; int error; #ifdef MPLS @@ -1227,19 +1223,13 @@ rt_ifa_del(struct ifaddr *ifa, int flags, struct sockaddr *dst) } } - sa_dl.sdl_type = ifa->ifa_ifp->if_type; - sa_dl.sdl_index = ifa->ifa_ifp->if_index; - memset(&info, 0, sizeof(info)); info.rti_ifa = ifa; info.rti_flags = flags; info.rti_info[RTAX_DST] = dst; - if (flags & RTF_LLINFO) - info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&sa_dl; - else + if ((flags & RTF_LLINFO) == 0) info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr; - info.rti_info[RTAX_LABEL] = - rtlabel_id2sa(ifa->ifa_ifp->if_rtlabelid, &sa_rl); + info.rti_info[RTAX_LABEL] = rtlabel_id2sa(ifp->if_rtlabelid, &sa_rl); if ((flags & RTF_HOST) == 0) info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask; diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index cea57b8c5de..4f87e5a6a8e 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.c,v 1.136 2015/05/15 12:00:57 claudio Exp $ */ +/* $OpenBSD: nd6.c,v 1.137 2015/06/06 09:31:53 mpi Exp $ */ /* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */ /* @@ -651,7 +651,6 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp, } if (!rt) { if (create && ifp) { - struct sockaddr_dl sa_dl = { sizeof(sa_dl), AF_LINK }; struct rt_addrinfo info; int e; @@ -667,9 +666,6 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp, if (ifa == NULL) return (NULL); - sa_dl.sdl_type = ifp->if_type; - sa_dl.sdl_index = ifp->if_index; - /* * Create a new route. RTF_LLINFO is necessary * to create a Neighbor Cache entry for the @@ -679,7 +675,8 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp, bzero(&info, sizeof(info)); info.rti_flags = RTF_UP | RTF_HOST | RTF_LLINFO; info.rti_info[RTAX_DST] = sin6tosa(&sin6); - info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&sa_dl; + info.rti_info[RTAX_GATEWAY] = + (struct sockaddr *)ifp->if_sadl; if ((e = rtrequest1(RTM_ADD, &info, RTP_CONNECTED, &rt, rtableid)) != 0) { #if 0