diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-address.c | 20 | ||||
-rw-r--r-- | src/network/networkd-address.h | 3 | ||||
-rw-r--r-- | src/network/networkd-dhcp4.c | 4 | ||||
-rw-r--r-- | src/network/networkd-dhcp6.c | 8 | ||||
-rw-r--r-- | src/network/networkd-manager.c | 18 |
5 files changed, 31 insertions, 22 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index f1b364f40e..98ff027536 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -282,6 +282,24 @@ static int address_release(Address *address, Link *link) { return 0; } +int address_update(Address *address, unsigned char flags, unsigned char scope, struct ifa_cacheinfo *cinfo) { + bool ready; + + assert(address); + assert(cinfo); + + ready = address_is_ready(address); + + address->flags = flags; + address->scope = scope; + address->cinfo = *cinfo; + + if (!ready && address_is_ready(address) && address->link) + link_check_ready(address->link); + + return 0; +} + int address_drop(Address *address) { Link *link; bool ready; @@ -359,7 +377,7 @@ int address_remove(Address *address, Link *link, return 0; } -int address_update(Address *address, Link *link, +int address_change(Address *address, Link *link, sd_netlink_message_handler_t callback) { _cleanup_netlink_message_unref_ sd_netlink_message *req = NULL; int r; diff --git a/src/network/networkd-address.h b/src/network/networkd-address.h index 425344fe48..07a7ad2026 100644 --- a/src/network/networkd-address.h +++ b/src/network/networkd-address.h @@ -62,9 +62,10 @@ int address_new(Address **ret); void address_free(Address *address); int address_add(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret); int address_get(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret); +int address_update(Address *address, unsigned char flags, unsigned char scope, struct ifa_cacheinfo *cinfo); int address_drop(Address *address); int address_configure(Address *address, Link *link, sd_netlink_message_handler_t callback); -int address_update(Address *address, Link *link, sd_netlink_message_handler_t callback); +int address_change(Address *address, Link *link, sd_netlink_message_handler_t callback); int address_remove(Address *address, Link *link, sd_netlink_message_handler_t callback); bool address_equal(Address *a1, Address *a2); bool address_is_ready(const Address *a); diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index e2f7d69666..5c91d9609f 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -299,9 +299,9 @@ static int dhcp4_update_address(Link *link, addr->prefixlen = prefixlen; addr->broadcast.s_addr = address->s_addr | ~netmask->s_addr; - /* use update rather than configure so that we will update the + /* use change rather than configure so that we will update the * lifetime of an existing address if it has already been configured */ - r = address_update(addr, link, &dhcp4_address_handler); + r = address_change(addr, link, &dhcp4_address_handler); if (r < 0) return r; diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c index 8115232e1d..95cdb80b0a 100644 --- a/src/network/networkd-dhcp6.c +++ b/src/network/networkd-dhcp6.c @@ -63,7 +63,7 @@ static int dhcp6_address_handler(sd_netlink *rtnl, sd_netlink_message *m, return 1; } -static int dhcp6_address_update(Link *link, struct in6_addr *ip6_addr, +static int dhcp6_address_change(Link *link, struct in6_addr *ip6_addr, uint8_t prefixlen, uint32_t lifetime_preferred, uint32_t lifetime_valid) { int r; @@ -87,7 +87,7 @@ static int dhcp6_address_update(Link *link, struct in6_addr *ip6_addr, SD_ICMP6_ND_ADDRESS_FORMAT_VAL(addr->in_addr.in6), addr->prefixlen, lifetime_preferred, lifetime_valid); - r = address_update(addr, link, dhcp6_address_handler); + r = address_change(addr, link, dhcp6_address_handler); if (r < 0) log_link_warning_errno(link, r, "Could not assign DHCPv6 address: %m"); @@ -121,7 +121,7 @@ static int dhcp6_lease_address_acquired(sd_dhcp6_client *client, Link *link) { if (r == -EADDRNOTAVAIL) prefixlen = 128; - r = dhcp6_address_update(link, &ip6_addr, prefixlen, + r = dhcp6_address_change(link, &ip6_addr, prefixlen, lifetime_preferred, lifetime_valid); if (r < 0) return r; @@ -300,7 +300,7 @@ static int dhcp6_prefix_expired(Link *link) { log_link_info(link, "IPv6 prefix length updated "SD_ICMP6_ND_ADDRESS_FORMAT_STR"/%d", SD_ICMP6_ND_ADDRESS_FORMAT_VAL(ip6_addr), 128); - dhcp6_address_update(link, &ip6_addr, 128, lifetime_preferred, lifetime_valid); + dhcp6_address_change(link, &ip6_addr, 128, lifetime_preferred, lifetime_valid); } return 0; diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index 2cd4f4fef7..9a7e71fce8 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -397,29 +397,19 @@ int manager_rtnl_process_address(sd_netlink *rtnl, sd_netlink_message *message, switch (type) { case RTM_NEWADDR: - if (address) { + if (address) log_link_debug(link, "Updating address: %s/%u (valid for %s)", buf, prefixlen, valid_str); - - address->scope = scope; - address->flags = flags; - address->cinfo = cinfo; - - link_check_ready(link); - } else { + else { r = address_add(link, family, &in_addr, prefixlen, &address); if (r < 0) { log_link_warning_errno(link, r, "Failed to add address %s/%u: %m", buf, prefixlen); return 0; } else log_link_debug(link, "Adding address: %s/%u (valid for %s)", buf, prefixlen, valid_str); - - address->scope = scope; - address->flags = flags; - address->cinfo = cinfo; - - link_check_ready(link); } + address_update(address, scope, flags, &cinfo); + break; case RTM_DELADDR: |