device: set the addrgenmode to none for disconnected device

When NM manages the device, it should set the addrgenmode to none for
the disconnected device, as a result, the IPv6 link local address should
not be assigned for the device.
This commit is contained in:
Wen Liang 2022-09-21 11:34:41 -04:00
parent 531cc96737
commit 99343c3b06

View file

@ -15782,12 +15782,12 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
case NM_DEVICE_STATE_UNMANAGED:
nm_device_set_firmware_missing(self, FALSE);
if (old_state > NM_DEVICE_STATE_UNMANAGED) {
if (priv->sys_iface_state != NM_DEVICE_SYS_IFACE_STATE_MANAGED) {
nm_device_cleanup(self,
reason,
priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_REMOVED
? CLEANUP_TYPE_REMOVED
: CLEANUP_TYPE_KEEP);
if (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_REMOVED) {
nm_device_cleanup(self, reason, CLEANUP_TYPE_REMOVED);
_dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_EUI64);
_dev_sysctl_restore_ip6_properties(self);
} else if (priv->sys_iface_state != NM_DEVICE_SYS_IFACE_STATE_MANAGED) {
nm_device_cleanup(self, reason, CLEANUP_TYPE_KEEP);
} else {
/* Clean up if the device is now unmanaged but was activated */
if (nm_device_get_act_request(self))
@ -15842,7 +15842,8 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
nm_device_cleanup(self, reason, CLEANUP_TYPE_DECONFIGURE);
} else if (old_state < NM_DEVICE_STATE_DISCONNECTED) {
if (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_MANAGED) {
if (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_MANAGED
|| priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_ASSUME) {
/* Ensure IPv6 is set up as it may not have been done when
* entering the UNAVAILABLE state depending on the reason.
*/
@ -17522,7 +17523,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
reason = NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED;
if (NM_IN_SET_TYPED(NMDeviceSysIfaceState,
priv->sys_iface_state,
NM_DEVICE_SYS_IFACE_STATE_EXTERNAL,
NM_DEVICE_SYS_IFACE_STATE_REMOVED))
nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_ASSUME);
} else {