]> git.ipfire.org Git - people/ms/dnsmasq.git/commitdiff
Don't BIND DHCP socket if more interfaces may come along later.
authorSimon Kelley <simon@thekelleys.org.uk>
Fri, 31 May 2013 16:04:25 +0000 (17:04 +0100)
committerSimon Kelley <simon@thekelleys.org.uk>
Fri, 31 May 2013 16:04:25 +0000 (17:04 +0100)
CHANGELOG
src/dhcp-common.c

index 31c2ea8a98f394bc802d89472054916f8307c1c9..63941071c906db43305f4ae1441f9f3927f9c9aa 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -50,6 +50,12 @@ version 2.67
            Log when the maximum number of concurrent DNS queries is
            reached. Thanks to Marcelo Salhab Brogliato for the patch.
 
+           If wildcards are used in --interface, don't assume that 
+           there will only ever be one available interface for DHCP
+           just because there is one at start-up. More may appear, so
+           we can't use SO_BINDTODEVICE. Thanks to Natrio for the bug
+           report. 
+
                
 version 2.66
             Add the ability to act as an authoritative DNS
index 8de426854e45f2b111d3b0482eba7640cfc31905..9321e924d33e2c571c1468b56804d177e95a5ac3 100644 (file)
@@ -347,21 +347,27 @@ void bindtodevice(int fd)
      to that device. This is for the use case of  (eg) OpenStack, which runs a new
      dnsmasq instance for each VLAN interface it creates. Without the BINDTODEVICE, 
      individual processes don't always see the packets they should.
-     SO_BINDTODEVICE is only available Linux. */
+     SO_BINDTODEVICE is only available Linux. 
+
+     Note that if wildcards are used in --interface, or a configured interface doesn't
+     yet exist, then more interfaces may arrive later, so we can't safely assert there
+     is only one interface and proceed.
+*/
   
   struct irec *iface, *found;
-  
+  struct iname *if_tmp;
+
+  for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next)
+    if (if_tmp->name && (!if_tmp->used || strchr(if_tmp->name, '*')))
+      return;
+
   for (found = NULL, iface = daemon->interfaces; iface; iface = iface->next)
     if (iface->dhcp_ok)
       {
        if (!found)
          found = iface;
        else if (strcmp(found->name, iface->name) != 0) 
-         {
-           /* more than one. */
-           found = NULL;
-           break;
-         }
+         return; /* more than one. */
       }
   
   if (found)