* [PATCHv6 net-next 0/2] ipv6: update route when delete source address @ 2023-08-16 6:07 Hangbin Liu 2023-08-16 6:07 ` [PATCHv6 net-next 1/2] ipv6: do not match device when remove source route Hangbin Liu 2023-08-16 6:07 ` [PATCHv6 net-next 2/2] selftests: fib_test: add a test case for IPv6 source address delete Hangbin Liu 0 siblings, 2 replies; 5+ messages in thread From: Hangbin Liu @ 2023-08-16 6:07 UTC (permalink / raw) To: netdev Cc: David S . Miller, David Ahern, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Ido Schimmel, Hangbin Liu Currently, when remove an address, the IPv6 route will not remove the prefer source address when the address is bond to other device. Fix this issue and add related tests as Ido and David suggested. Hangbin Liu (2): ipv6: do not match device when remove source route selftests: fib_test: add a test case for IPv6 source address delete net/ipv6/route.c | 7 +- tools/testing/selftests/net/fib_tests.sh | 163 ++++++++++++++++++++++- 2 files changed, 164 insertions(+), 6 deletions(-) -- 2.38.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCHv6 net-next 1/2] ipv6: do not match device when remove source route 2023-08-16 6:07 [PATCHv6 net-next 0/2] ipv6: update route when delete source address Hangbin Liu @ 2023-08-16 6:07 ` Hangbin Liu 2023-08-17 12:02 ` Ido Schimmel 2023-08-16 6:07 ` [PATCHv6 net-next 2/2] selftests: fib_test: add a test case for IPv6 source address delete Hangbin Liu 1 sibling, 1 reply; 5+ messages in thread From: Hangbin Liu @ 2023-08-16 6:07 UTC (permalink / raw) To: netdev Cc: David S . Miller, David Ahern, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Ido Schimmel, Hangbin Liu, Thomas Haller After deleting an IPv6 address on an interface and cleaning up the related preferred source entries, it is important to ensure that all routes associated with the deleted address are properly cleared. The current implementation of rt6_remove_prefsrc() only checks the preferred source addresses bound to the current device. However, there may be routes that are bound to other devices but still utilize the same preferred source address. To address this issue, it is necessary to also delete entries that are bound to other interfaces but share the same source address with the current device. Failure to delete these entries would leave routes that are bound to the deleted address unclear. Here is an example reproducer (I have omitted unrelated routes): + ip link add dummy1 type dummy + ip link add dummy2 type dummy + ip link set dummy1 up + ip link set dummy2 up + ip addr add 1:2:3:4::5/64 dev dummy1 + ip route add 7:7:7:0::1 dev dummy1 src 1:2:3:4::5 + ip route add 7:7:7:0::2 dev dummy2 src 1:2:3:4::5 + ip -6 route show 1:2:3:4::/64 dev dummy1 proto kernel metric 256 pref medium 7:7:7::1 dev dummy1 src 1:2:3:4::5 metric 1024 pref medium 7:7:7::2 dev dummy2 src 1:2:3:4::5 metric 1024 pref medium + ip addr del 1:2:3:4::5/64 dev dummy1 + ip -6 route show 7:7:7::1 dev dummy1 metric 1024 pref medium 7:7:7::2 dev dummy2 src 1:2:3:4::5 metric 1024 pref medium As Ido reminds, in IPv6, the preferred source address is looked up in the same VRF as the first nexthop device, which is different with IPv4. So, while removing the device checking, we also need to add an ipv6_chk_addr() check to make sure the address does not exist on the other devices of the rt nexthop device's VRF. After fix: + ip addr del 1:2:3:4::5/64 dev dummy1 + ip -6 route show 7:7:7::1 dev dummy1 metric 1024 pref medium 7:7:7::2 dev dummy2 metric 1024 pref medium Reported-by: Thomas Haller <thaller@redhat.com> Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2170513 Fixes: c3968a857a6b ("ipv6: RTA_PREFSRC support for ipv6 route source address selection") Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> --- v6: - Add back the "!rt->nh" checking as Ido said this should be fixed in another patch. - Remove the table id checking as the preferred source address is looked up in the same VRF as the first nexthop device in IPv6. not VRF table like IPv4. - Move the fib tests to a separate patch. v5: Move the addr check back to fib6_remove_prefsrc. v4: check if the prefsrc address still exists on other device v3: remove rt nh checking. update the ipv6_del_addr test descriptions v2: checking table id and update fib_test.sh --- net/ipv6/route.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 10751df16dab..3e1c76c7bdd3 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -4582,21 +4582,19 @@ struct fib6_info *addrconf_f6i_alloc(struct net *net, /* remove deleted ip from prefsrc entries */ struct arg_dev_net_ip { - struct net_device *dev; struct net *net; struct in6_addr *addr; }; static int fib6_remove_prefsrc(struct fib6_info *rt, void *arg) { - struct net_device *dev = ((struct arg_dev_net_ip *)arg)->dev; struct net *net = ((struct arg_dev_net_ip *)arg)->net; struct in6_addr *addr = ((struct arg_dev_net_ip *)arg)->addr; if (!rt->nh && - ((void *)rt->fib6_nh->fib_nh_dev == dev || !dev) && rt != net->ipv6.fib6_null_entry && - ipv6_addr_equal(addr, &rt->fib6_prefsrc.addr)) { + ipv6_addr_equal(addr, &rt->fib6_prefsrc.addr) && + !ipv6_chk_addr(net, addr, rt->fib6_nh->fib_nh_dev, 0)) { spin_lock_bh(&rt6_exception_lock); /* remove prefsrc entry */ rt->fib6_prefsrc.plen = 0; @@ -4609,7 +4607,6 @@ void rt6_remove_prefsrc(struct inet6_ifaddr *ifp) { struct net *net = dev_net(ifp->idev->dev); struct arg_dev_net_ip adni = { - .dev = ifp->idev->dev, .net = net, .addr = &ifp->addr, }; -- 2.38.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCHv6 net-next 1/2] ipv6: do not match device when remove source route 2023-08-16 6:07 ` [PATCHv6 net-next 1/2] ipv6: do not match device when remove source route Hangbin Liu @ 2023-08-17 12:02 ` Ido Schimmel 0 siblings, 0 replies; 5+ messages in thread From: Ido Schimmel @ 2023-08-17 12:02 UTC (permalink / raw) To: Hangbin Liu Cc: netdev, David S . Miller, David Ahern, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Thomas Haller On Wed, Aug 16, 2023 at 02:07:23PM +0800, Hangbin Liu wrote: > After deleting an IPv6 address on an interface and cleaning up the > related preferred source entries, it is important to ensure that all > routes associated with the deleted address are properly cleared. The > current implementation of rt6_remove_prefsrc() only checks the preferred > source addresses bound to the current device. However, there may be > routes that are bound to other devices but still utilize the same > preferred source address. > > To address this issue, it is necessary to also delete entries that are > bound to other interfaces but share the same source address with the > current device. Failure to delete these entries would leave routes that > are bound to the deleted address unclear. Here is an example reproducer > (I have omitted unrelated routes): > > + ip link add dummy1 type dummy > + ip link add dummy2 type dummy > + ip link set dummy1 up > + ip link set dummy2 up > + ip addr add 1:2:3:4::5/64 dev dummy1 > + ip route add 7:7:7:0::1 dev dummy1 src 1:2:3:4::5 > + ip route add 7:7:7:0::2 dev dummy2 src 1:2:3:4::5 > + ip -6 route show > 1:2:3:4::/64 dev dummy1 proto kernel metric 256 pref medium > 7:7:7::1 dev dummy1 src 1:2:3:4::5 metric 1024 pref medium > 7:7:7::2 dev dummy2 src 1:2:3:4::5 metric 1024 pref medium > + ip addr del 1:2:3:4::5/64 dev dummy1 > + ip -6 route show > 7:7:7::1 dev dummy1 metric 1024 pref medium > 7:7:7::2 dev dummy2 src 1:2:3:4::5 metric 1024 pref medium > > As Ido reminds, in IPv6, the preferred source address is looked up in > the same VRF as the first nexthop device, which is different with IPv4. > So, while removing the device checking, we also need to add an > ipv6_chk_addr() check to make sure the address does not exist on the other > devices of the rt nexthop device's VRF. > > After fix: > + ip addr del 1:2:3:4::5/64 dev dummy1 > + ip -6 route show > 7:7:7::1 dev dummy1 metric 1024 pref medium > 7:7:7::2 dev dummy2 metric 1024 pref medium > > Reported-by: Thomas Haller <thaller@redhat.com> > Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2170513 > Fixes: c3968a857a6b ("ipv6: RTA_PREFSRC support for ipv6 route source address selection") > Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> But I suggest removing the Fixes tag given the patch is targeted at net-next and does not fix a regression (never worked). ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCHv6 net-next 2/2] selftests: fib_test: add a test case for IPv6 source address delete 2023-08-16 6:07 [PATCHv6 net-next 0/2] ipv6: update route when delete source address Hangbin Liu 2023-08-16 6:07 ` [PATCHv6 net-next 1/2] ipv6: do not match device when remove source route Hangbin Liu @ 2023-08-16 6:07 ` Hangbin Liu 2023-08-17 12:57 ` Ido Schimmel 1 sibling, 1 reply; 5+ messages in thread From: Hangbin Liu @ 2023-08-16 6:07 UTC (permalink / raw) To: netdev Cc: David S . Miller, David Ahern, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Ido Schimmel, Hangbin Liu Add a test case for IPv6 source address delete. As David suggested, add tests: - Single device using src address - Two devices with the same source address - VRF with single device using src address - VRF with two devices using src address As Ido points out, in IPv6, the preferred source address is looked up in the same VRF as the first nexthop device. This will give us similar results to IPv4 if the route is installed in the same VRF as the nexthop device, but not when the nexthop device is enslaved to a different VRF. So add tests: - src address and nexthop dev in same VR - src address and nexthop device in different VRF The link local address delete logic is different from the global address. It should only affect the associate device it bonds to. Add tests cases for link local address testing. The table 0 and same FIB info tests are copied from IPv4 tests. Here is the test result: IPv6 delete address route tests Single device using src address TEST: Prefsrc removed when src address removed on other device [ OK ] Two devices with the same source address TEST: Prefsrc not removed when src address exist on other device [ OK ] VRF with single device using src address TEST: Prefsrc removed when src address removed on other device [ OK ] VRF with two devices using src address TEST: Prefsrc not removed when src address exist on other device [ OK ] src address and nexthop dev in same VRF TEST: Prefsrc removed from VRF when source address deleted [ OK ] TEST: Prefsrc in default VRF not removed [ OK ] TEST: Prefsrc not removed from VRF when source address exist [ OK ] TEST: Prefsrc in default VRF removed [ OK ] src address and nexthop device in different VRF TEST: Prefsrc not removed from VRF when nexthop dev in diff VRF [ OK ] TEST: Prefsrc not removed in default VRF [ OK ] TEST: Prefsrc removed from VRF when nexthop dev in diff VRF [ OK ] TEST: Prefsrc removed in default VRF [ OK ] Same FIB info with different table ID TEST: Prefsrc removed from VRF when source address deleted [ OK ] TEST: Prefsrc in default VRF not removed [ OK ] TEST: Prefsrc not removed from VRF when source address exist [ OK ] TEST: Prefsrc in default VRF removed [ OK ] Table ID 0 TEST: Prefsrc removed from default VRF when source address deleted [ OK ] Link local source route TEST: Prefsrc not removed when delete ll addr from other dev [ OK ] TEST: Prefsrc removed when delete ll addr [ OK ] TEST: Prefsrc not removed when delete ll addr from other dev [ OK ] TEST: Prefsrc removed even ll addr still exist on other dev [ OK ] Tests passed: 21 Tests failed: 0 Suggested-by: Ido Schimmel <idosch@idosch.org> Suggested-by: David Ahern <dsahern@kernel.org> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> --- v7: add more tests as Ido and David suggested. Remove the IPv4 part as I want to focus on the IPv6 fixes. --- tools/testing/selftests/net/fib_tests.sh | 163 ++++++++++++++++++++++- 1 file changed, 162 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh index 35d89dfa6f11..0aa17b2ac8e1 100755 --- a/tools/testing/selftests/net/fib_tests.sh +++ b/tools/testing/selftests/net/fib_tests.sh @@ -9,7 +9,7 @@ ret=0 ksft_skip=4 # all tests in this script. Can be overridden with -t option -TESTS="unregister down carrier nexthop suppress ipv6_notify ipv4_notify ipv6_rt ipv4_rt ipv6_addr_metric ipv4_addr_metric ipv6_route_metrics ipv4_route_metrics ipv4_route_v6_gw rp_filter ipv4_del_addr ipv4_mangle ipv6_mangle ipv4_bcast_neigh" +TESTS="unregister down carrier nexthop suppress ipv6_notify ipv4_notify ipv6_rt ipv4_rt ipv6_addr_metric ipv4_addr_metric ipv6_route_metrics ipv4_route_metrics ipv4_route_v6_gw rp_filter ipv4_del_addr ipv6_del_addr ipv4_mangle ipv6_mangle ipv4_bcast_neigh" VERBOSE=0 PAUSE_ON_FAIL=no @@ -1869,6 +1869,166 @@ ipv4_del_addr_test() cleanup } +ipv6_del_addr_test() +{ + echo + echo "IPv6 delete address route tests" + + setup + + set -e + for i in $(seq 6); do + $IP li add dummy${i} up type dummy + done + + $IP li add red up type vrf table 1111 + $IP ro add vrf red unreachable default + for i in $(seq 4 6); do + $IP li set dummy${i} vrf red + done + + $IP addr add dev dummy1 fe80::1/128 + $IP addr add dev dummy1 2001:db8:101::1/64 + $IP addr add dev dummy1 2001:db8:101::10/64 + $IP addr add dev dummy1 2001:db8:101::11/64 + $IP addr add dev dummy1 2001:db8:101::12/64 + $IP addr add dev dummy1 2001:db8:101::13/64 + $IP addr add dev dummy1 2001:db8:101::14/64 + $IP addr add dev dummy1 2001:db8:101::15/64 + $IP addr add dev dummy2 fe80::1/128 + $IP addr add dev dummy2 2001:db8:101::1/64 + $IP addr add dev dummy2 2001:db8:101::11/64 + $IP addr add dev dummy3 fe80::1/128 + + $IP addr add dev dummy4 2001:db8:101::1/64 + $IP addr add dev dummy4 2001:db8:101::10/64 + $IP addr add dev dummy4 2001:db8:101::11/64 + $IP addr add dev dummy4 2001:db8:101::12/64 + $IP addr add dev dummy4 2001:db8:101::13/64 + $IP addr add dev dummy4 2001:db8:101::14/64 + $IP addr add dev dummy5 2001:db8:101::1/64 + $IP addr add dev dummy5 2001:db8:101::11/64 + + # Single device using src address + $IP route add 2001:db8:110::/64 dev dummy3 src 2001:db8:101::10 + # Two devices with the same source address + $IP route add 2001:db8:111::/64 dev dummy3 src 2001:db8:101::11 + # VRF with single device using src address + $IP route add vrf red 2001:db8:110::/64 dev dummy6 src 2001:db8:101::10 + # VRF with two devices using src address + $IP route add vrf red 2001:db8:111::/64 dev dummy6 src 2001:db8:101::11 + # src address and nexthop dev in same VRF + $IP route add 2001:db8:112::/64 dev dummy3 src 2001:db8:101::12 + $IP route add vrf red 2001:db8:112::/64 dev dummy6 src 2001:db8:101::12 + # src address and nexthop device in different VRF + $IP route add 2001:db8:113::/64 dev lo src 2001:db8:101::13 + $IP route add vrf red 2001:db8:113::/64 dev lo src 2001:db8:101::13 + # Same FIB info with different table ID + $IP route add 2001:db8:114::/64 via 2001:db8:101::2 src 2001:db8:101::14 + $IP route add vrf red 2001:db8:114::/64 via 2001:db8:101::2 src 2001:db8:101::14 + # table ID 0 + $IP route add table 0 2001:db8:115::/64 via 2001:db8:101::2 src 2001:db8:101::15 + # Link local source route + $IP route add 2001:db8:116::/64 dev dummy2 src fe80::1 + $IP route add 2001:db8:117::/64 dev dummy3 src fe80::1 + set +e + + echo " Single device using src address" + + $IP addr del dev dummy1 2001:db8:101::10/64 + $IP -6 route show | grep -q "src 2001:db8:101::10 " + log_test $? 1 "Prefsrc removed when src address removed on other device" + + echo " Two devices with the same source address" + + $IP addr del dev dummy1 2001:db8:101::11/64 + $IP -6 route show | grep -q "src 2001:db8:101::11 " + log_test $? 0 "Prefsrc not removed when src address exist on other device" + + echo " VRF with single device using src address" + + $IP addr del dev dummy4 2001:db8:101::10/64 + $IP -6 route show vrf red | grep -q "src 2001:db8:101::10 " + log_test $? 1 "Prefsrc removed when src address removed on other device" + + echo " VRF with two devices using src address" + + $IP addr del dev dummy4 2001:db8:101::11/64 + $IP -6 route show vrf red | grep -q "src 2001:db8:101::11 " + log_test $? 0 "Prefsrc not removed when src address exist on other device" + + echo " src address and nexthop dev in same VRF" + + $IP addr del dev dummy4 2001:db8:101::12/64 + $IP -6 route show vrf red | grep -q "src 2001:db8:101::12 " + log_test $? 1 "Prefsrc removed from VRF when source address deleted" + $IP -6 route show | grep -q " src 2001:db8:101::12 " + log_test $? 0 "Prefsrc in default VRF not removed" + + $IP addr add dev dummy4 2001:db8:101::12/64 + $IP route replace vrf red 2001:db8:112::/64 dev dummy6 src 2001:db8:101::12 + $IP addr del dev dummy1 2001:db8:101::12/64 + $IP -6 route show vrf red | grep -q "src 2001:db8:101::12 " + log_test $? 0 "Prefsrc not removed from VRF when source address exist" + $IP -6 route show | grep -q " src 2001:db8:101::12 " + log_test $? 1 "Prefsrc in default VRF removed" + + echo " src address and nexthop device in different VRF" + + $IP addr del dev dummy4 2001:db8:101::13/64 + $IP -6 route show vrf red | grep -q "src 2001:db8:101::13 " + log_test $? 0 "Prefsrc not removed from VRF when nexthop dev in diff VRF" + $IP -6 route show | grep -q " src 2001:db8:101::13 " + log_test $? 0 "Prefsrc not removed in default VRF" + + $IP addr add dev dummy4 2001:db8:101::13/64 + $IP addr del dev dummy1 2001:db8:101::13/64 + $IP -6 route show vrf red | grep -q "src 2001:db8:101::13 " + log_test $? 1 "Prefsrc removed from VRF when nexthop dev in diff VRF" + $IP -6 route show | grep -q " src 2001:db8:101::13 " + log_test $? 1 "Prefsrc removed in default VRF" + + echo " Same FIB info with different table ID" + + $IP addr del dev dummy4 2001:db8:101::14/64 + $IP -6 route show vrf red | grep -q "src 2001:db8:101::14 " + log_test $? 1 "Prefsrc removed from VRF when source address deleted" + $IP -6 route show | grep -q " src 2001:db8:101::14 " + log_test $? 0 "Prefsrc in default VRF not removed" + + $IP addr add dev dummy4 2001:db8:101::14/64 + $IP route replace vrf red 2001:db8:114::/64 via 2001:db8:101::2 src 2001:db8:101::14 + $IP addr del dev dummy1 2001:db8:101::14/64 + $IP -6 route show vrf red | grep -q "src 2001:db8:101::14 " + log_test $? 0 "Prefsrc not removed from VRF when source address exist" + $IP -6 route show | grep -q " src 2001:db8:101::14 " + log_test $? 1 "Prefsrc in default VRF removed" + + echo " Table ID 0" + + $IP addr del dev dummy1 2001:db8:101::15/64 + $IP -6 route show | grep -q "src 2001:db8:101::15" + log_test $? 1 "Prefsrc removed from default VRF when source address deleted" + + echo " Link local source route" + $IP addr del dev dummy1 fe80::1/128 + $IP -6 route show | grep -q "2001:db8:116::/64 dev dummy2 src fe80::1" + log_test $? 0 "Prefsrc not removed when delete ll addr from other dev" + $IP addr del dev dummy2 fe80::1/128 + $IP -6 route show | grep -q "2001:db8:116::/64 dev dummy2 src fe80::1" + log_test $? 1 "Prefsrc removed when delete ll addr" + $IP -6 route show | grep -q "2001:db8:117::/64 dev dummy3 src fe80::1" + log_test $? 0 "Prefsrc not removed when delete ll addr from other dev" + $IP addr add dev dummy1 fe80::1/128 + $IP addr del dev dummy3 fe80::1/128 + $IP -6 route show | grep -q "2001:db8:117::/64 dev dummy3 src fe80::1" + log_test $? 1 "Prefsrc removed even ll addr still exist on other dev" + + for i in $(seq 6); do + $IP li del dummy${i} + done + cleanup +} ipv4_route_v6_gw_test() { @@ -2211,6 +2371,7 @@ do ipv6_addr_metric) ipv6_addr_metric_test;; ipv4_addr_metric) ipv4_addr_metric_test;; ipv4_del_addr) ipv4_del_addr_test;; + ipv6_del_addr) ipv6_del_addr_test;; ipv6_route_metrics) ipv6_route_metrics_test;; ipv4_route_metrics) ipv4_route_metrics_test;; ipv4_route_v6_gw) ipv4_route_v6_gw_test;; -- 2.38.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCHv6 net-next 2/2] selftests: fib_test: add a test case for IPv6 source address delete 2023-08-16 6:07 ` [PATCHv6 net-next 2/2] selftests: fib_test: add a test case for IPv6 source address delete Hangbin Liu @ 2023-08-17 12:57 ` Ido Schimmel 0 siblings, 0 replies; 5+ messages in thread From: Ido Schimmel @ 2023-08-17 12:57 UTC (permalink / raw) To: Hangbin Liu Cc: netdev, David S . Miller, David Ahern, Eric Dumazet, Jakub Kicinski, Paolo Abeni This no longer applies after commit a63e10da42e7 ("selftests: fib_tests: Add a test case for IPv6 garbage collection") so you will need to rebase. Thanks for the test cases. See a few comments below. On Wed, Aug 16, 2023 at 02:07:24PM +0800, Hangbin Liu wrote: > Add a test case for IPv6 source address delete. As David suggested, add tests: > - Single device using src address > - Two devices with the same source address > - VRF with single device using src address > - VRF with two devices using src address > > As Ido points out, in IPv6, the preferred source address is looked up in > the same VRF as the first nexthop device. This will give us similar results > to IPv4 if the route is installed in the same VRF as the nexthop device, but > not when the nexthop device is enslaved to a different VRF. So add tests: > - src address and nexthop dev in same VR > - src address and nexthop device in different VRF > > The link local address delete logic is different from the global address. > It should only affect the associate device it bonds to. Add tests cases > for link local address testing. > > The table 0 and same FIB info tests are copied from IPv4 tests. > > Here is the test result: > > IPv6 delete address route tests > Single device using src address > TEST: Prefsrc removed when src address removed on other device [ OK ] > Two devices with the same source address > TEST: Prefsrc not removed when src address exist on other device [ OK ] > VRF with single device using src address > TEST: Prefsrc removed when src address removed on other device [ OK ] > VRF with two devices using src address > TEST: Prefsrc not removed when src address exist on other device [ OK ] > src address and nexthop dev in same VRF > TEST: Prefsrc removed from VRF when source address deleted [ OK ] > TEST: Prefsrc in default VRF not removed [ OK ] > TEST: Prefsrc not removed from VRF when source address exist [ OK ] > TEST: Prefsrc in default VRF removed [ OK ] > src address and nexthop device in different VRF > TEST: Prefsrc not removed from VRF when nexthop dev in diff VRF [ OK ] > TEST: Prefsrc not removed in default VRF [ OK ] > TEST: Prefsrc removed from VRF when nexthop dev in diff VRF [ OK ] > TEST: Prefsrc removed in default VRF [ OK ] > Same FIB info with different table ID > TEST: Prefsrc removed from VRF when source address deleted [ OK ] > TEST: Prefsrc in default VRF not removed [ OK ] > TEST: Prefsrc not removed from VRF when source address exist [ OK ] > TEST: Prefsrc in default VRF removed [ OK ] > Table ID 0 > TEST: Prefsrc removed from default VRF when source address deleted [ OK ] > Link local source route > TEST: Prefsrc not removed when delete ll addr from other dev [ OK ] > TEST: Prefsrc removed when delete ll addr [ OK ] > TEST: Prefsrc not removed when delete ll addr from other dev [ OK ] > TEST: Prefsrc removed even ll addr still exist on other dev [ OK ] > > Tests passed: 21 > Tests failed: 0 > > Suggested-by: Ido Schimmel <idosch@idosch.org> > Suggested-by: David Ahern <dsahern@kernel.org> > Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> > --- > v7: add more tests as Ido and David suggested. Remove the IPv4 part as I want > to focus on the IPv6 fixes. > --- > tools/testing/selftests/net/fib_tests.sh | 163 ++++++++++++++++++++++- > 1 file changed, 162 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh > index 35d89dfa6f11..0aa17b2ac8e1 100755 > --- a/tools/testing/selftests/net/fib_tests.sh > +++ b/tools/testing/selftests/net/fib_tests.sh > @@ -9,7 +9,7 @@ ret=0 > ksft_skip=4 > > # all tests in this script. Can be overridden with -t option > -TESTS="unregister down carrier nexthop suppress ipv6_notify ipv4_notify ipv6_rt ipv4_rt ipv6_addr_metric ipv4_addr_metric ipv6_route_metrics ipv4_route_metrics ipv4_route_v6_gw rp_filter ipv4_del_addr ipv4_mangle ipv6_mangle ipv4_bcast_neigh" > +TESTS="unregister down carrier nexthop suppress ipv6_notify ipv4_notify ipv6_rt ipv4_rt ipv6_addr_metric ipv4_addr_metric ipv6_route_metrics ipv4_route_metrics ipv4_route_v6_gw rp_filter ipv4_del_addr ipv6_del_addr ipv4_mangle ipv6_mangle ipv4_bcast_neigh" > > VERBOSE=0 > PAUSE_ON_FAIL=no > @@ -1869,6 +1869,166 @@ ipv4_del_addr_test() > cleanup > } > > +ipv6_del_addr_test() > +{ > + echo > + echo "IPv6 delete address route tests" > + > + setup > + > + set -e > + for i in $(seq 6); do > + $IP li add dummy${i} up type dummy > + done > + > + $IP li add red up type vrf table 1111 > + $IP ro add vrf red unreachable default > + for i in $(seq 4 6); do > + $IP li set dummy${i} vrf red > + done > + > + $IP addr add dev dummy1 fe80::1/128 > + $IP addr add dev dummy1 2001:db8:101::1/64 > + $IP addr add dev dummy1 2001:db8:101::10/64 > + $IP addr add dev dummy1 2001:db8:101::11/64 > + $IP addr add dev dummy1 2001:db8:101::12/64 > + $IP addr add dev dummy1 2001:db8:101::13/64 > + $IP addr add dev dummy1 2001:db8:101::14/64 > + $IP addr add dev dummy1 2001:db8:101::15/64 > + $IP addr add dev dummy2 fe80::1/128 > + $IP addr add dev dummy2 2001:db8:101::1/64 > + $IP addr add dev dummy2 2001:db8:101::11/64 > + $IP addr add dev dummy3 fe80::1/128 > + > + $IP addr add dev dummy4 2001:db8:101::1/64 > + $IP addr add dev dummy4 2001:db8:101::10/64 > + $IP addr add dev dummy4 2001:db8:101::11/64 > + $IP addr add dev dummy4 2001:db8:101::12/64 > + $IP addr add dev dummy4 2001:db8:101::13/64 > + $IP addr add dev dummy4 2001:db8:101::14/64 > + $IP addr add dev dummy5 2001:db8:101::1/64 > + $IP addr add dev dummy5 2001:db8:101::11/64 > + > + # Single device using src address > + $IP route add 2001:db8:110::/64 dev dummy3 src 2001:db8:101::10 > + # Two devices with the same source address > + $IP route add 2001:db8:111::/64 dev dummy3 src 2001:db8:101::11 > + # VRF with single device using src address > + $IP route add vrf red 2001:db8:110::/64 dev dummy6 src 2001:db8:101::10 > + # VRF with two devices using src address > + $IP route add vrf red 2001:db8:111::/64 dev dummy6 src 2001:db8:101::11 > + # src address and nexthop dev in same VRF > + $IP route add 2001:db8:112::/64 dev dummy3 src 2001:db8:101::12 > + $IP route add vrf red 2001:db8:112::/64 dev dummy6 src 2001:db8:101::12 > + # src address and nexthop device in different VRF > + $IP route add 2001:db8:113::/64 dev lo src 2001:db8:101::13 > + $IP route add vrf red 2001:db8:113::/64 dev lo src 2001:db8:101::13 > + # Same FIB info with different table ID I suggest removing this test case as in IPv6 there is no sharing of FIB info, unlike in IPv4. > + $IP route add 2001:db8:114::/64 via 2001:db8:101::2 src 2001:db8:101::14 > + $IP route add vrf red 2001:db8:114::/64 via 2001:db8:101::2 src 2001:db8:101::14 > + # table ID 0 > + $IP route add table 0 2001:db8:115::/64 via 2001:db8:101::2 src 2001:db8:101::15 > + # Link local source route > + $IP route add 2001:db8:116::/64 dev dummy2 src fe80::1 > + $IP route add 2001:db8:117::/64 dev dummy3 src fe80::1 > + set +e > + > + echo " Single device using src address" > + > + $IP addr del dev dummy1 2001:db8:101::10/64 > + $IP -6 route show | grep -q "src 2001:db8:101::10 " > + log_test $? 1 "Prefsrc removed when src address removed on other device" > + > + echo " Two devices with the same source address" > + > + $IP addr del dev dummy1 2001:db8:101::11/64 > + $IP -6 route show | grep -q "src 2001:db8:101::11 " > + log_test $? 0 "Prefsrc not removed when src address exist on other device" What about deleting the address from dummy2 and checking that the preferred source address is removed from the route? I know it's similar to the previous case, but still a good test case. > + > + echo " VRF with single device using src address" > + > + $IP addr del dev dummy4 2001:db8:101::10/64 > + $IP -6 route show vrf red | grep -q "src 2001:db8:101::10 " > + log_test $? 1 "Prefsrc removed when src address removed on other device" > + > + echo " VRF with two devices using src address" > + > + $IP addr del dev dummy4 2001:db8:101::11/64 > + $IP -6 route show vrf red | grep -q "src 2001:db8:101::11 " > + log_test $? 0 "Prefsrc not removed when src address exist on other device" Likewise. > + > + echo " src address and nexthop dev in same VRF" > + > + $IP addr del dev dummy4 2001:db8:101::12/64 > + $IP -6 route show vrf red | grep -q "src 2001:db8:101::12 " > + log_test $? 1 "Prefsrc removed from VRF when source address deleted" > + $IP -6 route show | grep -q " src 2001:db8:101::12 " > + log_test $? 0 "Prefsrc in default VRF not removed" > + > + $IP addr add dev dummy4 2001:db8:101::12/64 > + $IP route replace vrf red 2001:db8:112::/64 dev dummy6 src 2001:db8:101::12 > + $IP addr del dev dummy1 2001:db8:101::12/64 > + $IP -6 route show vrf red | grep -q "src 2001:db8:101::12 " ^ Please be consistent about the space before "src". In some places you have it and in some you don't. > + log_test $? 0 "Prefsrc not removed from VRF when source address exist" > + $IP -6 route show | grep -q " src 2001:db8:101::12 " > + log_test $? 1 "Prefsrc in default VRF removed" > + > + echo " src address and nexthop device in different VRF" > + > + $IP addr del dev dummy4 2001:db8:101::13/64 > + $IP -6 route show vrf red | grep -q "src 2001:db8:101::13 " > + log_test $? 0 "Prefsrc not removed from VRF when nexthop dev in diff VRF" > + $IP -6 route show | grep -q " src 2001:db8:101::13 " > + log_test $? 0 "Prefsrc not removed in default VRF" > + > + $IP addr add dev dummy4 2001:db8:101::13/64 > + $IP addr del dev dummy1 2001:db8:101::13/64 > + $IP -6 route show vrf red | grep -q "src 2001:db8:101::13 " > + log_test $? 1 "Prefsrc removed from VRF when nexthop dev in diff VRF" > + $IP -6 route show | grep -q " src 2001:db8:101::13 " > + log_test $? 1 "Prefsrc removed in default VRF" > + > + echo " Same FIB info with different table ID" > + > + $IP addr del dev dummy4 2001:db8:101::14/64 > + $IP -6 route show vrf red | grep -q "src 2001:db8:101::14 " > + log_test $? 1 "Prefsrc removed from VRF when source address deleted" > + $IP -6 route show | grep -q " src 2001:db8:101::14 " > + log_test $? 0 "Prefsrc in default VRF not removed" > + > + $IP addr add dev dummy4 2001:db8:101::14/64 > + $IP route replace vrf red 2001:db8:114::/64 via 2001:db8:101::2 src 2001:db8:101::14 > + $IP addr del dev dummy1 2001:db8:101::14/64 > + $IP -6 route show vrf red | grep -q "src 2001:db8:101::14 " > + log_test $? 0 "Prefsrc not removed from VRF when source address exist" > + $IP -6 route show | grep -q " src 2001:db8:101::14 " > + log_test $? 1 "Prefsrc in default VRF removed" > + > + echo " Table ID 0" > + > + $IP addr del dev dummy1 2001:db8:101::15/64 > + $IP -6 route show | grep -q "src 2001:db8:101::15" > + log_test $? 1 "Prefsrc removed from default VRF when source address deleted" > + > + echo " Link local source route" > + $IP addr del dev dummy1 fe80::1/128 > + $IP -6 route show | grep -q "2001:db8:116::/64 dev dummy2 src fe80::1" > + log_test $? 0 "Prefsrc not removed when delete ll addr from other dev" > + $IP addr del dev dummy2 fe80::1/128 > + $IP -6 route show | grep -q "2001:db8:116::/64 dev dummy2 src fe80::1" > + log_test $? 1 "Prefsrc removed when delete ll addr" > + $IP -6 route show | grep -q "2001:db8:117::/64 dev dummy3 src fe80::1" > + log_test $? 0 "Prefsrc not removed when delete ll addr from other dev" > + $IP addr add dev dummy1 fe80::1/128 > + $IP addr del dev dummy3 fe80::1/128 > + $IP -6 route show | grep -q "2001:db8:117::/64 dev dummy3 src fe80::1" > + log_test $? 1 "Prefsrc removed even ll addr still exist on other dev" > + > + for i in $(seq 6); do > + $IP li del dummy${i} > + done > + cleanup > +} > > ipv4_route_v6_gw_test() > { > @@ -2211,6 +2371,7 @@ do > ipv6_addr_metric) ipv6_addr_metric_test;; > ipv4_addr_metric) ipv4_addr_metric_test;; > ipv4_del_addr) ipv4_del_addr_test;; > + ipv6_del_addr) ipv6_del_addr_test;; > ipv6_route_metrics) ipv6_route_metrics_test;; > ipv4_route_metrics) ipv4_route_metrics_test;; > ipv4_route_v6_gw) ipv4_route_v6_gw_test;; > -- > 2.38.1 > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-08-17 12:57 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-08-16 6:07 [PATCHv6 net-next 0/2] ipv6: update route when delete source address Hangbin Liu 2023-08-16 6:07 ` [PATCHv6 net-next 1/2] ipv6: do not match device when remove source route Hangbin Liu 2023-08-17 12:02 ` Ido Schimmel 2023-08-16 6:07 ` [PATCHv6 net-next 2/2] selftests: fib_test: add a test case for IPv6 source address delete Hangbin Liu 2023-08-17 12:57 ` Ido Schimmel
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).