]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: make link_request_set_nexthop() called from link_request_set_routes() or...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 12 Jul 2020 18:12:11 +0000 (03:12 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 15 Jul 2020 08:15:25 +0000 (17:15 +0900)
Then we can drop static_routes_ready() flag.

src/network/networkd-dhcp4.c
src/network/networkd-dhcp6.c
src/network/networkd-link.c
src/network/networkd-link.h
src/network/networkd-ndisc.c

index 37b16315e52931bd4ced1b0eda91a9506dae1010..38cf3f287b4f2a1e3ae0113c81c56f0102d4907b 100644 (file)
@@ -842,6 +842,12 @@ static int dhcp4_update_address(Link *link,
         assert(netmask);
         assert(lifetime);
 
         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);
         prefixlen = in4_addr_netmask_to_prefixlen(netmask);
 
         r = address_new(&addr);
index 70be2d6da758e9a52ee1a19f3d8e23d4fbb02e27..f21dd29ec112a297e74e6fceed1c3c467feae443 100644 (file)
@@ -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;
 
         struct in6_addr ip6_addr;
         uint32_t lifetime_preferred, lifetime_valid;
 
-
         link->dhcp6_address_configured = false;
 
         r = sd_dhcp6_client_get_lease(client, &lease);
         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");
                 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);
         }
 
                 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->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);
 
         link->dhcp6_pd_address_configured = false;
         link_set_state(link, LINK_STATE_CONFIGURING);
 
index 4c16255a7547b84987629cca54b3a7377102e1a8..3949f88a227e9f2228eb217be11ed8a46d0f7cfb 100644 (file)
@@ -976,6 +976,8 @@ static int link_request_set_nexthop(Link *link) {
         NextHop *nh;
         int r;
 
         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)
         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;
         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;
         }
 
         return 1;
@@ -1040,7 +1042,6 @@ int link_request_set_routes(Link *link) {
         assert(link->state != _LINK_STATE_INVALID);
 
         link->static_routes_configured = false;
         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
 
         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;
 
         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);
         } 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;
         }
 
                 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;
         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->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;
 
         link->static_nexthops_configured = false;
         link->routing_policy_rules_configured = false;
 
index d0340b9719320c8edc4256ab67a4375ecf4b6f69..5e5e1c833552007198ed52d4d9c43b131a2d0206 100644 (file)
@@ -124,7 +124,6 @@ typedef struct Link {
         bool addresses_ready:1;
         bool neighbors_configured:1;
         bool static_routes_configured:1;
         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;
         bool static_nexthops_configured:1;
         bool routing_policy_rules_configured:1;
         bool tc_configured:1;
index ac5b242fc1535c6c7ddf52553df256f8e0ccd9ae..62392d37b6811f6d2ecd18b75058a19cbb5bfd77 100644 (file)
@@ -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;
 
                 if (link->ndisc_addresses_messages == 0)
                         link->ndisc_addresses_configured = true;
-                else
+                else {
                         log_link_debug(link, "Setting SLAAC addresses.");
 
                         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
                 if (link->ndisc_routes_messages == 0)
                         link->ndisc_routes_configured = true;
                 else