Skip to content

Commit 996b44f

Browse files
Paolo Abenidavem330
authored andcommitted
udp: fix bcast packet reception
The commit bc044e8 ("udp: perform source validation for mcast early demux") does not take into account that broadcast packets lands in the same code path and they need different checks for the source address - notably, zero source address are valid for bcast and invalid for mcast. As a result, 2nd and later broadcast packets with 0 source address landing to the same socket are dropped. This breaks dhcp servers. Since we don't have stringent performance requirements for ingress broadcast traffic, fix it by disabling UDP early demux such traffic. Reported-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Fixes: bc044e8 ("udp: perform source validation for mcast early demux") Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 41c8742 commit 996b44f

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

net/ipv4/udp.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,20 +2240,16 @@ int udp_v4_early_demux(struct sk_buff *skb)
22402240
iph = ip_hdr(skb);
22412241
uh = udp_hdr(skb);
22422242

2243-
if (skb->pkt_type == PACKET_BROADCAST ||
2244-
skb->pkt_type == PACKET_MULTICAST) {
2243+
if (skb->pkt_type == PACKET_MULTICAST) {
22452244
in_dev = __in_dev_get_rcu(skb->dev);
22462245

22472246
if (!in_dev)
22482247
return 0;
22492248

2250-
/* we are supposed to accept bcast packets */
2251-
if (skb->pkt_type == PACKET_MULTICAST) {
2252-
ours = ip_check_mc_rcu(in_dev, iph->daddr, iph->saddr,
2253-
iph->protocol);
2254-
if (!ours)
2255-
return 0;
2256-
}
2249+
ours = ip_check_mc_rcu(in_dev, iph->daddr, iph->saddr,
2250+
iph->protocol);
2251+
if (!ours)
2252+
return 0;
22572253

22582254
sk = __udp4_lib_mcast_demux_lookup(net, uh->dest, iph->daddr,
22592255
uh->source, iph->saddr,

0 commit comments

Comments
 (0)