diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/route.c | 19 | ||||
-rw-r--r-- | sys/net/route.h | 6 | ||||
-rw-r--r-- | sys/netinet/ip_icmp.c | 7 | ||||
-rw-r--r-- | sys/netinet6/icmp6.c | 5 |
4 files changed, 15 insertions, 22 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index b534bc83d03..f27fb46d0dd 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.277 2015/11/27 11:52:44 mpi Exp $ */ +/* $OpenBSD: route.c,v 1.278 2015/12/01 21:26:43 mpi Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -529,8 +529,7 @@ ifafree(struct ifaddr *ifa) */ void rtredirect(struct sockaddr *dst, struct sockaddr *gateway, - struct sockaddr *netmask, int flags, struct sockaddr *src, - struct rtentry **rtp, u_int rdomain) + struct sockaddr *src, struct rtentry **rtp, unsigned int rdomain) { struct rtentry *rt; int error = 0; @@ -538,6 +537,7 @@ rtredirect(struct sockaddr *dst, struct sockaddr *gateway, struct rt_addrinfo info; struct ifaddr *ifa; unsigned int ifidx = 0; + int flags = RTF_GATEWAY|RTF_HOST; splsoftassert(IPL_SOFTNET); @@ -557,8 +557,7 @@ rtredirect(struct sockaddr *dst, struct sockaddr *gateway, #define equal(a1, a2) \ ((a1)->sa_len == (a2)->sa_len && \ bcmp((caddr_t)(a1), (caddr_t)(a2), (a1)->sa_len) == 0) - if (!(flags & RTF_DONE) && rt && - (!equal(src, rt->rt_gateway) || rt->rt_ifa != ifa)) + if (rt != NULL && (!equal(src, rt->rt_gateway) || rt->rt_ifa != ifa)) error = EINVAL; else if (ifa_ifwithaddr(gateway, rdomain) != NULL) error = EHOSTUNREACH; @@ -574,21 +573,20 @@ rtredirect(struct sockaddr *dst, struct sockaddr *gateway, goto create; /* * Don't listen to the redirect if it's - * for a route to an interface. + * for a route to an interface. */ - if (rt->rt_flags & RTF_GATEWAY) { - if (((rt->rt_flags & RTF_HOST) == 0) && (flags & RTF_HOST)) { + if (ISSET(rt->rt_flags, RTF_GATEWAY)) { + if (!ISSET(rt->rt_flags, RTF_HOST)) { /* * Changing from route to net => route to host. * Create new route, rather than smashing route to net. */ create: rtfree(rt); - flags |= RTF_GATEWAY | RTF_DYNAMIC; + flags |= RTF_DYNAMIC; bzero(&info, sizeof(info)); info.rti_info[RTAX_DST] = dst; info.rti_info[RTAX_GATEWAY] = gateway; - info.rti_info[RTAX_NETMASK] = netmask; info.rti_ifa = ifa; info.rti_flags = flags; rt = NULL; @@ -624,7 +622,6 @@ out: bzero((caddr_t)&info, sizeof(info)); info.rti_info[RTAX_DST] = dst; info.rti_info[RTAX_GATEWAY] = gateway; - info.rti_info[RTAX_NETMASK] = netmask; info.rti_info[RTAX_AUTHOR] = src; rt_missmsg(RTM_REDIRECT, &info, flags, ifidx, error, rdomain); } diff --git a/sys/net/route.h b/sys/net/route.h index 1c51a4ac9f2..c14b35b2dd4 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.122 2015/11/29 16:02:18 mpi Exp $ */ +/* $OpenBSD: route.h,v 1.123 2015/12/01 21:26:43 mpi Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -392,9 +392,7 @@ int rt_ifa_del(struct ifaddr *, int, struct sockaddr *); int rt_ifa_addlocal(struct ifaddr *); int rt_ifa_dellocal(struct ifaddr *); int rtioctl(u_long, caddr_t, struct proc *); -void rtredirect(struct sockaddr *, struct sockaddr *, - struct sockaddr *, int, struct sockaddr *, - struct rtentry **, u_int); +void rtredirect(struct sockaddr *, struct sockaddr *, struct sockaddr *, struct rtentry **, unsigned int); int rtrequest(int, struct rt_addrinfo *, u_int8_t, struct rtentry **, u_int); void rt_if_remove(struct ifnet *); diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index ec367837d64..32af2eec09d 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_icmp.c,v 1.146 2015/11/21 11:26:59 mpi Exp $ */ +/* $OpenBSD: ip_icmp.c,v 1.147 2015/12/01 21:26:43 mpi Exp $ */ /* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */ /* @@ -652,9 +652,8 @@ reflect: &ip->ip_dst.s_addr)) goto freeit; #endif - rtredirect(sintosa(&sdst), sintosa(&sgw), NULL, - RTF_GATEWAY | RTF_HOST, sintosa(&ssrc), - &newrt, m->m_pkthdr.ph_rtableid); + rtredirect(sintosa(&sdst), sintosa(&sgw), + sintosa(&ssrc), &newrt, m->m_pkthdr.ph_rtableid); if (newrt != NULL && icmp_redirtimeout != 0) { (void)rt_timer_add(newrt, icmp_redirect_timeout, icmp_redirect_timeout_q, m->m_pkthdr.ph_rtableid); diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 01613b8e320..ec25dbc1b4f 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icmp6.c,v 1.178 2015/11/21 11:23:07 mpi Exp $ */ +/* $OpenBSD: icmp6.c,v 1.179 2015/12/01 21:26:43 mpi Exp $ */ /* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ /* @@ -1517,8 +1517,7 @@ icmp6_redirect_input(struct mbuf *m, int off) bcopy(&redtgt6, &sgw.sin6_addr, sizeof(struct in6_addr)); bcopy(&reddst6, &sdst.sin6_addr, sizeof(struct in6_addr)); bcopy(&src6, &ssrc.sin6_addr, sizeof(struct in6_addr)); - rtredirect(sin6tosa(&sdst), sin6tosa(&sgw), NULL, - RTF_GATEWAY | RTF_HOST, sin6tosa(&ssrc), + rtredirect(sin6tosa(&sdst), sin6tosa(&sgw), sin6tosa(&ssrc), &newrt, m->m_pkthdr.ph_rtableid); if (newrt) { |