Ejemplo n.º 1
0
Archivo: pool4.c Proyecto: NICMx/Jool
int handle_pool4_config(struct xlator *jool, struct genl_info *info)
{
	struct request_hdr *hdr = get_jool_hdr(info);
	union request_pool4 *request = (union request_pool4 *)(hdr + 1);
	int error;

	if (xlat_is_siit()) {
		log_err("SIIT doesn't have pool4.");
		return nlcore_respond(info, -EINVAL);
	}

	error = validate_request_size(info, sizeof(*request));
	if (error)
		return nlcore_respond(info, error);

	switch (hdr->operation) {
	case OP_FOREACH:
		return handle_pool4_display(jool->nat64.pool4, info, request);
	case OP_ADD:
		return handle_pool4_add(jool->nat64.pool4, info, request);
	case OP_UPDATE:
		return handle_pool4_update(jool->nat64.pool4, info, request);
	case OP_REMOVE:
		return handle_pool4_rm(jool, info, request);
	case OP_FLUSH:
		return handle_pool4_flush(jool, info, request);
	}

	log_err("Unknown operation: %u", hdr->operation);
	return nlcore_respond(info, -EINVAL);
}
Ejemplo n.º 2
0
int handle_session_config(struct xlator *jool, struct genl_info *info)
{
	struct request_hdr *hdr;
	struct request_session *request;
	int error;

	if (xlat_is_siit()) {
		log_err("SIIT doesn't have session tables.");
		return nlcore_respond(info, -EINVAL);
	}

	hdr = get_jool_hdr(info);
	request = (struct request_session *)(hdr + 1);

	error = validate_request_size(info, sizeof(*request));
	if (error)
		return nlcore_respond(info, error);

	switch (be16_to_cpu(hdr->operation)) {
	case OP_DISPLAY:
		return handle_session_display(jool->nat64.bib, info, request);
	case OP_COUNT:
		return handle_session_count(jool->nat64.bib, info, request);
	}

	log_err("Unknown operation: %u", be16_to_cpu(hdr->operation));
	return nlcore_respond(info, -EINVAL);
}
Ejemplo n.º 3
0
static int __handle_jool_message(struct genl_info *info)
{
	struct xlator translator;
	bool client_is_jool;
	int error;

	log_debug("===============================================");
	log_debug("Received a request from userspace.");

	error = validate_request(nla_data(info->attrs[ATTR_DATA]),
			nla_len(info->attrs[ATTR_DATA]),
			"userspace client",
			"kernel module",
			&client_is_jool);
	if (error)
		return client_is_jool ? nlcore_respond(info, error) : error;

	if (be16_to_cpu(get_jool_hdr(info)->mode) == MODE_INSTANCE)
		return handle_instance_request(info);

	error = xlator_find_current(&translator);
	if (error == -ESRCH) {
		log_err("This namespace lacks a Jool instance.");
		return nlcore_respond(info, -ESRCH);
	}
	if (error) {
		log_err("Unknown error %d; Jool instance not found.", error);
		return nlcore_respond(info, error);
	}

	error = multiplex_request(&translator, info);
	xlator_put(&translator);
	return error;
}
Ejemplo n.º 4
0
static int multiplex_request(struct xlator *jool, struct genl_info *info)
{
	struct request_hdr *hdr = get_jool_hdr(info);

	switch (be16_to_cpu(hdr->mode)) {
	case MODE_POOL6:
		return handle_pool6_config(jool, info);
	case MODE_POOL4:
		return handle_pool4_config(jool, info);
	case MODE_BIB:
		return handle_bib_config(jool, info);
	case MODE_SESSION:
		return handle_session_config(jool, info);
	case MODE_EAMT:
		return handle_eamt_config(jool, info);
	case MODE_RFC6791:
		return handle_pool6791_config(jool, info);
	case MODE_BLACKLIST:
		return handle_blacklist_config(jool, info);
	case MODE_LOGTIME:
		return handle_logtime_config(info);
	case MODE_GLOBAL:
		return handle_global_config(jool, info);
	case MODE_PARSE_FILE:
		return handle_atomconfig_request(jool, info);
	case MODE_JOOLD:
		return handle_joold_request(jool, info);
	case MODE_INSTANCE:
		return handle_instance_request(info);
	}

	log_err("Unknown configuration mode: %d", be16_to_cpu(hdr->mode));
	return nlcore_respond(info, -EINVAL);
}
Ejemplo n.º 5
0
int handle_eamt_config(struct xlator *jool, struct genl_info *info)
{
	struct request_hdr *hdr;
	union request_eamt *request;
	int error;

	if (xlat_is_nat64()) {
		log_err("Stateful NAT64 doesn't have an EAMT.");
		return nlcore_respond(info, -EINVAL);
	}

	hdr = get_jool_hdr(info);
	request = (union request_eamt *)(hdr + 1);

	error = validate_request_size(info, sizeof(*request));
	if (error)
		return nlcore_respond(info, error);

	switch (be16_to_cpu(hdr->operation)) {
	case OP_DISPLAY:
		return handle_eamt_display(jool->siit.eamt, info, request);
	case OP_COUNT:
		return handle_eamt_count(jool->siit.eamt, info);
	case OP_ADD:
		error = handle_eamt_add(jool->siit.eamt, request);
		break;
	case OP_REMOVE:
		error = handle_eamt_rm(jool->siit.eamt, request);
		break;
	case OP_FLUSH:
		error = handle_eamt_flush(jool->siit.eamt);
		break;
	default:
		log_err("Unknown operation: %u", be16_to_cpu(hdr->operation));
		error = -EINVAL;
	}

	return nlcore_respond(info, error);
}