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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
  25. @@ -300,7 +298,7 @@ void dhcp_packet(time_t now, int pxe_fd)
  26. parm.relay_local.s_addr = 0;
  27. parm.ind = iface_index;
  28. - if (!iface_check(AF_INET, (struct all_addr *)&iface_addr, ifr.ifr_name, NULL))
  29. + if (!iface_check(AF_INET, (struct all_addr *)addrp, ifr.ifr_name, NULL))
  30. {
  31. /* If we failed to match the primary address of the interface, see if we've got a --listen-address
  32. for a secondary */
  33. @@ -320,6 +318,12 @@ void dhcp_packet(time_t now, int pxe_fd)
  34. complete_context(match.addr, iface_index, NULL, match.netmask, match.broadcast, &parm);
  35. }
  36. + if (!addrp)
  37. + {
  38. + my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name);
  39. + return;
  40. + }
  41. +
  42. if (!iface_enumerate(AF_INET, &parm, complete_context))
  43. return;