Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issues about loopback interface address #113

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

yue-fred-gao
Copy link
Contributor

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.

  1. vpp needs to delete the loopback interface to recreate it as tap.
  2. SAI sends ROUTE_ENTRY create request when address is set to a loopback interface. The route is to-me route with CPU_PORT as nexthop. There is no information about the loopback interface.
  3. SAI-VPP has to query linux kernel to know which interface the address belongs to. Because we have to delete the interface, if an address is configured from intfmgr between we record the addresses and delete the interface, the address will be lost.

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

  - Issue 111: fix race condition in loopback interface address assignment
  - Issue 103: fix loopback interface address removal issue
@yue-fred-gao yue-fred-gao merged commit eac7a81 into sonic-net:main Sep 26, 2024
1 check passed
@yue-fred-gao yue-fred-gao deleted the loopback_addr branch September 26, 2024 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants