|
|
cab8d5 |
From e2ba0df2d4798e52e188c2f7f74613867d5aa82a Mon Sep 17 00:00:00 2001
|
|
|
cab8d5 |
From: Simon Kelley <simon@thekelleys.org.uk>
|
|
|
cab8d5 |
Date: Fri, 31 May 2013 17:04:25 +0100
|
|
|
cab8d5 |
Subject: [PATCH 1/1] Don't BIND DHCP socket if more interfaces may come along later.
|
|
|
cab8d5 |
|
|
|
cab8d5 |
---
|
|
|
cab8d5 |
src/dhcp-common.c | 20 +++++++++++++-------
|
|
|
cab8d5 |
1 file changed, 13 insertions(+), 7 deletions(-)
|
|
|
cab8d5 |
|
|
|
cab8d5 |
diff --git a/src/dhcp-common.c b/src/dhcp-common.c
|
|
|
cab8d5 |
index 8de4268..9321e92 100644
|
|
|
cab8d5 |
--- a/src/dhcp-common.c
|
|
|
cab8d5 |
+++ b/src/dhcp-common.c
|
|
|
cab8d5 |
@@ -347,21 +347,27 @@ void bindtodevice(int fd)
|
|
|
cab8d5 |
to that device. This is for the use case of (eg) OpenStack, which runs a new
|
|
|
cab8d5 |
dnsmasq instance for each VLAN interface it creates. Without the BINDTODEVICE,
|
|
|
cab8d5 |
individual processes don't always see the packets they should.
|
|
|
cab8d5 |
- SO_BINDTODEVICE is only available Linux. */
|
|
|
cab8d5 |
+ SO_BINDTODEVICE is only available Linux.
|
|
|
cab8d5 |
+
|
|
|
cab8d5 |
+ Note that if wildcards are used in --interface, or a configured interface doesn't
|
|
|
cab8d5 |
+ yet exist, then more interfaces may arrive later, so we can't safely assert there
|
|
|
cab8d5 |
+ is only one interface and proceed.
|
|
|
cab8d5 |
+*/
|
|
|
cab8d5 |
|
|
|
cab8d5 |
struct irec *iface, *found;
|
|
|
cab8d5 |
-
|
|
|
cab8d5 |
+ struct iname *if_tmp;
|
|
|
cab8d5 |
+
|
|
|
cab8d5 |
+ for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next)
|
|
|
cab8d5 |
+ if (if_tmp->name && (!if_tmp->used || strchr(if_tmp->name, '*')))
|
|
|
cab8d5 |
+ return;
|
|
|
cab8d5 |
+
|
|
|
cab8d5 |
for (found = NULL, iface = daemon->interfaces; iface; iface = iface->next)
|
|
|
cab8d5 |
if (iface->dhcp_ok)
|
|
|
cab8d5 |
{
|
|
|
cab8d5 |
if (!found)
|
|
|
cab8d5 |
found = iface;
|
|
|
cab8d5 |
else if (strcmp(found->name, iface->name) != 0)
|
|
|
cab8d5 |
- {
|
|
|
cab8d5 |
- /* more than one. */
|
|
|
cab8d5 |
- found = NULL;
|
|
|
cab8d5 |
- break;
|
|
|
cab8d5 |
- }
|
|
|
cab8d5 |
+ return; /* more than one. */
|
|
|
cab8d5 |
}
|
|
|
cab8d5 |
|
|
|
cab8d5 |
if (found)
|
|
|
cab8d5 |
--
|
|
|
cab8d5 |
1.7.2.5
|
|
|
cab8d5 |
|