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:
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user