chiark / gitweb /
libsystemd-network: Don't unnecessarily send too long packets
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 19 Mar 2014 12:38:59 +0000 (14:38 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Thu, 20 Mar 2014 08:55:27 +0000 (10:55 +0200)
Since the length used by options is known, send packets with no
extra padding.

src/libsystemd-network/sd-dhcp-client.c

index 1a57939..9052b84 100644 (file)
@@ -315,7 +315,7 @@ static int client_send_discover(sd_dhcp_client *client, uint16_t secs) {
         if (err < 0)
                 return err;
 
-        err = dhcp_client_send_raw(client, discover, len);
+        err = dhcp_client_send_raw(client, discover, len - optlen);
         if (err < 0)
                 return err;
 
@@ -385,9 +385,9 @@ static int client_send_request(sd_dhcp_client *client, uint16_t secs) {
                                                    client->lease->server_address,
                                                    DHCP_PORT_SERVER,
                                                    &request->dhcp,
-                                                   len - DHCP_IP_UDP_SIZE);
+                                                   len - optlen - DHCP_IP_UDP_SIZE);
         } else {
-                err = dhcp_client_send_raw(client, request, len);
+                err = dhcp_client_send_raw(client, request, len - optlen);
         }
         if (err < 0)
                 return err;