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