Index: net/if_loop.c =================================================================== RCS file: /cvs/src/sys/net/if_loop.c,v diff -u -p -r1.98 if_loop.c --- net/if_loop.c 29 Dec 2023 11:43:04 -0000 1.98 +++ net/if_loop.c 28 Jul 2024 11:58:10 -0000 @@ -261,10 +261,10 @@ looutput(struct ifnet *ifp, struct mbuf if ((m->m_flags & M_PKTHDR) == 0) panic("%s: no header mbuf", __func__); - if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) { + if (rt != NULL && !ISSET(rt->rt_flags, RTF_LOCAL)) { m_freem(m); - return (rt->rt_flags & RTF_BLACKHOLE ? 0 : - rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH); + return (ISSET(rt->rt_flags, RTF_HOST) ? + EHOSTUNREACH : ENETUNREACH); } /* Index: netinet/ip_output.c =================================================================== RCS file: /cvs/src/sys/netinet/ip_output.c,v diff -u -p -r1.401 ip_output.c --- netinet/ip_output.c 2 Jul 2024 18:33:47 -0000 1.401 +++ netinet/ip_output.c 28 Jul 2024 11:58:10 -0000 @@ -398,6 +398,20 @@ sendit: } #endif /* IPSEC */ + if (ro && ro->ro_rt) { + struct rtentry *rt = ro->ro_rt; + + if (ISSET(rt->rt_flags, RTF_REJECT)) { + error = ISSET(rt->rt_flags, RTF_HOST) ? + EHOSTUNREACH : ENETUNREACH; + goto bad; + } + if (ISSET(rt->rt_flags, RTF_BLACKHOLE)) { + error = 0; + goto bad; + } + } + /* * Packet filter */ Index: netinet6/ip6_output.c =================================================================== RCS file: /cvs/src/sys/netinet6/ip6_output.c,v diff -u -p -r1.292 ip6_output.c --- netinet6/ip6_output.c 4 Jul 2024 12:50:08 -0000 1.292 +++ netinet6/ip6_output.c 28 Jul 2024 11:58:10 -0000 @@ -483,9 +483,20 @@ reroute: route6_cache(ro, &ip6->ip6_dst, NULL, m->m_pkthdr.ph_rtableid); } - if (rt && (rt->rt_flags & RTF_GATEWAY) && - !IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) - dst = satosin6(rt->rt_gateway); + if (rt != NULL) { + if (ISSET(rt->rt_flags, RTF_REJECT)) { + error = ISSET(rt->rt_flags, RTF_HOST) ? + EHOSTUNREACH : ENETUNREACH; + goto bad; + } + if (ISSET(rt->rt_flags, RTF_BLACKHOLE)) { + error = 0; + goto bad; + } + if (ISSET(rt->rt_flags, RTF_GATEWAY) && + !IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) + dst = satosin6(rt->rt_gateway); + } if (!IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { /* Unicast */