aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-06-21 17:36:22 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-06-21 17:38:14 +0200
commit148788eb0ee96026105755cf3fd1ad3d94f49cd2 (patch)
treeaa300fa3e844410b823b87ca759060b668ff5b80 /networking/udhcp
parent6fb8bd795c3f40735ced3f51b8082f91956fd786 (diff)
downloadbusybox-w32-148788eb0ee96026105755cf3fd1ad3d94f49cd2.tar.gz
busybox-w32-148788eb0ee96026105755cf3fd1ad3d94f49cd2.tar.bz2
busybox-w32-148788eb0ee96026105755cf3fd1ad3d94f49cd2.zip
udhcpc: remove code which requires server ID to be on local network
This reverts "udhcpc: paranoia when using kernel UDP mode for sending renew: server ID may be bogus". Users complain that they do have servers behind routers (with DHCP relays). function old new delta send_packet 168 166 -2 bcast_or_ucast 25 23 -2 udhcp_send_kernel_packet 301 295 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-10) Total: -10 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp')
-rw-r--r--networking/udhcp/common.h4
-rw-r--r--networking/udhcp/d6_dhcpc.c4
-rw-r--r--networking/udhcp/dhcpc.c10
-rw-r--r--networking/udhcp/dhcpd.c4
-rw-r--r--networking/udhcp/packet.c7
5 files changed, 8 insertions, 21 deletions
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h
index 5f890459c..50ea9199b 100644
--- a/networking/udhcp/common.h
+++ b/networking/udhcp/common.h
@@ -317,9 +317,7 @@ int udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
317 317
318int udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, 318int udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt,
319 uint32_t source_nip, int source_port, 319 uint32_t source_nip, int source_port,
320 uint32_t dest_nip, int dest_port, 320 uint32_t dest_nip, int dest_port) FAST_FUNC;
321 int send_flags
322) FAST_FUNC;
323 321
324void udhcp_sp_setup(void) FAST_FUNC; 322void udhcp_sp_setup(void) FAST_FUNC;
325void udhcp_sp_fd_set(struct pollfd *pfds, int extra_fd) FAST_FUNC; 323void udhcp_sp_fd_set(struct pollfd *pfds, int extra_fd) FAST_FUNC;
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index 4dbc2b1bd..ed2255ef3 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -803,15 +803,13 @@ static NOINLINE int send_d6_renew(uint32_t xid, struct in6_addr *server_ipv6, st
803 opt_ptr = add_d6_client_options(opt_ptr); 803 opt_ptr = add_d6_client_options(opt_ptr);
804 804
805 bb_error_msg("sending %s", "renew"); 805 bb_error_msg("sending %s", "renew");
806 if (server_ipv6) { 806 if (server_ipv6)
807 return d6_send_kernel_packet( 807 return d6_send_kernel_packet(
808 &packet, (opt_ptr - (uint8_t*) &packet), 808 &packet, (opt_ptr - (uint8_t*) &packet),
809 our_cur_ipv6, CLIENT_PORT6, 809 our_cur_ipv6, CLIENT_PORT6,
810 server_ipv6, SERVER_PORT6, 810 server_ipv6, SERVER_PORT6,
811 client_config.ifindex 811 client_config.ifindex
812 /* TODO? send_flags: MSG_DONTROUTE (see IPv4 code for reason why) */
813 ); 812 );
814 }
815 return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); 813 return d6_mcast_from_client_config_ifindex(&packet, opt_ptr);
816} 814}
817 815
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index c206a5825..c2805a009 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -693,16 +693,10 @@ static int raw_bcast_from_client_config_ifindex(struct dhcp_packet *packet, uint
693 693
694static int bcast_or_ucast(struct dhcp_packet *packet, uint32_t ciaddr, uint32_t server) 694static int bcast_or_ucast(struct dhcp_packet *packet, uint32_t ciaddr, uint32_t server)
695{ 695{
696 if (server) { 696 if (server)
697 /* Without MSG_DONTROUTE, the packet was seen routed over
698 * _other interface_ if server ID is bogus (example: 1.1.1.1).
699 */
700 return udhcp_send_kernel_packet(packet, 697 return udhcp_send_kernel_packet(packet,
701 ciaddr, CLIENT_PORT, 698 ciaddr, CLIENT_PORT,
702 server, SERVER_PORT, 699 server, SERVER_PORT);
703 /*send_flags: "to hosts only on directly connected networks" */ MSG_DONTROUTE
704 );
705 }
706 return raw_bcast_from_client_config_ifindex(packet, ciaddr); 700 return raw_bcast_from_client_config_ifindex(packet, ciaddr);
707} 701}
708 702
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index ef59dca5c..a8cd3f03b 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -591,9 +591,7 @@ static void send_packet_to_relay(struct dhcp_packet *dhcp_pkt)
591 591
592 udhcp_send_kernel_packet(dhcp_pkt, 592 udhcp_send_kernel_packet(dhcp_pkt,
593 server_config.server_nip, SERVER_PORT, 593 server_config.server_nip, SERVER_PORT,
594 dhcp_pkt->gateway_nip, SERVER_PORT, 594 dhcp_pkt->gateway_nip, SERVER_PORT);
595 /*send_flags:*/ 0
596 );
597} 595}
598 596
599static void send_packet(struct dhcp_packet *dhcp_pkt, int force_broadcast) 597static void send_packet(struct dhcp_packet *dhcp_pkt, int force_broadcast)
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c
index fc2bb5416..ff16904f7 100644
--- a/networking/udhcp/packet.c
+++ b/networking/udhcp/packet.c
@@ -189,8 +189,7 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
189/* Let the kernel do all the work for packet generation */ 189/* Let the kernel do all the work for packet generation */
190int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, 190int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt,
191 uint32_t source_nip, int source_port, 191 uint32_t source_nip, int source_port,
192 uint32_t dest_nip, int dest_port, 192 uint32_t dest_nip, int dest_port)
193 int send_flags)
194{ 193{
195 struct sockaddr_in sa; 194 struct sockaddr_in sa;
196 unsigned padding; 195 unsigned padding;
@@ -227,8 +226,8 @@ int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt,
227 padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(dhcp_pkt->options); 226 padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(dhcp_pkt->options);
228 if (padding > DHCP_SIZE - 300) 227 if (padding > DHCP_SIZE - 300)
229 padding = DHCP_SIZE - 300; 228 padding = DHCP_SIZE - 300;
230 result = send(fd, dhcp_pkt, DHCP_SIZE - padding, send_flags); 229 result = safe_write(fd, dhcp_pkt, DHCP_SIZE - padding);
231 msg = "send"; 230 msg = "write";
232 ret_close: 231 ret_close:
233 close(fd); 232 close(fd);
234 if (result < 0) { 233 if (result < 0) {