modernize backfire 10.03 so it can be operational again
[openwrt-10.03/.git] / package / dnsmasq / patches / 100-fix-dhcp-no-address-warning.patch
1 --- a/src/dhcp.c
2 +++ b/src/dhcp.c
3 @@ -147,7 +147,7 @@ void dhcp_packet(time_t now, int pxe_fd)
4    ssize_t sz; 
5    int iface_index = 0, unicast_dest = 0, is_inform = 0;
6    int rcvd_iface_index;
7 -  struct in_addr iface_addr;
8 +  struct in_addr iface_addr, *addrp = NULL;
9    struct iface_param parm;
10  #ifdef HAVE_LINUX_NETWORK
11    struct arpreq arp_req;
12 @@ -277,11 +277,9 @@ void dhcp_packet(time_t now, int pxe_fd)
13      {
14        ifr.ifr_addr.sa_family = AF_INET;
15        if (ioctl(daemon->dhcpfd, SIOCGIFADDR, &ifr) != -1 )
16 -       iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
17 -      else
18         {
19 -         my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name);
20 -         return;
21 +         addrp = &iface_addr;
22 +         iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
23         }
24        
25        for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
26 @@ -300,7 +298,7 @@ void dhcp_packet(time_t now, int pxe_fd)
27        parm.relay_local.s_addr = 0;
28        parm.ind = iface_index;
29        
30 -      if (!iface_check(AF_INET, (struct all_addr *)&iface_addr, ifr.ifr_name, NULL))
31 +      if (!iface_check(AF_INET, (struct all_addr *)addrp, ifr.ifr_name, NULL))
32         {
33           /* If we failed to match the primary address of the interface, see if we've got a --listen-address
34              for a secondary */
35 @@ -320,6 +318,12 @@ void dhcp_packet(time_t now, int pxe_fd)
36           complete_context(match.addr, iface_index, NULL, match.netmask, match.broadcast, &parm);
37         }    
38        
39 +      if (!addrp)
40 +        {
41 +          my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name);
42 +          return;
43 +        }
44 +
45        if (!iface_enumerate(AF_INET, &parm, complete_context))
46         return;
47