Patch "ipv4: Fix incorrect route flushing when table ID 0 is used" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ipv4: Fix incorrect route flushing when table ID 0 is used

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ipv4-fix-incorrect-route-flushing-when-table-id-0-is.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit cfd0d5e5b7af2976d3d6bc06078ed2cdffe9fd88
Author: Ido Schimmel <idosch@xxxxxxxxxx>
Date:   Sun Dec 4 09:50:45 2022 +0200

    ipv4: Fix incorrect route flushing when table ID 0 is used
    
    [ Upstream commit c0d999348e01df03e0a7f550351f3907fabbf611 ]
    
    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@xxxxxxxxxx>
    Signed-off-by: Ido Schimmel <idosch@xxxxxxxxxx>
    Reviewed-by: David Ahern <dsahern@xxxxxxxxxx>
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index d38c8ca93ba0..be31eeacb0be 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -840,6 +840,9 @@ static int rtm_to_fib_config(struct net *net, struct sk_buff *skb,
 		return -EINVAL;
 	}
 
+	if (!cfg->fc_table)
+		cfg->fc_table = RT_TABLE_MAIN;
+
 	return 0;
 errout:
 	return err;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux