From 0eca25ba0098803b0b14c680aafd77c42bf12b17 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 7 Feb 2022 03:23:34 +0900 Subject: [PATCH] sd-dhcp6-client: move client_ensure_iaid() No functional change. --- src/libsystemd-network/sd-dhcp6-client.c | 50 ++++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index 5a046414d7d..044cf317330 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -384,10 +384,27 @@ int sd_dhcp6_client_set_iaid(sd_dhcp6_client *client, uint32_t iaid) { return 0; } -void dhcp6_client_set_test_mode(sd_dhcp6_client *client, bool test_mode) { +static int client_ensure_iaid(sd_dhcp6_client *client) { + int r; + uint32_t iaid; + assert(client); - client->test_mode = test_mode; + if (client->iaid_set) + return 0; + + r = dhcp_identifier_set_iaid(client->ifindex, client->mac_addr, client->mac_addr_len, + /* legacy_unstable_byteorder = */ true, + /* use_mac = */ client->test_mode, + &iaid); + if (r < 0) + return r; + + client->ia_na.header.id = iaid; + client->ia_pd.header.id = iaid; + client->iaid_set = true; + + return 0; } int sd_dhcp6_client_get_iaid(sd_dhcp6_client *client, uint32_t *iaid) { @@ -402,6 +419,12 @@ int sd_dhcp6_client_get_iaid(sd_dhcp6_client *client, uint32_t *iaid) { return 0; } +void dhcp6_client_set_test_mode(sd_dhcp6_client *client, bool test_mode) { + assert(client); + + client->test_mode = test_mode; +} + int sd_dhcp6_client_set_fqdn( sd_dhcp6_client *client, const char *fqdn) { @@ -1022,29 +1045,6 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, void *userda return 0; } -static int client_ensure_iaid(sd_dhcp6_client *client) { - int r; - uint32_t iaid; - - assert(client); - - if (client->iaid_set) - return 0; - - r = dhcp_identifier_set_iaid(client->ifindex, client->mac_addr, client->mac_addr_len, - /* legacy_unstable_byteorder = */ true, - /* use_mac = */ client->test_mode, - &iaid); - if (r < 0) - return r; - - client->ia_na.header.id = iaid; - client->ia_pd.header.id = iaid; - client->iaid_set = true; - - return 0; -} - static int log_invalid_message_type(sd_dhcp6_client *client, const DHCP6Message *message) { const char *type_str;