Netdev List
 help / color / mirror / Atom feed
From: David Ahern <dsahern@kernel.org>
To: Eric Dumazet <edumazet@google.com>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>, Ido Schimmel <idosch@nvidia.com>,
	netdev@vger.kernel.org, eric.dumazet@gmail.com,
	Muhammad Ziad <muhzi100@gmail.com>
Subject: Re: [PATCH v2 net] ipv4: icmp: fill flow parameters in icmp_route_lookup decoy lookup
Date: Wed, 22 Jul 2026 17:06:19 -0600	[thread overview]
Message-ID: <d61be2b8-a313-4957-9927-ec8c63221f59@kernel.org> (raw)
In-Reply-To: <20260722104236.2938082-1-edumazet@google.com>

On 7/22/26 4:42 AM, Eric Dumazet wrote:
> When Linux forwards a packet and needs to generate an ICMP error,
> icmp_route_lookup() performs a reverse-path relookup. For non-local
> destinations, it performs a decoy lookup to find the expected egress
> interface (rt2->dst.dev) before validating the path with ip_route_input().
> 
> Currently, the decoy flow structure (fl4_2) only sets .daddr = fl4_dec.saddr,
> leaving .saddr, .flowi4_dscp, .flowi4_proto, .flowi4_mark, .flowi4_oif,
> .fl4_sport, .fl4_dport, and .flowi4_uid zeroed out.
> 
> When policy routing rules (such as ip rule add from $SRC lookup 100, or
> dscp/fwmark/ipproto/port rules, or VRF bindings) are configured:
> 1. The decoy lookup fails to match the policy rule because saddr and other
>    key flow selectors are missing in fl4_2.
> 2. It resolves a route using the default table instead, returning an incorrect
>    egress netdev.
> 3. Passing the wrong netdev to ip_route_input() causes strict reverse-path
>    filtering (rp_filter=1) to fail, logging false-positive "martian source"
>    warnings and causing the relookup to fail.
> 
> Fix this by initializing fl4_2 from fl4_dec and:
> - Swapping source/destination IP addresses.
> - Swapping L4 ports for transport protocols with ports (TCP, UDP, SCTP, DCCP)
>   so port-based policy routing matches correctly. Non-port protocols (such as
>   ICMP or GRE) leave the flowi_uli union fields intact to prevent corruption.
> - Setting .flowi4_oif = l3mdev_master_ifindex(route_lookup_dev) to ensure
>   VRF routing tables are respected.
> - Setting .flowi4_flags |= FLOWI_FLAG_ANYSRC to allow output route lookups
>   for non-local source IP addresses.
> - Using __ip_route_output_key() instead of ip_route_output_key() for fl4_2
>   so that raw FIB routing is used without triggering spurious XFRM policy
>   lookups on the decoy flow (the actual XFRM lookup is performed later using
>   fl4_dec).
> 
> Fixes: 415b3334a21a ("icmp: Fix regression in nexthop resolution during replies.")
> Reported-by: Muhammad Ziad <muhzi100@gmail.com>
> Closes: https://lore.kernel.org/netdev/CAOAwikA60AYKdFr_UDLyja3oU4hqyAE7uFZWqum5uRdaQsgRYg@mail.gmail.com/
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
> v2: addressed Sashiko and Jakub feedback
> v1: https://lore.kernel.org/netdev/20260716021049.2124921-1-edumazet@google.com/
> 
>  net/ipv4/icmp.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 

Reviewed-by: David Ahern <dsahern@kernel.org>



      reply	other threads:[~2026-07-22 23:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 10:42 [PATCH v2 net] ipv4: icmp: fill flow parameters in icmp_route_lookup decoy lookup Eric Dumazet
2026-07-22 23:06 ` David Ahern [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d61be2b8-a313-4957-9927-ec8c63221f59@kernel.org \
    --to=dsahern@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=muhzi100@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox