From: mpi Date: Mon, 11 Jul 2016 09:23:06 +0000 (+0000) Subject: Revert the introduction of ``rt_addr''. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8671bacf252810113294d1153d13669ae3192ac5;p=openbsd Revert the introduction of ``rt_addr''. Being able to add route entries without configured addresses is a nice feature but this is not my fight. So I'd rather no add another pointer to ``struct rtentry'' if I'm not removing another one. --- diff --git a/sys/net/route.c b/sys/net/route.c index d4d708a8df1..c5f2847fb7b 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.309 2016/06/14 09:48:52 mpi Exp $ */ +/* $OpenBSD: route.c,v 1.310 2016/07/11 09:23:06 mpi Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -153,7 +153,6 @@ struct pool rtentry_pool; /* pool for rtentry structures */ struct pool rttimer_pool; /* pool for rttimer structures */ void rt_timer_init(void); -int rt_setaddr(struct rtentry *, struct sockaddr *); int rtflushclone1(struct rtentry *, void *, u_int); void rtflushclone(unsigned int, struct rtentry *); int rt_if_remove_rtdelete(struct rtentry *, void *, u_int); @@ -460,7 +459,6 @@ rtfree(struct rtentry *rt) if (rt->rt_flags & RTF_MPLS) free(rt->rt_llinfo, M_TEMP, sizeof(struct rt_mpls)); #endif - free(rt->rt_addr, M_RTABLE, ROUNDUP(rt->rt_addr->sa_len)); free(rt->rt_gateway, M_RTABLE, ROUNDUP(rt->rt_gateway->sa_len)); free(rt_key(rt), M_RTABLE, rt_key(rt)->sa_len); KERNEL_UNLOCK(); @@ -486,7 +484,7 @@ rt_sendmsg(struct rtentry *rt, int cmd, u_int rtableid) ifp = if_get(rt->rt_ifidx); if (ifp != NULL) { info.rti_info[RTAX_IFP] = sdltosa(ifp->if_sadl); - info.rti_info[RTAX_IFA] = rt->rt_addr; + info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; } rt_missmsg(cmd, &info, rt->rt_flags, rt->rt_priority, rt->rt_ifidx, 0, @@ -956,7 +954,7 @@ rtrequest(int req, struct rt_addrinfo *info, u_int8_t prio, * will get the new address and interface later. */ info->rti_ifa = NULL; - info->rti_info[RTAX_IFA] = rt->rt_addr; + info->rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; } info->rti_flags = rt->rt_flags | (RTF_CLONED|RTF_HOST); @@ -1088,12 +1086,10 @@ rtrequest(int req, struct rt_addrinfo *info, u_int8_t prio, * the routing table because the radix MPATH code use * it to (re)order routes. */ - if ((error = rt_setaddr(rt, ifa->ifa_addr)) || - (error = rt_setgate(rt, info->rti_info[RTAX_GATEWAY]))) { + if ((error = rt_setgate(rt, info->rti_info[RTAX_GATEWAY]))) { ifafree(ifa); rtfree(rt->rt_parent); rtfree(rt->rt_gwroute); - free(rt->rt_addr, M_RTABLE, 0); free(rt->rt_gateway, M_RTABLE, 0); free(ndst, M_RTABLE, dlen); pool_put(&rtentry_pool, rt); @@ -1124,7 +1120,6 @@ rtrequest(int req, struct rt_addrinfo *info, u_int8_t prio, ifafree(ifa); rtfree(rt->rt_parent); rtfree(rt->rt_gwroute); - free(rt->rt_addr, M_RTABLE, 0); free(rt->rt_gateway, M_RTABLE, 0); free(ndst, M_RTABLE, dlen); pool_put(&rtentry_pool, rt); @@ -1150,24 +1145,6 @@ rtrequest(int req, struct rt_addrinfo *info, u_int8_t prio, return (0); } -int -rt_setaddr(struct rtentry *rt, struct sockaddr *addr) -{ - int alen = ROUNDUP(addr->sa_len); - struct sockaddr *sa; - - KASSERT(rt->rt_addr == NULL); - - sa = malloc(alen, M_RTABLE, M_NOWAIT); - if (sa == NULL) - return (ENOBUFS); - - memmove(sa, addr, alen); - rt->rt_addr = sa; - - return (0); -} - int rt_setgate(struct rtentry *rt, struct sockaddr *gate) { diff --git a/sys/net/route.h b/sys/net/route.h index f7ba9c3b5a2..7652ea27243 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.138 2016/06/14 09:48:52 mpi Exp $ */ +/* $OpenBSD: route.h,v 1.139 2016/07/11 09:23:06 mpi Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -99,7 +99,6 @@ struct rtentry { struct sockaddr *rt_dest; /* destination */ SRPL_ENTRY(rtentry) rt_next; /* Next multipath entry to our dst. */ #endif - struct sockaddr *rt_addr; /* the answer: address to use */ struct sockaddr *rt_gateway; /* value */ struct ifaddr *rt_ifa; /* the answer: interface addr to use */ caddr_t rt_llinfo; /* pointer to link level info cache or diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 54d5600e9cc..6ab9ef937ac 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.192 2016/06/14 09:48:52 mpi Exp $ */ +/* $OpenBSD: rtsock.c,v 1.193 2016/07/11 09:23:06 mpi Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -695,7 +695,7 @@ report: ifp = if_get(rt->rt_ifidx); if (ifp != NULL && rtm->rtm_addrs & (RTA_IFP|RTA_IFA)) { info.rti_info[RTAX_IFP] = sdltosa(ifp->if_sadl); - info.rti_info[RTAX_IFA] = rt->rt_addr; + info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; if (ifp->if_flags & IFF_POINTOPOINT) info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr; @@ -1278,7 +1278,7 @@ sysctl_dumpentry(struct rtentry *rt, void *v, unsigned int id) ifp = if_get(rt->rt_ifidx); if (ifp != NULL) { info.rti_info[RTAX_IFP] = sdltosa(ifp->if_sadl); - info.rti_info[RTAX_IFA] = rt->rt_addr; + info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; if (ifp->if_flags & IFF_POINTOPOINT) info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr; } diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 31ef3eff061..e612402325d 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.c,v 1.216 2016/06/28 17:18:24 chris Exp $ */ +/* $OpenBSD: if_ether.c,v 1.217 2016/07/11 09:23:06 mpi Exp $ */ /* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */ /* @@ -389,7 +389,7 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m, rt->rt_expire = time_uptime; if (la->la_asked++ < arp_maxtries) arprequest(ifp, - &satosin(rt->rt_addr)->sin_addr.s_addr, + &satosin(rt->rt_ifa->ifa_addr)->sin_addr.s_addr, &satosin(dst)->sin_addr.s_addr, ac->ac_enaddr); else { diff --git a/sys/netmpls/mpls_input.c b/sys/netmpls/mpls_input.c index 349e465c34b..4db0bc506bd 100644 --- a/sys/netmpls/mpls_input.c +++ b/sys/netmpls/mpls_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpls_input.c,v 1.55 2016/06/14 09:44:41 mpi Exp $ */ +/* $OpenBSD: mpls_input.c,v 1.56 2016/07/11 09:23:06 mpi Exp $ */ /* * Copyright (c) 2008 Claudio Jeker @@ -374,7 +374,7 @@ mpls_do_error(struct mbuf *m, int type, int code, int destmtu) m_freem(m); return (NULL); } - if (rt->rt_addr->sa_family == AF_INET) + if (rt->rt_ifa->ifa_addr->sa_family == AF_INET) ia = ifatoia(rt->rt_ifa); else { /* XXX this needs fixing, if the MPLS is on an IP