Skip to content

Commit ce9388d

Browse files
committed
network: fix possible message counter double decrement
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.
1 parent c54cfef commit ce9388d

File tree

5 files changed

+15
-0
lines changed

5 files changed

+15
-0
lines changed

src/network/networkd-address.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,9 @@ int request_process_address(Request *req) {
11491149
if (r < 0)
11501150
return r;
11511151

1152+
/* To prevent a double decrement on failure in after_configure(). */
1153+
req->message_counter = NULL;
1154+
11521155
if (req->after_configure) {
11531156
r = req->after_configure(req, ret);
11541157
if (r < 0)

src/network/networkd-neighbor.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ int request_process_neighbor(Request *req) {
479479
if (r < 0)
480480
return r;
481481

482+
/* To prevent a double decrement on failure in after_configure(). */
483+
req->message_counter = NULL;
484+
482485
if (req->after_configure) {
483486
r = req->after_configure(req, ret);
484487
if (r < 0)

src/network/networkd-nexthop.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,9 @@ int request_process_nexthop(Request *req) {
751751
if (r < 0)
752752
return r;
753753

754+
/* To prevent a double decrement on failure in after_configure(). */
755+
req->message_counter = NULL;
756+
754757
if (req->after_configure) {
755758
r = req->after_configure(req, ret);
756759
if (r < 0)

src/network/networkd-route.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,6 +1622,9 @@ int request_process_route(Request *req) {
16221622
if (r < 0)
16231623
return r;
16241624

1625+
/* To prevent a double decrement on failure in after_configure(). */
1626+
req->message_counter = NULL;
1627+
16251628
if (req->after_configure) {
16261629
assert(n_routes > 0);
16271630

src/network/networkd-routing-policy-rule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,9 @@ int request_process_routing_policy_rule(Request *req) {
814814
if (r < 0)
815815
return r;
816816

817+
/* To prevent a double decrement on failure in after_configure(). */
818+
req->message_counter = NULL;
819+
817820
if (req->after_configure) {
818821
r = req->after_configure(req, ret);
819822
if (r < 0)

0 commit comments

Comments
 (0)