Skip to content

fix(wireless): drop default MAC binding on connect - #608

Open
caixr23 wants to merge 1 commit into
linuxdeepin:masterfrom
caixr23:master
Open

fix(wireless): drop default MAC binding on connect#608
caixr23 wants to merge 1 commit into
linuxdeepin:masterfrom
caixr23:master

Conversation

@caixr23

@caixr23 caixr23 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor
  1. Remove code that wrote the device permanent/real hardware address into the Wireless setting when creating or activating a connection (WirelessDeviceManagerRealize::connectNetwork, NetWirelessConnect::activateConnection)
  2. Keep user-selected device binding in WirelessSection
  3. A pinned MAC defeats random-MAC mode and blocks auto-connect after reboot, leaving wifi disconnected

Log: Wireless auto-reconnects after reboot with random MAC enabled

Influence:

  1. Connect to WiFi, reboot, verify it reconnects automatically
  2. Bind a wireless connection to a specific NIC in control center, verify profile keeps that mac-address
  3. Choose "Not Bind", verify mac-address cleared from profile

fix(wireless): 默认不再将连接绑定到网卡MAC地址

  1. 移除创建/激活连接时将设备永久/真实硬件地址写入无线配置的代码 (WirelessDeviceManagerRealize::connectNetwork、 NetWirelessConnect::activateConnection)
  2. 保留控制中心 WirelessSection 中用户手动选择的网卡绑定
  3. 固定 MAC 会破坏随机 MAC 功能,且导致重启后无线无法自动回连

Log: 开启随机 MAC 后,重启系统可自动重连无线网络

Influence:

  1. 连接 WiFi 后重启系统,验证能自动重连
  2. 控制中心绑定指定网卡后,验证配置保留该 mac-address
  3. 选择"不绑定",验证配置中 mac-address 已清空

PMS: BUG-374945

Summary by Sourcery

Remove default wireless MAC binding so randomized-MAC connections can reconnect automatically while retaining user-selected device bindings.

Bug Fixes:

  • Stop automatically binding wireless connections to the device’s permanent hardware MAC address, preserving random-MAC operation and reboot auto-reconnect.

Enhancements:

  • Preserve MAC bindings only when explicitly selected by the user in the wireless connection settings.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: caixr23

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes automatic persistence of a wireless device’s permanent MAC address during connection creation and activation, preventing interference with randomized-MAC auto-reconnect while leaving explicit user-selected bindings under WirelessSection control.

Sequence diagram for wireless connection without default MAC binding

sequenceDiagram
    participant User
    participant WirelessDeviceManagerRealize
    participant NetWirelessConnect
    participant WirelessSection
    participant ConnectionProfile

    User->>WirelessDeviceManagerRealize: connectNetwork(accessPoint)
    WirelessDeviceManagerRealize->>ConnectionProfile: setSsid(ssid)
    WirelessDeviceManagerRealize->>ConnectionProfile: setInitialized(true)
    User->>NetWirelessConnect: activateConnection()
    NetWirelessConnect->>ConnectionProfile: setAutoconnect(false)
    User->>WirelessSection: Select NIC binding or Not Bind
    WirelessSection->>ConnectionProfile: setMacAddress(selectedMacOrEmpty)
    ConnectionProfile-->>User: Profile keeps explicit binding or cleared MAC
Loading

File-Level Changes

Change Details Files
Stop implicitly binding wireless profiles to the connected device’s permanent hardware MAC address.
  • Removed default MAC assignment during connection activation.
  • Removed permanent hardware MAC assignment when creating a connection from an access point.
  • Continued initializing the wireless setting without overriding its user-selected binding.
net-view/operation/private/netwirelessconnect.cpp
src/impl/networkmanager/devicemanagerrealize.cpp
Preserve explicit device-binding behavior managed by the control center.
  • Allow user-selected MAC bindings in WirelessSection to remain unchanged.
  • Allow the “Not Bind” choice to clear the profile MAC address instead of being replaced during connection.
net-view/operation/private/netwirelessconnect.cpp
src/impl/networkmanager/devicemanagerrealize.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@caixr23
caixr23 force-pushed the master branch 2 times, most recently from c42df76 to 618eb33 Compare August 27, 2026 06:36
1. Remove code that wrote the device permanent/real hardware address
   into the Wireless setting when creating or activating a connection
   (WirelessDeviceManagerRealize::connectNetwork,
   NetWirelessConnect::activateConnection)
2. Keep user-selected device binding in WirelessSection
3. A pinned MAC defeats random-MAC mode and blocks auto-connect after
   reboot, leaving wifi disconnected

Log: Wireless auto-reconnects after reboot with random MAC enabled

Influence:
1. Connect to WiFi, reboot, verify it reconnects automatically
2. Bind a wireless connection to a specific NIC in control center,
   verify profile keeps that mac-address
3. Choose "Not Bind", verify mac-address cleared from profile

fix(wireless): 默认不再将连接绑定到网卡MAC地址

1. 移除创建/激活连接时将设备永久/真实硬件地址写入无线配置的代码
   (WirelessDeviceManagerRealize::connectNetwork、
   NetWirelessConnect::activateConnection)
2. 保留控制中心 WirelessSection 中用户手动选择的网卡绑定
3. 固定 MAC 会破坏随机 MAC 功能,且导致重启后无线无法自动回连

Log: 开启随机 MAC 后,重启系统可自动重连无线网络

Influence:
1. 连接 WiFi 后重启系统,验证能自动重连
2. 控制中心绑定指定网卡后,验证配置保留该 mac-address
3. 选择"不绑定",验证配置中 mac-address 已清空

PMS: BUG-374945
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 100 分,大于 70 分通过阈值,代码质量符合要求。本次变更移除了无线连接时默认绑定 MAC 地址的逻辑,变更范围明确、实现清晰,未引入安全漏洞或逻辑缺陷。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 无需修改,代码变更逻辑清晰,移除操作完整且不影响后续代码流程。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 代码变更干净利落,注释和版权信息同步更新,无需额外修改。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 移除不必要的 MAC 地址字符串处理操作,轻微提升性能,无需优化。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 移除 MAC 地址绑定反而有助于提升隐私保护(允许 MAC 随机化),无需安全加固。


💡 改进建议代码示例

// 本次变更为移除代码,无需修复示例
// 移除的代码块(netwirelessconnect.cpp, activateConnection 方法):
// // 默认设置Mac地址
// NetworkManager::WirelessSetting::Ptr wirelessSetting = 
//     m_connectionSettings->setting(NetworkManager::Setting::Wireless)
//         .dynamicCast<NetworkManager::WirelessSetting>();
// if (wirelessSetting) {
//     QString macAddress = m_device->realHwAdr();
//     macAddress.remove(":");
//     wirelessSetting->setMacAddress(QByteArray::fromHex(macAddress.toUtf8()));
//     wirelessSetting->setInitialized(true);
// }
//
// 移除的代码块(devicemanagerrealize.cpp, connectNetwork 方法):
// QString macAddress = m_device->permanentHardwareAddress();
// macAddress.remove(":");
// wirelessSetting->setMacAddress(QByteArray::fromHex(macAddress.toUtf8()));

本报告由 AI 代码审查工具自动生成

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