[systemd-devel] [PATCH] libsystemd-network: Don't unnecessarily send too long packets

Patrik Flykt patrik.flykt at linux.intel.com
Wed Mar 19 05:38:59 PDT 2014


Since the length used by options is known, send packets with no
extra padding.
---

	Hi,

Discovered that the full buffer was sent out even though the length of
all options would indicate a shorter one. Shave off extra padding from
the packets by properly setting the buffer length.


Cheers,

	Patrik


 src/libsystemd-network/sd-dhcp-client.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index 1a57939..9052b84 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -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;
-- 
1.8.5.2



More information about the systemd-devel mailing list