diff --git a/sys/netinet/in.c b/sys/netinet/in.c index d1dd2b31b6ef..2794fc068f09 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -81,6 +81,12 @@ static void in_purgemaddrs(struct ifnet *); static bool ia_need_loopback_route(const struct in_ifaddr *); +static bool subnet_addr_is_broadcast = 1; + +SYSCTL_BOOL(_net_inet_ip, OID_AUTO, subnet_addr_is_broadcast, CTLFLAG_RW, + &subnet_addr_is_broadcast, true, + "Treat IPv4 subnet address as a broadcast address"); + VNET_DEFINE_STATIC(int, nosameprefix); #define V_nosameprefix VNET(nosameprefix) SYSCTL_INT(_net_inet_ip, OID_AUTO, no_same_prefix, CTLFLAG_VNET | CTLFLAG_RW, @@ -1137,9 +1143,11 @@ in_ifaddr_broadcast(struct in_addr in, struct in_ifaddr *ia) /* * Check for old-style (host 0) broadcast, but * taking into account that RFC 3021 obsoletes it. + * Also gated by subnet_addr_is_broadcast sysctl. */ (ia->ia_subnetmask != IN_RFC3021_MASK && - ntohl(in.s_addr) == ia->ia_subnet)) && + ntohl(in.s_addr) == ia->ia_subnet && + subnet_addr_is_broadcast)) && /* * Check for an all one subnetmask. These * only exist when an interface gets a secondary