Skip to contentSkip to conversation

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

PATCH Superseded Oscar Maes 3 participants 3 messages Jul 24, 2025 – Jul 25, 2025

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Oscar Maes

author
#0 lore raw

PATCH 1/1 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.

---
 net/ipv4/ip_input.c | 6 ++++--
 net/ipv4/route.c    | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)
net/ipv4/ip_input.c +4 -2
index fc323994b..1581b98bc 100644
@@ -589,8 +589,10 @@ static void ip_sublist_rcv_finish(struct list_head *head)
 static struct sk_buff *ip_extract_route_hint(const struct net *net,
 					     struct sk_buff *skb, int rt_type)
 {
-	if (fib4_has_custom_rules(net) || rt_type == RTN_BROADCAST ||
-	    IPCB(skb)->flags & IPSKB_MULTIPATH)
+	const struct iphdr *iph = ip_hdr(skb);
+
+	if (fib4_has_custom_rules(net) || ipv4_is_lbcast(iph->daddr) ||
+	    (iph->daddr == 0 && iph->saddr == 0) || IPCB(skb)->flags & IPSKB_MULTIPATH)
 		return NULL;
 
 	return skb;
net/ipv4/route.c +1 -1
index f639a2ae8..1f212b2ce 100644
@@ -2210,7 +2210,7 @@ ip_route_use_hint(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 		goto martian_source;
 	}
 
-	if (rt->rt_type != RTN_LOCAL)
+	if (!(rt->rt_flags & RTCF_LOCAL))
 		goto skip_validate_source;
 
 	reason = fib_validate_source_reason(skb, saddr, daddr, dscp, 0, dev,
Signature · 1 line
2.39.5
#1 lore raw
FYI: kernel test robot notices the stable kernel rule is not satisfied.

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1

Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH net-next] net: ipv4: allow directed broadcast routes to use dst hint

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
maintainer
#2 lore raw
In reply to Oscar Maes
Quoted 9 lines · On Thu, 24 Jul 2025 14:49:42 +0200 Oscar Maes wrote:

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.

We are wrapping up our 6.17 material, I think this will need to wait for 6.18. In the meantime, would it make sense to add a selftest? Sounds like a relatively rare use case, easy to regress.

Quoted 5 lines
net/ipv4/ip_input.c +0 -0
index fc323994b..1581b98bc 100644

net/ipv4/ip_input.c static void ip_sublist_rcv_finish(struct list_head *head) · line 595

Quoted 9 lines
net/ipv4/ip_input.c +4 -2
@@ -589,8 +589,10 @@ static void ip_sublist_rcv_finish(struct list_head *head)
 static struct sk_buff *ip_extract_route_hint(const struct net *net,
 					     struct sk_buff *skb, int rt_type)
 {
-	if (fib4_has_custom_rules(net) || rt_type == RTN_BROADCAST ||
-	    IPCB(skb)->flags & IPSKB_MULTIPATH)
+	const struct iphdr *iph = ip_hdr(skb);
+
+	if (fib4_has_custom_rules(net) || ipv4_is_lbcast(iph->daddr) ||
+	    (iph->daddr == 0 && iph->saddr == 0) || IPCB(skb)->flags & IPSKB_MULTIPATH)

nit: we still prefer to wrap lines at 80 chars in networking

Signature · 1 line
pw-bot: cr