From: Alejandro Enrique Date: Wed, 11 Feb 2015 10:02:47 +0000 (+0100) Subject: improve host detection on interface change X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=b12322b8e1ac473b09b26f99a9c14a8e6a20df04;p=project%2Frelayd.git improve host detection on interface change This patch improve host detection and refresh when it moves from and interface to another by pinging for it on all managed interfaces. Previous to this patch host expiration was done by pinging for it on the last interface it was known to be. If it does not reply after a number of retries it will be expired and its entries deleted. Nevertheless, if the host has moved to another managed interface it will not be detected until there is some ARP packet sent by the host. This detection can be improved by pinging for the host on all managed interfaces instead of just the one where it is supposed to be connected, as it will reply to the ARP ping on the new interface it is connected to and a host refresh will be triggered. Signed-off-by: Alejandro Enrique --- diff --git a/main.c b/main.c index a78076c..318ba1c 100644 --- a/main.c +++ b/main.c @@ -252,6 +252,7 @@ static void send_arp_reply(struct relayd_interface *rif, const uint8_t spa[4], static void host_entry_timeout(struct uloop_timeout *timeout) { struct relayd_host *host = container_of(timeout, struct relayd_host, timeout); + struct relayd_interface *rif; /* * When a host is behind a managed interface, we must not expire its host @@ -261,7 +262,9 @@ static void host_entry_timeout(struct uloop_timeout *timeout) * giving up on it. */ if (host->rif->managed && host->cleanup_pending < host_ping_tries) { - send_arp_request(host->rif, host->ipaddr); + list_for_each_entry(rif, &interfaces, list) { + send_arp_request(rif, host->ipaddr); + } host->cleanup_pending++; uloop_timeout_set(&host->timeout, 1000); return;