udhcpc[6]: fold perform_renew() into its only caller
function old new delta udhcpc_main 2550 2541 -9 udhcpc6_main 2576 2567 -9 change_listen_mode 321 299 -22 .rodata 103294 103225 -69 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-109) Total: -109 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
a1a77ad5ea
commit
e6007c4911
@ -1040,7 +1040,6 @@ static int d6_raw_socket(int ifindex)
|
|||||||
log2("opening raw socket on ifindex %d", ifindex);
|
log2("opening raw socket on ifindex %d", ifindex);
|
||||||
|
|
||||||
fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6));
|
fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6));
|
||||||
log3("got raw socket fd %d", fd);
|
|
||||||
|
|
||||||
memset(&sock, 0, sizeof(sock)); /* let's be deterministic */
|
memset(&sock, 0, sizeof(sock)); /* let's be deterministic */
|
||||||
sock.sll_family = AF_PACKET;
|
sock.sll_family = AF_PACKET;
|
||||||
@ -1087,29 +1086,6 @@ static void change_listen_mode(int new_mode)
|
|||||||
/* else LISTEN_NONE: client_data.sockfd stays closed */
|
/* else LISTEN_NONE: client_data.sockfd stays closed */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called only on SIGUSR1 */
|
|
||||||
static void perform_renew(void)
|
|
||||||
{
|
|
||||||
bb_simple_info_msg("performing DHCP renew");
|
|
||||||
switch (client_data.state) {
|
|
||||||
case BOUND:
|
|
||||||
change_listen_mode(LISTEN_KERNEL);
|
|
||||||
case RENEWING:
|
|
||||||
case REBINDING:
|
|
||||||
client_data.state = RENEW_REQUESTED;
|
|
||||||
break;
|
|
||||||
case RENEW_REQUESTED: /* impatient are we? fine, square 1 */
|
|
||||||
d6_run_script_no_option("deconfig");
|
|
||||||
case REQUESTING:
|
|
||||||
case RELEASED:
|
|
||||||
change_listen_mode(LISTEN_RAW);
|
|
||||||
client_data.state = INIT_SELECTING;
|
|
||||||
break;
|
|
||||||
case INIT_SELECTING:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *our_cur_ipv6)
|
static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *our_cur_ipv6)
|
||||||
{
|
{
|
||||||
/* send release packet */
|
/* send release packet */
|
||||||
@ -1535,10 +1511,26 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
switch (udhcp_sp_read()) {
|
switch (udhcp_sp_read()) {
|
||||||
case SIGUSR1:
|
case SIGUSR1:
|
||||||
client_data.first_secs = 0; /* make secs field count from 0 */
|
client_data.first_secs = 0; /* make secs field count from 0 */
|
||||||
perform_renew();
|
bb_simple_info_msg("performing DHCP renew");
|
||||||
if (client_data.state == RENEW_REQUESTED)
|
|
||||||
|
switch (client_data.state) {
|
||||||
|
/* Try to renew/rebind */
|
||||||
|
case BOUND:
|
||||||
|
case RENEWING:
|
||||||
|
case REBINDING:
|
||||||
|
change_listen_mode(LISTEN_KERNEL);
|
||||||
|
client_data.state = RENEW_REQUESTED;
|
||||||
goto case_RENEW_REQUESTED;
|
goto case_RENEW_REQUESTED;
|
||||||
|
|
||||||
/* Start things over */
|
/* Start things over */
|
||||||
|
case RENEW_REQUESTED: /* two or more SIGUSR1 received */
|
||||||
|
d6_run_script_no_option("deconfig");
|
||||||
|
/* case REQUESTING: break; */
|
||||||
|
/* case RELEASED: break; */
|
||||||
|
/* case INIT_SELECTING: break; */
|
||||||
|
}
|
||||||
|
change_listen_mode(LISTEN_RAW);
|
||||||
|
client_data.state = INIT_SELECTING;
|
||||||
packet_num = 0;
|
packet_num = 0;
|
||||||
/* Kill any timeouts, user wants this to hurry along */
|
/* Kill any timeouts, user wants this to hurry along */
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
|
@ -1027,7 +1027,6 @@ static int udhcp_raw_socket(int ifindex)
|
|||||||
* SOCK_DGRAM: remove link-layer headers on input (SOCK_RAW keeps them)
|
* SOCK_DGRAM: remove link-layer headers on input (SOCK_RAW keeps them)
|
||||||
* ETH_P_IP: want to receive only packets with IPv4 eth type
|
* ETH_P_IP: want to receive only packets with IPv4 eth type
|
||||||
*/
|
*/
|
||||||
log3("got raw socket fd %d", fd);
|
|
||||||
|
|
||||||
memset(&sock, 0, sizeof(sock)); /* let's be deterministic */
|
memset(&sock, 0, sizeof(sock)); /* let's be deterministic */
|
||||||
sock.sll_family = AF_PACKET;
|
sock.sll_family = AF_PACKET;
|
||||||
@ -1122,29 +1121,6 @@ static void change_listen_mode(int new_mode)
|
|||||||
/* else LISTEN_NONE: client_data.sockfd stays closed */
|
/* else LISTEN_NONE: client_data.sockfd stays closed */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called only on SIGUSR1 */
|
|
||||||
static void perform_renew(void)
|
|
||||||
{
|
|
||||||
bb_simple_info_msg("performing DHCP renew");
|
|
||||||
switch (client_data.state) {
|
|
||||||
case BOUND:
|
|
||||||
change_listen_mode(LISTEN_KERNEL);
|
|
||||||
case RENEWING:
|
|
||||||
case REBINDING:
|
|
||||||
client_data.state = RENEW_REQUESTED;
|
|
||||||
break;
|
|
||||||
case RENEW_REQUESTED: /* impatient are we? fine, square 1 */
|
|
||||||
udhcp_run_script(NULL, "deconfig");
|
|
||||||
case REQUESTING:
|
|
||||||
case RELEASED:
|
|
||||||
change_listen_mode(LISTEN_RAW);
|
|
||||||
client_data.state = INIT_SELECTING;
|
|
||||||
break;
|
|
||||||
case INIT_SELECTING:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void perform_release(uint32_t server_addr, uint32_t requested_ip)
|
static void perform_release(uint32_t server_addr, uint32_t requested_ip)
|
||||||
{
|
{
|
||||||
char buffer[sizeof("255.255.255.255")];
|
char buffer[sizeof("255.255.255.255")];
|
||||||
@ -1247,7 +1223,6 @@ static void client_background(void)
|
|||||||
//usage: "\n USR1 Renew lease"
|
//usage: "\n USR1 Renew lease"
|
||||||
//usage: "\n USR2 Release lease"
|
//usage: "\n USR2 Release lease"
|
||||||
|
|
||||||
|
|
||||||
int udhcpc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int udhcpc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
@ -1597,10 +1572,26 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
switch (udhcp_sp_read()) {
|
switch (udhcp_sp_read()) {
|
||||||
case SIGUSR1:
|
case SIGUSR1:
|
||||||
client_data.first_secs = 0; /* make secs field count from 0 */
|
client_data.first_secs = 0; /* make secs field count from 0 */
|
||||||
perform_renew();
|
bb_simple_info_msg("performing DHCP renew");
|
||||||
if (client_data.state == RENEW_REQUESTED)
|
|
||||||
|
switch (client_data.state) {
|
||||||
|
/* Try to renew/rebind */
|
||||||
|
case BOUND:
|
||||||
|
case RENEWING:
|
||||||
|
case REBINDING:
|
||||||
|
change_listen_mode(LISTEN_KERNEL);
|
||||||
|
client_data.state = RENEW_REQUESTED;
|
||||||
goto case_RENEW_REQUESTED;
|
goto case_RENEW_REQUESTED;
|
||||||
|
|
||||||
/* Start things over */
|
/* Start things over */
|
||||||
|
case RENEW_REQUESTED: /* two or more SIGUSR1 received */
|
||||||
|
udhcp_run_script(NULL, "deconfig");
|
||||||
|
/* case REQUESTING: break; */
|
||||||
|
/* case RELEASED: break; */
|
||||||
|
/* case INIT_SELECTING: break; */
|
||||||
|
}
|
||||||
|
change_listen_mode(LISTEN_RAW);
|
||||||
|
client_data.state = INIT_SELECTING;
|
||||||
packet_num = 0;
|
packet_num = 0;
|
||||||
/* Kill any timeouts, user wants this to hurry along */
|
/* Kill any timeouts, user wants this to hurry along */
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
@ -1737,7 +1728,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
/* paranoia: must not be too small and not prone to overflows */
|
/* paranoia: must not be too small and not prone to overflows */
|
||||||
/* NB: 60s leases _are_ used in real world
|
/* NB: 60s leases _are_ used in real world
|
||||||
* (temporary IPs while ISP modem initializes)
|
* (temporary IPs while ISP modem initializes)
|
||||||
* do not break this case by bumplit it up.
|
* do not break this case by bumping it up.
|
||||||
*/
|
*/
|
||||||
if (lease_remaining < 0) /* signed overflow? */
|
if (lease_remaining < 0) /* signed overflow? */
|
||||||
lease_remaining = INT_MAX;
|
lease_remaining = INT_MAX;
|
||||||
|
Loading…
Reference in New Issue
Block a user