diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-07-01 13:11:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-01 13:11:36 +0200 |
commit | fac6511e4943f9a873f136c0bb3185d3cd8cbbfa (patch) | |
tree | d98807459d5b6812331c2c8d36c164d74b915a3e | |
parent | NEWS: fix misplaces parenthesis (diff) | |
parent | network: fix segfault in link_update_hardware_address() (diff) | |
download | systemd-fac6511e4943f9a873f136c0bb3185d3cd8cbbfa.tar.xz systemd-fac6511e4943f9a873f136c0bb3185d3cd8cbbfa.zip |
Merge pull request #20083 from yuwata/network-ipv4acd-follow-ups
network: ipv4acd follow-ups
-rw-r--r-- | src/network/networkd-ipv4acd.c | 6 | ||||
-rw-r--r-- | src/network/networkd-link.c | 19 |
2 files changed, 13 insertions, 12 deletions
diff --git a/src/network/networkd-ipv4acd.c b/src/network/networkd-ipv4acd.c index ea902d9766..c2cadc0a30 100644 --- a/src/network/networkd-ipv4acd.c +++ b/src/network/networkd-ipv4acd.c @@ -36,12 +36,12 @@ static int static_address_on_conflict(Link *link, Address *address) { assert(address); if (address_get(link, address, NULL) < 0) { - log_link_warning(link, "Cannot configure requested address "IPV4_ADDRESS_FMT_STR", as an address conflict is detected.", + log_link_warning(link, "Cannot configure requested address "IPV4_ADDRESS_FMT_STR", as an address conflict was detected.", IPV4_ADDRESS_FMT_VAL(address->in_addr.in)); return 0; } - log_link_warning(link, "Dropping address "IPV4_ADDRESS_FMT_STR", as an address conflict is detected.", + log_link_warning(link, "Dropping address "IPV4_ADDRESS_FMT_STR", as an address conflict was detected.", IPV4_ADDRESS_FMT_VAL(address->in_addr.in)); r = address_remove(address, link); @@ -66,7 +66,7 @@ static int dhcp4_address_on_conflict(Link *link) { /* Unlikely, but during probing the address, the lease may be lost. */ return 0; - log_link_warning(link, "Dropping DHCPv4 lease, as an address conflict is detected."); + log_link_warning(link, "Dropping DHCPv4 lease, as an address conflict was detected."); r = dhcp4_lease_lost(link); if (r < 0) return log_link_warning_errno(link, r, "Failed to drop DHCPv4 lease: %m"); diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 4efe74ad41..a939f55731 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1998,7 +1998,7 @@ static int link_update_master(Link *link, sd_netlink_message *message) { } static int link_update_hardware_address(Link *link, sd_netlink_message *message) { - struct hw_addr_data old; + struct hw_addr_data addr; int r; assert(link); @@ -2008,26 +2008,27 @@ static int link_update_hardware_address(Link *link, sd_netlink_message *message) if (r < 0 && r != -ENODATA) return log_link_debug_errno(link, r, "rtnl: failed to read broadcast address: %m"); - old = link->hw_addr; - r = netlink_message_read_hw_addr(message, IFLA_ADDRESS, &link->hw_addr); + r = netlink_message_read_hw_addr(message, IFLA_ADDRESS, &addr); if (r == -ENODATA) return 0; if (r < 0) return log_link_debug_errno(link, r, "rtnl: failed to read hardware address: %m"); - if (hw_addr_equal(&link->hw_addr, &old)) + if (hw_addr_equal(&link->hw_addr, &addr)) return 0; - if (hw_addr_is_null(&old)) - log_link_debug(link, "Saved hardware address: %s", HW_ADDR_TO_STR(&link->hw_addr)); + if (hw_addr_is_null(&link->hw_addr)) + log_link_debug(link, "Saved hardware address: %s", HW_ADDR_TO_STR(&addr)); else { log_link_debug(link, "Hardware address is changed: %s → %s", - HW_ADDR_TO_STR(&old), HW_ADDR_TO_STR(&link->hw_addr)); + HW_ADDR_TO_STR(&link->hw_addr), HW_ADDR_TO_STR(&addr)); - if (hashmap_get(link->manager->links_by_hw_addr, &old) == link) - hashmap_remove(link->manager->links_by_hw_addr, &old); + if (hashmap_get(link->manager->links_by_hw_addr, &link->hw_addr) == link) + hashmap_remove(link->manager->links_by_hw_addr, &link->hw_addr); } + link->hw_addr = addr; + if (!hw_addr_is_null(&link->hw_addr)) { r = hashmap_ensure_put(&link->manager->links_by_hw_addr, &hw_addr_hash_ops, &link->hw_addr, link); if (r == -EEXIST && streq_ptr(link->kind, "bond")) |