Skip to content
Permalink
Browse files

net: ipv4: Allow UDP packets with broadcast dst address

Make sure we are able to receive UDP packets with broadcast
destination address. If CONFIG_NET_IPV4_ACCEPT_ZERO_BROADCAST
is set, then check here also non-standard broadcast address
that is described in RFC 1122 chapter 3.3.6.

Fixes #11617

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information...
jukkar committed May 15, 2019
1 parent 65352a7 commit b800737f7209002d9bc051bb74b4ac5595c1b87f
Showing with 15 additions and 6 deletions.
  1. +6 −0 subsys/net/ip/Kconfig.ipv4
  2. +9 −6 subsys/net/ip/ipv4.c
@@ -43,6 +43,12 @@ config NET_ICMPV4_ACCEPT_BROADCAST
If set, then respond to ICMPv4 echo-request that is sent to
broadcast address.

config NET_IPV4_ACCEPT_ZERO_BROADCAST
bool "Accept 0.0.0.0 broadcast destination address"
help
If set, then accept UDP packets destined to non-standard
0.0.0.0 broadcast address as described in RFC 1122 ch. 3.3.6

config NET_DHCPV4
bool "Enable DHCPv4 client"

@@ -166,12 +166,15 @@ enum net_verdict net_ipv4_input(struct net_pkt *pkt)
}

if ((!net_ipv4_is_my_addr(&hdr->dst) &&
!net_ipv4_is_addr_mcast(&hdr->dst)) ||
((hdr->proto == IPPROTO_UDP &&
net_ipv4_addr_cmp(&hdr->dst, net_ipv4_broadcast_address()) &&
!IS_ENABLED(CONFIG_NET_DHCPV4)) ||
(hdr->proto == IPPROTO_TCP &&
net_ipv4_is_addr_bcast(net_pkt_iface(pkt), &hdr->dst)))) {
!net_ipv4_is_addr_mcast(&hdr->dst) &&
!(hdr->proto == IPPROTO_UDP &&
(net_ipv4_addr_cmp(&hdr->dst, net_ipv4_broadcast_address()) ||
/* RFC 1122 ch. 3.3.6 The 0.0.0.0 is non-standard bcast addr */
(IS_ENABLED(CONFIG_NET_IPV4_ACCEPT_ZERO_BROADCAST) &&
net_ipv4_addr_cmp(&hdr->dst,
net_ipv4_unspecified_address()))))) ||
(hdr->proto == IPPROTO_TCP &&
net_ipv4_is_addr_bcast(net_pkt_iface(pkt), &hdr->dst))) {
NET_DBG("DROP: not for me");
goto drop;
}

0 comments on commit b800737

Please sign in to comment.
You can’t perform that action at this time.