diff options
-rw-r--r-- | src/network/networkd-address-label.c | 27 | ||||
-rw-r--r-- | src/network/networkd-address-label.h | 2 | ||||
-rw-r--r-- | src/network/networkd-link.c | 11 |
3 files changed, 24 insertions, 16 deletions
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; diff --git a/src/network/networkd-address-label.h b/src/network/networkd-address-label.h index 994a4f69bf..dde6877eef 100644 --- a/src/network/networkd-address-label.h +++ b/src/network/networkd-address-label.h @@ -33,7 +33,7 @@ DEFINE_NETWORK_SECTION_FUNCTIONS(AddressLabel, address_label_free); void network_verify_address_labels(Network *network); -int address_label_configure(AddressLabel *address, Link *link, link_netlink_message_handler_t callback, bool update); +int link_set_address_labels(Link *link); CONFIG_PARSER_PROTOTYPE(config_parse_address_label); CONFIG_PARSER_PROTOTYPE(config_parse_address_label_prefix); diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index dc12a9694c..fd339e289a 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1248,7 +1248,6 @@ static int static_address_configure(Address *address, Link *link, bool update) { } static int link_request_set_addresses(Link *link) { - AddressLabel *label; Address *ad; Prefix *p; int r; @@ -1322,13 +1321,9 @@ static int link_request_set_addresses(Link *link) { return r; } - HASHMAP_FOREACH(label, link->network->address_labels_by_section) { - r = address_label_configure(label, link, NULL, false); - if (r < 0) - return log_link_warning_errno(link, r, "Could not set address label: %m"); - - link->address_label_messages++; - } + r = link_set_address_labels(link); + if (r < 0) + return r; /* now that we can figure out a default address for the dhcp server, start it */ if (link_dhcp4_server_enabled(link) && (link->flags & IFF_UP)) { |