Re: [PATCH net-next v3 2/2] ipv4: snapshot dst.dev in ip_rt_send_redirect() and ip_rt_get_source()

From: Ido Schimmel

Date: Mon Jul 13 2026 - 12:02:44 EST


On Wed, Jul 08, 2026 at 02:05:37PM +0800, xuanqiang.luo@xxxxxxxxx wrote:
> From: Xuanqiang Luo <luoxuanqiang@xxxxxxxxxx>
>
> rt_flush_dev() can replace rt->dst.dev with blackhole_netdev while RCU
> readers are running. ip_rt_send_redirect() and ip_rt_get_source() both
> read rt->dst.dev more than once and use the results in one operation.
>
> If rt->dst.dev changes between those reads, the operation can use values
> from two devices. For example, ip_rt_send_redirect() can use in_dev from
> the old device and the L3 master ifindex from blackhole_netdev.
>
> Read rt->dst.dev once in these two functions and use the snapshot for the
> later device accesses.
>
> Signed-off-by: Xuanqiang Luo <luoxuanqiang@xxxxxxxxxx>

Reviewed-by: Ido Schimmel <idosch@xxxxxxxxxx>