summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-address-label.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-11-28 21:14:53 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-12-02 06:23:45 +0100
commitcccf9517f19cf5731c9f8e107a3715844ff9f320 (patch)
tree924877fc2814410599d4b2b5865625be2991606a /src/network/networkd-address-label.c
parentnetwork: simplify dhcp6_get_prefix_delegation() (diff)
downloadsystemd-cccf9517f19cf5731c9f8e107a3715844ff9f320.tar.xz
systemd-cccf9517f19cf5731c9f8e107a3715844ff9f320.zip
network: move address_label_handler() to networkd-address-label.c
And use it as the default callback function of address_label_configure().
Diffstat (limited to 'src/network/networkd-address-label.c')
-rw-r--r--src/network/networkd-address-label.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/network/networkd-address-label.c b/src/network/networkd-address-label.c
index 691bbf4761..d0fd2a0969 100644
--- a/src/network/networkd-address-label.c
+++ b/src/network/networkd-address-label.c
@@ -79,6 +79,33 @@ static int address_label_new_static(Network *network, const char *filename, unsi
return 0;
}
+static int address_label_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
+ Link *link = userdata;
+ int r;
+
+ assert(rtnl);
+ assert(m);
+ assert(link);
+ assert(link->ifname);
+ assert(link->address_label_messages > 0);
+
+ link->address_label_messages--;
+
+ if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER))
+ return 1;
+
+ r = sd_netlink_message_get_errno(m);
+ if (r < 0 && r != -EEXIST)
+ log_link_warning_errno(link, r, "could not set address label: %m");
+ else if (r >= 0)
+ manager_rtnl_process_address(rtnl, m, link->manager);
+
+ if (link->address_label_messages == 0)
+ log_link_debug(link, "Addresses label set");
+
+ return 1;
+}
+
int address_label_configure(
AddressLabel *label,
Link *link,
@@ -111,7 +138,8 @@ int address_label_configure(
if (r < 0)
return log_error_errno(r, "Could not append IFA_ADDRESS attribute: %m");
- r = sd_netlink_call_async(link->manager->rtnl, NULL, req, callback,
+ r = sd_netlink_call_async(link->manager->rtnl, NULL, req,
+ callback ?: address_label_handler,
link_netlink_destroy_callback, link, 0, __func__);
if (r < 0)
return log_error_errno(r, "Could not send rtnetlink message: %m");