Index: UPDATING =================================================================== --- UPDATING +++ UPDATING @@ -31,6 +31,14 @@ disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20160808: + The UDP receive code has been updated to only treat incoming UDP + packets that were addressed to an L2 broadcast address as L3 + broadcast packets. It is not expected that this will affect any + standards-conforming UDP application. The new behaviour can be + disabled by setting the sysctl net.inet.udp.require_l2_bcast to + 0. + 20160622: The libc stub for the pipe(2) system call has been replaced with a wrapper that calls the pipe2(2) system call and the pipe(2) Index: sys/net/ethernet.h =================================================================== --- sys/net/ethernet.h +++ sys/net/ethernet.h @@ -71,6 +71,9 @@ } __packed; #define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */ +#define ETHER_IS_BROADCAST(addr) \ + (((addr)[0] & (addr)[1] & (addr)[2] & \ + (addr)[3] & (addr)[4] & (addr)[5]) == 0xff) /* * 802.1q Virtual LAN header. Index: sys/net/if_ethersubr.c =================================================================== --- sys/net/if_ethersubr.c +++ sys/net/if_ethersubr.c @@ -115,8 +115,6 @@ #endif static int ether_requestencap(struct ifnet *, struct if_encap_req *); -#define ETHER_IS_BROADCAST(addr) \ - (bcmp(etherbroadcastaddr, (addr), ETHER_ADDR_LEN) == 0) #define senderr(e) do { error = (e); goto bad;} while (0) Index: sys/net/if_gif.c =================================================================== --- sys/net/if_gif.c +++ sys/net/if_gif.c @@ -166,14 +166,6 @@ CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(parallel_tunnels), 0, "Allow parallel tunnels?"); -/* copy from src/sys/net/if_ethersubr.c */ -static const u_char etherbroadcastaddr[ETHER_ADDR_LEN] = - { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -#ifndef ETHER_IS_BROADCAST -#define ETHER_IS_BROADCAST(addr) \ - (bcmp(etherbroadcastaddr, (addr), ETHER_ADDR_LEN) == 0) -#endif - static int gif_clone_create(struct if_clone *ifc, int unit, caddr_t params) { Index: sys/net80211/ieee80211_input.c =================================================================== --- sys/net80211/ieee80211_input.c +++ sys/net80211/ieee80211_input.c @@ -283,7 +283,10 @@ IEEE80211_NODE_STAT(ni, rx_data); IEEE80211_NODE_STAT_ADD(ni, rx_bytes, m->m_pkthdr.len); if (ETHER_IS_MULTICAST(eh->ether_dhost)) { - m->m_flags |= M_MCAST; /* XXX M_BCAST? */ + if (ETHER_IS_BROADCAST(eh->ether_dhost)) + m->m_flags |= M_BCAST; + else + m->m_flags |= M_MCAST; IEEE80211_NODE_STAT(ni, rx_mcast); } else IEEE80211_NODE_STAT(ni, rx_ucast); Index: sys/netinet/udp_usrreq.c =================================================================== --- sys/netinet/udp_usrreq.c +++ sys/netinet/udp_usrreq.c @@ -126,6 +126,11 @@ &VNET_NAME(udp_blackhole), 0, "Do not send port unreachables for refused connects"); +static VNET_DEFINE(int, udp_require_l2_bcast) = 1; +SYSCTL_INT(_net_inet_udp, OID_AUTO, require_l2_bcast, CTLFLAG_VNET | CTLFLAG_RW, + &VNET_NAME(udp_require_l2_bcast), 0, + "Only treat packets sent to an L2 broadcast address as broadcast packets"); + u_long udp_sendspace = 9216; /* really max datagram size */ SYSCTL_ULONG(_net_inet_udp, UDPCTL_MAXDGRAM, maxdgram, CTLFLAG_RW, &udp_sendspace, 0, "Maximum outgoing UDP datagram size"); @@ -523,7 +528,8 @@ pcbinfo = udp_get_inpcbinfo(proto); if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) || - in_broadcast(ip->ip_dst, ifp)) { + ((!VNET_NAME(udp_require_l2_bcast) || m->m_flags & M_BCAST) && + in_broadcast(ip->ip_dst, ifp))) { struct inpcb *last; struct inpcbhead *pcblist; struct ip_moptions *imo;