On Tue, Nov 25, 2014 at 04:39:38PM +0100, Martin Pieuchot wrote: > 3 places where we don't need any "struct route". ok?
OK bluhm@ > > Index: netinet/ip_icmp.c > =================================================================== > RCS file: /home/ncvs/src/sys/netinet/ip_icmp.c,v > retrieving revision 1.126 > diff -u -p -r1.126 ip_icmp.c > --- netinet/ip_icmp.c 1 Nov 2014 21:40:38 -0000 1.126 > +++ netinet/ip_icmp.c 25 Nov 2014 14:51:16 -0000 > @@ -912,19 +912,16 @@ icmp_sysctl(int *name, u_int namelen, vo > struct rtentry * > icmp_mtudisc_clone(struct in_addr dst, u_int rtableid) > { > - struct sockaddr_in *sin; > - struct route ro; > + struct sockaddr_in sin; > struct rtentry *rt; > int error; > > - memset(&ro, 0, sizeof(ro)); > - ro.ro_tableid = rtableid; > - sin = satosin(&ro.ro_dst); > - sin->sin_family = AF_INET; > - sin->sin_len = sizeof(*sin); > - sin->sin_addr = dst; > + memset(&sin, 0, sizeof(sin)); > + sin.sin_family = AF_INET; > + sin.sin_len = sizeof(sin); > + sin.sin_addr = dst; > > - rt = rtalloc(&ro.ro_dst, RT_REPORT|RT_RESOLVE, rtableid); > + rt = rtalloc(sintosa(&sin), RT_REPORT|RT_RESOLVE, rtableid); > if (rt == NULL) > return (NULL); > > @@ -940,7 +937,7 @@ icmp_mtudisc_clone(struct in_addr dst, u > struct rt_addrinfo info; > > memset(&info, 0, sizeof(info)); > - info.rti_info[RTAX_DST] = sintosa(sin); > + info.rti_info[RTAX_DST] = sintosa(&sin); > info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; > info.rti_flags = RTF_GATEWAY | RTF_HOST | RTF_DYNAMIC; > > Index: netinet/ip_output.c > =================================================================== > RCS file: /home/ncvs/src/sys/netinet/ip_output.c,v > retrieving revision 1.272 > diff -u -p -r1.272 ip_output.c > --- netinet/ip_output.c 20 Nov 2014 15:55:04 -0000 1.272 > +++ netinet/ip_output.c 25 Nov 2014 14:51:16 -0000 > @@ -1663,8 +1663,8 @@ ip_setmoptions(int optname, struct ip_mo > struct ifnet *ifp = NULL; > struct ip_moptions *imo = *imop; > struct in_multi **immp; > - struct route ro; > - struct sockaddr_in *dst, sin; > + struct rtentry *rt; > + struct sockaddr_in sin; > int i, error = 0; > u_char loop; > > @@ -1768,21 +1768,18 @@ ip_setmoptions(int optname, struct ip_mo > * the route to the given multicast address. > */ > if (mreq->imr_interface.s_addr == INADDR_ANY) { > - ro.ro_rt = NULL; > - dst = satosin(&ro.ro_dst); > - dst->sin_len = sizeof(*dst); > - dst->sin_family = AF_INET; > - dst->sin_addr = mreq->imr_multiaddr; > - if (!(ro.ro_rt && ro.ro_rt->rt_ifp && > - (ro.ro_rt->rt_flags & RTF_UP))) > - ro.ro_rt = rtalloc(&ro.ro_dst, > - RT_REPORT|RT_RESOLVE, rtableid); > - if (ro.ro_rt == NULL) { > + memset(&sin, 0, sizeof(sin)); > + sin.sin_len = sizeof(sin); > + sin.sin_family = AF_INET; > + sin.sin_addr = mreq->imr_multiaddr; > + rt = rtalloc(sintosa(&sin), RT_REPORT|RT_RESOLVE, > + rtableid); > + if (rt == NULL) { > error = EADDRNOTAVAIL; > break; > } > - ifp = ro.ro_rt->rt_ifp; > - rtfree(ro.ro_rt); > + ifp = rt->rt_ifp; > + rtfree(rt); > } else { > memset(&sin, 0, sizeof(sin)); > sin.sin_len = sizeof(sin); > Index: netinet6/frag6.c > =================================================================== > RCS file: /home/ncvs/src/sys/netinet6/frag6.c,v > retrieving revision 1.57 > diff -u -p -r1.57 frag6.c > --- netinet6/frag6.c 18 Nov 2014 02:37:31 -0000 1.57 > +++ netinet6/frag6.c 25 Nov 2014 14:51:16 -0000 > @@ -172,8 +172,8 @@ frag6_input(struct mbuf **mp, int *offp, > int fragoff, frgpartlen; /* must be larger than u_int16_t */ > struct ifnet *dstifp; > #ifdef IN6_IFSTAT_STRICT > - struct route_in6 ro; > - struct sockaddr_in6 *dst; > + struct sockaddr_in6 dst; > + struct rtentry *rt; > #endif > u_int8_t ecn, ecn0; > > @@ -185,21 +185,19 @@ frag6_input(struct mbuf **mp, int *offp, > dstifp = NULL; > #ifdef IN6_IFSTAT_STRICT > /* find the destination interface of the packet. */ > - bzero(&ro, sizeof(ro)); > - ro.ro_tableid = m->m_pkthdr.ph_rtableid; > - dst = &ro.ro_dst; > - dst->sin6_family = AF_INET6; > - dst->sin6_len = sizeof(struct sockaddr_in6); > - dst->sin6_addr = ip6->ip6_dst; > + memset(&dst, 0, sizeof(dst)); > + dst.sin6_family = AF_INET6; > + dst.sin6_len = sizeof(struct sockaddr_in6); > + dst.sin6_addr = ip6->ip6_dst; > > - ro.ro_rt = rtalloc_mpath(sin6tosa(&ro.ro_dst), > - &ip6->ip6_src.s6_addr32[0], ro.ro_tableid); > + rt = rtalloc_mpath(sin6tosa(&dst), &ip6->ip6_src.s6_addr32[0], > + m->m_pkthdr.ph_rtableid); > > - if (ro.ro_rt != NULL && ro.ro_rt->rt_ifa != NULL) > - dstifp = ifatoia6(ro.ro_rt->rt_ifa)->ia_ifp; > - if (ro.ro_rt != NULL) { > - rtfree(ro.ro_rt); > - ro.ro_rt = NULL; > + if (rt != NULL) { > + if (rt->rt_ifa != NULL) > + dstifp = ifatoia6(rt->rt_ifa)->ia_ifp; > + rtfree(rt); > + rt = NULL; > } > #else > /* we are violating the spec, this is not the destination interface */