[OpenWrt-Devel] [PATCH] improve host detection on interface change

Alejandro Enrique alejandro.enrique at fon.com
Wed Feb 11 05:02:47 EST 2015


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 <alejandro.enrique at fon.com>
---
 main.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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;
-- 
1.7.10.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list