Merge pull request #19315 from yuwata/network-wait-online-address-family-follow-ups

network: several follow-ups for #19069
This commit is contained in:
Luca Boccassi
2021-04-14 21:17:00 +01:00
committed by GitHub
3 changed files with 31 additions and 42 deletions

View File

@@ -182,7 +182,7 @@ void link_update_operstate(Link *link, bool also_update_master) {
LinkCarrierState carrier_state;
LinkAddressState ipv4_address_state, ipv6_address_state, address_state;
_cleanup_strv_free_ char **p = NULL;
uint8_t ipv4_scope = RT_SCOPE_NOWHERE, ipv6_scope = RT_SCOPE_NOWHERE, scope;
uint8_t ipv4_scope = RT_SCOPE_NOWHERE, ipv6_scope = RT_SCOPE_NOWHERE;
bool changed = false;
Address *address;
@@ -215,11 +215,11 @@ void link_update_operstate(Link *link, bool also_update_master) {
if (!address_is_ready(address))
continue;
if (address->family == AF_INET && address->scope < ipv4_scope)
ipv4_scope = address->scope;
if (address->family == AF_INET)
ipv4_scope = MIN(ipv4_scope, address->scope);
if (address->family == AF_INET6 && address->scope < ipv6_scope)
ipv6_scope = address->scope;
if (address->family == AF_INET6)
ipv6_scope = MIN(ipv6_scope, address->scope);
}
/* for operstate we also take foreign addresses into account */
@@ -227,18 +227,16 @@ void link_update_operstate(Link *link, bool also_update_master) {
if (!address_is_ready(address))
continue;
if (address->family == AF_INET && address->scope < ipv4_scope)
ipv4_scope = address->scope;
if (address->family == AF_INET)
ipv4_scope = MIN(ipv4_scope, address->scope);
if (address->family == AF_INET6 && address->scope < ipv6_scope)
ipv6_scope = address->scope;
if (address->family == AF_INET6)
ipv6_scope = MIN(ipv6_scope, address->scope);
}
ipv4_address_state = address_state_from_scope(ipv4_scope);
ipv6_address_state = address_state_from_scope(ipv6_scope);
scope = MIN(ipv4_scope, ipv6_scope);
address_state = address_state_from_scope(scope);
address_state = address_state_from_scope(MIN(ipv4_scope, ipv6_scope));
/* Mapping of address and carrier state vs operational state
* carrier state

View File

@@ -125,20 +125,11 @@ int manager_save(Manager *m) {
if (link->flags & IFF_LOOPBACK)
continue;
if (link->operstate > operstate)
operstate = link->operstate;
if (link->carrier_state > carrier_state)
carrier_state = link->carrier_state;
if (link->address_state > address_state)
address_state = link->address_state;
if (link->ipv4_address_state > ipv4_address_state)
ipv4_address_state = link->ipv4_address_state;
if (link->ipv6_address_state > ipv6_address_state)
ipv6_address_state = link->ipv6_address_state;
operstate = MAX(operstate, link->operstate);
carrier_state = MAX(carrier_state, link->carrier_state);
address_state = MAX(address_state, link->address_state);
ipv4_address_state = MAX(ipv4_address_state, link->ipv4_address_state);
ipv6_address_state = MAX(ipv6_address_state, link->ipv6_address_state);
if (!link->network)
continue;

View File

@@ -72,30 +72,30 @@ static int manager_link_is_online(Manager *m, Link *l, LinkOperationalStateRange
needs_ipv6 = required_family & ADDRESS_FAMILY_IPV6;
if (s.min >= LINK_OPERSTATE_DEGRADED) {
if (needs_ipv4 && l->ipv4_address_state < LINK_ADDRESS_STATE_DEGRADED)
goto ipv4_not_ready;
if (needs_ipv4 && l->ipv4_address_state < LINK_ADDRESS_STATE_DEGRADED) {
log_link_debug(l, "No routable or link-local IPv4 address is configured.");
return 0;
}
if (needs_ipv6 && l->ipv6_address_state < LINK_ADDRESS_STATE_DEGRADED)
goto ipv6_not_ready;
if (needs_ipv6 && l->ipv6_address_state < LINK_ADDRESS_STATE_DEGRADED) {
log_link_debug(l, "No routable or link-local IPv6 address is configured.");
return 0;
}
}
if (s.min >= LINK_OPERSTATE_ROUTABLE) {
if (needs_ipv4 && l->ipv4_address_state < LINK_ADDRESS_STATE_ROUTABLE)
goto ipv4_not_ready;
if (needs_ipv4 && l->ipv4_address_state < LINK_ADDRESS_STATE_ROUTABLE) {
log_link_debug(l, "No routable IPv4 address is configured.");
return 0;
}
if (needs_ipv6 && l->ipv6_address_state < LINK_ADDRESS_STATE_ROUTABLE)
goto ipv6_not_ready;
if (needs_ipv6 && l->ipv6_address_state < LINK_ADDRESS_STATE_ROUTABLE) {
log_link_debug(l, "No routable IPv6 address is configured.");
return 0;
}
}
return 1;
ipv4_not_ready:
log_link_debug(l, "No routable or link-local IPv4 address is configured.");
return 0;
ipv6_not_ready:
log_link_debug(l, "No routable or link-local IPv6 address is configured.");
return 0;
}
bool manager_configured(Manager *m) {