100-fix-dhcp-no-address-warning.patch 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --- a/src/dhcp.c
  2. +++ b/src/dhcp.c
  3. @@ -134,7 +134,7 @@ void dhcp_packet(time_t now, int pxe_fd)
  4. struct iovec iov;
  5. ssize_t sz;
  6. int iface_index = 0, unicast_dest = 0, is_inform = 0;
  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. @@ -246,11 +246,9 @@ void dhcp_packet(time_t now, int pxe_fd)
  13. ifr.ifr_addr.sa_family = AF_INET;
  14. if (ioctl(daemon->dhcpfd, SIOCGIFADDR, &ifr) != -1 )
  15. - iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
  16. - else
  17. {
  18. - my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name);
  19. - return;
  20. + addrp = &iface_addr;
  21. + iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
  22. }
  23. for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
  24. @@ -272,7 +270,7 @@ void dhcp_packet(time_t now, int pxe_fd)
  25. parm.current = NULL;
  26. parm.ind = iface_index;
  27. - if (!iface_check(AF_INET, (struct all_addr *)&iface_addr, ifr.ifr_name))
  28. + if (!iface_check(AF_INET, (struct all_addr *)addrp, ifr.ifr_name))
  29. {
  30. /* If we failed to match the primary address of the interface, see if we've got a --listen-address
  31. for a secondary */
  32. @@ -291,7 +289,13 @@ void dhcp_packet(time_t now, int pxe_fd)
  33. there is more than one address on the interface in the same subnet */
  34. complete_context(match.addr, iface_index, match.netmask, match.broadcast, &parm);
  35. }
  36. -
  37. +
  38. + if (!addrp)
  39. + {
  40. + my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name);
  41. + return;
  42. + }
  43. +
  44. if (!iface_enumerate(AF_INET, &parm, complete_context))
  45. return;