aboutsummaryrefslogtreecommitdiffstats
path: root/package/dnsmasq/patches/100-fix-dhcp-no-address-warning.patch
blob: 474f62f13ff167ceb17683d10886aa1919f7d303 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Index: dnsmasq-2.66/src/dhcp.c
===================================================================
--- dnsmasq-2.66.orig/src/dhcp.c	2013-04-17 14:52:49.000000000 +0200
+++ dnsmasq-2.66/src/dhcp.c	2013-04-24 08:24:20.393711625 +0200
@@ -140,7 +140,7 @@
   struct iovec iov;
   ssize_t sz; 
   int iface_index = 0, unicast_dest = 0, is_inform = 0;
-  struct in_addr iface_addr;
+  struct in_addr iface_addr, *addrp = NULL;
   struct iface_param parm;
 #ifdef HAVE_LINUX_NETWORK
   struct arpreq arp_req;
@@ -252,11 +252,9 @@
   
   ifr.ifr_addr.sa_family = AF_INET;
   if (ioctl(daemon->dhcpfd, SIOCGIFADDR, &ifr) != -1 )
-    iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
-  else
     {
-      my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name);
-      return;
+      addrp = &iface_addr;
+      iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
     }
   
   for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
@@ -270,7 +268,7 @@
   parm.current = NULL;
   parm.ind = iface_index;
 
-  if (!iface_check(AF_INET, (struct all_addr *)&iface_addr, ifr.ifr_name, NULL))
+  if (!iface_check(AF_INET, (struct all_addr *)addrp, ifr.ifr_name, NULL))
     {
       /* If we failed to match the primary address of the interface, see if we've got a --listen-address
 	 for a secondary */
@@ -289,7 +287,13 @@
 	 there is more than one address on the interface in the same subnet */
       complete_context(match.addr, iface_index, match.netmask, match.broadcast, &parm);
     }    
-      
+
+  if (!addrp)
+    {
+      my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name);
+      return;
+    }
+
   if (!iface_enumerate(AF_INET, &parm, complete_context))
     return;