From fe2bc17ca7bd42218b147a7781ecf7313090a18c Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 30 Sep 2020 01:33:25 +0900 Subject: network: introduce link_set_address_labels() --- src/network/networkd-address-label.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/network/networkd-address-label.c') diff --git a/src/network/networkd-address-label.c b/src/network/networkd-address-label.c index c25ac0ae1e..b48e997782 100644 --- a/src/network/networkd-address-label.c +++ b/src/network/networkd-address-label.c @@ -93,12 +93,7 @@ static int address_label_handler(sd_netlink *rtnl, sd_netlink_message *m, Link * return 1; } -int address_label_configure( - AddressLabel *label, - Link *link, - link_netlink_message_handler_t callback, - bool update) { - +static int address_label_configure(AddressLabel *label, Link *link) { _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL; int r; @@ -126,7 +121,7 @@ int address_label_configure( return log_link_error_errno(link, r, "Could not append IFA_ADDRESS attribute: %m"); r = netlink_call_async(link->manager->rtnl, NULL, req, - callback ?: address_label_handler, + address_label_handler, link_netlink_destroy_callback, link); if (r < 0) return log_link_error_errno(link, r, "Could not send rtnetlink message: %m"); @@ -136,6 +131,24 @@ int address_label_configure( return 0; } +int link_set_address_labels(Link *link) { + AddressLabel *label; + int r; + + assert(link); + assert(link->network); + + HASHMAP_FOREACH(label, link->network->address_labels_by_section) { + r = address_label_configure(label, link); + if (r < 0) + return log_link_warning_errno(link, r, "Could not set address label: %m"); + + link->address_label_messages++; + } + + return 0; +} + void network_verify_address_labels(Network *network) { AddressLabel *label; -- cgit v1.2.3