]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkd: do not touch link_messages when expiring routes
authorMichael Chapman <mike@very.puzzling.org>
Thu, 18 Aug 2016 07:46:21 +0000 (17:46 +1000)
committerMichael Chapman <mike@very.puzzling.org>
Thu, 18 Aug 2016 07:53:53 +0000 (17:53 +1000)
link_messages is used during link configuration to advance the link
state machine through SETTING_ADDRESSES -> SETTING_ROUTES -> CONFIGURED.

If a route expires in the middle of this, it is possible for
link_messages to hit zero inside route_expire_callback, rather than in
route_handler or address_handler where it would trigger the next step in
configuration. Should this happen, the link will not complete
configuration, and it may not have its static routes configured.

Since route_expire_callback does not need to do anything once the
expired route has been removed from the kernel, it is safe to simply not
account for the netlink request.

src/network/networkd-route.c

index 82f9047ff610812dce8757487c14e7368ba7a192..5335df53c7e976405ca7bb3f4a57ca552c4b0343 100644 (file)
@@ -441,20 +441,14 @@ static int route_expire_callback(sd_netlink *rtnl, sd_netlink_message *m, void *
         assert(m);
         assert(link);
         assert(link->ifname);
-        assert(link->link_messages > 0);
 
         if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER))
                 return 1;
 
-        link->link_messages--;
-
         r = sd_netlink_message_get_errno(m);
         if (r < 0 && r != -EEXIST)
                 log_link_warning_errno(link, r, "could not remove route: %m");
 
-        if (link->link_messages == 0)
-                log_link_debug(link, "route removed");
-
         return 1;
 }
 
@@ -467,11 +461,8 @@ int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata) {
         r = route_remove(route, route->link, route_expire_callback);
         if (r < 0)
                 log_warning_errno(r, "Could not remove route: %m");
-        else {
-                /* route may not be exist in kernel. If we fail still remove it */
-                route->link->link_messages++;
+        else
                 route_free(route);
-        }
 
         return 1;
 }