mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 02:21:44 +03:00
network: introduce link_set_address_labels()
This commit is contained in:
parent
ab316813ea
commit
fe2bc17ca7
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
r = link_set_address_labels(link);
|
||||
if (r < 0)
|
||||
return log_link_warning_errno(link, r, "Could not set address label: %m");
|
||||
|
||||
link->address_label_messages++;
|
||||
}
|
||||
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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user