network: make link_request_set_nexthop() called from link_request_set_routes() or route_handler()
Then we can drop static_routes_ready() flag.
This commit is contained in:
parent
659ad3a0af
commit
0c816fcc7b
|
@ -842,6 +842,12 @@ static int dhcp4_update_address(Link *link,
|
|||
assert(netmask);
|
||||
assert(lifetime);
|
||||
|
||||
/* address_handler calls link_request_set_routes() and link_request_set_nexthop(). Before they
|
||||
* are called, the related flags must be cleared. Otherwise, the link becomes configured state
|
||||
* before routes are configured. */
|
||||
link->static_routes_configured = false;
|
||||
link->static_nexthops_configured = false;
|
||||
|
||||
prefixlen = in4_addr_netmask_to_prefixlen(netmask);
|
||||
|
||||
r = address_new(&addr);
|
||||
|
|
|
@ -596,7 +596,6 @@ static int dhcp6_lease_address_acquired(sd_dhcp6_client *client, Link *link) {
|
|||
struct in6_addr ip6_addr;
|
||||
uint32_t lifetime_preferred, lifetime_valid;
|
||||
|
||||
|
||||
link->dhcp6_address_configured = false;
|
||||
|
||||
r = sd_dhcp6_client_get_lease(client, &lease);
|
||||
|
@ -618,6 +617,11 @@ static int dhcp6_lease_address_acquired(sd_dhcp6_client *client, Link *link) {
|
|||
return link_request_set_routes(link);
|
||||
} else {
|
||||
log_link_debug(link, "Setting DHCPv6 addresses");
|
||||
/* address_handler calls link_request_set_routes() and link_request_set_nexthop().
|
||||
* Before they are called, the related flags must be cleared. Otherwise, the link
|
||||
* becomes configured state before routes are configured. */
|
||||
link->static_routes_configured = false;
|
||||
link->static_nexthops_configured = false;
|
||||
link_set_state(link, LINK_STATE_CONFIGURING);
|
||||
}
|
||||
|
||||
|
@ -1118,6 +1122,11 @@ static int dhcp6_assign_delegated_prefix(Link *link,
|
|||
address->cinfo.ifa_prefered = lifetime_preferred;
|
||||
address->cinfo.ifa_valid = lifetime_valid;
|
||||
|
||||
/* address_handler calls link_request_set_routes() and link_request_set_nexthop(). Before they
|
||||
* are called, the related flags must be cleared. Otherwise, the link becomes configured state
|
||||
* before routes are configured. */
|
||||
link->static_routes_configured = false;
|
||||
link->static_nexthops_configured = false;
|
||||
link->dhcp6_pd_address_configured = false;
|
||||
link_set_state(link, LINK_STATE_CONFIGURING);
|
||||
|
||||
|
|
|
@ -976,6 +976,8 @@ static int link_request_set_nexthop(Link *link) {
|
|||
NextHop *nh;
|
||||
int r;
|
||||
|
||||
link->static_nexthops_configured = false;
|
||||
|
||||
LIST_FOREACH(nexthops, nh, link->network->static_nexthops) {
|
||||
r = nexthop_configure(nh, link, nexthop_handler);
|
||||
if (r < 0)
|
||||
|
@ -1018,7 +1020,7 @@ static int route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
|||
if (link->route_messages == 0) {
|
||||
log_link_debug(link, "Routes set");
|
||||
link->static_routes_configured = true;
|
||||
link_check_ready(link);
|
||||
link_request_set_nexthop(link);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -1040,7 +1042,6 @@ int link_request_set_routes(Link *link) {
|
|||
assert(link->state != _LINK_STATE_INVALID);
|
||||
|
||||
link->static_routes_configured = false;
|
||||
link->static_routes_ready = false;
|
||||
|
||||
if (!link_has_carrier(link) && !link->network->configure_without_carrier)
|
||||
/* During configuring addresses, the link lost its carrier. As networkd is dropping
|
||||
|
@ -1069,7 +1070,7 @@ int link_request_set_routes(Link *link) {
|
|||
|
||||
if (link->route_messages == 0) {
|
||||
link->static_routes_configured = true;
|
||||
link_check_ready(link);
|
||||
link_request_set_nexthop(link);
|
||||
} else {
|
||||
log_link_debug(link, "Setting routes");
|
||||
link_set_state(link, LINK_STATE_CONFIGURING);
|
||||
|
@ -1126,15 +1127,6 @@ void link_check_ready(Link *link) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!link->static_routes_ready) {
|
||||
link->static_routes_ready = true;
|
||||
r = link_request_set_nexthop(link);
|
||||
if (r < 0)
|
||||
link_enter_failed(link);
|
||||
log_link_debug(link, "%s(): static routes are configured. Configuring static nexthops.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!link->static_nexthops_configured) {
|
||||
log_link_debug(link, "%s(): static nexthops are not configured.", __func__);
|
||||
return;
|
||||
|
@ -1291,7 +1283,6 @@ static int link_request_set_addresses(Link *link) {
|
|||
link->addresses_ready = false;
|
||||
link->neighbors_configured = false;
|
||||
link->static_routes_configured = false;
|
||||
link->static_routes_ready = false;
|
||||
link->static_nexthops_configured = false;
|
||||
link->routing_policy_rules_configured = false;
|
||||
|
||||
|
|
|
@ -124,7 +124,6 @@ typedef struct Link {
|
|||
bool addresses_ready:1;
|
||||
bool neighbors_configured:1;
|
||||
bool static_routes_configured:1;
|
||||
bool static_routes_ready:1;
|
||||
bool static_nexthops_configured:1;
|
||||
bool routing_policy_rules_configured:1;
|
||||
bool tc_configured:1;
|
||||
|
|
|
@ -818,9 +818,16 @@ static void ndisc_handler(sd_ndisc *nd, sd_ndisc_event event, sd_ndisc_router *r
|
|||
|
||||
if (link->ndisc_addresses_messages == 0)
|
||||
link->ndisc_addresses_configured = true;
|
||||
else
|
||||
else {
|
||||
log_link_debug(link, "Setting SLAAC addresses.");
|
||||
|
||||
/* address_handler calls link_request_set_routes() and link_request_set_nexthop().
|
||||
* Before they are called, the related flags must be cleared. Otherwise, the link
|
||||
* becomes configured state before routes are configured. */
|
||||
link->static_routes_configured = false;
|
||||
link->static_nexthops_configured = false;
|
||||
}
|
||||
|
||||
if (link->ndisc_routes_messages == 0)
|
||||
link->ndisc_routes_configured = true;
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue