From: mpi Date: Mon, 19 Oct 2015 12:10:05 +0000 (+0000) Subject: Stop checking for RTF_UP directly, call rtisvalid(9) instead. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4b4e5248e57a916917f0a2c75187bdb3d91bcf1a;p=openbsd Stop checking for RTF_UP directly, call rtisvalid(9) instead. While here add a missing ``rtableid'' check in in_selectsrc(). ok bluhm@ --- diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 699d44ccd90..b7aa013330a 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.183 2015/10/19 08:49:13 vgross Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.184 2015/10/19 12:10:05 mpi Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -764,7 +764,7 @@ in_pcbrtentry(struct inpcb *inp) ro = &inp->inp_route; /* check if route is still valid */ - if (ro->ro_rt && (ro->ro_rt->rt_flags & RTF_UP) == 0) { + if (!rtisvalid(ro->ro_rt)) { rtfree(ro->ro_rt); ro->ro_rt = NULL; } @@ -857,8 +857,8 @@ in_selectsrc(struct in_addr **insrc, struct sockaddr_in *sin, * If route is known or can be allocated now, * our src addr is taken from the i/f, else punt. */ - if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 || - (satosin(&ro->ro_dst)->sin_addr.s_addr != sin->sin_addr.s_addr))) { + if (!rtisvalid(ro->ro_rt) || (ro->ro_tableid != rtableid) || + (satosin(&ro->ro_dst)->sin_addr.s_addr != sin->sin_addr.s_addr)) { rtfree(ro->ro_rt); ro->ro_rt = NULL; } diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index 8392adff7e9..1212137cdbc 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_icmp.c,v 1.142 2015/10/19 12:02:11 mpi Exp $ */ +/* $OpenBSD: ip_icmp.c,v 1.143 2015/10/19 12:10:05 mpi Exp $ */ /* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */ /* @@ -935,18 +935,14 @@ icmp_mtudisc_clone(struct in_addr dst, u_int rtableid) sin.sin_addr = dst; rt = rtalloc(sintosa(&sin), RT_REPORT|RT_RESOLVE, rtableid); - if (rt == NULL) - return (NULL); /* Check if the route is actually usable */ - if (rt->rt_flags & (RTF_REJECT | RTF_BLACKHOLE) || - (rt->rt_flags & RTF_UP) == 0) { + if (!rtisvalid(rt) || (rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE))) { rtfree(rt); return (NULL); } /* If we didn't get a host route, allocate one */ - if ((rt->rt_flags & RTF_HOST) == 0) { struct rtentry *nrt; struct rt_addrinfo info; diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 11af574b2b4..8d575b7904d 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.301 2015/10/13 10:16:17 mpi Exp $ */ +/* $OpenBSD: ip_output.c,v 1.302 2015/10/19 12:10:05 mpi Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -588,8 +588,8 @@ sendit: * them, there is no way for one to update all its * routes when the MTU is changed. */ - if (ro->ro_rt != NULL && - (ro->ro_rt->rt_flags & (RTF_UP | RTF_HOST)) && + if (rtisvalid(ro->ro_rt) && + ISSET(ro->ro_rt->rt_flags, RTF_HOST) && !(ro->ro_rt->rt_rmx.rmx_locks & RTV_MTU) && (ro->ro_rt->rt_rmx.rmx_mtu > ifp->if_mtu)) { ro->ro_rt->rt_rmx.rmx_mtu = ifp->if_mtu;