sd-dhcp6-client: stop client on error in client state transition

This commit is contained in:
Yu Watanabe
2022-02-14 14:43:45 +09:00
parent bfa1139af4
commit 4db6334c9a
+6 -18
View File
@@ -1056,13 +1056,7 @@ static int client_process_information(
client->lease = TAKE_PTR(lease);
client_notify(client, SD_DHCP6_CLIENT_EVENT_INFORMATION_REQUEST);
r = client_set_state(client, DHCP6_STATE_STOPPED);
if (r < 0) {
client_stop(client, r);
return r;
}
return 0;
return client_set_state(client, DHCP6_STATE_STOPPED);
}
static int client_process_reply(
@@ -1089,10 +1083,8 @@ static int client_process_reply(
client->lease = TAKE_PTR(lease);
r = client_set_state(client, DHCP6_STATE_BOUND);
if (r < 0) {
client_stop(client, r);
if (r < 0)
return r;
}
client_notify(client, SD_DHCP6_CLIENT_EVENT_IP_ACQUIRE);
return 0;
@@ -1135,10 +1127,8 @@ static int client_process_advertise_or_rapid_commit_reply(
client->lease = TAKE_PTR(lease);
r = client_set_state(client, DHCP6_STATE_BOUND);
if (r < 0) {
client_stop(client, r);
if (r < 0)
return r;
}
client_notify(client, SD_DHCP6_CLIENT_EVENT_IP_ACQUIRE);
return 0;
@@ -1162,10 +1152,8 @@ static int client_process_advertise_or_rapid_commit_reply(
if (pref_advertise == 255 || client->retransmit_count > 1) {
r = client_set_state(client, DHCP6_STATE_REQUEST);
if (r < 0) {
client_stop(client, r);
if (r < 0)
return r;
}
}
return 0;
@@ -1397,8 +1385,8 @@ static int client_set_state(sd_dhcp6_client *client, DHCP6State state) {
return 0;
error:
client_reset(client);
error:
client_stop(client, r);
return r;
}