예제 #1
0
파일: main.c 프로젝트: weixu8/dpdk-ovs
/*
 * Delete single flow or all flows.
 *
 * When request->key is empty delete all flows
 */
static void
flow_cmd_del(struct dpdk_flow_message *request)
{
	struct dpdk_message reply = {0};
	struct flow_key empty = {0};
	int32_t pos = 0;

	if (!memcmp(&request->key, &empty, sizeof(request->key))) {
		/* if flow is empty, delete all flows */
		for (pos = 0; pos < MAX_FLOWS; pos++) {
			if (flow_table->used[pos]) {
				rte_hash_del_key(handle, &request->key);
				flow_table_del_flow(pos);
			}
		}
		reply.type = 0;
	} else {
		/* delete specified flow */
		pos = rte_hash_del_key(handle, &request->key);

		if (pos < 0) {
			reply.type = ENOENT;
			}
		else {
			flow_table_get_flow(pos, NULL, NULL, &request->stats);
			flow_table_del_flow(pos);
			reply.type = 0;
		}
	}

	reply.flow_msg = *request;

	send_reply_to_vswitchd(&reply);
}
예제 #2
0
/*
 * Delete single flow or all flows.
 *
 * When request->key is empty delete all flows
 */
static void
flow_cmd_del(struct dpdk_flow_message *request)
{
	struct dpdk_message reply = {0};
	struct flow_key empty = {0};
	int pos = 0;

	if (!memcmp(&request->key, &empty, sizeof(request->key))) {
		flow_table_del_all();
		reply.type = 0;
	} else {
		pos = flow_table_lookup(&request->key);
		if (pos < 0) {
			reply.type = ENOENT;
		} else {
			/* Retrieve flow stats*/
			flow_table_get_flow(&request->key,
			               NULL, &request->stats);
			flow_table_del_flow(&request->key);
			reply.type = 0;
		}
	}

	reply.flow_msg = *request;
	send_reply_to_vswitchd(&reply);
}
예제 #3
0
/* Try to add a normal flow and duplicate flow, and add a flow with
 * incorrect parameters, which should succeed, fail with -1 and fail
 * with -1 respectively */
static void
test_flow_table_add_flow(int argc, char *argv[])
{
	struct flow_key key1 = {1};
	struct action action_multiple[MAX_ACTIONS] = {0};
	int ret = 0;

	flow_table_init();

	/* TODO: Break this into multiple tests? */
	action_output_build(&action_multiple[0], 1);
	action_output_build(&action_multiple[1], 2);
	action_null_build(&action_multiple[2]);
	ret = flow_table_add_flow(&key1, action_multiple);
	assert(ret >= 0);
	/* check no duplicates */
	ret = flow_table_add_flow(&key1, action_multiple);
	assert(ret < 0);
	/* check incorrect parameters */
	flow_table_del_flow(&key1);
	ret = flow_table_add_flow(NULL, action_multiple);
	assert(ret < 0);
	ret = flow_table_add_flow(&key1, NULL);
	assert(ret < 0);
}