From bbe3f62a163795153b085850023d60601199b74a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Feb 2022 21:44:28 +0900 Subject: [PATCH] sd-dhcp6-client: append extra options before elapsed time option 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 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index bc76e026bd..45994c93ce 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -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)