public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2] net: ipv4: fix stat increase when udp early demux drops the packet
@ 2025-07-01  7:49 Antoine Tenart
  2025-07-01 14:33 ` Sabrina Dubroca
  2025-07-02 22:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Antoine Tenart @ 2025-07-01  7:49 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet
  Cc: Antoine Tenart, netdev, Menglong Dong, Sabrina Dubroca

udp_v4_early_demux now returns drop reasons as it either returns 0 or
ip_mc_validate_source, which returns itself a drop reason. However its
use was not converted in ip_rcv_finish_core and the drop reason is
ignored, leading to potentially skipping increasing LINUX_MIB_IPRPFILTER
if the drop reason is SKB_DROP_REASON_IP_RPFILTER.

This is a fix and we're not converting udp_v4_early_demux to explicitly
return a drop reason to ease backports; this can be done as a follow-up.

Fixes: d46f827016d8 ("net: ip: make ip_mc_validate_source() return drop reason")
Cc: Menglong Dong <menglong8.dong@gmail.com>
Reported-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Antoine Tenart <atenart@kernel.org>
---
Changes in v2:
  - Reset the drop reason to NOT_SPECIFIED if not returning early. The
    diff remains small and this aligns with the rest of the function.
---
 net/ipv4/ip_input.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 30a5e9460d00..5a49eb99e5c4 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -319,8 +319,8 @@ static int ip_rcv_finish_core(struct net *net,
 			      const struct sk_buff *hint)
 {
 	const struct iphdr *iph = ip_hdr(skb);
-	int err, drop_reason;
 	struct rtable *rt;
+	int drop_reason;
 
 	if (ip_can_use_hint(skb, iph, hint)) {
 		drop_reason = ip_route_use_hint(skb, iph->daddr, iph->saddr,
@@ -345,9 +345,10 @@ static int ip_rcv_finish_core(struct net *net,
 			break;
 		case IPPROTO_UDP:
 			if (READ_ONCE(net->ipv4.sysctl_udp_early_demux)) {
-				err = udp_v4_early_demux(skb);
-				if (unlikely(err))
+				drop_reason = udp_v4_early_demux(skb);
+				if (unlikely(drop_reason))
 					goto drop_error;
+				drop_reason = SKB_DROP_REASON_NOT_SPECIFIED;
 
 				/* must reload iph, skb->head might have changed */
 				iph = ip_hdr(skb);
-- 
2.50.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net: ipv4: fix stat increase when udp early demux drops the packet
  2025-07-01  7:49 [PATCH net v2] net: ipv4: fix stat increase when udp early demux drops the packet Antoine Tenart
@ 2025-07-01 14:33 ` Sabrina Dubroca
  2025-07-02 22:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Sabrina Dubroca @ 2025-07-01 14:33 UTC (permalink / raw)
  To: Antoine Tenart; +Cc: davem, kuba, pabeni, edumazet, netdev, Menglong Dong

2025-07-01, 09:49:34 +0200, Antoine Tenart wrote:
> udp_v4_early_demux now returns drop reasons as it either returns 0 or
> ip_mc_validate_source, which returns itself a drop reason. However its
> use was not converted in ip_rcv_finish_core and the drop reason is
> ignored, leading to potentially skipping increasing LINUX_MIB_IPRPFILTER
> if the drop reason is SKB_DROP_REASON_IP_RPFILTER.
> 
> This is a fix and we're not converting udp_v4_early_demux to explicitly
> return a drop reason to ease backports; this can be done as a follow-up.
> 
> Fixes: d46f827016d8 ("net: ip: make ip_mc_validate_source() return drop reason")
> Cc: Menglong Dong <menglong8.dong@gmail.com>
> Reported-by: Sabrina Dubroca <sd@queasysnail.net>
> Signed-off-by: Antoine Tenart <atenart@kernel.org>
> ---
> Changes in v2:
>   - Reset the drop reason to NOT_SPECIFIED if not returning early. The
>     diff remains small and this aligns with the rest of the function.
> ---
>  net/ipv4/ip_input.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>

Thanks Antoine.

-- 
Sabrina

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net: ipv4: fix stat increase when udp early demux drops the packet
  2025-07-01  7:49 [PATCH net v2] net: ipv4: fix stat increase when udp early demux drops the packet Antoine Tenart
  2025-07-01 14:33 ` Sabrina Dubroca
@ 2025-07-02 22:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-07-02 22:00 UTC (permalink / raw)
  To: Antoine Tenart; +Cc: davem, kuba, pabeni, edumazet, netdev, menglong8.dong, sd

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue,  1 Jul 2025 09:49:34 +0200 you wrote:
> udp_v4_early_demux now returns drop reasons as it either returns 0 or
> ip_mc_validate_source, which returns itself a drop reason. However its
> use was not converted in ip_rcv_finish_core and the drop reason is
> ignored, leading to potentially skipping increasing LINUX_MIB_IPRPFILTER
> if the drop reason is SKB_DROP_REASON_IP_RPFILTER.
> 
> This is a fix and we're not converting udp_v4_early_demux to explicitly
> return a drop reason to ease backports; this can be done as a follow-up.
> 
> [...]

Here is the summary with links:
  - [net,v2] net: ipv4: fix stat increase when udp early demux drops the packet
    https://git.kernel.org/netdev/net/c/c2a2ff6b4db5

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-02 21:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-01  7:49 [PATCH net v2] net: ipv4: fix stat increase when udp early demux drops the packet Antoine Tenart
2025-07-01 14:33 ` Sabrina Dubroca
2025-07-02 22:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox