From ea7fdc0372b9ea876836f1f2ec609a556971931c Mon Sep 17 00:00:00 2001 From: mpi Date: Mon, 19 Oct 2015 11:59:26 +0000 Subject: [PATCH] Remove superfluous NULL checks. ifa are refcounted to ensure that rt_ifa is always valid. --- sys/netinet/ip_input.c | 5 ++--- sys/netinet6/frag6.c | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 2d8cc521d8d..ec34355e90a 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.257 2015/10/13 10:29:16 mpi Exp $ */ +/* $OpenBSD: ip_input.c,v 1.258 2015/10/19 11:59:26 mpi Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -1457,8 +1457,7 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, int srcrt) satosin(rt_key(rt))->sin_addr.s_addr != 0 && ipsendredirects && !srcrt && !arpproxy(satosin(rt_key(rt))->sin_addr, m->m_pkthdr.ph_rtableid)) { - if (rt->rt_ifa && - (ip->ip_src.s_addr & ifatoia(rt->rt_ifa)->ia_netmask) == + if ((ip->ip_src.s_addr & ifatoia(rt->rt_ifa)->ia_netmask) == ifatoia(rt->rt_ifa)->ia_net) { if (rt->rt_flags & RTF_GATEWAY) dest = satosin(rt->rt_gateway)->sin_addr.s_addr; diff --git a/sys/netinet6/frag6.c b/sys/netinet6/frag6.c index 890f7e4dcdc..3e27729e1d6 100644 --- a/sys/netinet6/frag6.c +++ b/sys/netinet6/frag6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: frag6.c,v 1.63 2015/09/10 16:39:39 mpi Exp $ */ +/* $OpenBSD: frag6.c,v 1.64 2015/10/19 11:59:26 mpi Exp $ */ /* $KAME: frag6.c,v 1.40 2002/05/27 21:40:31 itojun Exp $ */ /* @@ -183,10 +183,8 @@ frag6_input(struct mbuf **mp, int *offp, int proto) rt = rtalloc_mpath(sin6tosa(&dst), &ip6->ip6_src.s6_addr32[0], m->m_pkthdr.ph_rtableid); - if (rt != NULL) { - if (rt->rt_ifa != NULL) - dstifp = ifatoia6(rt->rt_ifa)->ia_ifp; + dstifp = ifatoia6(rt->rt_ifa)->ia_ifp; rtfree(rt); rt = NULL; } -- 2.20.1