-
Notifications
You must be signed in to change notification settings - Fork 911
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Determining route metric based on NIC name
In the Alibaba Cloud scenario, we do not wish to define routing priority based on MAC addresses. In a cloud environment where the kernel parameter net.ifnames=0 has been configured, network interface card (NIC) names are determined by default according to their underlying Bus, Device, and Function (BDF) numbers, incrementing from eth0 to ethN, with eth0 acting as the default primary NIC name. In the previous logic, network-card has the highest priority, followed by device-number as the second priority. When default_nic_order is set to NicOrder.MAC, the mac address takes the third priority. On the other hand, when default_nic_order is set to NicOrder.NIC_NAME, the NIC name becomes the third priority. In AWS environments, the default setting remains as default_nic_order = NicOrder.MAC, maintaining the original behavior. However, in Alibaba Cloud scenarios, we set default_nic_order = NicOrder.NIC_NAME. In the earlier code snippet, before calling _build_nic_order, the input macs were sorted. Therefore, in the test cases, there should not be a scenario where macs are given as ["0a:f7:8d:96:f2:a1", "0a:0d:dd:44:cd:7b"]. macs = sorted(macs_to_nics.keys()) nic_order = _build_nic_order(macs_metadata, macs) For the new code implementation, I move the line macs = sorted(macs_to_nics.keys()) inside the function and pass the macs_to_nics dictionary as a parameter instead, which allows for easy access to the nic names.
- Loading branch information
Showing
5 changed files
with
243 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.