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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int address_label_configure(
|
static int address_label_configure(AddressLabel *label, Link *link) {
|
||||||
AddressLabel *label,
|
|
||||||
Link *link,
|
|
||||||
link_netlink_message_handler_t callback,
|
|
||||||
bool update) {
|
|
||||||
|
|
||||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
|
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -126,7 +121,7 @@ int address_label_configure(
|
||||||
return log_link_error_errno(link, r, "Could not append IFA_ADDRESS attribute: %m");
|
return log_link_error_errno(link, r, "Could not append IFA_ADDRESS attribute: %m");
|
||||||
|
|
||||||
r = netlink_call_async(link->manager->rtnl, NULL, req,
|
r = netlink_call_async(link->manager->rtnl, NULL, req,
|
||||||
callback ?: address_label_handler,
|
address_label_handler,
|
||||||
link_netlink_destroy_callback, link);
|
link_netlink_destroy_callback, link);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
|
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
|
||||||
|
@ -136,6 +131,24 @@ int address_label_configure(
|
||||||
return 0;
|
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) {
|
void network_verify_address_labels(Network *network) {
|
||||||
AddressLabel *label;
|
AddressLabel *label;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ DEFINE_NETWORK_SECTION_FUNCTIONS(AddressLabel, address_label_free);
|
||||||
|
|
||||||
void network_verify_address_labels(Network *network);
|
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);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_address_label_prefix);
|
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) {
|
static int link_request_set_addresses(Link *link) {
|
||||||
AddressLabel *label;
|
|
||||||
Address *ad;
|
Address *ad;
|
||||||
Prefix *p;
|
Prefix *p;
|
||||||
int r;
|
int r;
|
||||||
|
@ -1322,13 +1321,9 @@ static int link_request_set_addresses(Link *link) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
HASHMAP_FOREACH(label, link->network->address_labels_by_section) {
|
r = link_set_address_labels(link);
|
||||||
r = address_label_configure(label, link, NULL, false);
|
if (r < 0)
|
||||||
if (r < 0)
|
return r;
|
||||||
return log_link_warning_errno(link, r, "Could not set address label: %m");
|
|
||||||
|
|
||||||
link->address_label_messages++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now that we can figure out a default address for the dhcp server, start it */
|
/* 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)) {
|
if (link_dhcp4_server_enabled(link) && (link->flags & IFF_UP)) {
|
||||||
|
|
Loading…
Reference in a new issue