diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-02 16:49:20 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-02 17:53:09 +0200 |
commit | 0ae53451cf6fd61bcfa4bc78ef575fe6606373b4 (patch) | |
tree | ea901dafdba97d61143d920905b8f18b76cc609d | |
parent | 949e9621d10faada3bb55a4aa206df44e7d39ae8 (diff) | |
download | busybox-w32-0ae53451cf6fd61bcfa4bc78ef575fe6606373b4.tar.gz busybox-w32-0ae53451cf6fd61bcfa4bc78ef575fe6606373b4.tar.bz2 busybox-w32-0ae53451cf6fd61bcfa4bc78ef575fe6606373b4.zip |
udhcpc[6]: close listening socket more eagerly (e.g. across script runs)
function old new delta
udhcpc6_main 2571 2600 +29
udhcpc_main 2588 2566 -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 29/-22) Total: 7 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/udhcp/d6_dhcpc.c | 32 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 41 |
2 files changed, 45 insertions, 28 deletions
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index c68dc8c4f..b2df9f091 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
@@ -1090,6 +1090,8 @@ static void change_listen_mode(int new_mode) | |||
1090 | 1090 | ||
1091 | static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *our_cur_ipv6) | 1091 | static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *our_cur_ipv6) |
1092 | { | 1092 | { |
1093 | change_listen_mode(LISTEN_NONE); | ||
1094 | |||
1093 | /* send release packet */ | 1095 | /* send release packet */ |
1094 | if (client_data.state == BOUND | 1096 | if (client_data.state == BOUND |
1095 | || client_data.state == RENEWING | 1097 | || client_data.state == RENEWING |
@@ -1107,7 +1109,6 @@ static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *ou | |||
1107 | * of the states above. | 1109 | * of the states above. |
1108 | */ | 1110 | */ |
1109 | d6_run_script_no_option("deconfig"); | 1111 | d6_run_script_no_option("deconfig"); |
1110 | change_listen_mode(LISTEN_NONE); | ||
1111 | client_data.state = RELEASED; | 1112 | client_data.state = RELEASED; |
1112 | } | 1113 | } |
1113 | 1114 | ||
@@ -1311,7 +1312,6 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1311 | 1312 | ||
1312 | client_data.state = INIT_SELECTING; | 1313 | client_data.state = INIT_SELECTING; |
1313 | d6_run_script_no_option("deconfig"); | 1314 | d6_run_script_no_option("deconfig"); |
1314 | change_listen_mode(LISTEN_RAW); | ||
1315 | packet_num = 0; | 1315 | packet_num = 0; |
1316 | timeout = 0; | 1316 | timeout = 0; |
1317 | lease_remaining = 0; | 1317 | lease_remaining = 0; |
@@ -1387,8 +1387,10 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1387 | switch (client_data.state) { | 1387 | switch (client_data.state) { |
1388 | case INIT_SELECTING: | 1388 | case INIT_SELECTING: |
1389 | if (!discover_retries || packet_num < discover_retries) { | 1389 | if (!discover_retries || packet_num < discover_retries) { |
1390 | if (packet_num == 0) | 1390 | if (packet_num == 0) { |
1391 | change_listen_mode(LISTEN_RAW); | ||
1391 | xid = random_xid(); | 1392 | xid = random_xid(); |
1393 | } | ||
1392 | /* multicast */ | 1394 | /* multicast */ |
1393 | if (opt & OPT_l) | 1395 | if (opt & OPT_l) |
1394 | send_d6_info_request(xid); | 1396 | send_d6_info_request(xid); |
@@ -1399,6 +1401,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1399 | continue; | 1401 | continue; |
1400 | } | 1402 | } |
1401 | leasefail: | 1403 | leasefail: |
1404 | change_listen_mode(LISTEN_NONE); | ||
1402 | d6_run_script_no_option("leasefail"); | 1405 | d6_run_script_no_option("leasefail"); |
1403 | #if BB_MMU /* -b is not supported on NOMMU */ | 1406 | #if BB_MMU /* -b is not supported on NOMMU */ |
1404 | if (opt & OPT_b) { /* background if no lease */ | 1407 | if (opt & OPT_b) { /* background if no lease */ |
@@ -1435,7 +1438,6 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1435 | * "discover...select...discover..." loops | 1438 | * "discover...select...discover..." loops |
1436 | * were seen in the wild. Treat them similarly | 1439 | * were seen in the wild. Treat them similarly |
1437 | * to "no response to discover" case */ | 1440 | * to "no response to discover" case */ |
1438 | change_listen_mode(LISTEN_RAW); | ||
1439 | client_data.state = INIT_SELECTING; | 1441 | client_data.state = INIT_SELECTING; |
1440 | goto leasefail; | 1442 | goto leasefail; |
1441 | case BOUND: | 1443 | case BOUND: |
@@ -1470,11 +1472,11 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1470 | /* Timed out, enter rebinding state */ | 1472 | /* Timed out, enter rebinding state */ |
1471 | log1s("entering rebinding state"); | 1473 | log1s("entering rebinding state"); |
1472 | client_data.state = REBINDING; | 1474 | client_data.state = REBINDING; |
1475 | /* Switch to bcast receive */ | ||
1476 | change_listen_mode(LISTEN_RAW); | ||
1473 | packet_num = 0; | 1477 | packet_num = 0; |
1474 | /* fall right through */ | 1478 | /* fall right through */ |
1475 | case REBINDING: | 1479 | case REBINDING: |
1476 | /* Switch to bcast receive */ | ||
1477 | change_listen_mode(LISTEN_RAW); | ||
1478 | /* Lease is *really* about to run out, | 1480 | /* Lease is *really* about to run out, |
1479 | * try to find DHCP server using broadcast */ | 1481 | * try to find DHCP server using broadcast */ |
1480 | if (lease_remaining > 0 && packet_num < 3) { | 1482 | if (lease_remaining > 0 && packet_num < 3) { |
@@ -1487,6 +1489,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1487 | continue; | 1489 | continue; |
1488 | } | 1490 | } |
1489 | /* Timed out, enter init state */ | 1491 | /* Timed out, enter init state */ |
1492 | change_listen_mode(LISTEN_NONE); | ||
1490 | bb_simple_info_msg("lease lost, entering init state"); | 1493 | bb_simple_info_msg("lease lost, entering init state"); |
1491 | d6_run_script_no_option("deconfig"); | 1494 | d6_run_script_no_option("deconfig"); |
1492 | client_data.state = INIT_SELECTING; | 1495 | client_data.state = INIT_SELECTING; |
@@ -1522,12 +1525,15 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1522 | 1525 | ||
1523 | /* Start things over */ | 1526 | /* Start things over */ |
1524 | case RENEW_REQUESTED: /* two or more SIGUSR1 received */ | 1527 | case RENEW_REQUESTED: /* two or more SIGUSR1 received */ |
1528 | change_listen_mode(LISTEN_NONE); | ||
1525 | d6_run_script_no_option("deconfig"); | 1529 | d6_run_script_no_option("deconfig"); |
1526 | /* case REQUESTING: break; */ | 1530 | |
1527 | /* case RELEASED: break; */ | 1531 | default: |
1528 | /* case INIT_SELECTING: break; */ | 1532 | /* case REQUESTING: */ |
1533 | /* case RELEASED: */ | ||
1534 | /* case INIT_SELECTING: */ | ||
1535 | change_listen_mode(LISTEN_NONE); | ||
1529 | } | 1536 | } |
1530 | change_listen_mode(LISTEN_RAW); | ||
1531 | client_data.state = INIT_SELECTING; | 1537 | client_data.state = INIT_SELECTING; |
1532 | packet_num = 0; | 1538 | packet_num = 0; |
1533 | /* Kill any timeouts, user wants this to hurry along */ | 1539 | /* Kill any timeouts, user wants this to hurry along */ |
@@ -1535,6 +1541,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1535 | continue; | 1541 | continue; |
1536 | case SIGUSR2: | 1542 | case SIGUSR2: |
1537 | perform_d6_release(&srv6_buf, requested_ipv6); | 1543 | perform_d6_release(&srv6_buf, requested_ipv6); |
1544 | /* ^^^ switches to LISTEN_NONE */ | ||
1538 | timeout = INT_MAX; | 1545 | timeout = INT_MAX; |
1539 | continue; | 1546 | continue; |
1540 | case SIGTERM: | 1547 | case SIGTERM: |
@@ -1592,6 +1599,8 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1592 | unsigned address_timeout; | 1599 | unsigned address_timeout; |
1593 | unsigned prefix_timeout; | 1600 | unsigned prefix_timeout; |
1594 | type_is_ok: | 1601 | type_is_ok: |
1602 | change_listen_mode(LISTEN_NONE); | ||
1603 | |||
1595 | address_timeout = 0; | 1604 | address_timeout = 0; |
1596 | prefix_timeout = 0; | 1605 | prefix_timeout = 0; |
1597 | option = d6_find_option(packet.d6_options, packet_end, D6_OPT_STATUS_CODE); | 1606 | option = d6_find_option(packet.d6_options, packet_end, D6_OPT_STATUS_CODE); |
@@ -1602,7 +1611,6 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1602 | packet_end, "nak"); | 1611 | packet_end, "nak"); |
1603 | if (client_data.state != REQUESTING) | 1612 | if (client_data.state != REQUESTING) |
1604 | d6_run_script_no_option("deconfig"); | 1613 | d6_run_script_no_option("deconfig"); |
1605 | change_listen_mode(LISTEN_RAW); | ||
1606 | sleep(3); /* avoid excessive network traffic */ | 1614 | sleep(3); /* avoid excessive network traffic */ |
1607 | client_data.state = INIT_SELECTING; | 1615 | client_data.state = INIT_SELECTING; |
1608 | client_data.first_secs = 0; /* make secs field count from 0 */ | 1616 | client_data.first_secs = 0; /* make secs field count from 0 */ |
@@ -1624,6 +1632,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1624 | client6_data.server_id = option; | 1632 | client6_data.server_id = option; |
1625 | if (packet.d6_msg_type == D6_MSG_ADVERTISE) { | 1633 | if (packet.d6_msg_type == D6_MSG_ADVERTISE) { |
1626 | /* enter requesting state */ | 1634 | /* enter requesting state */ |
1635 | change_listen_mode(LISTEN_RAW); | ||
1627 | client_data.state = REQUESTING; | 1636 | client_data.state = REQUESTING; |
1628 | timeout = 0; | 1637 | timeout = 0; |
1629 | packet_num = 0; | 1638 | packet_num = 0; |
@@ -1826,7 +1835,6 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1826 | // BOUND_for_half_lease: | 1835 | // BOUND_for_half_lease: |
1827 | timeout = (unsigned)lease_remaining / 2; | 1836 | timeout = (unsigned)lease_remaining / 2; |
1828 | client_data.state = BOUND; | 1837 | client_data.state = BOUND; |
1829 | change_listen_mode(LISTEN_NONE); | ||
1830 | packet_num = 0; | 1838 | packet_num = 0; |
1831 | continue; /* back to main loop */ | 1839 | continue; /* back to main loop */ |
1832 | } | 1840 | } |
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index ab669d2b5..5fb96c2d8 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -1122,6 +1122,8 @@ static void perform_release(uint32_t server_addr, uint32_t requested_ip) | |||
1122 | char buffer[sizeof("255.255.255.255")]; | 1122 | char buffer[sizeof("255.255.255.255")]; |
1123 | struct in_addr temp_addr; | 1123 | struct in_addr temp_addr; |
1124 | 1124 | ||
1125 | change_listen_mode(LISTEN_NONE); | ||
1126 | |||
1125 | /* send release packet */ | 1127 | /* send release packet */ |
1126 | if (client_data.state == BOUND | 1128 | if (client_data.state == BOUND |
1127 | || client_data.state == RENEWING | 1129 | || client_data.state == RENEWING |
@@ -1143,8 +1145,6 @@ static void perform_release(uint32_t server_addr, uint32_t requested_ip) | |||
1143 | * of the states above. | 1145 | * of the states above. |
1144 | */ | 1146 | */ |
1145 | udhcp_run_script(NULL, "deconfig"); | 1147 | udhcp_run_script(NULL, "deconfig"); |
1146 | |||
1147 | change_listen_mode(LISTEN_NONE); | ||
1148 | client_data.state = RELEASED; | 1148 | client_data.state = RELEASED; |
1149 | } | 1149 | } |
1150 | 1150 | ||
@@ -1343,6 +1343,10 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1343 | clientid_mac_ptr += OPT_DATA + 1; /* skip option code, len, ethernet */ | 1343 | clientid_mac_ptr += OPT_DATA + 1; /* skip option code, len, ethernet */ |
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | /* Not really necessary (we redo it on every iteration) | ||
1347 | * but allows early (before daemonization) detection | ||
1348 | * of bad interface name. | ||
1349 | */ | ||
1346 | if (udhcp_read_interface(client_data.interface, | 1350 | if (udhcp_read_interface(client_data.interface, |
1347 | &client_data.ifindex, | 1351 | &client_data.ifindex, |
1348 | NULL, | 1352 | NULL, |
@@ -1372,7 +1376,6 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1372 | 1376 | ||
1373 | client_data.state = INIT_SELECTING; | 1377 | client_data.state = INIT_SELECTING; |
1374 | udhcp_run_script(NULL, "deconfig"); | 1378 | udhcp_run_script(NULL, "deconfig"); |
1375 | change_listen_mode(LISTEN_RAW); | ||
1376 | packet_num = 0; | 1379 | packet_num = 0; |
1377 | timeout = 0; | 1380 | timeout = 0; |
1378 | lease_remaining = 0; | 1381 | lease_remaining = 0; |
@@ -1446,8 +1449,10 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1446 | switch (client_data.state) { | 1449 | switch (client_data.state) { |
1447 | case INIT_SELECTING: | 1450 | case INIT_SELECTING: |
1448 | if (!discover_retries || packet_num < discover_retries) { | 1451 | if (!discover_retries || packet_num < discover_retries) { |
1449 | if (packet_num == 0) | 1452 | if (packet_num == 0) { |
1453 | change_listen_mode(LISTEN_RAW); | ||
1450 | xid = random_xid(); | 1454 | xid = random_xid(); |
1455 | } | ||
1451 | /* broadcast */ | 1456 | /* broadcast */ |
1452 | send_discover(xid, requested_ip); | 1457 | send_discover(xid, requested_ip); |
1453 | timeout = discover_timeout; | 1458 | timeout = discover_timeout; |
@@ -1455,6 +1460,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1455 | continue; | 1460 | continue; |
1456 | } | 1461 | } |
1457 | leasefail: | 1462 | leasefail: |
1463 | change_listen_mode(LISTEN_NONE); | ||
1458 | udhcp_run_script(NULL, "leasefail"); | 1464 | udhcp_run_script(NULL, "leasefail"); |
1459 | #if BB_MMU /* -b is not supported on NOMMU */ | 1465 | #if BB_MMU /* -b is not supported on NOMMU */ |
1460 | if (opt & OPT_b) { /* background if no lease */ | 1466 | if (opt & OPT_b) { /* background if no lease */ |
@@ -1491,7 +1497,6 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1491 | * "discover...select...discover..." loops | 1497 | * "discover...select...discover..." loops |
1492 | * were seen in the wild. Treat them similarly | 1498 | * were seen in the wild. Treat them similarly |
1493 | * to "no response to discover" case */ | 1499 | * to "no response to discover" case */ |
1494 | change_listen_mode(LISTEN_RAW); | ||
1495 | client_data.state = INIT_SELECTING; | 1500 | client_data.state = INIT_SELECTING; |
1496 | goto leasefail; | 1501 | goto leasefail; |
1497 | case BOUND: | 1502 | case BOUND: |
@@ -1528,17 +1533,17 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1528 | } | 1533 | } |
1529 | //TODO: if 3 renew's failed (no reply) but remaining lease is large enough, | 1534 | //TODO: if 3 renew's failed (no reply) but remaining lease is large enough, |
1530 | //it might make sense to go back to BOUND and try later? a-la | 1535 | //it might make sense to go back to BOUND and try later? a-la |
1531 | // if (lease_remaining > 30) goto BOUND_for_half_lease; | 1536 | // if (lease_remaining > 30) change_listen_mode(LISTEN_NONE) + goto BOUND_for_half_lease; |
1532 | //If we do that, "packet_num < 3" test below might be superfluous | 1537 | //If we do that, "packet_num < 3" test below might be superfluous |
1533 | //(lease_remaining will run out anyway) | 1538 | //(lease_remaining will run out anyway) |
1534 | /* Timed out or error, enter rebinding state */ | 1539 | /* Timed out or error, enter rebinding state */ |
1535 | log1s("entering rebinding state"); | 1540 | log1s("entering rebinding state"); |
1536 | client_data.state = REBINDING; | 1541 | client_data.state = REBINDING; |
1542 | /* Switch to bcast receive */ | ||
1543 | change_listen_mode(LISTEN_RAW); | ||
1537 | packet_num = 0; | 1544 | packet_num = 0; |
1538 | /* fall right through */ | 1545 | /* fall right through */ |
1539 | case REBINDING: | 1546 | case REBINDING: |
1540 | /* Switch to bcast receive */ | ||
1541 | change_listen_mode(LISTEN_RAW); | ||
1542 | /* Lease is *really* about to run out, | 1547 | /* Lease is *really* about to run out, |
1543 | * try to find DHCP server using broadcast */ | 1548 | * try to find DHCP server using broadcast */ |
1544 | if (lease_remaining > 0 && packet_num < 3) { | 1549 | if (lease_remaining > 0 && packet_num < 3) { |
@@ -1549,6 +1554,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1549 | continue; | 1554 | continue; |
1550 | } | 1555 | } |
1551 | /* Timed out, enter init state */ | 1556 | /* Timed out, enter init state */ |
1557 | change_listen_mode(LISTEN_NONE); | ||
1552 | bb_simple_info_msg("lease lost, entering init state"); | 1558 | bb_simple_info_msg("lease lost, entering init state"); |
1553 | udhcp_run_script(NULL, "deconfig"); | 1559 | udhcp_run_script(NULL, "deconfig"); |
1554 | client_data.state = INIT_SELECTING; | 1560 | client_data.state = INIT_SELECTING; |
@@ -1584,12 +1590,15 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1584 | 1590 | ||
1585 | /* Start things over */ | 1591 | /* Start things over */ |
1586 | case RENEW_REQUESTED: /* two or more SIGUSR1 received */ | 1592 | case RENEW_REQUESTED: /* two or more SIGUSR1 received */ |
1593 | change_listen_mode(LISTEN_NONE); | ||
1587 | udhcp_run_script(NULL, "deconfig"); | 1594 | udhcp_run_script(NULL, "deconfig"); |
1588 | /* case REQUESTING: break; */ | 1595 | |
1589 | /* case RELEASED: break; */ | 1596 | default: |
1590 | /* case INIT_SELECTING: break; */ | 1597 | /* case REQUESTING: */ |
1598 | /* case RELEASED: */ | ||
1599 | /* case INIT_SELECTING: */ | ||
1600 | change_listen_mode(LISTEN_NONE); | ||
1591 | } | 1601 | } |
1592 | change_listen_mode(LISTEN_RAW); | ||
1593 | client_data.state = INIT_SELECTING; | 1602 | client_data.state = INIT_SELECTING; |
1594 | packet_num = 0; | 1603 | packet_num = 0; |
1595 | /* Kill any timeouts, user wants this to hurry along */ | 1604 | /* Kill any timeouts, user wants this to hurry along */ |
@@ -1597,6 +1606,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1597 | continue; | 1606 | continue; |
1598 | case SIGUSR2: | 1607 | case SIGUSR2: |
1599 | perform_release(server_addr, requested_ip); | 1608 | perform_release(server_addr, requested_ip); |
1609 | /* ^^^ switches to LISTEN_NONE */ | ||
1600 | timeout = INT_MAX; | 1610 | timeout = INT_MAX; |
1601 | continue; | 1611 | continue; |
1602 | case SIGTERM: | 1612 | case SIGTERM: |
@@ -1706,6 +1716,8 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1706 | char server_str[sizeof("255.255.255.255")]; | 1716 | char server_str[sizeof("255.255.255.255")]; |
1707 | uint8_t *temp; | 1717 | uint8_t *temp; |
1708 | 1718 | ||
1719 | change_listen_mode(LISTEN_NONE); | ||
1720 | |||
1709 | temp_addr.s_addr = server_addr; | 1721 | temp_addr.s_addr = server_addr; |
1710 | strcpy(server_str, inet_ntoa(temp_addr)); | 1722 | strcpy(server_str, inet_ntoa(temp_addr)); |
1711 | temp_addr.s_addr = packet.yiaddr; | 1723 | temp_addr.s_addr = packet.yiaddr; |
@@ -1758,7 +1770,6 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1758 | 1770 | ||
1759 | if (client_data.state != REQUESTING) | 1771 | if (client_data.state != REQUESTING) |
1760 | udhcp_run_script(NULL, "deconfig"); | 1772 | udhcp_run_script(NULL, "deconfig"); |
1761 | change_listen_mode(LISTEN_RAW); | ||
1762 | client_data.state = INIT_SELECTING; | 1773 | client_data.state = INIT_SELECTING; |
1763 | client_data.first_secs = 0; /* make secs field count from 0 */ | 1774 | client_data.first_secs = 0; /* make secs field count from 0 */ |
1764 | requested_ip = 0; | 1775 | requested_ip = 0; |
@@ -1768,7 +1779,6 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1768 | } | 1779 | } |
1769 | } | 1780 | } |
1770 | #endif | 1781 | #endif |
1771 | |||
1772 | /* enter bound state */ | 1782 | /* enter bound state */ |
1773 | start = monotonic_sec(); | 1783 | start = monotonic_sec(); |
1774 | udhcp_run_script(&packet, client_data.state == REQUESTING ? "bound" : "renew"); | 1784 | udhcp_run_script(&packet, client_data.state == REQUESTING ? "bound" : "renew"); |
@@ -1791,7 +1801,6 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1791 | // BOUND_for_half_lease: | 1801 | // BOUND_for_half_lease: |
1792 | timeout = (unsigned)lease_remaining / 2; | 1802 | timeout = (unsigned)lease_remaining / 2; |
1793 | client_data.state = BOUND; | 1803 | client_data.state = BOUND; |
1794 | change_listen_mode(LISTEN_NONE); | ||
1795 | /* make future renew packets use different xid */ | 1804 | /* make future renew packets use different xid */ |
1796 | /* xid = random_xid(); ...but why bother? */ | 1805 | /* xid = random_xid(); ...but why bother? */ |
1797 | packet_num = 0; | 1806 | packet_num = 0; |
@@ -1818,11 +1827,11 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1818 | goto non_matching_svid; | 1827 | goto non_matching_svid; |
1819 | } | 1828 | } |
1820 | /* return to init state */ | 1829 | /* return to init state */ |
1830 | change_listen_mode(LISTEN_NONE); | ||
1821 | bb_info_msg("received %s", "DHCP NAK"); | 1831 | bb_info_msg("received %s", "DHCP NAK"); |
1822 | udhcp_run_script(&packet, "nak"); | 1832 | udhcp_run_script(&packet, "nak"); |
1823 | if (client_data.state != REQUESTING) | 1833 | if (client_data.state != REQUESTING) |
1824 | udhcp_run_script(NULL, "deconfig"); | 1834 | udhcp_run_script(NULL, "deconfig"); |
1825 | change_listen_mode(LISTEN_RAW); | ||
1826 | sleep(3); /* avoid excessive network traffic */ | 1835 | sleep(3); /* avoid excessive network traffic */ |
1827 | client_data.state = INIT_SELECTING; | 1836 | client_data.state = INIT_SELECTING; |
1828 | client_data.first_secs = 0; /* make secs field count from 0 */ | 1837 | client_data.first_secs = 0; /* make secs field count from 0 */ |