aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/packet.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-09-29 15:55:24 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-09-29 16:02:11 +0200
commita6a3ad327360669e0c12552f680382e3b9713489 (patch)
tree7dcfc65aa41e6f0f22e5b6631c35dbae8b99052f /networking/udhcp/packet.c
parent2b9acc60c0468379cd24d13bc9e3f3e50761c0c9 (diff)
downloadbusybox-w32-a6a3ad327360669e0c12552f680382e3b9713489.tar.gz
busybox-w32-a6a3ad327360669e0c12552f680382e3b9713489.tar.bz2
busybox-w32-a6a3ad327360669e0c12552f680382e3b9713489.zip
udhcpc: paranoia when using kernel UDP mode for sending renew: server ID may be bogus
With new code, we request that target IP (server ID) must be directly reachable. If it's not, this happens: udhcpc: waiting 2000 seconds udhcpc: entering listen mode: kernel udhcpc: opening listen socket on *:68 wlan0 udhcpc: entering renew state udhcpc: sending renew to 1.1.1.1 udhcpc: send: Network is unreachable ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1.1.1.1 needs routing, this is fishy! udhcpc: entering rebinding state udhcpc: entering listen mode: raw udhcpc: created raw socket udhcpc: sending renew to 0.0.0.0 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ going to use broadcast which is the desired behavior. Before the patch, packet to 1.1.1.1 was routed over eth0 (!) and maybe even into Internet (!!!). function old new delta udhcpc_main 2752 2763 +11 udhcp_send_kernel_packet 295 301 +6 send_renew 82 84 +2 send_packet 166 168 +2 bcast_or_ucast 23 25 +2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 5/0 up/down: 23/0) Total: 23 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp/packet.c')
-rw-r--r--networking/udhcp/packet.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c
index 44d9ceec7..ad0028bd0 100644
--- a/networking/udhcp/packet.c
+++ b/networking/udhcp/packet.c
@@ -191,7 +191,8 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
191/* Let the kernel do all the work for packet generation */ 191/* Let the kernel do all the work for packet generation */
192int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, 192int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt,
193 uint32_t source_nip, int source_port, 193 uint32_t source_nip, int source_port,
194 uint32_t dest_nip, int dest_port) 194 uint32_t dest_nip, int dest_port,
195 int send_flags)
195{ 196{
196 struct sockaddr_in sa; 197 struct sockaddr_in sa;
197 unsigned padding; 198 unsigned padding;
@@ -228,8 +229,8 @@ int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt,
228 padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(dhcp_pkt->options); 229 padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(dhcp_pkt->options);
229 if (padding > DHCP_SIZE - 300) 230 if (padding > DHCP_SIZE - 300)
230 padding = DHCP_SIZE - 300; 231 padding = DHCP_SIZE - 300;
231 result = safe_write(fd, dhcp_pkt, DHCP_SIZE - padding); 232 result = send(fd, dhcp_pkt, DHCP_SIZE - padding, send_flags);
232 msg = "write"; 233 msg = "send";
233 ret_close: 234 ret_close:
234 close(fd); 235 close(fd);
235 if (result < 0) { 236 if (result < 0) {