Now that we can use the routing table to check if the destination of a packet is a broadcast address, we can replace the lookup done for every packet by the simple check below.
Ok? Index: netinet/ip_output.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/ip_output.c,v retrieving revision 1.267 diff -u -p -r1.267 ip_output.c --- netinet/ip_output.c 27 Sep 2014 12:26:16 -0000 1.267 +++ netinet/ip_output.c 7 Oct 2014 10:09:56 -0000 @@ -484,8 +484,8 @@ reroute: * such a packet; if the packet is going in an IPsec tunnel, skip * this check. */ - if ((sproto == 0) && (in_broadcast(dst->sin_addr, ifp, - m->m_pkthdr.ph_rtableid))) { + if ((sproto == 0) && ((dst->sin_addr.s_addr == INADDR_BROADCAST) || + (ro && ro->ro_rt && ISSET(ro->ro_rt->rt_flags, RTF_BROADCAST)))) { if ((ifp->if_flags & IFF_BROADCAST) == 0) { error = EADDRNOTAVAIL; goto bad;