RTF_LOCAL are always UP so this is safe.  ok?

Index: netinet/ip_input.c
===================================================================
RCS file: /cvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.256
diff -u -p -r1.256 ip_input.c
--- netinet/ip_input.c  25 Sep 2015 09:51:20 -0000      1.256
+++ netinet/ip_input.c  12 Oct 2015 11:57:35 -0000
@@ -671,13 +671,9 @@ in_ouraddr(struct mbuf *m, struct ifnet 
        sin.sin_family = AF_INET;
        sin.sin_addr = ina;
        rt = rtalloc(sintosa(&sin), 0, m->m_pkthdr.ph_rtableid);
-       if (rt != NULL) {
-               /* only use non-stale local address, check before route free */
-               if ((rt->rt_flags & (RTF_LOCAL|RTF_BROADCAST)) &&
-                   rt->rt_ifa != NULL && rt->rt_ifa->ifa_ifp != NULL)
-                       ia = ifatoia(rt->rt_ifa);
-               rtfree(rt);
-       }
+       if (rtisvalid(rt) && ISSET(rt->rt_flags, RTF_LOCAL|RTF_BROADCAST))
+               ia = ifatoia(rt->rt_ifa);
+       rtfree(rt);
 
        if (ia == NULL) {
                struct ifaddr *ifa;
Index: netinet6/ip6_input.c
===================================================================
RCS file: /cvs/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.146
diff -u -p -r1.146 ip6_input.c
--- netinet6/ip6_input.c        11 Sep 2015 09:54:46 -0000      1.146
+++ netinet6/ip6_input.c        12 Oct 2015 11:58:16 -0000
@@ -445,7 +445,7 @@ ip6_input(struct mbuf *m)
         * Accept the packet if the route to the destination is marked
         * as local.
         */
-       if (ip6_forward_rt.ro_rt &&
+       if (rtisvalid(ip6_forward_rt.ro_rt) &&
            ISSET(ip6_forward_rt.ro_rt->rt_flags, RTF_LOCAL)) {
                struct in6_ifaddr *ia6 =
                        ifatoia6(ip6_forward_rt.ro_rt->rt_ifa);

Reply via email to