enum target_state {
STATE_DISABLED,
STATE_ENABLED,
+ STATE_DEACTIVATED,
};
/**
if (ret)
goto out_unlock;
+ /* When the user explicitly enables or disables a target that is
+ * currently deactivated, reset its state to disabled. The DEACTIVATED
+ * state only tracks interface-driven deactivation and should _not_
+ * persist when the user manually changes the target's enabled state.
+ */
+ if (nt->state == STATE_DEACTIVATED)
+ nt->state = STATE_DISABLED;
+
ret = -EINVAL;
current_enabled = nt->state == STATE_ENABLED;
if (enabled == current_enabled) {
break;
case NETDEV_RELEASE:
case NETDEV_JOIN:
- case NETDEV_UNREGISTER:
+ /* transition target to DISABLED instead of
+ * DEACTIVATED when (de)enslaving devices as
+ * their targets should not be automatically
+ * resumed when the interface is brought up.
+ */
nt->state = STATE_DISABLED;
list_move(&nt->list, &target_cleanup_list);
stopped = true;
+ break;
+ case NETDEV_UNREGISTER:
+ nt->state = STATE_DEACTIVATED;
+ list_move(&nt->list, &target_cleanup_list);
+ stopped = true;
}
}
netconsole_target_put(nt);