[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <36936855-97be-4dda-b579-a3050704f874@kernel.org>
Date: Mon, 15 Jul 2024 15:34:51 -0700
From: David Ahern <dsahern@...nel.org>
To: Ido Schimmel <idosch@...dia.com>, netdev@...r.kernel.org
Cc: davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com,
edumazet@...gle.com, gnault@...hat.com, roopa@...ulusnetworks.com
Subject: Re: [PATCH net 2/2] ipv4: Fix incorrect TOS in fibmatch route get
reply
On 7/15/24 7:23 AM, Ido Schimmel wrote:
> The TOS value that is returned to user space in the route get reply is
> the one with which the lookup was performed ('fl4->flowi4_tos'). This is
> fine when the matched route is configured with a TOS as it would not
> match if its TOS value did not match the one with which the lookup was
> performed.
>
> However, matching on TOS is only performed when the route's TOS is not
> zero. It is therefore possible to have the kernel incorrectly return a
> non-zero TOS:
>
> # ip link add name dummy1 up type dummy
> # ip address add 192.0.2.1/24 dev dummy1
> # ip route get fibmatch 192.0.2.2 tos 0xfc
> 192.0.2.0/24 tos 0x1c dev dummy1 proto kernel scope link src 192.0.2.1
>
> Fix by instead returning the DSCP field from the FIB result structure
> which was populated during the route lookup.
>
> Output after the patch:
>
> # ip link add name dummy1 up type dummy
> # ip address add 192.0.2.1/24 dev dummy1
> # ip route get fibmatch 192.0.2.2 tos 0xfc
> 192.0.2.0/24 dev dummy1 proto kernel scope link src 192.0.2.1
>
> Extend the existing selftests to not only verify that the correct route
> is returned, but that it is also returned with correct "tos" value (or
> without it).
>
> Fixes: b61798130f1b ("net: ipv4: RTM_GETROUTE: return matched fib result when requested")
> Signed-off-by: Ido Schimmel <idosch@...dia.com>
> ---
> net/ipv4/route.c | 2 +-
> tools/testing/selftests/net/fib_tests.sh | 24 ++++++++++++------------
> 2 files changed, 13 insertions(+), 13 deletions(-)
>
Reviewed-by: David Ahern <dsahern@...nel.org>
Powered by blists - more mailing lists