Repository navigation
Commit f673e3a
committed
[net][dhcpd] recycle expired DHCP client leases
Fix #11878
Store and renew node->lease_end in sys_now() milliseconds, align
DHCP_DEFAULT_LIVE_TIME with option 51 (86400 seconds), and reclaim expired
leases via dhcp_client_remove_expired() before allocating a new IP.
- Validate MAC ownership before reusing nodes in requested-IP paths of
dhcp_client_find() and dhcp_client_alloc() to prevent giving one client's
active lease to another MAC.
- Register a periodic lwIP sys_timeout timer to clean up expired client leases
even during long idle periods where no incoming DHCP packets arrive,
preventing expired leases from persisting across 2^32 ms counter wraparounds.
- Move the periodic recycle callback to file scope so LWIP_USING_DHCPD
configurations compile, and make it visible to dhcpd_stop().
- Reserve one MEMP_NUM_SYS_TIMEOUT slot for the permanent DHCPD timer across
the supported lwIP versions.
- Run start/stop, server/node teardown and sys_timeout/sys_untimeout under the
lwIP core lock, serializing them with the recycle callback.
- Drive the regression test through the production lease code: it builds
dhcp_server_raw.c against lwIP/RT-Thread stubs and checks dhcp_client_find(),
dhcp_client_alloc() and dhcp_client_remove_expired(), instead of comparing
two hand-filled MACs and keeping a private copy of the expiry rule.1 parent aee8d01 commit f673e3a
17 files changed
Lines changed: 924 additions & 38 deletions
File tree
- components/net
- lwip-dhcpd
- test/mock
- lwip
- prot
- netif
- lwip/port
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments