]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp6-client: stop client on error in client state transition
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 6 Feb 2022 13:22:38 +0000 (22:22 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 14 Feb 2022 05:43:45 +0000 (14:43 +0900)
src/libsystemd-network/sd-dhcp6-client.c

index 3cdaf4915611b92ea5152b1d4641d70c86491982..dfb0b2c65fcef143583e862cd4d870290f15f7c3 100644 (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;
 }