204-udhcpc_src_ip_rebind.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --- a/networking/udhcp/dhcpc.c
  2. +++ b/networking/udhcp/dhcpc.c
  3. @@ -663,10 +663,10 @@ static void add_client_options(struct dh
  4. * client reverts to using the IP broadcast address.
  5. */
  6. -static int raw_bcast_from_client_config_ifindex(struct dhcp_packet *packet)
  7. +static int raw_bcast_from_client_config_ifindex(struct dhcp_packet *packet, uint32_t src_nip)
  8. {
  9. return udhcp_send_raw_packet(packet,
  10. - /*src*/ INADDR_ANY, CLIENT_PORT,
  11. + /*src*/ src_nip, CLIENT_PORT,
  12. /*dst*/ INADDR_BROADCAST, SERVER_PORT, MAC_BCAST_ADDR,
  13. client_config.ifindex);
  14. }
  15. @@ -677,7 +677,7 @@ static int bcast_or_ucast(struct dhcp_pa
  16. return udhcp_send_kernel_packet(packet,
  17. ciaddr, CLIENT_PORT,
  18. server, SERVER_PORT);
  19. - return raw_bcast_from_client_config_ifindex(packet);
  20. + return raw_bcast_from_client_config_ifindex(packet, ciaddr);
  21. }
  22. /* Broadcast a DHCP discover packet to the network, with an optionally requested IP */
  23. @@ -705,7 +705,7 @@ static NOINLINE int send_discover(uint32
  24. if (msgs++ < 3)
  25. bb_info_msg("Sending discover...");
  26. - return raw_bcast_from_client_config_ifindex(&packet);
  27. + return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
  28. }
  29. /* Broadcast a DHCP request message */
  30. @@ -749,7 +749,7 @@ static NOINLINE int send_select(uint32_t
  31. addr.s_addr = requested;
  32. bb_info_msg("Sending select for %s...", inet_ntoa(addr));
  33. - return raw_bcast_from_client_config_ifindex(&packet);
  34. + return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
  35. }
  36. /* Unicast or broadcast a DHCP renew message */
  37. @@ -817,7 +817,7 @@ static NOINLINE int send_decline(/*uint3
  38. udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server);
  39. bb_info_msg("Sending decline...");
  40. - return raw_bcast_from_client_config_ifindex(&packet);
  41. + return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
  42. }
  43. #endif