diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2022-08-24 16:52:52 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2022-08-31 10:07:43 +0200 |
commit | d0fb3fbf8e68c8452840adeb2ee818596b4b54af (patch) | |
tree | 19d1c8f580042e09cbf94ad084c3cb70b0887643 | |
parent | 8011d0b32bedf8096a67d68d7f94eaac927fcd44 (diff) | |
download | NetworkManager-d0fb3fbf8e68c8452840adeb2ee818596b4b54af.tar.gz |
device: restart DHCP when the MAC changes
If the MAC changes there is the possibility that the DHCP client will
not be able to renew the address because it uses the old MAC as
CHADDR. Depending on the implementation, the DHCP server might use
CHADDR (so, the old address) as the destination MAC for DHCP replies,
and those packets will be lost.
To avoid this problem, restart the DHCP client when the MAC changes.
https://bugzilla.redhat.com/show_bug.cgi?id=2110000
(cherry picked from commit 905adabdba033bbfc33013d0ad203bd444131dc5)
(cherry picked from commit 5a49a2f6b20e6d124ac705e79ab7d5df3837b8c1)
-rw-r--r-- | src/core/devices/nm-device.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index ab49db3f89..6c613c570b 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -6426,6 +6426,7 @@ device_link_changed(gpointer user_data) NMDeviceClass *klass = NM_DEVICE_GET_CLASS(self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gboolean ip_ifname_changed = FALSE; + gboolean hw_addr_changed; nm_auto_nmpobj const NMPObject *pllink_keep_alive = NULL; const NMPlatformLink *pllink; const char *str; @@ -6472,9 +6473,9 @@ device_link_changed(gpointer user_data) if (ifindex == nm_device_get_ip_ifindex(self)) _stats_update_counters_from_pllink(self, pllink); - had_hw_addr = (priv->hw_addr != NULL); - nm_device_update_hw_address(self); - got_hw_addr = (!had_hw_addr && priv->hw_addr); + had_hw_addr = (priv->hw_addr != NULL); + hw_addr_changed = nm_device_update_hw_address(self); + got_hw_addr = (!had_hw_addr && priv->hw_addr); nm_device_update_permanent_hw_address(self, FALSE); if (pllink->name[0] && !nm_streq(priv->iface, pllink->name)) { @@ -6525,6 +6526,8 @@ device_link_changed(gpointer user_data) /* Update DHCP, etc, if needed */ if (ip_ifname_changed) nm_device_update_dynamic_ip_setup(self, "IP interface changed"); + else if (hw_addr_changed) + nm_device_update_dynamic_ip_setup(self, "hw-address changed"); was_up = priv->up; priv->up = NM_FLAGS_HAS(pllink->n_ifi_flags, IFF_UP); |