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 25 Jul 2024 23:41:27 -0000 @@ -261,12 +261,6 @@ 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)) { - m_freem(m); - return (rt->rt_flags & RTF_BLACKHOLE ? 0 : - rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH); - } - /* * Do not call if_input_local() directly. Queue the packet to avoid * stack overflow and make TCP handshake over loopback work. Index: netinet/ip_output.c =================================================================== RCS file: /cvs/src/sys/netinet/ip_output.c,v diff -u -p -r1.400 ip_output.c --- netinet/ip_output.c 7 Jun 2024 18:24:16 -0000 1.400 +++ netinet/ip_output.c 25 Jul 2024 23:41:27 -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.291 ip6_output.c --- netinet6/ip6_output.c 17 Apr 2024 20:48:51 -0000 1.291 +++ netinet6/ip6_output.c 25 Jul 2024 23:41:27 -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 */