Make frenew() less insane. It was most likely subtly buggy before depending
on state.
This commit is contained in:
parent
3a81f1ea6c
commit
e77190e2e9
@ -85,13 +85,14 @@ out:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void arp_close_fd(struct client_state_t *cs)
|
int arp_close_fd(struct client_state_t *cs)
|
||||||
{
|
{
|
||||||
if (cs->arpFd == -1)
|
if (cs->arpFd == -1)
|
||||||
return;
|
return 0;
|
||||||
epoll_del(cs, cs->arpFd);
|
epoll_del(cs, cs->arpFd);
|
||||||
close(cs->arpFd);
|
close(cs->arpFd);
|
||||||
cs->arpFd = -1;
|
cs->arpFd = -1;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns 0 on success, -1 on failure.
|
// Returns 0 on success, -1 on failure.
|
||||||
|
@ -49,7 +49,7 @@ struct arpMsg {
|
|||||||
uint8_t pad[18]; /* 2a pad for min. ethernet payload (60 bytes) */
|
uint8_t pad[18]; /* 2a pad for min. ethernet payload (60 bytes) */
|
||||||
};
|
};
|
||||||
|
|
||||||
void arp_close_fd(struct client_state_t *cs);
|
int arp_close_fd(struct client_state_t *cs);
|
||||||
int arp_check(struct client_state_t *cs, struct dhcpmsg *packet);
|
int arp_check(struct client_state_t *cs, struct dhcpmsg *packet);
|
||||||
int arp_gw_check(struct client_state_t *cs);
|
int arp_gw_check(struct client_state_t *cs);
|
||||||
int arp_get_gw_hwaddr(struct client_state_t *cs);
|
int arp_get_gw_hwaddr(struct client_state_t *cs);
|
||||||
|
15
ndhc/state.c
15
ndhc/state.c
@ -260,31 +260,32 @@ static void frelease(struct client_state_t *cs)
|
|||||||
cs->timeout = -1;
|
cs->timeout = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: DS_ARP_CHECK_GW? Also split this up?
|
|
||||||
static void frenew(struct client_state_t *cs)
|
static void frenew(struct client_state_t *cs)
|
||||||
{
|
{
|
||||||
log_line("Forcing a DHCP renew...");
|
log_line("Forcing a DHCP renew...");
|
||||||
retry:
|
retry:
|
||||||
switch (cs->dhcpState) {
|
switch (cs->dhcpState) {
|
||||||
case DS_BOUND:
|
case DS_BOUND:
|
||||||
|
case DS_BOUND_GW_CHECK:
|
||||||
|
arp_close_fd(cs);
|
||||||
|
cs->dhcpState = DS_RENEWING;
|
||||||
change_listen_mode(cs, LM_KERNEL);
|
change_listen_mode(cs, LM_KERNEL);
|
||||||
|
send_renew(cs->xid, cs->serverAddr, cs->requestedIP);
|
||||||
|
break;
|
||||||
case DS_ARP_CHECK:
|
case DS_ARP_CHECK:
|
||||||
// Cancel arp ping in progress and treat as previous state.
|
// Cancel arp ping in progress and treat as previous state.
|
||||||
epoll_del(cs, cs->arpFd);
|
if (arp_close_fd(cs))
|
||||||
close(cs->arpFd);
|
|
||||||
cs->arpFd = -1;
|
|
||||||
cs->dhcpState = cs->arpPrevState;
|
cs->dhcpState = cs->arpPrevState;
|
||||||
goto retry;
|
goto retry;
|
||||||
case DS_REQUESTING:
|
|
||||||
case DS_RELEASED:
|
case DS_RELEASED:
|
||||||
change_listen_mode(cs, LM_RAW);
|
change_listen_mode(cs, LM_RAW);
|
||||||
cs->dhcpState = DS_SELECTING;
|
cs->dhcpState = DS_SELECTING;
|
||||||
break;
|
break;
|
||||||
case DS_RENEWING:
|
case DS_RENEWING:
|
||||||
case DS_REBINDING:
|
case DS_REBINDING:
|
||||||
case DS_SELECTING:
|
|
||||||
default:
|
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
cs->packetNum = 0;
|
cs->packetNum = 0;
|
||||||
cs->timeout = 0;
|
cs->timeout = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user