summaryrefslogtreecommitdiff
path: root/src/network/networkd-nexthop.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-05-07 20:52:49 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-05-12 11:26:06 +0900
commit17060f02ccf78610e6921f58f4b354602e777df6 (patch)
treed3e1704aa54b54ace91f4417c83897d53e2c30f5 /src/network/networkd-nexthop.c
parent5a07fa9dd1f8c41f80631239ef2a4991029ca1e2 (diff)
downloadsystemd-17060f02ccf78610e6921f58f4b354602e777df6.tar.gz
network: nexthop: add NextHop object before sending netlink request
Otherwise, if nexthop_add() fails, then assertion about nexthop_messages in static_nexthop_handler() will be triggered.
Diffstat (limited to 'src/network/networkd-nexthop.c')
-rw-r--r--src/network/networkd-nexthop.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/network/networkd-nexthop.c b/src/network/networkd-nexthop.c
index b0759cac90..661310352c 100644
--- a/src/network/networkd-nexthop.c
+++ b/src/network/networkd-nexthop.c
@@ -413,7 +413,7 @@ static int nexthop_configure(
NextHop **ret) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
- int r;
+ int r, k;
assert(link);
assert(link->manager);
@@ -458,6 +458,10 @@ static int nexthop_configure(
}
}
+ k = nexthop_add(link, nexthop, ret);
+ if (k < 0)
+ return log_link_error_errno(link, k, "Could not add nexthop: %m");
+
r = netlink_call_async(link->manager->rtnl, NULL, req, callback,
link_netlink_destroy_callback, link);
if (r < 0)
@@ -465,11 +469,7 @@ static int nexthop_configure(
link_ref(link);
- r = nexthop_add(link, nexthop, ret);
- if (r < 0)
- return log_link_error_errno(link, r, "Could not add nexthop: %m");
-
- return r;
+ return k;
}
static int static_nexthop_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {