]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: fix possible message counter double decrement
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 17 May 2021 06:23:57 +0000 (15:23 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 18 May 2021 11:40:50 +0000 (20:40 +0900)
When after_configure() for a request fails, then the request is not
removed from the queue at that time, and the link enters to failed
state. After that, if the link is reconfigured or its carrier is lost,
then the request is dropped from the queue, and the message_counter is
decreased. However, the counter is already or will be also decreased
when the corresponding netlink reply is received.
So, the counter is decreased twice.

src/network/networkd-address.c
src/network/networkd-neighbor.c
src/network/networkd-nexthop.c
src/network/networkd-route.c
src/network/networkd-routing-policy-rule.c

index 5a3388c3c4aa85083099043523913a9f736897a2..daf959ec5f3d75dcbcb50bd93545f269dd771a6c 100644 (file)
@@ -1149,6 +1149,9 @@ int request_process_address(Request *req) {
         if (r < 0)
                 return r;
 
+        /* To prevent a double decrement on failure in after_configure(). */
+        req->message_counter = NULL;
+
         if (req->after_configure) {
                 r = req->after_configure(req, ret);
                 if (r < 0)
index 2afe71c5f8a175b553955d4be90dc6639a45e41e..88620579ac5674c1f9b96c3dcfdf0af9cf5f4136 100644 (file)
@@ -479,6 +479,9 @@ int request_process_neighbor(Request *req) {
         if (r < 0)
                 return r;
 
+        /* To prevent a double decrement on failure in after_configure(). */
+        req->message_counter = NULL;
+
         if (req->after_configure) {
                 r = req->after_configure(req, ret);
                 if (r < 0)
index 5c6c58356c68c3ea8c787f62ceaeeeda1db0015b..013bddf30c322bc713684eb42e44c1be7a6116e7 100644 (file)
@@ -751,6 +751,9 @@ int request_process_nexthop(Request *req) {
         if (r < 0)
                 return r;
 
+        /* To prevent a double decrement on failure in after_configure(). */
+        req->message_counter = NULL;
+
         if (req->after_configure) {
                 r = req->after_configure(req, ret);
                 if (r < 0)
index 8707e5c089dac7f1cb11199e941e3dfcf06985e1..e6c1d712659e5d2e7c5682f7d3cb76ca7d9d23b9 100644 (file)
@@ -1622,6 +1622,9 @@ int request_process_route(Request *req) {
         if (r < 0)
                 return r;
 
+        /* To prevent a double decrement on failure in after_configure(). */
+        req->message_counter = NULL;
+
         if (req->after_configure) {
                 assert(n_routes > 0);
 
index 9b9880d1da7b2cb871e145775e86106f299355dd..20512d247767924fefe2bf7acd9f13ed674b35ae 100644 (file)
@@ -814,6 +814,9 @@ int request_process_routing_policy_rule(Request *req) {
         if (r < 0)
                 return r;
 
+        /* To prevent a double decrement on failure in after_configure(). */
+        req->message_counter = NULL;
+
         if (req->after_configure) {
                 r = req->after_configure(req, ret);
                 if (r < 0)