Skip to content

Commit 0a1dc07

Browse files
committed
Merge branch 'bugfix/fix_dhcp_pool_issue_on_dhcp_server_v5.3' into 'release/v5.3'
fix(lwip): fixed the dhcp pool error on dhcp server (v5.3) See merge request espressif/esp-idf!31264
2 parents 31439df + 561146f commit 0a1dc07

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

components/lwip/apps/dhcpserver/dhcpserver.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -1006,7 +1006,7 @@ static s16_t parse_msg(dhcps_t *dhcps, struct dhcps_msg *m, u16_t len)
10061006
dhcps->client_address.addr = dhcps->client_address_plus.addr;
10071007
}
10081008

1009-
if (flag == false) { // search the fisrt unused ip
1009+
if (flag == false) { // search the first unused ip
10101010
if (first_address.addr < pdhcps_pool->ip.addr) {
10111011
flag = true;
10121012
} else {
@@ -1399,7 +1399,7 @@ static void kill_oldest_dhcps_pool(dhcps_t *dhcps)
13991399
assert(pre != NULL && pre->pnext != NULL); // Expect the list to have at least 2 nodes
14001400
p = pre->pnext;
14011401
minpre = pre;
1402-
minp = p;
1402+
minp = pre;
14031403

14041404
while (p != NULL) {
14051405
pdhcps_pool = p->pnode;
@@ -1413,8 +1413,11 @@ static void kill_oldest_dhcps_pool(dhcps_t *dhcps)
14131413
pre = p;
14141414
p = p->pnext;
14151415
}
1416-
1417-
minpre->pnext = minp->pnext;
1416+
if (minp == dhcps->plist) {
1417+
dhcps->plist = minp->pnext;
1418+
} else {
1419+
minpre->pnext = minp->pnext;
1420+
}
14181421
free(minp->pnode);
14191422
minp->pnode = NULL;
14201423
free(minp);

0 commit comments

Comments
 (0)