Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ipv4: allow directed broadcast routes to use dst hint

Currently, ip_extract_route_hint uses RTN_BROADCAST to decide
whether to use the route dst hint mechanism.

This check is too strict, as it prevents directed broadcast
routes from using the hint, resulting in poor performance
during bursts of directed broadcast traffic.

Fix this in ip_extract_route_hint and modify ip_route_use_hint
to preserve the intended behaviour.

Signed-off-by: Oscar Maes <oscmaes92@gmail.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20250819174642.5148-2-oscmaes92@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Oscar Maes and committed by
Jakub Kicinski
1b8c5fa0 7f052126

+8 -5
+7 -4
net/ipv4/ip_input.c
··· 587 587 } 588 588 589 589 static struct sk_buff *ip_extract_route_hint(const struct net *net, 590 - struct sk_buff *skb, int rt_type) 590 + struct sk_buff *skb) 591 591 { 592 - if (fib4_has_custom_rules(net) || rt_type == RTN_BROADCAST || 592 + const struct iphdr *iph = ip_hdr(skb); 593 + 594 + if (fib4_has_custom_rules(net) || 595 + ipv4_is_lbcast(iph->daddr) || 596 + ipv4_is_zeronet(iph->daddr) || 593 597 IPCB(skb)->flags & IPSKB_MULTIPATH) 594 598 return NULL; 595 599 ··· 622 618 623 619 dst = skb_dst(skb); 624 620 if (curr_dst != dst) { 625 - hint = ip_extract_route_hint(net, skb, 626 - dst_rtable(dst)->rt_type); 621 + hint = ip_extract_route_hint(net, skb); 627 622 628 623 /* dispatch old sublist */ 629 624 if (!list_empty(&sublist))
+1 -1
net/ipv4/route.c
··· 2210 2210 goto martian_source; 2211 2211 } 2212 2212 2213 - if (rt->rt_type != RTN_LOCAL) 2213 + if (!(rt->rt_flags & RTCF_LOCAL)) 2214 2214 goto skip_validate_source; 2215 2215 2216 2216 reason = fib_validate_source_reason(skb, saddr, daddr, dscp, 0, dev,