reinit_shared_deconfig() was not fully resetting arp state.

This commit is contained in:
Nicholas J. Kain 2017-02-27 11:30:35 -05:00
parent 8ca0d28f61
commit 348e975f2d
3 changed files with 29 additions and 22 deletions

View File

@ -85,8 +85,34 @@ void arp_reply_clear(void)
garp.reply_offset = 0;
}
void arp_reset_send_stats(void)
static void arp_min_close_fd(struct client_state_t cs[static 1])
{
if (cs->arpFd < 0)
return;
epoll_del(cs->epollFd, cs->arpFd);
close(cs->arpFd);
cs->arpFd = -1;
cs->arp_is_defense = false;
}
static void arp_close_fd(struct client_state_t cs[static 1])
{
arp_min_close_fd(cs);
for (int i = 0; i < AS_MAX; ++i)
garp.wake_ts[i] = -1;
}
void arp_reset_state(struct client_state_t cs[static 1])
{
arp_close_fd(cs);
arp_reply_clear();
garp.last_conflict_ts = 0;
garp.gw_check_initpings = 0;
garp.arp_check_start_ts = 0;
garp.total_conflicts = 0;
garp.probe_wait_time = 0;
garp.server_replied = false;
garp.router_replied = false;
for (int i = 0; i < ASEND_MAX; ++i) {
garp.send_stats[i].ts = 0;
garp.send_stats[i].count = 0;
@ -129,23 +155,6 @@ static int get_arp_defense_socket(struct client_state_t cs[static 1])
return fd;
}
static void arp_min_close_fd(struct client_state_t cs[static 1])
{
if (cs->arpFd < 0)
return;
epoll_del(cs->epollFd, cs->arpFd);
close(cs->arpFd);
cs->arpFd = -1;
cs->arp_is_defense = false;
}
void arp_close_fd(struct client_state_t cs[static 1])
{
arp_min_close_fd(cs);
for (int i = 0; i < AS_MAX; ++i)
garp.wake_ts[i] = -1;
}
static int arp_open_fd(struct client_state_t cs[static 1], bool defense)
{
if (cs->arpFd >= 0 && defense == cs->arp_is_defense)

View File

@ -105,12 +105,11 @@ struct arp_data {
};
void arp_reply_clear(void);
void arp_reset_state(struct client_state_t cs[static 1]);
bool arp_packet_get(struct client_state_t cs[static 1]);
void set_arp_relentless_def(bool v);
void arp_reset_send_stats(void);
void arp_close_fd(struct client_state_t cs[static 1]);
int arp_check(struct client_state_t cs[static 1],
struct dhcpmsg packet[static 1]);
int arp_gw_check(struct client_state_t cs[static 1]);

View File

@ -75,7 +75,6 @@ static int delay_timeout(struct client_state_t cs[static 1], size_t numpackets)
static void reinit_shared_deconfig(struct client_state_t cs[static 1])
{
arp_close_fd(cs);
cs->clientAddr = 0;
cs->num_dhcp_requests = 0;
cs->got_router_arp = false;
@ -86,7 +85,7 @@ static void reinit_shared_deconfig(struct client_state_t cs[static 1])
cs->sent_second_announce = false;
memset(&cs->routerArp, 0, sizeof cs->routerArp);
memset(&cs->serverArp, 0, sizeof cs->serverArp);
arp_reset_send_stats();
arp_reset_state(cs);
}
static void reinit_selecting(struct client_state_t cs[static 1], int timeout)