aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2016-02-18 12:27:07 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2016-03-03 02:05:53 +0100
commitabe8f7515aded80889d78c2c1c8947997918cf90 (patch)
treec3d52bc87c0cae0725796e73bee0d83038d6a0c0
parentea2b71be66b7500cc3ddaa0f617491610ff07dc4 (diff)
downloadbusybox-w32-abe8f7515aded80889d78c2c1c8947997918cf90.tar.gz
busybox-w32-abe8f7515aded80889d78c2c1c8947997918cf90.tar.bz2
busybox-w32-abe8f7515aded80889d78c2c1c8947997918cf90.zip
dhcpc: Use client IP address as source address for DHCP renew/rebind messages
RFC2131 paragraph 4.1 states DHCP messages broadcast by a client prior to that client obtaining its IP address must have the source IP address field in the header set to 0. Request messages transmitted in renewing and rebinding state need to use the obtained IP address as source IP address in the header; this behavior lines up with other implementations like ISC dhcp client. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/udhcp/dhcpc.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 2fe84e1ca..6c2b112f0 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -675,10 +675,10 @@ static void add_client_options(struct dhcp_packet *packet)
675 * client reverts to using the IP broadcast address. 675 * client reverts to using the IP broadcast address.
676 */ 676 */
677 677
678static int raw_bcast_from_client_config_ifindex(struct dhcp_packet *packet) 678static int raw_bcast_from_client_config_ifindex(struct dhcp_packet *packet, uint32_t src_nip)
679{ 679{
680 return udhcp_send_raw_packet(packet, 680 return udhcp_send_raw_packet(packet,
681 /*src*/ INADDR_ANY, CLIENT_PORT, 681 /*src*/ src_nip, CLIENT_PORT,
682 /*dst*/ INADDR_BROADCAST, SERVER_PORT, MAC_BCAST_ADDR, 682 /*dst*/ INADDR_BROADCAST, SERVER_PORT, MAC_BCAST_ADDR,
683 client_config.ifindex); 683 client_config.ifindex);
684} 684}
@@ -689,7 +689,7 @@ static int bcast_or_ucast(struct dhcp_packet *packet, uint32_t ciaddr, uint32_t
689 return udhcp_send_kernel_packet(packet, 689 return udhcp_send_kernel_packet(packet,
690 ciaddr, CLIENT_PORT, 690 ciaddr, CLIENT_PORT,
691 server, SERVER_PORT); 691 server, SERVER_PORT);
692 return raw_bcast_from_client_config_ifindex(packet); 692 return raw_bcast_from_client_config_ifindex(packet, ciaddr);
693} 693}
694 694
695/* Broadcast a DHCP discover packet to the network, with an optionally requested IP */ 695/* Broadcast a DHCP discover packet to the network, with an optionally requested IP */
@@ -715,7 +715,7 @@ static NOINLINE int send_discover(uint32_t xid, uint32_t requested)
715 add_client_options(&packet); 715 add_client_options(&packet);
716 716
717 bb_info_msg("Sending discover..."); 717 bb_info_msg("Sending discover...");
718 return raw_bcast_from_client_config_ifindex(&packet); 718 return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
719} 719}
720 720
721/* Broadcast a DHCP request message */ 721/* Broadcast a DHCP request message */
@@ -759,7 +759,7 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste
759 759
760 addr.s_addr = requested; 760 addr.s_addr = requested;
761 bb_info_msg("Sending select for %s...", inet_ntoa(addr)); 761 bb_info_msg("Sending select for %s...", inet_ntoa(addr));
762 return raw_bcast_from_client_config_ifindex(&packet); 762 return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
763} 763}
764 764
765/* Unicast or broadcast a DHCP renew message */ 765/* Unicast or broadcast a DHCP renew message */
@@ -827,7 +827,7 @@ static NOINLINE int send_decline(/*uint32_t xid,*/ uint32_t server, uint32_t req
827 udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server); 827 udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server);
828 828
829 bb_info_msg("Sending decline..."); 829 bb_info_msg("Sending decline...");
830 return raw_bcast_from_client_config_ifindex(&packet); 830 return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
831} 831}
832#endif 832#endif
833 833