[OpenWrt-Devel] add host route on local ip arp request
diff mbox

Message ID 1423648967-2579-1-git-send-email-alejandro.enrique@fon.com
State Accepted
Headers show

Commit Message

Alejandro Enrique Feb. 11, 2015, 10:02 a.m. UTC
This patch fixes relayd not adding a host on an ARP request for the local
IP address.
When relayd is launched using the -L option, it was not adding the
necessary host routes when it receives an ARP request for the local
IP address.

This issue makes a host not able to connect to the device running
relayd until there is ARP traffic involving a third host.

Signed-off-by: Alejandro Enrique <alejandro.enrique@fon.com>
---
 main.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Felix Fietkau Feb. 11, 2015, 10:12 a.m. UTC | #1
On 2015-02-11 21:02, Alejandro Enrique wrote:
> This patch fixes relayd not adding a host on an ARP request for the local
> IP address.
> When relayd is launched using the -L option, it was not adding the
> necessary host routes when it receives an ARP request for the local
> IP address.
> 
> This issue makes a host not able to connect to the device running
> relayd until there is ARP traffic involving a third host.
> 
> Signed-off-by: Alejandro Enrique <alejandro.enrique@fon.com>
Applied all three and committed the update to OpenWrt.

Thanks,

- Felix
Alejandro Enrique Feb. 11, 2015, 10:19 a.m. UTC | #2
Great.

Thank you

 [image: Fon] <http://www.fon.com/>  Alejandro Enrique  Router Development
   All information in this email is confidential
<http://corp.fon.com/legal/email-disclaimer>

On 11 February 2015 at 11:12, Felix Fietkau <nbd@openwrt.org> wrote:

> On 2015-02-11 21:02, Alejandro Enrique wrote:
> > This patch fixes relayd not adding a host on an ARP request for the local
> > IP address.
> > When relayd is launched using the -L option, it was not adding the
> > necessary host routes when it receives an ARP request for the local
> > IP address.
> >
> > This issue makes a host not able to connect to the device running
> > relayd until there is ARP traffic involving a third host.
> >
> > Signed-off-by: Alejandro Enrique <alejandro.enrique@fon.com>
> Applied all three and committed the update to OpenWrt.
>
> Thanks,
>
> - Felix
>

Patch
diff mbox

diff --git a/main.c b/main.c
index 801d2f2..2e34954 100644
--- a/main.c
+++ b/main.c
@@ -386,15 +386,15 @@  static void recv_arp_request(struct relayd_interface *rif, struct arp_packet *pk
 	if (!memcmp(pkt->arp.arp_spa, "\x00\x00\x00\x00", 4))
 		return;
 
+	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);
+
 	if (local_route_table && !memcmp(pkt->arp.arp_tpa, local_addr, sizeof(local_addr))) {
 		send_arp_reply(rif, local_addr, pkt->arp.arp_sha, pkt->arp.arp_spa);
 		return;
 	}
 
-	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);
 
 	/*