Skip to content

Conversation

@zs39
Copy link
Contributor

@zs39 zs39 commented Dec 26, 2025

Summary

The previous method of terminating the dhcp daemon via a global variable has been removed; instead, the kill pid command is used. Also, because the original dhcp_start method creates tasks via task_create, which is not supported in kernel mode, dhcp_start is not compiled in kernel mode. The daemon can be started in kernel mode using dhcpd xxx &.

Impact

The dhcpd_start and dhcpd_stop functions

Testing

Tested normally in flat mode

nsh> dhcpd_start eth0
nsh> ps
  TID   PID  PPID PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK            STACK COMMAND
    0     0     0   0 FIFO     Kthread   - Ready              0000000000000000 0069568 Idle_Task
    1     0     0 224 FIFO     Kthread   - Waiting  Semaphore 0000000000000000 0067448 hpwork 0x400b8020 0x400b80a0
    2     0     0 100 FIFO     Kthread   - Waiting  Semaphore 0000000000000000 0067448 lpwork 0x400b80e0 0x400b8160
    3     3     0 100 FIFO     Task      - Running            0000000000000000 0067488 nsh_main
    5     5     4 100 FIFO     Task      - Waiting  Semaphore 0000000000000000 0067464 dhcpd eth0
nsh> dhcpd_stop
nsh> ps
  TID   PID  PPID PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK            STACK COMMAND
    0     0     0   0 FIFO     Kthread   - Ready              0000000000000000 0069568 Idle_Task
    1     0     0 224 FIFO     Kthread   - Waiting  Semaphore 0000000000000000 0067448 hpwork 0x400b8020 0x400b80a0
    2     0     0 100 FIFO     Kthread   - Waiting  Semaphore 0000000000000000 0067448 lpwork 0x400b80e0 0x400b8160
    3     3     0 100 FIFO     Task      - Running            0000000000000000 0067488 nsh_main
nsh> 

The build process works correctly in kernel mode and also functions properly on the internal QEMU platform.

The previous method of terminating the dhcp daemon via a global variable has been removed; instead, the `kill pid` command is used. Also, because the original `dhcp_start` method creates tasks via `task_create`, which is not supported in kernel mode, `dhcp_start` is not compiled in kernel mode. The daemon can be started in kernel mode using `dhcpd xxx &`.

Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
@xiaoxiang781216
Copy link
Contributor

@zs39 please fix:

../nuttx/tools/checkpatch.sh -c -u -m -g 9da2bc06961587ec0d288686099a3e75524f8cc3..HEAD
Used config files:
    1: .codespellrc
/home/runner/work/nuttx-apps/nuttx-apps/apps/netutils/dhcpd/dhcpd.c:1019: re-use ==> reuse
/home/runner/work/nuttx-apps/nuttx-apps/apps/netutils/dhcpd/dhcpd.c:1407: re-used ==> reused
Some checks failed. For contributing guidelines, see:
  https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants