network: use RET_GATHER() macro

This commit is contained in:
Yu Watanabe
2023-12-25 22:02:14 +08:00
committed by Mike Yuan
parent 38617c516a
commit 372acaad58
5 changed files with 56 additions and 79 deletions
+32 -32
View File
@@ -322,7 +322,7 @@ void link_set_state(Link *link, LinkState state) {
}
int link_stop_engines(Link *link, bool may_keep_dhcp) {
int r = 0, k;
int r, ret = 0;
assert(link);
assert(link->manager);
@@ -335,50 +335,50 @@ int link_stop_engines(Link *link, bool may_keep_dhcp) {
FLAGS_SET(link->network->keep_configuration, KEEP_CONFIGURATION_DHCP_ON_STOP));
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");
r = sd_dhcp_client_stop(link->dhcp_client);
if (r < 0)
RET_GATHER(ret, log_link_warning_errno(link, r, "Could not stop DHCPv4 client: %m"));
}
k = sd_dhcp_server_stop(link->dhcp_server);
if (k < 0)
r = log_link_warning_errno(link, k, "Could not stop DHCPv4 server: %m");
r = sd_dhcp_server_stop(link->dhcp_server);
if (r < 0)
RET_GATHER(ret, log_link_warning_errno(link, r, "Could not stop DHCPv4 server: %m"));
k = sd_lldp_rx_stop(link->lldp_rx);
if (k < 0)
r = log_link_warning_errno(link, k, "Could not stop LLDP Rx: %m");
r = sd_lldp_rx_stop(link->lldp_rx);
if (r < 0)
RET_GATHER(ret, log_link_warning_errno(link, r, "Could not stop LLDP Rx: %m"));
k = sd_lldp_tx_stop(link->lldp_tx);
if (k < 0)
r = log_link_warning_errno(link, k, "Could not stop LLDP Tx: %m");
r = sd_lldp_tx_stop(link->lldp_tx);
if (r < 0)
RET_GATHER(ret, log_link_warning_errno(link, r, "Could not stop LLDP Tx: %m"));
k = sd_ipv4ll_stop(link->ipv4ll);
if (k < 0)
r = log_link_warning_errno(link, k, "Could not stop IPv4 link-local: %m");
r = sd_ipv4ll_stop(link->ipv4ll);
if (r < 0)
RET_GATHER(ret, log_link_warning_errno(link, r, "Could not stop IPv4 link-local: %m"));
k = ipv4acd_stop(link);
if (k < 0)
r = log_link_warning_errno(link, k, "Could not stop IPv4 ACD client: %m");
r = ipv4acd_stop(link);
if (r < 0)
RET_GATHER(ret, log_link_warning_errno(link, r, "Could not stop IPv4 ACD 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");
r = sd_dhcp6_client_stop(link->dhcp6_client);
if (r < 0)
RET_GATHER(ret, log_link_warning_errno(link, r, "Could not stop DHCPv6 client: %m"));
k = dhcp_pd_remove(link, /* only_marked = */ false);
if (k < 0)
r = log_link_warning_errno(link, k, "Could not remove DHCPv6 PD addresses and routes: %m");
r = dhcp_pd_remove(link, /* only_marked = */ false);
if (r < 0)
RET_GATHER(ret, log_link_warning_errno(link, r, "Could not remove DHCPv6 PD addresses and routes: %m"));
k = ndisc_stop(link);
if (k < 0)
r = log_link_warning_errno(link, k, "Could not stop IPv6 Router Discovery: %m");
r = ndisc_stop(link);
if (r < 0)
RET_GATHER(ret, log_link_warning_errno(link, r, "Could not stop IPv6 Router Discovery: %m"));
ndisc_flush(link);
k = sd_radv_stop(link->radv);
if (k < 0)
r = log_link_warning_errno(link, k, "Could not stop IPv6 Router Advertisement: %m");
r = sd_radv_stop(link->radv);
if (r < 0)
RET_GATHER(ret, log_link_warning_errno(link, r, "Could not stop IPv6 Router Advertisement: %m"));
return r;
return ret;
}
void link_enter_failed(Link *link) {