X-Git-Url: http://git.archive.openwrt.org/?p=project%2Frelayd.git;a=blobdiff_plain;f=main.c;h=2f3bae855be804c6b26ef2e03dde1579a63f5e2f;hp=e677f49ba2a5770e93e79aa0b7ae271fa31e77ff;hb=d515c3bc3b1eb92c4ae9f5e8f51ea3886b8d2d2f;hpb=3771bad14d2423062f8ae6ef8734b52182618e92 diff --git a/main.c b/main.c index e677f49..2f3bae8 100644 --- a/main.c +++ b/main.c @@ -36,6 +36,7 @@ LIST_HEAD(interfaces); int debug; static int host_timeout; +static int host_ping_tries; static int inet_sock; static int forward_bcast; static int forward_dhcp; @@ -244,7 +245,7 @@ static void host_entry_timeout(struct uloop_timeout *timeout) * When the timeout is reached, try pinging the host a few times before * giving up on it. */ - if (host->rif->managed && host->cleanup_pending < 2) { + if (host->rif->managed && host->cleanup_pending < host_ping_tries) { send_arp_request(host->rif, host->ipaddr); host->cleanup_pending++; uloop_timeout_set(&host->timeout, 1000); @@ -359,7 +360,9 @@ static void recv_arp_request(struct relayd_interface *rif, struct arp_packet *pk return; } - relayd_refresh_host(rif, pkt->eth.ether_shost, pkt->arp.arp_spa); + host = find_host_by_ipaddr(NULL, pkt->arp.arp_spa); + if (!host || host->rif != rif) + relayd_refresh_host(rif, pkt->eth.ether_shost, pkt->arp.arp_spa); host = find_host_by_ipaddr(NULL, pkt->arp.arp_tpa); @@ -667,6 +670,7 @@ static int usage(const char *progname) " -R :/\n" " Add a static route for / via \n" " -t Host entry expiry timeout\n" + " -p Number of ARP ping attempts before considering a host dead\n" " -T Set routing table number for automatically added routes\n" " -B Enable broadcast forwarding\n" " -D Enable DHCP forwarding\n" @@ -694,7 +698,8 @@ int main(int argc, char **argv) return 1; } - host_timeout = 60; + host_timeout = 30; + host_ping_tries = 5; forward_bcast = 0; local_route_table = 0; uloop_init(); @@ -717,6 +722,11 @@ int main(int argc, char **argv) if (host_timeout <= 0) return usage(argv[0]); break; + case 'p': + host_ping_tries = atoi(optarg); + if (host_ping_tries <= 0) + return usage(argv[0]); + break; case 'd': debug++; break;