diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2016-02-18 12:27:07 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-03-03 02:05:53 +0100 |
commit | abe8f7515aded80889d78c2c1c8947997918cf90 (patch) | |
tree | c3d52bc87c0cae0725796e73bee0d83038d6a0c0 | |
parent | ea2b71be66b7500cc3ddaa0f617491610ff07dc4 (diff) | |
download | busybox-abe8f7515aded80889d78c2c1c8947997918cf90.tar.gz |
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.c | 12 |
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) * client reverts to using the IP broadcast address. */ -static int raw_bcast_from_client_config_ifindex(struct dhcp_packet *packet) +static int raw_bcast_from_client_config_ifindex(struct dhcp_packet *packet, uint32_t src_nip) { return udhcp_send_raw_packet(packet, - /*src*/ INADDR_ANY, CLIENT_PORT, + /*src*/ src_nip, CLIENT_PORT, /*dst*/ INADDR_BROADCAST, SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex); } @@ -689,7 +689,7 @@ static int bcast_or_ucast(struct dhcp_packet *packet, uint32_t ciaddr, uint32_t return udhcp_send_kernel_packet(packet, ciaddr, CLIENT_PORT, server, SERVER_PORT); - return raw_bcast_from_client_config_ifindex(packet); + return raw_bcast_from_client_config_ifindex(packet, ciaddr); } /* 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) add_client_options(&packet); bb_info_msg("Sending discover..."); - return raw_bcast_from_client_config_ifindex(&packet); + return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY); } /* Broadcast a DHCP request message */ @@ -759,7 +759,7 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste addr.s_addr = requested; bb_info_msg("Sending select for %s...", inet_ntoa(addr)); - return raw_bcast_from_client_config_ifindex(&packet); + return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY); } /* 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 udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server); bb_info_msg("Sending decline..."); - return raw_bcast_from_client_config_ifindex(&packet); + return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY); } #endif |