Fixes issues about loopback interface address #113
Merged
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.
Issue 111: fix race condition in loopback interface address assignment
Why
When sonic-vpp receives ROUTE_ENTRY create, it will remove the Loopback interface in kernel and recreate it as tap interface via vpp lcp create. Then reconfigure the address to the loopback interface after that. When there are multiple loopback addresses (for example, one v4 and one v6 address) configured in a short time, such as loading mini-graph, the loopback addresses except the first one will be lost due to this race condition.
What this change is doing
When the first time addresses are configured on a loopback interface, we record all the addresses on the interface before destroying it. When the tap interface is created, recreate the addresses. This doesn't completely remove the race condition but will keep it minimal. There isn't a fail-safe solution due to multiple reasons.
Issue 103: fix loopback interface address removal issue
Why
When there are multiple addresses configured on loopback interface, the interface should be removed from vpp when the last address is deleted. However, the interface is removed when an address is deleted no matter if there is other addresses on the interface. This is because the code uses get_intf_name_for_prefix to check if the address still exists in the kernel. If it does, it assumes the operation is removing the address only. Otherwise, it will remove the interface. However, intfmgr removes address from kernel before updating APPL_DB, which triggers the SAI call of ROUTE_ENTRY delete.
What this change is doing
Loopback interface is deleted from vpp when the last address is removed from the interface