Skip to content

Conversation

Rbb666
Copy link
Member

@Rbb666 Rbb666 commented Sep 13, 2025

Fixed incorrect pairing of DHCP enable/disable in lwip (≤v2.0.3)

测试发现 lwip (≤v2.0.3) 版本成对调用打开和关闭DHCP的API的时候,会出现:dhcp_create_msg: dhcp->p_out == NULL 断言错误,在 v2.1.2后lwip源码已经修复此问题

image

测试代码如下:

static void test_netdev_dhcp(void)
{
    rt_err_t res;
    rt_bool_t initial_state;

    /* Save initial DHCP state */
    initial_state = netdev_is_dhcp_enabled(netdev_default);

    /* DHCP disable */
    res = netdev_dhcp_enabled(netdev_default, RT_FALSE);
    if (res == RT_EOK)
    {
        uassert_false(netdev_is_dhcp_enabled(netdev_default));
    }
    else
    {
        uassert_true(RT_FALSE);
        return;
    }

    /* Restore initial state */
    res = netdev_dhcp_enabled(netdev_default, initial_state);
    uassert_true(res == RT_EOK);
}

Copy link

github-actions bot commented Sep 13, 2025

📌 Code Review Assignment

🏷️ Tag: components

Reviewers: Maihuanyi

Changed Files (Click to expand)
  • components/net/lwip/lwip-1.4.1/src/core/dhcp.c
  • components/net/lwip/lwip-2.0.3/src/core/ipv4/dhcp.c

📊 Current Review Status (Last Updated: 2025-09-13 20:12 CST)

  • Maihuanyi Pending Review

📝 Review Instructions

  1. 维护者可以通过单击此处来刷新审查状态: 🔄 刷新状态
    Maintainers can refresh the review status by clicking here: 🔄 Refresh Status

  2. 确认审核通过后评论 LGTM/lgtm
    Comment LGTM/lgtm after confirming approval

  3. PR合并前需至少一位维护者确认
    PR must be confirmed by at least one maintainer before merging

ℹ️ 刷新CI状态操作需要具备仓库写入权限。
ℹ️ Refresh CI status operation requires repository Write permission.

@Rbb666
Copy link
Member Author

Rbb666 commented Sep 13, 2025

@Ryan-CW-Code 大佬帮看看

@Rbb666 Rbb666 added the bug This PR/issue is a bug in the current code. label Sep 13, 2025
@Rbb666 Rbb666 requested a review from Guozhanxin September 13, 2025 12:28
@Ryan-CW-Code
Copy link
Contributor

感觉尽量不修改lwip的源代码比较好,尽量不增加修改源码的地方了。
看看netifapi_dhcp_startnetifapi_dhcp_stop这种线程安全封装可以不

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This PR/issue is a bug in the current code. component: net/lwip component: net Component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants