From 8190a388a6c6755893b818b2e57289b22d3090f8 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 15 Oct 2018 17:49:53 +0900 Subject: sd-netlink: make sd_netlink_slot take its description --- src/core/loopback-setup.c | 6 ++--- src/libsystemd/sd-netlink/netlink-internal.h | 1 + src/libsystemd/sd-netlink/netlink-slot.c | 38 ++++++++++++++++++++++++---- src/libsystemd/sd-netlink/netlink-slot.h | 6 +++-- src/libsystemd/sd-netlink/sd-netlink.c | 34 +++++++++++++++++-------- src/libsystemd/sd-netlink/test-netlink.c | 20 +++++++-------- src/network/netdev/bridge.c | 2 +- src/network/netdev/geneve.c | 2 +- src/network/netdev/netdev.c | 6 ++--- src/network/networkd-address-label.c | 2 +- src/network/networkd-address.c | 4 +-- src/network/networkd-brvlan.c | 2 +- src/network/networkd-fdb.c | 2 +- src/network/networkd-ipv6-proxy-ndp.c | 2 +- src/network/networkd-link.c | 18 ++++++------- src/network/networkd-manager.c | 16 ++++++------ src/network/networkd-route.c | 4 +-- src/network/networkd-routing-policy-rule.c | 4 +-- src/network/wait-online/manager.c | 4 +-- src/nspawn/nspawn-expose-ports.c | 4 +-- src/resolve/resolved-manager.c | 8 +++--- src/systemd/sd-netlink.h | 8 ++++-- 22 files changed, 120 insertions(+), 73 deletions(-) diff --git a/src/core/loopback-setup.c b/src/core/loopback-setup.c index d0585158c5..f613db83ce 100644 --- a/src/core/loopback-setup.c +++ b/src/core/loopback-setup.c @@ -53,7 +53,7 @@ static int start_loopback(sd_netlink *rtnl, struct state *s) { if (r < 0) return r; - r = sd_netlink_call_async(rtnl, NULL, req, generic_handler, NULL, s, LOOPBACK_SETUP_TIMEOUT_USEC); + r = sd_netlink_call_async(rtnl, NULL, req, generic_handler, NULL, s, LOOPBACK_SETUP_TIMEOUT_USEC, "systemd-start-loopback"); if (r < 0) return r; @@ -88,7 +88,7 @@ static int add_ipv4_address(sd_netlink *rtnl, struct state *s) { if (r < 0) return r; - r = sd_netlink_call_async(rtnl, NULL, req, generic_handler, NULL, s, USEC_INFINITY); + r = sd_netlink_call_async(rtnl, NULL, req, generic_handler, NULL, s, USEC_INFINITY, "systemd-loopback-ipv4"); if (r < 0) return r; @@ -123,7 +123,7 @@ static int add_ipv6_address(sd_netlink *rtnl, struct state *s) { if (r < 0) return r; - r = sd_netlink_call_async(rtnl, NULL, req, generic_handler, NULL, s, USEC_INFINITY); + r = sd_netlink_call_async(rtnl, NULL, req, generic_handler, NULL, s, USEC_INFINITY, "systemd-loopback-ipv6"); if (r < 0) return r; diff --git a/src/libsystemd/sd-netlink/netlink-internal.h b/src/libsystemd/sd-netlink/netlink-internal.h index d7fccad87e..98de4f0a83 100644 --- a/src/libsystemd/sd-netlink/netlink-internal.h +++ b/src/libsystemd/sd-netlink/netlink-internal.h @@ -45,6 +45,7 @@ struct sd_netlink_slot { NetlinkSlotType type:2; bool floating:1; + char *description; LIST_FIELDS(sd_netlink_slot, slots); diff --git a/src/libsystemd/sd-netlink/netlink-slot.c b/src/libsystemd/sd-netlink/netlink-slot.c index ecd34c2bc1..ed136d03d1 100644 --- a/src/libsystemd/sd-netlink/netlink-slot.c +++ b/src/libsystemd/sd-netlink/netlink-slot.c @@ -7,22 +7,26 @@ #include "alloc-util.h" #include "netlink-internal.h" #include "netlink-slot.h" +#include "string-util.h" -sd_netlink_slot *netlink_slot_allocate( +int netlink_slot_allocate( sd_netlink *nl, bool floating, NetlinkSlotType type, size_t extra, sd_netlink_destroy_t destroy_callback, - void *userdata) { + void *userdata, + const char *description, + sd_netlink_slot **ret) { - sd_netlink_slot *slot; + _cleanup_free_ sd_netlink_slot *slot = NULL; assert(nl); + assert(ret); slot = malloc0(offsetof(sd_netlink_slot, reply_callback) + extra); if (!slot) - return NULL; + return -ENOMEM; slot->n_ref = 1; slot->netlink = nl; @@ -31,12 +35,20 @@ sd_netlink_slot *netlink_slot_allocate( slot->type = type; slot->floating = floating; + if (description) { + slot->description = strdup(description); + if (!slot->description) + return -ENOMEM; + } + if (!floating) sd_netlink_ref(nl); LIST_PREPEND(slots, nl->slots, slot); - return slot; + *ret = TAKE_PTR(slot); + + return 0; } void netlink_slot_disconnect(sd_netlink_slot *slot, bool unref) { @@ -103,6 +115,7 @@ static sd_netlink_slot* netlink_slot_free(sd_netlink_slot *slot) { if (slot->destroy_callback) slot->destroy_callback(slot->userdata); + free(slot->description); return mfree(slot); } @@ -174,3 +187,18 @@ int sd_netlink_slot_set_floating(sd_netlink_slot *slot, int b) { return 1; } + +int sd_netlink_slot_get_description(sd_netlink_slot *slot, const char **description) { + assert_return(slot, -EINVAL); + + if (description) + *description = slot->description; + + return !!slot->description; +} + +int sd_netlink_slot_set_description(sd_netlink_slot *slot, const char *description) { + assert_return(slot, -EINVAL); + + return free_and_strdup(&slot->description, description); +} diff --git a/src/libsystemd/sd-netlink/netlink-slot.h b/src/libsystemd/sd-netlink/netlink-slot.h index d7d084a205..e57d61921b 100644 --- a/src/libsystemd/sd-netlink/netlink-slot.h +++ b/src/libsystemd/sd-netlink/netlink-slot.h @@ -3,11 +3,13 @@ #include "sd-netlink.h" -sd_netlink_slot *netlink_slot_allocate( +int netlink_slot_allocate( sd_netlink *nl, bool floating, NetlinkSlotType type, size_t extra, sd_netlink_destroy_t destroy_callback, - void *userdata); + void *userdata, + const char *description, + sd_netlink_slot **ret); void netlink_slot_disconnect(sd_netlink_slot *slot, bool unref); diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c index 9484446ca1..7b497d1ccb 100644 --- a/src/libsystemd/sd-netlink/sd-netlink.c +++ b/src/libsystemd/sd-netlink/sd-netlink.c @@ -15,6 +15,7 @@ #include "netlink-util.h" #include "process-util.h" #include "socket-util.h" +#include "string-util.h" #include "util.h" static int sd_netlink_new(sd_netlink **ret) { @@ -303,7 +304,10 @@ static int process_timeout(sd_netlink *rtnl) { r = c->callback(rtnl, m, slot->userdata); if (r < 0) - log_debug_errno(r, "sd-netlink: timedout callback failed: %m"); + log_debug_errno(r, "sd-netlink: timedout callback %s%s%sfailed: %m", + slot->description ? "'" : "", + strempty(slot->description), + slot->description ? "' " : ""); if (slot->floating) netlink_slot_disconnect(slot, true); @@ -342,7 +346,10 @@ static int process_reply(sd_netlink *rtnl, sd_netlink_message *m) { r = c->callback(rtnl, m, slot->userdata); if (r < 0) - log_debug_errno(r, "sd-netlink: callback failed: %m"); + log_debug_errno(r, "sd-netlink: reply callback %s%s%sfailed: %m", + slot->description ? "'" : "", + strempty(slot->description), + slot->description ? "' " : ""); if (slot->floating) netlink_slot_disconnect(slot, true); @@ -370,7 +377,10 @@ static int process_match(sd_netlink *rtnl, sd_netlink_message *m) { r = c->callback(rtnl, m, slot->userdata); if (r != 0) { if (r < 0) - log_debug_errno(r, "sd-netlink: match callback failed: %m"); + log_debug_errno(r, "sd-netlink: match callback %s%s%sfailed: %m", + slot->description ? "'" : "", + strempty(slot->description), + slot->description ? "' " : ""); break; } @@ -519,7 +529,8 @@ int sd_netlink_call_async( sd_netlink_message_handler_t callback, sd_netlink_destroy_t destroy_callback, void *userdata, - uint64_t usec) { + uint64_t usec, + const char *description) { _cleanup_free_ sd_netlink_slot *slot = NULL; uint32_t s; int r, k; @@ -539,9 +550,9 @@ int sd_netlink_call_async( return r; } - slot = netlink_slot_allocate(nl, !ret_slot, NETLINK_REPLY_CALLBACK, sizeof(struct reply_callback), destroy_callback, userdata); - if (!slot) - return -ENOMEM; + r = netlink_slot_allocate(nl, !ret_slot, NETLINK_REPLY_CALLBACK, sizeof(struct reply_callback), destroy_callback, userdata, description, &slot); + if (r < 0) + return r; slot->reply_callback.callback = callback; slot->reply_callback.timeout = calc_elapse(usec); @@ -820,7 +831,8 @@ int sd_netlink_add_match( uint16_t type, sd_netlink_message_handler_t callback, sd_netlink_destroy_t destroy_callback, - void *userdata) { + void *userdata, + const char *description) { _cleanup_free_ sd_netlink_slot *slot = NULL; int r; @@ -828,9 +840,9 @@ int sd_netlink_add_match( assert_return(callback, -EINVAL); assert_return(!rtnl_pid_changed(rtnl), -ECHILD); - slot = netlink_slot_allocate(rtnl, !ret_slot, NETLINK_MATCH_CALLBACK, sizeof(struct match_callback), destroy_callback, userdata); - if (!slot) - return -ENOMEM; + r = netlink_slot_allocate(rtnl, !ret_slot, NETLINK_MATCH_CALLBACK, sizeof(struct match_callback), destroy_callback, userdata, description, &slot); + if (r < 0) + return r; slot->match_callback.callback = callback; slot->match_callback.type = type; diff --git a/src/libsystemd/sd-netlink/test-netlink.c b/src/libsystemd/sd-netlink/test-netlink.c index 5fffb70119..69f5d78735 100644 --- a/src/libsystemd/sd-netlink/test-netlink.c +++ b/src/libsystemd/sd-netlink/test-netlink.c @@ -201,7 +201,7 @@ static void test_event_loop(int ifindex) { assert_se(sd_netlink_open(&rtnl) >= 0); assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0); - assert_se(sd_netlink_call_async(rtnl, NULL, m, link_handler, NULL, ifname, 0) >= 0); + assert_se(sd_netlink_call_async(rtnl, NULL, m, link_handler, NULL, ifname, 0, NULL) >= 0); assert_se(sd_event_default(&event) >= 0); @@ -227,7 +227,7 @@ static void test_async(int ifindex) { assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0); - assert_se(sd_netlink_call_async(rtnl, &slot, m, link_handler, NULL, ifname, 0) >= 0); + assert_se(sd_netlink_call_async(rtnl, &slot, m, link_handler, NULL, ifname, 0, NULL) >= 0); assert_se(sd_netlink_wait(rtnl, 0) >= 0); assert_se(sd_netlink_process(rtnl, &r) >= 0); @@ -293,7 +293,7 @@ static void test_async_destroy_callback(int ifindex) { /* destroy callback is called after processing message */ assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0); - assert_se(sd_netlink_call_async(rtnl, NULL, m, link_handler2, test_async_object_destroy, t, 0) >= 0); + assert_se(sd_netlink_call_async(rtnl, NULL, m, link_handler2, test_async_object_destroy, t, 0, NULL) >= 0); assert_se(t->n_ref == 1); assert_se(test_async_object_ref(t)); @@ -307,7 +307,7 @@ static void test_async_destroy_callback(int ifindex) { /* destroy callback is called when asynchronous call is cancelled, that is, slot is freed. */ assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0); - assert_se(sd_netlink_call_async(rtnl, &slot, m, link_handler2, test_async_object_destroy, t, 0) >= 0); + assert_se(sd_netlink_call_async(rtnl, &slot, m, link_handler2, test_async_object_destroy, t, 0, NULL) >= 0); assert_se(t->n_ref == 1); assert_se(test_async_object_ref(t)); @@ -320,7 +320,7 @@ static void test_async_destroy_callback(int ifindex) { /* destroy callback is also called by sd_netlink_unref() */ assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0); - assert_se(sd_netlink_call_async(rtnl, NULL, m, link_handler2, test_async_object_destroy, t, 0) >= 0); + assert_se(sd_netlink_call_async(rtnl, NULL, m, link_handler2, test_async_object_destroy, t, 0, NULL) >= 0); assert_se(t->n_ref == 1); assert_se(test_async_object_ref(t)); @@ -356,10 +356,10 @@ static void test_pipe(int ifindex) { assert_se(sd_rtnl_message_new_link(rtnl, &m2, RTM_GETLINK, ifindex) >= 0); counter++; - assert_se(sd_netlink_call_async(rtnl, NULL, m1, pipe_handler, NULL, &counter, 0) >= 0); + assert_se(sd_netlink_call_async(rtnl, NULL, m1, pipe_handler, NULL, &counter, 0, NULL) >= 0); counter++; - assert_se(sd_netlink_call_async(rtnl, NULL, m2, pipe_handler, NULL, &counter, 0) >= 0); + assert_se(sd_netlink_call_async(rtnl, NULL, m2, pipe_handler, NULL, &counter, 0, NULL) >= 0); while (counter > 0) { assert_se(sd_netlink_wait(rtnl, 0) >= 0); @@ -410,9 +410,9 @@ static void test_match(void) { assert_se(sd_netlink_open(&rtnl) >= 0); - assert_se(sd_netlink_add_match(rtnl, &s1, RTM_NEWLINK, link_handler, NULL, NULL) >= 0); - assert_se(sd_netlink_add_match(rtnl, &s2, RTM_NEWLINK, link_handler, NULL, NULL) >= 0); - assert_se(sd_netlink_add_match(rtnl, NULL, RTM_NEWLINK, link_handler, NULL, NULL) >= 0); + assert_se(sd_netlink_add_match(rtnl, &s1, RTM_NEWLINK, link_handler, NULL, NULL, NULL) >= 0); + assert_se(sd_netlink_add_match(rtnl, &s2, RTM_NEWLINK, link_handler, NULL, NULL, NULL) >= 0); + assert_se(sd_netlink_add_match(rtnl, NULL, RTM_NEWLINK, link_handler, NULL, NULL, NULL) >= 0); assert_se(!(s1 = sd_netlink_slot_unref(s1))); assert_se(!(s2 = sd_netlink_slot_unref(s2))); diff --git a/src/network/netdev/bridge.c b/src/network/netdev/bridge.c index 604a5e3f55..5a462f8376 100644 --- a/src/network/netdev/bridge.c +++ b/src/network/netdev/bridge.c @@ -130,7 +130,7 @@ static int netdev_bridge_post_create(NetDev *netdev, Link *link, sd_netlink_mess return log_netdev_error_errno(netdev, r, "Could not append IFLA_INFO_DATA attribute: %m"); r = sd_netlink_call_async(netdev->manager->rtnl, NULL, req, netdev_bridge_set_handler, - netdev_netlink_destroy_callback, netdev, 0); + netdev_netlink_destroy_callback, netdev, 0, __func__); if (r < 0) return log_netdev_error_errno(netdev, r, "Could not send rtnetlink message: %m"); diff --git a/src/network/netdev/geneve.c b/src/network/netdev/geneve.c index e7c8afd936..e407a8fc5c 100644 --- a/src/network/netdev/geneve.c +++ b/src/network/netdev/geneve.c @@ -137,7 +137,7 @@ static int netdev_geneve_create(NetDev *netdev) { return log_netdev_error_errno(netdev, r, "Could not append IFLA_LINKINFO attribute: %m"); r = sd_netlink_call_async(netdev->manager->rtnl, NULL, m, geneve_netdev_create_handler, - netdev_netlink_destroy_callback, netdev, 0); + netdev_netlink_destroy_callback, netdev, 0, __func__); if (r < 0) return log_netdev_error_errno(netdev, r, "Could not send rtnetlink message: %m"); diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c index 023cc922d5..6eb63355a4 100644 --- a/src/network/netdev/netdev.c +++ b/src/network/netdev/netdev.c @@ -226,7 +226,7 @@ static int netdev_enslave_ready(NetDev *netdev, Link* link, sd_netlink_message_h return log_netdev_error_errno(netdev, r, "Could not append IFLA_MASTER attribute: %m"); r = sd_netlink_call_async(netdev->manager->rtnl, NULL, req, callback, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_netdev_error_errno(netdev, r, "Could not send rtnetlink message: %m"); @@ -535,14 +535,14 @@ static int netdev_create(NetDev *netdev, Link *link, if (link) { r = sd_netlink_call_async(netdev->manager->rtnl, NULL, m, callback, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_netdev_error_errno(netdev, r, "Could not send rtnetlink message: %m"); link_ref(link); } else { r = sd_netlink_call_async(netdev->manager->rtnl, NULL, m, netdev_create_handler, - netdev_netlink_destroy_callback, netdev, 0); + netdev_netlink_destroy_callback, netdev, 0, __func__); if (r < 0) return log_netdev_error_errno(netdev, r, "Could not send rtnetlink message: %m"); diff --git a/src/network/networkd-address-label.c b/src/network/networkd-address-label.c index 6265701e3f..98e40d3f6a 100644 --- a/src/network/networkd-address-label.c +++ b/src/network/networkd-address-label.c @@ -113,7 +113,7 @@ int address_label_configure( return log_error_errno(r, "Could not append IFA_ADDRESS attribute: %m"); r = sd_netlink_call_async(link->manager->rtnl, NULL, req, callback, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_error_errno(r, "Could not send rtnetlink message: %m"); diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index f2fae866e2..cf33563bdd 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -454,7 +454,7 @@ int address_remove( return log_error_errno(r, "Could not append IFA_LOCAL attribute: %m"); r = sd_netlink_call_async(link->manager->rtnl, NULL, req, callback, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_error_errno(r, "Could not send rtnetlink message: %m"); @@ -633,7 +633,7 @@ int address_configure( return r; r = sd_netlink_call_async(link->manager->rtnl, NULL, req, callback, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) { address_release(address); return log_error_errno(r, "Could not send rtnetlink message: %m"); diff --git a/src/network/networkd-brvlan.c b/src/network/networkd-brvlan.c index 32e8547037..c7ca57d5e0 100644 --- a/src/network/networkd-brvlan.c +++ b/src/network/networkd-brvlan.c @@ -196,7 +196,7 @@ int br_vlan_configure(Link *link, uint16_t pvid, uint32_t *br_vid_bitmap, uint32 /* send message to the kernel */ r = sd_netlink_call_async(rtnl, NULL, req, set_brvlan_handler, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_link_error_errno(link, r, "Could not send rtnetlink message: %m"); diff --git a/src/network/networkd-fdb.c b/src/network/networkd-fdb.c index 337ff2e6ac..694065e3d9 100644 --- a/src/network/networkd-fdb.c +++ b/src/network/networkd-fdb.c @@ -135,7 +135,7 @@ int fdb_entry_configure(Link *link, FdbEntry *fdb_entry) { /* send message to the kernel to update its internal static MAC table. */ r = sd_netlink_call_async(rtnl, NULL, req, set_fdb_handler, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_link_error_errno(link, r, "Could not send rtnetlink message: %m"); diff --git a/src/network/networkd-ipv6-proxy-ndp.c b/src/network/networkd-ipv6-proxy-ndp.c index 11e1b8421f..c4e2091142 100644 --- a/src/network/networkd-ipv6-proxy-ndp.c +++ b/src/network/networkd-ipv6-proxy-ndp.c @@ -174,7 +174,7 @@ int ipv6_proxy_ndp_address_configure(Link *link, IPv6ProxyNDPAddress *ipv6_proxy return rtnl_log_create_error(r); r = sd_netlink_call_async(rtnl, NULL, req, set_ipv6_proxy_ndp_address_handler, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_link_error_errno(link, r, "Could not send rtnetlink message: %m"); diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index e160d75a65..f4ab8aadb8 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1341,7 +1341,7 @@ int link_set_mtu(Link *link, uint32_t mtu) { return log_link_error_errno(link, r, "Could not append MTU: %m"); r = sd_netlink_call_async(link->manager->rtnl, NULL, req, set_mtu_handler, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_link_error_errno(link, r, "Could not send rtnetlink message: %m"); @@ -1412,7 +1412,7 @@ static int link_set_flags(Link *link) { return log_link_error_errno(link, r, "Could not set link flags: %m"); r = sd_netlink_call_async(link->manager->rtnl, NULL, req, set_flags_handler, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_link_error_errno(link, r, "Could not send rtnetlink message: %m"); @@ -1488,7 +1488,7 @@ static int link_set_bridge(Link *link) { return log_link_error_errno(link, r, "Could not append IFLA_LINKINFO attribute: %m"); r = sd_netlink_call_async(link->manager->rtnl, NULL, req, link_set_handler, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_link_error_errno(link, r, "Could not send rtnetlink message: %m"); @@ -1541,7 +1541,7 @@ static int link_bond_set(Link *link) { return log_link_error_errno(link, r, "Could not append IFLA_INFO_DATA attribute: %m"); r = sd_netlink_call_async(link->manager->rtnl, NULL, req, set_flags_handler, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_link_error_errno(link, r, "Could not send rtnetlink message: %m"); @@ -1834,7 +1834,7 @@ int link_up(Link *link) { return log_link_error_errno(link, r, "Could not close IFLA_AF_SPEC container: %m"); r = sd_netlink_call_async(link->manager->rtnl, NULL, req, link_up_handler, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_link_error_errno(link, r, "Could not send rtnetlink message: %m"); @@ -1860,7 +1860,7 @@ static int link_up_can(Link *link) { return log_link_error_errno(link, r, "Could not set link flags: %m"); r = sd_netlink_call_async(link->manager->rtnl, NULL, req, link_up_handler, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_link_error_errno(link, r, "Could not send rtnetlink message: %m"); @@ -1950,7 +1950,7 @@ static int link_set_can(Link *link) { return log_link_error_errno(link, r, "Failed to close netlink container: %m"); r = sd_netlink_call_async(link->manager->rtnl, NULL, m, link_set_handler, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_link_error_errno(link, r, "Could not send rtnetlink message: %m"); @@ -2008,7 +2008,7 @@ int link_down(Link *link) { return log_link_error_errno(link, r, "Could not set link flags: %m"); r = sd_netlink_call_async(link->manager->rtnl, NULL, req, link_down_handler, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_link_error_errno(link, r, "Could not send rtnetlink message: %m"); @@ -3123,7 +3123,7 @@ int link_initialized(Link *link, sd_device *device) { return r; r = sd_netlink_call_async(link->manager->rtnl, NULL, req, link_initialized_handler, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return r; diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index 8c66986294..7fae143f37 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -930,35 +930,35 @@ static int manager_connect_rtnl(Manager *m) { if (r < 0) return r; - r = sd_netlink_add_match(m->rtnl, NULL, RTM_NEWLINK, &manager_rtnl_process_link, NULL, m); + r = sd_netlink_add_match(m->rtnl, NULL, RTM_NEWLINK, &manager_rtnl_process_link, NULL, m, "network-rtnl_process_link"); if (r < 0) return r; - r = sd_netlink_add_match(m->rtnl, NULL, RTM_DELLINK, &manager_rtnl_process_link, NULL, m); + r = sd_netlink_add_match(m->rtnl, NULL, RTM_DELLINK, &manager_rtnl_process_link, NULL, m, "network-rtnl_process_link"); if (r < 0) return r; - r = sd_netlink_add_match(m->rtnl, NULL, RTM_NEWADDR, &manager_rtnl_process_address, NULL, m); + r = sd_netlink_add_match(m->rtnl, NULL, RTM_NEWADDR, &manager_rtnl_process_address, NULL, m, "network-rtnl_process_address"); if (r < 0) return r; - r = sd_netlink_add_match(m->rtnl, NULL, RTM_DELADDR, &manager_rtnl_process_address, NULL, m); + r = sd_netlink_add_match(m->rtnl, NULL, RTM_DELADDR, &manager_rtnl_process_address, NULL, m, "network-rtnl_process_address"); if (r < 0) return r; - r = sd_netlink_add_match(m->rtnl, NULL, RTM_NEWROUTE, &manager_rtnl_process_route, NULL, m); + r = sd_netlink_add_match(m->rtnl, NULL, RTM_NEWROUTE, &manager_rtnl_process_route, NULL, m, "network-rtnl_process_route"); if (r < 0) return r; - r = sd_netlink_add_match(m->rtnl, NULL, RTM_DELROUTE, &manager_rtnl_process_route, NULL, m); + r = sd_netlink_add_match(m->rtnl, NULL, RTM_DELROUTE, &manager_rtnl_process_route, NULL, m, "network-rtnl_process_route"); if (r < 0) return r; - r = sd_netlink_add_match(m->rtnl, NULL, RTM_NEWRULE, &manager_rtnl_process_rule, NULL, m); + r = sd_netlink_add_match(m->rtnl, NULL, RTM_NEWRULE, &manager_rtnl_process_rule, NULL, m, "network-rtnl_process_rule"); if (r < 0) return r; - r = sd_netlink_add_match(m->rtnl, NULL, RTM_DELRULE, &manager_rtnl_process_rule, NULL, m); + r = sd_netlink_add_match(m->rtnl, NULL, RTM_DELRULE, &manager_rtnl_process_rule, NULL, m, "network-rtnl_process_rule"); if (r < 0) return r; diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 591fae6e76..33389676cf 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -440,7 +440,7 @@ int route_remove(Route *route, Link *link, } r = sd_netlink_call_async(link->manager->rtnl, NULL, req, callback, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_error_errno(r, "Could not send rtnetlink message: %m"); @@ -621,7 +621,7 @@ int route_configure( return log_error_errno(r, "Could not append RTA_METRICS attribute: %m"); r = sd_netlink_call_async(link->manager->rtnl, NULL, req, callback, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_error_errno(r, "Could not send rtnetlink message: %m"); diff --git a/src/network/networkd-routing-policy-rule.c b/src/network/networkd-routing-policy-rule.c index fe393856f8..28a2a0fcbf 100644 --- a/src/network/networkd-routing-policy-rule.c +++ b/src/network/networkd-routing-policy-rule.c @@ -371,7 +371,7 @@ int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *lin } r = sd_netlink_call_async(link->manager->rtnl, NULL, m, callback, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_error_errno(r, "Could not send rtnetlink message: %m"); @@ -540,7 +540,7 @@ int routing_policy_rule_configure(RoutingPolicyRule *rule, Link *link, sd_netlin rule->link = link; r = sd_netlink_call_async(link->manager->rtnl, NULL, m, callback, - link_netlink_destroy_callback, link, 0); + link_netlink_destroy_callback, link, 0, __func__); if (r < 0) return log_error_errno(r, "Could not send rtnetlink message: %m"); diff --git a/src/network/wait-online/manager.c b/src/network/wait-online/manager.c index 22252ef826..0dfe7482fc 100644 --- a/src/network/wait-online/manager.c +++ b/src/network/wait-online/manager.c @@ -169,11 +169,11 @@ static int manager_rtnl_listen(Manager *m) { if (r < 0) return r; - r = sd_netlink_add_match(m->rtnl, NULL, RTM_NEWLINK, on_rtnl_event, NULL, m); + r = sd_netlink_add_match(m->rtnl, NULL, RTM_NEWLINK, on_rtnl_event, NULL, m, "wait-online-on-NEWLINK"); if (r < 0) return r; - r = sd_netlink_add_match(m->rtnl, NULL, RTM_DELLINK, on_rtnl_event, NULL, m); + r = sd_netlink_add_match(m->rtnl, NULL, RTM_DELLINK, on_rtnl_event, NULL, m, "wait-online-on-DELLINK"); if (r < 0) return r; diff --git a/src/nspawn/nspawn-expose-ports.c b/src/nspawn/nspawn-expose-ports.c index 0eaf0ca5f5..13ce8490a0 100644 --- a/src/nspawn/nspawn-expose-ports.c +++ b/src/nspawn/nspawn-expose-ports.c @@ -209,11 +209,11 @@ int expose_port_watch_rtnl( return log_error_errno(r, "Failed to create rtnl object: %m"); } - r = sd_netlink_add_match(rtnl, NULL, RTM_NEWADDR, handler, NULL, exposed); + r = sd_netlink_add_match(rtnl, NULL, RTM_NEWADDR, handler, NULL, exposed, "nspawn-NEWADDR"); if (r < 0) return log_error_errno(r, "Failed to subscribe to RTM_NEWADDR messages: %m"); - r = sd_netlink_add_match(rtnl, NULL, RTM_DELADDR, handler, NULL, exposed); + r = sd_netlink_add_match(rtnl, NULL, RTM_DELADDR, handler, NULL, exposed, "nspawn-DELADDR"); if (r < 0) return log_error_errno(r, "Failed to subscribe to RTM_DELADDR messages: %m"); diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index 05244499c0..8e564216ed 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -200,19 +200,19 @@ static int manager_rtnl_listen(Manager *m) { if (r < 0) return r; - r = sd_netlink_add_match(m->rtnl, NULL, RTM_NEWLINK, manager_process_link, NULL, m); + r = sd_netlink_add_match(m->rtnl, NULL, RTM_NEWLINK, manager_process_link, NULL, m, "resolve-NEWLINK"); if (r < 0) return r; - r = sd_netlink_add_match(m->rtnl, NULL, RTM_DELLINK, manager_process_link, NULL, m); + r = sd_netlink_add_match(m->rtnl, NULL, RTM_DELLINK, manager_process_link, NULL, m, "resolve-DELLINK"); if (r < 0) return r; - r = sd_netlink_add_match(m->rtnl, NULL, RTM_NEWADDR, manager_process_address, NULL, m); + r = sd_netlink_add_match(m->rtnl, NULL, RTM_NEWADDR, manager_process_address, NULL, m, "resolve-NEWADDR"); if (r < 0) return r; - r = sd_netlink_add_match(m->rtnl, NULL, RTM_DELADDR, manager_process_address, NULL, m); + r = sd_netlink_add_match(m->rtnl, NULL, RTM_DELADDR, manager_process_address, NULL, m, "resolve-DELADDR"); if (r < 0) return r; diff --git a/src/systemd/sd-netlink.h b/src/systemd/sd-netlink.h index 90c679b84c..276953eb8e 100644 --- a/src/systemd/sd-netlink.h +++ b/src/systemd/sd-netlink.h @@ -53,7 +53,7 @@ sd_netlink *sd_netlink_unref(sd_netlink *nl); int sd_netlink_send(sd_netlink *nl, sd_netlink_message *message, uint32_t *serial); int sd_netlink_call_async(sd_netlink *nl, sd_netlink_slot **ret_slot, sd_netlink_message *message, sd_netlink_message_handler_t callback, sd_netlink_destroy_t destoy_callback, - void *userdata, uint64_t usec); + void *userdata, uint64_t usec, const char *description); int sd_netlink_call(sd_netlink *nl, sd_netlink_message *message, uint64_t timeout, sd_netlink_message **reply); @@ -64,7 +64,8 @@ int sd_netlink_wait(sd_netlink *nl, uint64_t timeout); int sd_netlink_add_match(sd_netlink *nl, sd_netlink_slot **ret_slot, uint16_t match, sd_netlink_message_handler_t callback, - sd_netlink_destroy_t destroy_callback, void *userdata); + sd_netlink_destroy_t destroy_callback, + void *userdata, const char *description); int sd_netlink_attach_event(sd_netlink *nl, sd_event *e, int64_t priority); int sd_netlink_detach_event(sd_netlink *nl); @@ -193,6 +194,9 @@ int sd_netlink_slot_get_destroy_callback(sd_netlink_slot *slot, sd_netlink_destr int sd_netlink_slot_set_destroy_callback(sd_netlink_slot *slot, sd_netlink_destroy_t callback); int sd_netlink_slot_get_floating(sd_netlink_slot *slot); int sd_netlink_slot_set_floating(sd_netlink_slot *slot, int b); +int sd_netlink_slot_get_description(sd_netlink_slot *slot, const char **description); +int sd_netlink_slot_set_description(sd_netlink_slot *slot, const char *description); + _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_netlink, sd_netlink_unref); _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_netlink_message, sd_netlink_message_unref); -- cgit v1.2.3