summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2022-08-24 16:52:52 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2022-08-24 17:20:18 +0200
commit34714ff8fff2a4618ce725a3e0c22b0abac00faa (patch)
tree83aba5af1a81f91f14fa4a508d7fad0c251f4af7
parent4f552f53bb44786a85a1254ce82c2c50eb5fb780 (diff)
device: restart DHCP when the MAC changesbg/restart-dhcp-on-mac-change
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
-rw-r--r--src/core/devices/nm-device.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c
index 96b4a1d26b..16a8e9028a 100644
--- a/src/core/devices/nm-device.c
+++ b/src/core/devices/nm-device.c
@@ -6637,6 +6637,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 = FALSE;
nm_auto_nmpobj const NMPObject *pllink_keep_alive = NULL;
const NMPlatformLink *pllink;
const char *str;
@@ -6684,7 +6685,7 @@ device_link_changed(gpointer user_data)
_stats_update_counters_from_pllink(self, pllink);
had_hw_addr = (priv->hw_addr != NULL);
- nm_device_update_hw_address(self);
+ 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);
@@ -6736,6 +6737,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);