network/address-label: split out address_label_fill_message()

No functional change, just refactoring and preparation for later
commits.
This commit is contained in:
Yu Watanabe 2024-08-17 13:02:06 +09:00
parent 4dfbecd2ff
commit 7b2e07ca4c

View File

@ -102,6 +102,23 @@ static int address_label_configure_handler(
return 1;
}
static int address_label_fill_message(AddressLabel *label, sd_netlink_message *m) {
int r;
assert(label);
assert(m);
r = sd_rtnl_message_addrlabel_set_prefixlen(m, label->prefixlen);
if (r < 0)
return r;
r = sd_netlink_message_append_u32(m, IFAL_LABEL, label->label);
if (r < 0)
return r;
return sd_netlink_message_append_in6_addr(m, IFA_ADDRESS, &label->prefix);
}
static int address_label_configure(AddressLabel *label, Link *link, Request *req) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
int r;
@ -118,15 +135,7 @@ static int address_label_configure(AddressLabel *label, Link *link, Request *req
if (r < 0)
return r;
r = sd_rtnl_message_addrlabel_set_prefixlen(m, label->prefixlen);
if (r < 0)
return r;
r = sd_netlink_message_append_u32(m, IFAL_LABEL, label->label);
if (r < 0)
return r;
r = sd_netlink_message_append_in6_addr(m, IFA_ADDRESS, &label->prefix);
r = address_label_fill_message(label, m);
if (r < 0)
return r;