udhcpc: remove code which requires server ID to be on local network
authorDenys Vlasenko <vda.linux@googlemail.com>
Thu, 21 Jun 2018 15:36:22 +0000 (17:36 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 21 Jun 2018 15:38:14 +0000 (17:38 +0200)
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>
networking/udhcp/common.h
networking/udhcp/d6_dhcpc.c
networking/udhcp/dhcpc.c
networking/udhcp/dhcpd.c
networking/udhcp/packet.c

index 5f890459cf8448546e1ff579240a89f1ad278e94..50ea9199b2a191361a8e912563d9a235d0a88692 100644 (file)
@@ -317,9 +317,7 @@ int udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
 
 int udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt,
                uint32_t source_nip, int source_port,
-               uint32_t dest_nip, int dest_port,
-               int send_flags
-) FAST_FUNC;
+               uint32_t dest_nip, int dest_port) FAST_FUNC;
 
 void udhcp_sp_setup(void) FAST_FUNC;
 void udhcp_sp_fd_set(struct pollfd *pfds, int extra_fd) FAST_FUNC;
index 4dbc2b1bd3215c96b1c0acf287e4faf6bacbbf34..ed2255ef3fee8bec03d5f82da4b49735d7093c21 100644 (file)
@@ -803,15 +803,13 @@ static NOINLINE int send_d6_renew(uint32_t xid, struct in6_addr *server_ipv6, st
        opt_ptr = add_d6_client_options(opt_ptr);
 
        bb_error_msg("sending %s", "renew");
-       if (server_ipv6) {
+       if (server_ipv6)
                return d6_send_kernel_packet(
                        &packet, (opt_ptr - (uint8_t*) &packet),
                        our_cur_ipv6, CLIENT_PORT6,
                        server_ipv6, SERVER_PORT6,
                        client_config.ifindex
-                       /* TODO? send_flags: MSG_DONTROUTE (see IPv4 code for reason why) */
                );
-       }
        return d6_mcast_from_client_config_ifindex(&packet, opt_ptr);
 }
 
index c206a58259279f1efb97477c677323b32e4ec45a..c2805a0090cf2949e881f89b381ad69714e472a9 100644 (file)
@@ -693,16 +693,10 @@ static int raw_bcast_from_client_config_ifindex(struct dhcp_packet *packet, uint
 
 static int bcast_or_ucast(struct dhcp_packet *packet, uint32_t ciaddr, uint32_t server)
 {
-       if (server) {
-               /* Without MSG_DONTROUTE, the packet was seen routed over
-                * _other interface_ if server ID is bogus (example: 1.1.1.1).
-                */
+       if (server)
                return udhcp_send_kernel_packet(packet,
                        ciaddr, CLIENT_PORT,
-                       server, SERVER_PORT,
-                       /*send_flags: "to hosts only on directly connected networks" */ MSG_DONTROUTE
-               );
-       }
+                       server, SERVER_PORT);
        return raw_bcast_from_client_config_ifindex(packet, ciaddr);
 }
 
index ef59dca5c1a181b193a6d70d16a64ea2c643e6e1..a8cd3f03b382991c1cc49b18891bb63b021a4faf 100644 (file)
@@ -591,9 +591,7 @@ static void send_packet_to_relay(struct dhcp_packet *dhcp_pkt)
 
        udhcp_send_kernel_packet(dhcp_pkt,
                        server_config.server_nip, SERVER_PORT,
-                       dhcp_pkt->gateway_nip, SERVER_PORT,
-                       /*send_flags:*/ 0
-       );
+                       dhcp_pkt->gateway_nip, SERVER_PORT);
 }
 
 static void send_packet(struct dhcp_packet *dhcp_pkt, int force_broadcast)
index fc2bb5416da73a60a3d2e2d2b1377e490054ea5a..ff16904f75bdc247230cd03c0be0ac15f0ee33b6 100644 (file)
@@ -189,8 +189,7 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
 /* Let the kernel do all the work for packet generation */
 int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt,
                uint32_t source_nip, int source_port,
-               uint32_t dest_nip, int dest_port,
-               int send_flags)
+               uint32_t dest_nip, int dest_port)
 {
        struct sockaddr_in sa;
        unsigned padding;
@@ -227,8 +226,8 @@ int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt,
        padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(dhcp_pkt->options);
        if (padding > DHCP_SIZE - 300)
                padding = DHCP_SIZE - 300;
-       result = send(fd, dhcp_pkt, DHCP_SIZE - padding, send_flags);
-       msg = "send";
+       result = safe_write(fd, dhcp_pkt, DHCP_SIZE - padding);
+       msg = "write";
  ret_close:
        close(fd);
        if (result < 0) {