]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: drop conditions to check existence of each engine
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 14 Oct 2020 22:38:45 +0000 (07:38 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 14 Oct 2020 22:38:45 +0000 (07:38 +0900)
src/network/networkd-address.c
src/network/networkd-dhcp4.c
src/network/networkd-link.c

index a6f8bcac145bbabe5f410e78d3cffeb2aed6ae5c..61ed4995004b0ae73dd2b542e39feb9a41612548 100644 (file)
@@ -1443,9 +1443,6 @@ int ipv4_dad_stop(Link *link) {
         assert(link);
 
         SET_FOREACH(address, link->addresses) {
-                if (!address->acd)
-                        continue;
-
                 k = sd_ipv4acd_stop(address->acd);
                 if (k < 0 && r >= 0)
                         r = k;
index 2920e615f3c4a024554c86eeac882dbfd98c179b..24501c13daadbc8cdf1fb3a856c7139ec55b0804 100644 (file)
@@ -563,8 +563,7 @@ static int dhcp_lease_lost(Link *link) {
         link->dhcp_lease = sd_dhcp_lease_unref(link->dhcp_lease);
         link_dirty(link);
 
-        if (link->dhcp_acd)
-                (void) sd_ipv4acd_stop(link->dhcp_acd);
+        (void) sd_ipv4acd_stop(link->dhcp_acd);
 
         return r;
 }
index 928e883dcc6c9cec34d3708c7517e3e20f1a3492..87ea5514b3db436b10009f8200b3532616d4e602 100644 (file)
@@ -617,49 +617,39 @@ int link_stop_clients(Link *link, bool may_keep_dhcp) {
                          (link->manager->restarting ||
                           FLAGS_SET(link->network->keep_configuration, KEEP_CONFIGURATION_DHCP_ON_STOP));
 
-        if (link->dhcp_client && !keep_dhcp) {
+        if (!keep_dhcp) {
                 k = sd_dhcp_client_stop(link->dhcp_client);
                 if (k < 0)
                         r = log_link_warning_errno(link, k, "Could not stop DHCPv4 client: %m");
         }
 
-        if (link->dhcp_acd) {
-                k = sd_ipv4acd_stop(link->dhcp_acd);
-                if (k < 0)
-                        r = log_link_warning_errno(link, k, "Could not stop IPv4 ACD client for DHCPv4: %m");
-        }
+        k = sd_ipv4acd_stop(link->dhcp_acd);
+        if (k < 0)
+                r = log_link_warning_errno(link, k, "Could not stop IPv4 ACD client for DHCPv4: %m");
 
-        if (link->ipv4ll) {
-                k = sd_ipv4ll_stop(link->ipv4ll);
-                if (k < 0)
-                        r = log_link_warning_errno(link, k, "Could not stop IPv4 link-local: %m");
-        }
+        k = sd_ipv4ll_stop(link->ipv4ll);
+        if (k < 0)
+                r = log_link_warning_errno(link, k, "Could not stop IPv4 link-local: %m");
 
         k = ipv4_dad_stop(link);
         if (k < 0)
                 r = log_link_warning_errno(link, k, "Could not stop IPv4 ACD client: %m");
 
-        if (link->dhcp6_client) {
-                k = sd_dhcp6_client_stop(link->dhcp6_client);
-                if (k < 0)
-                        r = log_link_warning_errno(link, k, "Could not stop DHCPv6 client: %m");
-        }
+        k = sd_dhcp6_client_stop(link->dhcp6_client);
+        if (k < 0)
+                r = log_link_warning_errno(link, k, "Could not stop DHCPv6 client: %m");
 
         k = dhcp6_pd_remove(link);
         if (k < 0)
                 r = log_link_warning_errno(link, k, "Could not remove DHCPv6 PD addresses and routes: %m");
 
-        if (link->ndisc) {
-                k = sd_ndisc_stop(link->ndisc);
-                if (k < 0)
-                        r = log_link_warning_errno(link, k, "Could not stop IPv6 Router Discovery: %m");
-        }
+        k = sd_ndisc_stop(link->ndisc);
+        if (k < 0)
+                r = log_link_warning_errno(link, k, "Could not stop IPv6 Router Discovery: %m");
 
-        if (link->radv) {
-                k = sd_radv_stop(link->radv);
-                if (k < 0)
-                        r = log_link_warning_errno(link, k, "Could not stop IPv6 Router Advertisement: %m");
-        }
+        k = sd_radv_stop(link->radv);
+        if (k < 0)
+                r = log_link_warning_errno(link, k, "Could not stop IPv6 Router Advertisement: %m");
 
         link_lldp_emit_stop(link);
         return r;
@@ -2094,8 +2084,7 @@ static int link_reconfigure_internal(Link *link, sd_netlink_message *m, bool for
         if (r < 0)
                 return r;
 
-        if (link->dhcp_server)
-                (void) sd_dhcp_server_stop(link->dhcp_server);
+        (void) sd_dhcp_server_stop(link->dhcp_server);
 
         r = link_drop_config(link);
         if (r < 0)
@@ -2547,8 +2536,7 @@ static int link_carrier_lost(Link *link) {
                 return r;
         }
 
-        if (link->dhcp_server)
-                (void) sd_dhcp_server_stop(link->dhcp_server);
+        (void) sd_dhcp_server_stop(link->dhcp_server);
 
         r = link_drop_config(link);
         if (r < 0)