Ejemplo n.º 1
0
/*
 * init_header - simple function to create a header, always insuring that
 * an accurate version string is inserted
 * OUT header - the message header to be send
 * IN msg_type - type of message to be send
 * IN flags - message flags to be send
 */
void init_header(header_t *header, slurm_msg_t *msg, uint16_t flags)
{
	memset(header, 0, sizeof(header));
	/* Since the slurmdbd could talk to a host of different
	   versions of slurm this needs to be kept current when the
	   protocol version changes. */
	if (msg->protocol_version != (uint16_t)NO_VAL)
		header->version = msg->protocol_version;
	else if (working_cluster_rec)
		header->version = _get_slurm_version(
			working_cluster_rec->rpc_version);
	else if ((msg->msg_type == ACCOUNTING_UPDATE_MSG) ||
	         (msg->msg_type == ACCOUNTING_FIRST_REG)) {
		uint32_t rpc_version =
			((accounting_update_msg_t *)msg->data)->rpc_version;
		header->version = _get_slurm_version(rpc_version);
	} else
		header->version = SLURM_PROTOCOL_VERSION;

	header->flags = flags;
	header->msg_type = msg->msg_type;
	header->body_length = 0;	/* over-written later */
	header->forward = msg->forward;
	if (msg->ret_list)
		header->ret_cnt = list_count(msg->ret_list);
	else
		header->ret_cnt = 0;
	header->ret_list = msg->ret_list;
	header->orig_addr = msg->orig_addr;
}
Ejemplo n.º 2
0
/*
 * check_header_version checks to see that the specified header was sent
 * from a node running the same version of the protocol as the current node
 * IN header - the message header received
 * RET - SLURM error code
 */
int check_header_version(header_t * header)
{
	uint16_t check_version = SLURM_PROTOCOL_VERSION;

	if (working_cluster_rec) {
		check_version = _get_slurm_version(
			working_cluster_rec->rpc_version);
	}

	if (slurmdbd_conf) {
		if ((header->version != SLURM_PROTOCOL_VERSION)     &&
		    (header->version != SLURM_14_03_PROTOCOL_VERSION) &&
		    (header->version != SLURM_2_6_PROTOCOL_VERSION)) {
			debug("unsupported RPC version %hu msg type %u",
			      header->version, header->msg_type);
			slurm_seterrno_ret(SLURM_PROTOCOL_VERSION_ERROR);
		}
	} else if (header->version != check_version) {
		switch (header->msg_type) {
		case REQUEST_LAUNCH_TASKS:
		case REQUEST_RUN_JOB_STEP:
		case RESPONSE_LAUNCH_TASKS:
		case RESPONSE_RUN_JOB_STEP:
			/* Disable job step creation/launch between major
			 * releases. Other RPCs should all be supported. */
			debug("unsupported RPC type %hu", header->msg_type);
			slurm_seterrno_ret(SLURM_PROTOCOL_VERSION_ERROR);
			break;
		default:
			if ((header->version != SLURM_PROTOCOL_VERSION)     &&
			    (header->version != SLURM_14_03_PROTOCOL_VERSION) &&
			    (header->version != SLURM_2_6_PROTOCOL_VERSION)) {
				debug("Unsupported RPC version %hu msg type %u",
				      header->version, header->msg_type);
				slurm_seterrno_ret(SLURM_PROTOCOL_VERSION_ERROR);
			}
			break;

		}
	}

	return SLURM_PROTOCOL_SUCCESS;
}
Ejemplo n.º 3
0
/*
 * check_header_version checks to see that the specified header was sent
 * from a node running the same version of the protocol as the current node
 * IN header - the message header received
 * RET - SLURM error code
 */
int check_header_version(header_t * header)
{
	uint16_t check_version = SLURM_PROTOCOL_VERSION;

	if (working_cluster_rec)
		check_version = _get_slurm_version(
			working_cluster_rec->rpc_version);

	if (slurmdbd_conf) {
		if ((header->version != SLURM_PROTOCOL_VERSION)     &&
		    (header->version != SLURM_2_2_PROTOCOL_VERSION) &&
		    (header->version != SLURM_2_1_PROTOCOL_VERSION))
			slurm_seterrno_ret(SLURM_PROTOCOL_VERSION_ERROR);
	} else if (header->version != check_version) {
		/* Starting with 2.2 we will handle previous versions
		 * of SLURM for some calls */
		switch(header->msg_type) {
		case REQUEST_BLOCK_INFO:
		case REQUEST_BUILD_INFO:
		case REQUEST_CANCEL_JOB_STEP:
		case REQUEST_CHECKPOINT:
		case REQUEST_CHECKPOINT_COMP:
		case REQUEST_CHECKPOINT_TASK_COMP:
		case REQUEST_COMPLETE_BATCH_SCRIPT:	/* From slurmstepd */
		case REQUEST_COMPLETE_JOB_ALLOCATION:
		case REQUEST_CREATE_PARTITION:
		case REQUEST_CREATE_RESERVATION:
		case REQUEST_JOB_END_TIME:
		case REQUEST_JOB_INFO:
		case REQUEST_JOB_INFO_SINGLE:
		case REQUEST_JOB_READY:
		case REQUEST_JOB_REQUEUE:
		case REQUEST_JOB_STEP_INFO:
		case REQUEST_JOB_WILL_RUN:
		case REQUEST_NODE_INFO:
		case REQUEST_PARTITION_INFO:
		case REQUEST_PRIORITY_FACTORS:
		case REQUEST_RECONFIGURE:
		case REQUEST_RESERVATION_INFO:
		case REQUEST_SET_DEBUG_FLAGS:
		case REQUEST_SET_DEBUG_LEVEL:
		case REQUEST_SHARE_INFO:
		case REQUEST_SHUTDOWN:
		case REQUEST_SHUTDOWN_IMMEDIATE:
		case REQUEST_STEP_COMPLETE:		/* From slurmstepd */
		case REQUEST_STEP_LAYOUT:
		case REQUEST_SUBMIT_BATCH_JOB:
		case REQUEST_SUSPEND:
		case REQUEST_TOPO_INFO:
		case REQUEST_UPDATE_BLOCK:
		case REQUEST_UPDATE_JOB:
		case REQUEST_UPDATE_PARTITION:
			if ((header->version == SLURM_2_2_PROTOCOL_VERSION)
			    || (header->version == SLURM_2_1_PROTOCOL_VERSION))
				break;
		default:
			slurm_seterrno_ret(SLURM_PROTOCOL_VERSION_ERROR);
			break;
		}
	}
	return SLURM_PROTOCOL_SUCCESS;
}