netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@kernel.org>
To: Ido Schimmel <idosch@nvidia.com>, netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	edumazet@google.com, mark.tomlinson@alliedtelesis.co.nz,
	sharpd@nvidia.com, mlxsw@nvidia.com
Subject: Re: [PATCH net 2/2] ipv4: Fix incorrect route flushing when table ID 0 is used
Date: Sun, 4 Dec 2022 09:27:02 -0700	[thread overview]
Message-ID: <31b1b29b-432b-f628-af3e-c5fd03973148@kernel.org> (raw)
In-Reply-To: <20221204075045.3780097-3-idosch@nvidia.com>

On 12/4/22 12:50 AM, Ido Schimmel wrote:
> Cited commit added the table ID to the FIB info structure, but did not
> properly initialize it when table ID 0 is used. This can lead to a route
> in the default VRF with a preferred source address not being flushed
> when the address is deleted.
> 
> Consider the following example:
> 
>  # ip address add dev dummy1 192.0.2.1/28
>  # ip address add dev dummy1 192.0.2.17/28
>  # ip route add 198.51.100.0/24 via 192.0.2.2 src 192.0.2.17 metric 100
>  # ip route add table 0 198.51.100.0/24 via 192.0.2.2 src 192.0.2.17 metric 200
>  # ip route show 198.51.100.0/24
>  198.51.100.0/24 via 192.0.2.2 dev dummy1 src 192.0.2.17 metric 100
>  198.51.100.0/24 via 192.0.2.2 dev dummy1 src 192.0.2.17 metric 200
> 
> Both routes are installed in the default VRF, but they are using two
> different FIB info structures. One with a metric of 100 and table ID of
> 254 (main) and one with a metric of 200 and table ID of 0. Therefore,
> when the preferred source address is deleted from the default VRF,
> the second route is not flushed:
> 
>  # ip address del dev dummy1 192.0.2.17/28
>  # ip route show 198.51.100.0/24
>  198.51.100.0/24 via 192.0.2.2 dev dummy1 src 192.0.2.17 metric 200
> 
> Fix by storing a table ID of 254 instead of 0 in the route configuration
> structure.
> 
> Add a test case that fails before the fix:
> 
>  # ./fib_tests.sh -t ipv4_del_addr
> 
>  IPv4 delete address route tests
>      Regular FIB info
>      TEST: Route removed from VRF when source address deleted            [ OK ]
>      TEST: Route in default VRF not removed                              [ OK ]
>      TEST: Route removed in default VRF when source address deleted      [ OK ]
>      TEST: Route in VRF is not removed by address delete                 [ OK ]
>      Identical FIB info with different table ID
>      TEST: Route removed from VRF when source address deleted            [ OK ]
>      TEST: Route in default VRF not removed                              [ OK ]
>      TEST: Route removed in default VRF when source address deleted      [ OK ]
>      TEST: Route in VRF is not removed by address delete                 [ OK ]
>      Table ID 0
>      TEST: Route removed in default VRF when source address deleted      [FAIL]
> 
>  Tests passed:   8
>  Tests failed:   1
> 
> And passes after:
> 
>  # ./fib_tests.sh -t ipv4_del_addr
> 
>  IPv4 delete address route tests
>      Regular FIB info
>      TEST: Route removed from VRF when source address deleted            [ OK ]
>      TEST: Route in default VRF not removed                              [ OK ]
>      TEST: Route removed in default VRF when source address deleted      [ OK ]
>      TEST: Route in VRF is not removed by address delete                 [ OK ]
>      Identical FIB info with different table ID
>      TEST: Route removed from VRF when source address deleted            [ OK ]
>      TEST: Route in default VRF not removed                              [ OK ]
>      TEST: Route removed in default VRF when source address deleted      [ OK ]
>      TEST: Route in VRF is not removed by address delete                 [ OK ]
>      Table ID 0
>      TEST: Route removed in default VRF when source address deleted      [ OK ]
> 
>  Tests passed:   9
>  Tests failed:   0
> 
> Fixes: 5a56a0b3a45d ("net: Don't delete routes in different VRFs")
> Reported-by: Donald Sharp <sharpd@nvidia.com>
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
> ---
>  net/ipv4/fib_frontend.c                  |  3 +++
>  tools/testing/selftests/net/fib_tests.sh | 10 ++++++++++
>  2 files changed, 13 insertions(+)
> 

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



  reply	other threads:[~2022-12-04 16:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-04  7:50 [PATCH net 0/2] ipv4: Two bug fixes Ido Schimmel
2022-12-04  7:50 ` [PATCH net 1/2] ipv4: Fix incorrect route flushing when source address is deleted Ido Schimmel
2022-12-04 16:25   ` David Ahern
2022-12-04  7:50 ` [PATCH net 2/2] ipv4: Fix incorrect route flushing when table ID 0 is used Ido Schimmel
2022-12-04 16:27   ` David Ahern [this message]
2022-12-07  4:40 ` [PATCH net 0/2] ipv4: Two bug fixes patchwork-bot+netdevbpf

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=31b1b29b-432b-f628-af3e-c5fd03973148@kernel.org \
    --to=dsahern@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=mark.tomlinson@alliedtelesis.co.nz \
    --cc=mlxsw@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sharpd@nvidia.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;
as well as URLs for NNTP newsgroup(s).