Rename DS_ARP_CHECK to the less confusing DS_COLLISION_CHECK.
Call arp_reopen_fd() if reading from the arp fd fails in any state other than AS_COLLISION_CHECK or AS_GW_CHECK.
This commit is contained in:
parent
b3acad9166
commit
a9c807c1df
@ -1,5 +1,5 @@
|
|||||||
/* arp.c - arp ping checking
|
/* arp.c - arp ping checking
|
||||||
* Time-stamp: <2011-07-04 22:51:19 njk>
|
* Time-stamp: <2011-07-04 22:57:35 njk>
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011 Nicholas J. Kain <njkain@gmail.com>
|
* Copyright 2010-2011 Nicholas J. Kain <njkain@gmail.com>
|
||||||
*
|
*
|
||||||
@ -316,7 +316,7 @@ int arp_check(struct client_state_t *cs, struct dhcpmsg *packet)
|
|||||||
if (arp_ip_anon_ping(cs, arp_dhcp_packet.yiaddr) == -1)
|
if (arp_ip_anon_ping(cs, arp_dhcp_packet.yiaddr) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
cs->arpPrevState = cs->dhcpState;
|
cs->arpPrevState = cs->dhcpState;
|
||||||
cs->dhcpState = DS_ARP_CHECK;
|
cs->dhcpState = DS_COLLISION_CHECK;
|
||||||
cs->timeout = 2000;
|
cs->timeout = 2000;
|
||||||
memcpy(&arp_dhcp_packet, packet, sizeof (struct dhcpmsg));
|
memcpy(&arp_dhcp_packet, packet, sizeof (struct dhcpmsg));
|
||||||
arpreply_clear();
|
arpreply_clear();
|
||||||
@ -378,8 +378,6 @@ void arp_success(struct client_state_t *cs)
|
|||||||
cs->dhcpState = DS_BOUND;
|
cs->dhcpState = DS_BOUND;
|
||||||
cs->init = 0;
|
cs->init = 0;
|
||||||
if (cs->arpPrevState == DS_RENEWING || cs->arpPrevState == DS_REBINDING) {
|
if (cs->arpPrevState == DS_RENEWING || cs->arpPrevState == DS_REBINDING) {
|
||||||
// XXX We need to be smarter about this and only issue an ifchange if
|
|
||||||
// the lease has actually changed.
|
|
||||||
ifchange_bind(&arp_dhcp_packet);
|
ifchange_bind(&arp_dhcp_packet);
|
||||||
arp_switch_state(cs, AS_DEFENSE);
|
arp_switch_state(cs, AS_DEFENSE);
|
||||||
} else {
|
} else {
|
||||||
@ -475,7 +473,7 @@ void handle_arp_response(struct client_state_t *cs)
|
|||||||
case AS_COLLISION_CHECK: arp_failed(cs); break;
|
case AS_COLLISION_CHECK: arp_failed(cs); break;
|
||||||
case AS_GW_CHECK: arp_gw_failed(cs); break;
|
case AS_GW_CHECK: arp_gw_failed(cs); break;
|
||||||
default:
|
default:
|
||||||
// XXX: close and re-open the FD in ALL cases
|
arp_reopen_fd(cs);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -42,7 +42,7 @@ dhcp_state_t dhcp_states[] = {
|
|||||||
{ an_packet, renewing_timeout, frenew, nfrelease}, // RENEWING
|
{ an_packet, renewing_timeout, frenew, nfrelease}, // RENEWING
|
||||||
{ an_packet, rebinding_timeout, frenew, nfrelease}, // REBINDING
|
{ an_packet, rebinding_timeout, frenew, nfrelease}, // REBINDING
|
||||||
{ 0, arp_gw_failed, frenew, anfrelease}, // BOUND_GW_CHECK
|
{ 0, arp_gw_failed, frenew, anfrelease}, // BOUND_GW_CHECK
|
||||||
{ 0, arp_success, frenew, anfrelease}, // ARP_CHECK
|
{ 0, arp_success, frenew, anfrelease}, // COLLISION_CHECK
|
||||||
{ 0, released_timeout, frenew, frelease}, // RELEASED
|
{ 0, released_timeout, frenew, frelease}, // RELEASED
|
||||||
{ 0, 0, 0, 0}, // NUM_STATES
|
{ 0, 0, 0, 0}, // NUM_STATES
|
||||||
};
|
};
|
||||||
@ -173,7 +173,7 @@ static void an_packet(struct client_state_t *cs, struct dhcpmsg *packet,
|
|||||||
cs->renewTime = cs->lease >> 1;
|
cs->renewTime = cs->lease >> 1;
|
||||||
cs->rebindTime = (cs->lease * 0x7) >> 3; // * 0.875
|
cs->rebindTime = (cs->lease * 0x7) >> 3; // * 0.875
|
||||||
|
|
||||||
// Can transition from DS_ARP_CHECK to DS_BOUND or DS_SELECTING.
|
// Can transition from DS_COLLISION_CHECK to DS_BOUND or DS_SELECTING.
|
||||||
if (arp_check(cs, packet) == -1) {
|
if (arp_check(cs, packet) == -1) {
|
||||||
log_warning("arp_check failed to make arp socket, retrying lease");
|
log_warning("arp_check failed to make arp socket, retrying lease");
|
||||||
reinit_selecting(cs, 3000);
|
reinit_selecting(cs, 3000);
|
||||||
@ -263,7 +263,7 @@ static void frenew(struct client_state_t *cs)
|
|||||||
set_listen_cooked(cs);
|
set_listen_cooked(cs);
|
||||||
send_renew(cs);
|
send_renew(cs);
|
||||||
break;
|
break;
|
||||||
case DS_ARP_CHECK:
|
case DS_COLLISION_CHECK:
|
||||||
// Cancel arp ping in progress and treat as previous state.
|
// Cancel arp ping in progress and treat as previous state.
|
||||||
if (arp_close_fd(cs))
|
if (arp_close_fd(cs))
|
||||||
cs->dhcpState = cs->arpPrevState;
|
cs->dhcpState = cs->arpPrevState;
|
||||||
|
@ -11,7 +11,7 @@ typedef enum {
|
|||||||
DS_RENEWING,
|
DS_RENEWING,
|
||||||
DS_REBINDING,
|
DS_REBINDING,
|
||||||
DS_BOUND_GW_CHECK,
|
DS_BOUND_GW_CHECK,
|
||||||
DS_ARP_CHECK,
|
DS_COLLISION_CHECK,
|
||||||
DS_RELEASED,
|
DS_RELEASED,
|
||||||
DS_NUM_STATES,
|
DS_NUM_STATES,
|
||||||
} dhcp_states_t;
|
} dhcp_states_t;
|
||||||
|
Loading…
Reference in New Issue
Block a user