summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-ipv6-proxy-ndp.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-02-28 01:20:42 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-03-11 06:20:31 +0100
commit80d62d4f1aa62c03828e4cbe2c2dfb2a19765af8 (patch)
tree33e0ee22b8f8e36836a585cf09e89523a4d01266 /src/network/networkd-ipv6-proxy-ndp.c
parentnetwork: make Request object take Manager* (diff)
downloadsystemd-80d62d4f1aa62c03828e4cbe2c2dfb2a19765af8.tar.xz
systemd-80d62d4f1aa62c03828e4cbe2c2dfb2a19765af8.zip
network: introduce request_call_netlink_async()
In most netlink handlers, we do the following, 1. decrease the message counter, 2. check the link state, 3. error handling, 4. update link state via e.g. link_check_ready(). The first two steps are mostly common, hence let's extract it. Moreover, this is not only extracting the common logic, but provide a strong advantage; `request_call_netlink_async()` assigns the relevant Request object to the userdata of the netlink slot, and the request object has full information about the message we sent. Hence, in the future, netlink handler can print more detailed error message. E.g. when an address is failed to configure, then currently we only show an address is failed to configure, but with this commit, potentially we can show which address is failed explicitly. This does not change such error handling yet. But let's do that later.
Diffstat (limited to 'src/network/networkd-ipv6-proxy-ndp.c')
-rw-r--r--src/network/networkd-ipv6-proxy-ndp.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/network/networkd-ipv6-proxy-ndp.c b/src/network/networkd-ipv6-proxy-ndp.c
index def456c9aa..b245a9eba2 100644
--- a/src/network/networkd-ipv6-proxy-ndp.c
+++ b/src/network/networkd-ipv6-proxy-ndp.c
@@ -26,13 +26,17 @@ void network_adjust_ipv6_proxy_ndp(Network *network) {
}
}
-static int ipv6_proxy_ndp_address_configure_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
+static int ipv6_proxy_ndp_address_configure_handler(
+ sd_netlink *rtnl,
+ sd_netlink_message *m,
+ Request *req,
+ Link *link,
+ struct in6_addr *address) {
+
int r;
+ assert(m);
assert(link);
- assert(link->static_ipv6_proxy_ndp_messages > 0);
-
- link->static_ipv6_proxy_ndp_messages--;
r = sd_netlink_message_get_errno(m);
if (r < 0)
@@ -71,13 +75,7 @@ static int ipv6_proxy_ndp_address_configure(const struct in6_addr *address, Link
if (r < 0)
return r;
- r = netlink_call_async(link->manager->rtnl, NULL, m, req->netlink_handler,
- link_netlink_destroy_callback, link);
- if (r < 0)
- return r;
-
- link_ref(link);
- return 0;
+ return request_call_netlink_async(link->manager->rtnl, m, req);
}
int ipv6_proxy_ndp_address_process_request(Request *req, Link *link, struct in6_addr *address) {
@@ -109,7 +107,8 @@ int link_request_static_ipv6_proxy_ndp_addresses(Link *link) {
SET_FOREACH(address, link->network->ipv6_proxy_ndp_addresses) {
r = link_queue_request(link, REQUEST_TYPE_IPV6_PROXY_NDP, address, false,
&link->static_ipv6_proxy_ndp_messages,
- ipv6_proxy_ndp_address_configure_handler, NULL);
+ (request_netlink_handler_t) ipv6_proxy_ndp_address_configure_handler,
+ NULL);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to request IPv6 proxy NDP address: %m");
}