fix(network): prefer permanent MAC address from hwinfo#672
Conversation
|
Hi @tianming-1996. Thanks for your PR. 😃 |
|
Hi @tianming-1996. Thanks for your PR. I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Reviewer's GuideAdjusts DeviceNetwork::setInfoFromHwinfo to prefer the permanent hardware MAC address when available and non-zero, falling back to the current MAC, and adds unit tests to verify the new precedence rules. Flow diagram for MAC address selection in setInfoFromHwinfoflowchart TD
A[setInfoFromHwinfo receives mapInfo] --> B[setAttribute mapInfo Permanent_HW_Address m_MACAddress]
B --> C{m_MACAddress == 00:00:00:00:00:00?}
C -- Yes --> D[clear m_MACAddress]
C -- No --> E[keep m_MACAddress]
D --> F[setAttribute mapInfo HW_Address m_MACAddress optional:false]
E --> F
F --> G[setAttribute mapInfo Permanent_HW_Address m_UniqueID]
G --> H[setAttribute mapInfo SysFS_Device_Link m_SysPath]
H --> I[setAttribute mapInfo Driver m_Driver]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
setInfoFromHwinfo,m_UniqueIDis still sourced directly from "Permanent HW Address" even when you’ve implemented fallback logic form_MACAddress; consider derivingm_UniqueIDfrom the already-resolvedm_MACAddress(or applying the same fallback logic) so the two stay consistent in cases where the permanent address is missing or zero. - The all-zero MAC check (
"00:00:00:00:00:00") is done with a literal string comparison; ifsetAttributecan introduce case differences, extra whitespace, or different delimiter styles, it may be safer to normalize the MAC string before comparison or centralize the "is zero MAC" check in a helper.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `setInfoFromHwinfo`, `m_UniqueID` is still sourced directly from "Permanent HW Address" even when you’ve implemented fallback logic for `m_MACAddress`; consider deriving `m_UniqueID` from the already-resolved `m_MACAddress` (or applying the same fallback logic) so the two stay consistent in cases where the permanent address is missing or zero.
- The all-zero MAC check (`"00:00:00:00:00:00"`) is done with a literal string comparison; if `setAttribute` can introduce case differences, extra whitespace, or different delimiter styles, it may be safer to normalize the MAC string before comparison or centralize the "is zero MAC" check in a helper.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Prefer the permanent hardware address when parsing network device info. 解析网卡信息时优先使用永久硬件地址。 Fall back to the current MAC address when the permanent address is empty or zero. 当永久地址为空或全零时,回退使用当前MAC地址。 Log: 修复网卡MAC地址显示优先级 PMS: Bug: https://pms.uniontech.com/bug-view-363471.html Influence: 网卡详情页优先显示永久物理地址,永久地址无效时显示当前MAC地址。
9c91f8d to
6e35e8f
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: max-lvs, tianming-1996 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
Prefer the permanent hardware address when parsing network device info.
解析网卡信息时优先使用永久硬件地址。
Fall back to the current MAC address when the permanent address is empty or zero.
当永久地址为空或全零时,回退使用当前MAC地址。
Log: 修复网卡MAC地址显示优先级
PMS: Bug: https://pms.uniontech.com/bug-view-363471.html
Influence: 网卡详情页优先显示永久物理地址,永久地址无效时显示当前MAC地址。
Summary by Sourcery
Prefer permanent hardware MAC addresses from hwinfo when populating network device info, falling back to the current MAC when the permanent address is missing or invalid.
Bug Fixes:
Tests: