network: check link state with link_is_ready_to_configure() before configuring DHCP client or friends

Otherwise, DHCP client or friends may started before link-layer properties,
e.g. MAC address, being configured or the link being activated.
This commit is contained in:
Yu Watanabe
2022-08-05 21:49:27 +09:00
parent 2fd3908b5c
commit 4b482e8bf4
7 changed files with 8 additions and 14 deletions
+2 -2
View File
@@ -292,7 +292,7 @@ static int l2tp_get_local_address(NetDev *netdev, union in_addr_union *ret) {
if (r < 0)
return r;
if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
return -EBUSY;
}
@@ -346,7 +346,7 @@ static int l2tp_get_local_address(NetDev *netdev, union in_addr_union *ret) {
return link_get_l2tp_local_address(link, t, ret);
HASHMAP_FOREACH(link, netdev->manager->links_by_index) {
if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
continue;
if (link_get_l2tp_local_address(link, t, ret) >= 0)
+1 -1
View File
@@ -51,7 +51,7 @@ int link_get_local_address(
assert_not_reached();
}
if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
return -EBUSY;
SET_FOREACH(a, link->addresses) {
+1 -7
View File
@@ -539,13 +539,7 @@ static bool dhcp_server_is_ready_to_configure(Link *link) {
assert(link);
if (!link->network)
return false;
if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
return false;
if (link->set_flags_messages > 0)
if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
return false;
if (!link_has_carrier(link))
+1 -1
View File
@@ -1557,7 +1557,7 @@ static int dhcp4_process_request(Request *req, Link *link, void *userdata) {
assert(link);
if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
return 0;
r = dhcp4_configure_duid(link);
+1 -1
View File
@@ -741,7 +741,7 @@ static int dhcp6_process_request(Request *req, Link *link, void *userdata) {
assert(link);
if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
return 0;
r = dhcp_configure_duid(link, link_get_dhcp6_duid(link));
+1 -1
View File
@@ -1099,7 +1099,7 @@ static int ndisc_process_request(Request *req, Link *link, void *userdata) {
assert(link);
if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
return 0;
r = ndisc_configure(link);
+1 -1
View File
@@ -549,7 +549,7 @@ static int radv_is_ready_to_configure(Link *link) {
assert(link);
assert(link->network);
if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
return false;
if (in6_addr_is_null(&link->ipv6ll_address))