networkd: RFC7844, do not set any other option
authorjuga0 <juga@riseup.net>
Fri, 4 Aug 2017 01:08:41 +0000 (03:08 +0200)
committerjuga0 <juga@riseup.net>
Wed, 6 Sep 2017 17:25:41 +0000 (19:25 +0200)
when Anonymize is enabled.

Use the Client variable to know whether it is enabled.

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

index b5f8539..11e66fa 100644 (file)
@@ -650,12 +650,16 @@ static int client_message_init(
            Maximum DHCP Message Size option is the total maximum packet size,
            including IP and UDP headers.)
          */
-        max_size = htobe16(size);
-        r = dhcp_option_append(&packet->dhcp, client->mtu, &optoffset, 0,
-                               SD_DHCP_OPTION_MAXIMUM_MESSAGE_SIZE,
-                               2, &max_size);
-        if (r < 0)
-                return r;
+        /* RFC7844 section 3:
+           SHOULD NOT contain any other option. */
+        if (!client->anonymize) {
+                max_size = htobe16(size);
+                r = dhcp_option_append(&packet->dhcp, client->mtu, &optoffset, 0,
+                                       SD_DHCP_OPTION_MAXIMUM_MESSAGE_SIZE,
+                                       2, &max_size);
+                if (r < 0)
+                        return r;
+        }
 
         *_optlen = optlen;
         *_optoffset = optoffset;