Re: ipv4: icmp: icmp_route_lookup() relookups pick wrong netdev with policy routing + strict rp_filter
From: Eric Dumazet
Date: Wed Jul 22 2026 - 03:02:00 EST
On Fri, Jul 17, 2026 at 12:28 PM Muhammad Ziad <muhzi100@xxxxxxxxx> wrote:
>
> Seems ANYSRC flag is required for ip_route_output_key() to not fail
> with an error:
>
> diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
> index 23e921d313b3..c2428fa21b07 100644
> --- a/net/ipv4/icmp.c
> +++ b/net/ipv4/icmp.c
> @@ -548,10 +548,15 @@ static struct rtable *icmp_route_lookup(struct
> net *net, struct flowi4 *fl4,
> if (IS_ERR(rt2))
> err = PTR_ERR(rt2);
> } else {
> - struct flowi4 fl4_2 = {};
> + struct flowi4 fl4_2 = fl4_dec;
> unsigned long orefdst;
>
> - fl4_2.daddr = fl4_dec.saddr;
> + swap(fl4_2.daddr, fl4_2.saddr);
> + swap(fl4_2.fl4_sport, fl4_2.fl4_dport);
> +
> + fl4_2.flowi4_oif = l3mdev_master_ifindex(route_lookup_dev);
> + fl4_2.flowi4_flags |= FLOWI_FLAG_ANYSRC;
> +
Thanks for the tip, I am going to test this today.