network: refuse further requests when manager is in MANAGER_STOPPED

In that case, requests will never be processed anyway. But further more,
we cannot call link_ref() at that stage. Otherwise, we trigger assertion.
This commit is contained in:
Yu Watanabe
2024-11-03 09:14:36 +09:00
parent d980aee1e8
commit ef45f5c8d0
4 changed files with 26 additions and 0 deletions
+15
View File
@@ -142,6 +142,15 @@ static int request_new(
assert(manager);
assert(process);
/* Note, requests will be processed only when the manager is in MANAGER_RUNNING. If a new operation
* is requested when the manager is in MANAGER_TERMINATING or MANAGER_RESTARTING, the request will be
* successfully queued but will never be processed. Then, here why we refuse new requests when the
* manager is in MANAGER_STOPPED? This is because we cannot call link_ref() in that case, as this may
* be called during link_free(), that means the reference counter of the link is already 0 and
* calling link_ref() below triggers assertion. */
if (manager->state == MANAGER_STOPPED)
return -EBUSY;
req = new(Request, 1);
if (!req)
return -ENOMEM;
@@ -426,6 +435,12 @@ int remove_request_add(
assert(netlink);
assert(message);
/* Unlike request_new(), remove requests will be also processed when the manager is in
* MANAGER_TERMINATING or MANAGER_RESTARTING. When the manager is in MANAGER_STOPPED, we cannot
* queue new remove requests anymore with the same reason explained in request_new(). */
if (manager->state == MANAGER_STOPPED)
return 0;
req = new(RemoveRequest, 1);
if (!req)
return -ENOMEM;