zebra: remove kernel route on last address deletion #19564
+141
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes issue #13561
Linux kernel deletes IPv4 routes when last interface IPv4 address is deleted, but intentionally doesn't send RTM_DELROUTE in this case.
FRR has function rib_update_handle_kernel_route_down_possibility that handles setting interface down, but not removal of last address.
To fix the situation:
RIB_UPDATE_KERNEL_LAST_ADDRESS_DELETED
to enum rib_update_eventzebra_if_addr_update_ctx
make more specific check that last address is deleted and triggerRIB_UPDATE_KERNEL_LAST_ADDRESS_DELETED
instead ofRIB_UPDATE_KERNEL
in this case. If it was not last address, don't emit any RIB_UPDATE.rib_update_handle_kernel_route_down_possibility
not only for eventRIB_UPDATE_INTERFACE_DOWN
, but also forRIB_UPDATE_KERNEL_LAST_ADDRESS_DELETED
.rib_update_handle_kernel_route_down_possibility
not to consider IPv4 route alive when interface is up, but there are no IPv4 addresses left.Relevant kernel code:
Comment from kernel networking author that RTM_DELROUTE isn't sent intentionally:
https://bugzilla.kernel.org/show_bug.cgi?id=207089
test
Also added test_zebra_kernel_last_ipv4_address_deleted to zebra_multiple_connected/test_zebra_multiple_connected.py with basic flow:
Check there are
default
and10.0.170.3
routes.Check there are still
default
and10.0.170.3
routes.Check there are no
default
and10.0.170.3
routes.In each check make sure kernel routes are as expected (using topotest.ip4_route) and zebra routes are as expected (using
show ip route json
).