diff options
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkd-address.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index 7d06cf8877..3f787948f9 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -101,14 +101,19 @@ int address_drop(Address *address, Link *link, assert(link->manager); assert(link->manager->rtnl); - r = sd_rtnl_message_addr_new(RTM_DELADDR, link->ifindex, - address->family, address->prefixlen, 0, 0, &req); + r = sd_rtnl_message_addr_new(RTM_DELADDR, link->ifindex, address->family, &req); if (r < 0) { log_error("Could not allocate RTM_DELADDR message: %s", strerror(-r)); return r; } + r = sd_rtnl_message_addr_set_prefixlen(req, address->prefixlen); + if (r < 0) { + log_error("Could not set prefixlen: %s", strerror(-r)); + return r; + } + if (address->family == AF_INET) r = sd_rtnl_message_append_in_addr(req, IFA_LOCAL, &address->in_addr.in); else if (address->family == AF_INET6) @@ -141,14 +146,31 @@ int address_configure(Address *address, Link *link, assert(link->manager->rtnl); r = sd_rtnl_message_addr_new(RTM_NEWADDR, link->ifindex, - address->family, address->prefixlen, - IFA_F_PERMANENT, RT_SCOPE_UNIVERSE, &req); + address->family, &req); if (r < 0) { log_error("Could not allocate RTM_NEWADDR message: %s", strerror(-r)); return r; } + r = sd_rtnl_message_addr_set_prefixlen(req, address->prefixlen); + if (r < 0) { + log_error("Could not set prefixlen: %s", strerror(-r)); + return r; + } + + r = sd_rtnl_message_addr_set_flags(req, IFA_F_PERMANENT); + if (r < 0) { + log_error("Could not set flags: %s", strerror(-r)); + return r; + } + + r = sd_rtnl_message_addr_set_scope(req, RT_SCOPE_UNIVERSE); + if (r < 0) { + log_error("Could not set scope: %s", strerror(-r)); + return r; + } + if (address->family == AF_INET) r = sd_rtnl_message_append_in_addr(req, IFA_LOCAL, &address->in_addr.in); else if (address->family == AF_INET6) |