aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/d6_dhcpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/d6_dhcpc.c')
-rw-r--r--networking/udhcp/d6_dhcpc.c32
1 files changed, 20 insertions, 12 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
1091static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *our_cur_ipv6) 1091static 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 }