6da568a91449c06ef4dd20da5a6b873df3f29df4
[openwrt.git] / package / utils / busybox / patches / 204-udhcpc_src_ip_rebind.patch
1 Index: busybox-1.22.1/networking/udhcp/dhcpc.c
2 ===================================================================
3 --- busybox-1.22.1.orig/networking/udhcp/dhcpc.c
4 +++ busybox-1.22.1/networking/udhcp/dhcpc.c
5 @@ -659,10 +659,10 @@ static void add_client_options(struct dh
6   * client reverts to using the IP broadcast address.
7   */
8  
9 -static int raw_bcast_from_client_config_ifindex(struct dhcp_packet *packet)
10 +static int raw_bcast_from_client_config_ifindex(struct dhcp_packet *packet, uint32_t src_nip)
11  {
12         return udhcp_send_raw_packet(packet,
13 -               /*src*/ INADDR_ANY, CLIENT_PORT,
14 +               /*src*/ src_nip, CLIENT_PORT,
15                 /*dst*/ INADDR_BROADCAST, SERVER_PORT, MAC_BCAST_ADDR,
16                 client_config.ifindex);
17  }
18 @@ -673,7 +673,7 @@ static int bcast_or_ucast(struct dhcp_pa
19                 return udhcp_send_kernel_packet(packet,
20                         ciaddr, CLIENT_PORT,
21                         server, SERVER_PORT);
22 -       return raw_bcast_from_client_config_ifindex(packet);
23 +       return raw_bcast_from_client_config_ifindex(packet, ciaddr);
24  }
25  
26  /* Broadcast a DHCP discover packet to the network, with an optionally requested IP */
27 @@ -701,7 +701,7 @@ static NOINLINE int send_discover(uint32
28  
29         if (msgs++ < 3)
30         bb_info_msg("Sending discover...");
31 -       return raw_bcast_from_client_config_ifindex(&packet);
32 +       return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
33  }
34  
35  /* Broadcast a DHCP request message */
36 @@ -745,7 +745,7 @@ static NOINLINE int send_select(uint32_t
37  
38         addr.s_addr = requested;
39         bb_info_msg("Sending select for %s...", inet_ntoa(addr));
40 -       return raw_bcast_from_client_config_ifindex(&packet);
41 +       return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
42  }
43  
44  /* Unicast or broadcast a DHCP renew message */
45 @@ -813,7 +813,7 @@ static NOINLINE int send_decline(/*uint3
46         udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server);
47  
48         bb_info_msg("Sending decline...");
49 -       return raw_bcast_from_client_config_ifindex(&packet);
50 +       return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
51  }
52  #endif
53