-
Notifications
You must be signed in to change notification settings - Fork 107
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
tests: Prefer permanent MAC for finding link info, fallback to current MAC #751
tests: Prefer permanent MAC for finding link info, fallback to current MAC #751
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #751 +/- ##
==========================================
- Coverage 43.11% 43.03% -0.09%
==========================================
Files 12 12
Lines 3124 3137 +13
==========================================
+ Hits 1347 1350 +3
- Misses 1777 1787 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
75a9f57
to
855766f
Compare
lsr_fail_debug: | ||
- __network_connections_result | ||
tags: | ||
- "tests::mac" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spetrosi I think we'll need to exclude this test from automated testing - we'll need to add tests::mac
to the --skip-tags
list @liangwen12year I think this test is meant to be run interactively
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a PR for that linux-system-roles/tft-tests#65
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow why the test cannot determine the MAC address itself instead of asking for it in a prompt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test is supposed to operate on an interface which has the permanent address, I do not want to make the test accidentally configured on the interface that is used to bridge the ssh connection between the control node and managed host. Possibly, I can search through all the links in /sys/class/net/
and use the first unconfigured ethernet interface. But such an ethernet interface (unconfigured and also have a permanent mac address) may not exist in the system environment of upstream testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. We can use ethtool -P $iface
to determine the mac address of the interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We controll the upstream test envirionment, so it should be clear whether or not such an interface exists and if it does not, there might be an option to create such an interface.
Nevertheless, the prompt also does not specify the requirements for the interface to ensure that it is eligible/the test does not ensure that it actually tests what it is supposed to test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, it turns out that the upstream testing environment does not have the interface with the permanent mac address. I also tried iproute2
, systemd-networkd
, and NetworkManager, but I can not create such an interface with the permanent mac address (the permanent mac address can be queried by calling ethtool -P $iface
), I can only create an interface with the current mac address (the current mac address can be queried by calling cat /sys/class/net/$iface/address
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I specified the requirements for the interface to ensure that it is eligible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does the upstream environment work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summarized from the slack discussion, the upstream testing uses Testing Farm, which uses AWS machines, we do not run kvm/qemu virtual machines on the AWS machines. According to the doc https://tmt.readthedocs.io/en/stable/spec/hardware.html#network, requesting a machine with extra NICs should be already supported via network.type
, we should be able to provision a machine with 2 NICs by specifying the following in the network system role test configuration.
hardware:
network:
- type: eth
- type: eth
855766f
to
4538327
Compare
linux-system-roles/network#751 adds a test that must be skipped upstream and will only be tested downstream
a1bac2e
to
9cd64bb
Compare
hosts: all | ||
vars_prompt: | ||
- name: "interface" | ||
prompt: "The test requires matching an Ethernet interface to its |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I understand, the current MAC address of this interface needs to be different than the permanent MAC address for the new code to actually be tested. And after further discussion, there should probably be a second interface (maybe a virtual one) that has the same MAC address as the permanent MAC address as this was causing an error condition. @liangwen12year told me about this in a meeting, AFAIU, this is not mentioned in the original PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://issues.redhat.com/browse/RHEL-73442, the issue occurs when both interface name and MAC address are specified in network connections to configure a parent and VLAN connection, and the configuration is applied multiple times. The error is raised because SysUtil._link_infos_fetch() creates a dictionary of link info from /sys/class/net/, comparing the user-specified MAC address against either the "perm-address" or "address." If the user-specified MAC matches only the "address" (current MAC) but not the "perm-address" (permanent MAC), the link info returned may have a different interface name than specified, leading to the error. If a physical interface has permanent MAC A and current MAC B, specifying MAC A in the network connection avoids errors because the VLAN's current MAC matches the parent's, but the VLAN’s perm-address is unset, so its link info isn’t used for comparing the interface name against the user-specified one. However, specifying MAC B causes NetworkManager to fail, as it expects the interface name to match the permanent MAC address, not the current one.
From my understanding, the current mac address of this interface should be the same as the permanent mac, then the created vlan interface will have the same current mac address as the permanent mac address of its parent (a virtual interface like a VLAN typically inherits the current MAC address of its parent interface instead of the permanent MAC.), then without the prior fix (c341683) on the issue, I can reproduce the problem by applying the same network connections multiple times for configuring the parent and the vlan connections.
50594c8
to
c4ac501
Compare
c4ac501
to
1871ed1
Compare
f63c768
to
a380ac4
Compare
[citest] |
a380ac4
to
052fc9b
Compare
[citest] |
ce44faf
to
57b4c00
Compare
a136ccd
to
869e15e
Compare
[citest] |
869e15e
to
b1f1407
Compare
[citest] |
b1f1407
to
6325901
Compare
[citest] |
6325901
to
7d316a7
Compare
[citest] |
1c3b84c
to
64a5f07
Compare
The existing implementation of `link_info_find()` had several issues that made it error-prone and harder to maintain: - The refresh parameter was unused, adding unnecessary complexity. - MAC address matching logic was convoluted, with redundant variables and conditions. - The use of locals() for fallback results was unclear and could lead to subtle bugs. - The order of checks (MAC vs ifname) didn't prioritize the most reliable matching criteria. To address these issues, the following changes were made: - Removed the unused `refresh` argument to reduce complexity. - Used `None` checks more idiomatically with `if mac` instead of `is not None`. - Eliminated redundant variables and conditions to improve readability. - Avoided using `locals()` by explicitly storing fallback results. - Made `ifname` matching take priority before checking MAC addresses. - Ensured that the function returns early when a definitive match is found. Signed-off-by: Wen Liang <[email protected]>
When a user provides both an interface name and a MAC address, the current validation process retrieves sysfs link info separately using the interface name and the MAC address, then compares the results. If the information doesn't match, an error is raised. However, this approach may trigger false alarms because retrieving the link info by MAC might return data that only matches the current MAC instead of the permanent MAC. Since the interface name is unique within the kernel, a more robust validation method is to fetch the MAC address using the interface name and then compare it directly with the user-provided MAC address. Signed-off-by: Wen Liang <[email protected]>
…t MAC When a network connection specifies both an interface name and MAC address, and the physical interface has identical permanent and current MACs, applying the configuration multiple times can cause an error: "no such interface exists." The issue occurs because `SysUtil.link_info_find()` may return a link info entry where the user-specified MAC matches only the current ("address") but not the permanent MAC ("perm-address"). In such cases, the returned link info may have a different interface name than the one specified in the network connection, leading to the error. We already implemented a fix (c341683) that ensures link lookup prioritizes the permanent MAC, only falling back to the current MAC when necessary. The integration test `tests_mac_address_match.yml` verifies this fix by requiring an Ethernet interface where the permanent and current MACs match. Resolves: https://issues.redhat.com/browse/RHEL-74211 Signed-off-by: Wen Liang <[email protected]>
64a5f07
to
82ac075
Compare
[citest] |
Close this PR as the patches in this PR have been split into multiple separate PRs. |
Add the integration test
tests_mac_address_match.yml
to verify that the commit "Prioritize find link info by permanent MAC address, with fallback to current address" (c341683) can properly resolve the scenarios where multiple network interfaces share the same current MAC address, leading to potential ambiguity in link matching (for example, Virtual interfaces or VLANs, which often lack a valid perm-address and rely on the parent interface's address).Notice that the test
tests_mac_address_match.yml
will be skipped in upstream testing and it will only be manually tested downstream since it requires to know the mac address to match when configuring vlan's parent.Enhancement:
Reason:
Result:
Issue Tracker Tickets (Jira or BZ if any):
Resolves: https://issues.redhat.com/browse/RHEL-74211