network/ipv4ll: introduce ipv4ll_start() helper function
No effective functional change. Just refactoring.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
#include "networkd-dhcp-prefix-delegation.h"
|
||||
#include "networkd-dhcp4-bus.h"
|
||||
#include "networkd-dhcp4.h"
|
||||
#include "networkd-ipv4acd.h"
|
||||
#include "networkd-ipv4ll.h"
|
||||
#include "networkd-link.h"
|
||||
#include "networkd-manager.h"
|
||||
#include "networkd-network.h"
|
||||
@@ -1192,13 +1192,11 @@ static int dhcp4_handler(sd_dhcp_client *client, int event, void *userdata) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (link->ipv4ll && !sd_ipv4ll_is_running(link->ipv4ll)) {
|
||||
log_link_debug(link, "DHCP client is stopped. Acquiring IPv4 link-local address");
|
||||
|
||||
r = sd_ipv4ll_start(link->ipv4ll);
|
||||
if (r < 0 && r != -ESTALE) /* On exit, we cannot and should not start sd-ipv4ll. */
|
||||
return log_link_warning_errno(link, r, "Could not acquire IPv4 link-local address: %m");
|
||||
}
|
||||
r = ipv4ll_start(link);
|
||||
if (r < 0)
|
||||
return log_link_warning_errno(link, r, "Could not acquire IPv4 link-local address: %m");
|
||||
if (r > 0)
|
||||
log_link_debug(link, "DHCP client is stopped. Acquiring IPv4 link-local address.");
|
||||
|
||||
if (link->dhcp_lease) {
|
||||
if (link->network->dhcp_send_release) {
|
||||
@@ -1270,13 +1268,11 @@ static int dhcp4_handler(sd_dhcp_client *client, int event, void *userdata) {
|
||||
break;
|
||||
|
||||
case SD_DHCP_CLIENT_EVENT_TRANSIENT_FAILURE:
|
||||
if (link->ipv4ll && !sd_ipv4ll_is_running(link->ipv4ll)) {
|
||||
r = ipv4ll_start(link);
|
||||
if (r < 0)
|
||||
return log_link_warning_errno(link, r, "Could not acquire IPv4 link-local address: %m");
|
||||
if (r > 0)
|
||||
log_link_debug(link, "Problems acquiring DHCP lease, acquiring IPv4 link-local address");
|
||||
|
||||
r = sd_ipv4ll_start(link->ipv4ll);
|
||||
if (r < 0)
|
||||
return log_link_warning_errno(link, r, "Could not acquire IPv4 link-local address: %m");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -264,6 +264,34 @@ int ipv4ll_configure(Link *link) {
|
||||
return sd_ipv4ll_set_check_mac_callback(link->ipv4ll, ipv4ll_check_mac, link->manager);
|
||||
}
|
||||
|
||||
int ipv4ll_start(Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
||||
if (!link->ipv4ll)
|
||||
return 0;
|
||||
|
||||
if (sd_ipv4ll_is_running(link->ipv4ll))
|
||||
return 0;
|
||||
|
||||
if (!link_has_carrier(link))
|
||||
return 0;
|
||||
|
||||
/* On exit, we cannot and should not start sd-ipv4ll. */
|
||||
r = sd_event_get_state(link->manager->event);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == SD_EVENT_FINISHED)
|
||||
return 0;
|
||||
|
||||
r = sd_ipv4ll_start(link->ipv4ll);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return 1; /* started */
|
||||
}
|
||||
|
||||
int link_drop_ipv4ll_config(Link *link, Network *network) {
|
||||
int ret = 0;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ typedef struct Network Network;
|
||||
bool link_ipv4ll_enabled(Link *link);
|
||||
|
||||
int ipv4ll_configure(Link *link);
|
||||
int ipv4ll_start(Link *link);
|
||||
int link_drop_ipv4ll_config(Link *link, Network *network);
|
||||
int ipv4ll_update_mac(Link *link);
|
||||
|
||||
|
||||
@@ -728,11 +728,11 @@ static int link_acquire_dynamic_ipv4_conf(Link *link) {
|
||||
return log_link_warning_errno(link, r, "Could not set IPv4 link-local start address: %m");
|
||||
}
|
||||
|
||||
r = sd_ipv4ll_start(link->ipv4ll);
|
||||
r = ipv4ll_start(link);
|
||||
if (r < 0)
|
||||
return log_link_warning_errno(link, r, "Could not acquire IPv4 link-local address: %m");
|
||||
|
||||
log_link_debug(link, "Acquiring IPv4 link-local address.");
|
||||
if (r > 0)
|
||||
log_link_debug(link, "Acquiring IPv4 link-local address.");
|
||||
}
|
||||
|
||||
r = link_start_dhcp4_server(link);
|
||||
|
||||
Reference in New Issue
Block a user