]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp6-client: append extra options before elapsed time option
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 10 Feb 2022 12:44:28 +0000 (21:44 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 14 Feb 2022 06:02:33 +0000 (15:02 +0900)
The value of elapsed time option is determined in runtime and not
deterministic. It is hard to test the sent packets if it is located
in the intermidiate of the packet.

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

index bc76e026bd653209077ac782d643786f8984e675..45994c93ce4f0a44c2c69f7c79f55f6062e53869 100644 (file)
@@ -726,6 +726,12 @@ static int client_send_message(sd_dhcp6_client *client) {
         if (r < 0)
                 return r;
 
+        ORDERED_HASHMAP_FOREACH(j, client->extra_options) {
+                r = dhcp6_option_append(&opt, &optlen, j->option, j->length, j->data);
+                if (r < 0)
+                        return r;
+        }
+
         /* RFC 8415 Section 21.9.
          * A client MUST include an Elapsed Time option in messages to indicate how long the client has
          * been trying to complete a DHCP message exchange. */
@@ -735,12 +741,6 @@ static int client_send_message(sd_dhcp6_client *client) {
         if (r < 0)
                 return r;
 
-        ORDERED_HASHMAP_FOREACH(j, client->extra_options) {
-                r = dhcp6_option_append(&opt, &optlen, j->option, j->length, j->data);
-                if (r < 0)
-                        return r;
-        }
-
         r = dhcp6_network_send_udp_socket(client->fd, &all_servers, message,
                                           len - optlen);
         if (r < 0)