On Mon, Jan 12, 2015 at 20:46:36, Simon Kelley wrote:
> You're well on the trail.
> 
> In src/network.c in iface_allowed() there's some code
> 
>  /* check whether the interface IP has been added already
>      we call this routine multiple times. */
>   for (iface = daemon->interfaces; iface; iface = iface->next)
>     if (sockaddr_isequal(&iface->addr, addr))
>       < return success without actually doing anything >
> 
> sockaddr_isequal DOESN'T compare the scope_ids.
> 
> It's debatable if sockaddr_isequal should be changed - I'd have to
> look where else it's called - or if there should be a scope_id check
> just in the loop; that would be a good start to see if it fixes things.

Simon,

Good spot, that's worked correctly. After applying the admittedly quite naïve 
patch at the bottom of this email, dnsmasq correctly bound on all those 
interfaces.

I haven't considered the repercussions of this patch fully yet: in particular I 
don't know how well it'll work for interfaces that only have IPv4 addresses. 
Regardless, the patch is below if you want to take it in its current form.

If you don't, I'm happy to take guidance on what you want the patch to be. For 
example, you may want to move the check into sockaddr_isequal, or gate it 
behind a check on the address (IN6_IS_ADDR_LINKLOCAL is a tempting candidate). 
Shout if you'd like that modification made to the patch and I'll make it, test 
it and resubmit it.

Cory



>From 1cfc68832bcee1e7b2eecda38d9d47c7913815c9 Mon Sep 17 00:00:00 2001
From: Cory Benfield <cory.benfi...@metaswitch.com>
Date: Tue, 13 Jan 2015 15:13:07 +0000
Subject: [PATCH] Allow different IFs with the same IP to be bound.

Signed-off-by: Cory Benfield <cory.benfi...@metaswitch.com>
---
 src/network.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/network.c b/src/network.c
index 14d2af2..f54d7aa 100644
--- a/src/network.c
+++ b/src/network.c
@@ -400,8 +400,9 @@ static int iface_allowed(struct iface_param *param, int 
if_index, char *label,
  
   /* check whether the interface IP has been added already 
      we call this routine multiple times. */
-  for (iface = daemon->interfaces; iface; iface = iface->next) 
-    if (sockaddr_isequal(&iface->addr, addr))
+  for (iface = daemon->interfaces; iface; iface = iface->next)
+    if (sockaddr_isequal(&iface->addr, addr) &&
+        (iface->addr.in6.sin6_scope_id == addr->in6.sin6_addr.sin6_scope_id))
       {
        iface->dad = !!(iface_flags & IFACE_TENTATIVE);
        iface->found = 1; /* for garbage collection */
-- 
1.9.4.msysgit.0

_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

Reply via email to