Skip to content

Commit

Permalink
Merge pull request #80 from lagopus/release-0.2
Browse files Browse the repository at this point in the history
Lagopus 0.2.6
  • Loading branch information
Yoshihiro Nakajima committed May 2, 2016
2 parents be08ceb + d98de47 commit 6a53310
Show file tree
Hide file tree
Showing 38 changed files with 1,676 additions and 388 deletions.
19 changes: 17 additions & 2 deletions configure
Expand Up @@ -649,7 +649,6 @@ PKG_VERSION
PKG_NAME
NUMA_LIBS
SSE42_CPPFLAGS
MBTREE_FLAGS
RTE_MBUF_HAS_PKT
RTE_OS
RTE_ARCH
Expand Down Expand Up @@ -796,6 +795,7 @@ enable_snmp
enable_jumbo_frame
enable_dpdk
enable_mbtree
enable_thtable
enable_sse4_2
enable_numa
'
Expand Down Expand Up @@ -1443,6 +1443,7 @@ Optional Features:
--enable-dpdk enable DPDK [default is yes]

--enable-mbtree use multiple branch tree lookup [default is no]
--enable-thtable use tuple hash table lookup [default is no]
--enable-sse4.2 build with SSE4.2 instruction [default is yes]
--enable-numa Support NUMA (if supported).

Expand Down Expand Up @@ -17401,7 +17402,21 @@ fi

MBTREE_FLAGS=''
if test "X${mbtree}" != "Xno"; then
MBTREE_FLAGS="-DUSE_MBTREE"
$as_echo "#define USE_MBTREE 1" >>confdefs.h

fi

# Check whether --enable-thtable was given.
if test "${enable_thtable+set}" = set; then :
enableval=$enable_thtable; thtable="$enableval"
else
thtable="no"
fi


THTABLE_FLAGS=''
if test "X${thtable}" != "Xno"; then
$as_echo "#define USE_THTABLE 1" >>confdefs.h

fi

Expand Down
13 changes: 11 additions & 2 deletions configure.ac
Expand Up @@ -440,8 +440,17 @@ AC_ARG_ENABLE([mbtree],

MBTREE_FLAGS=''
if test "X${mbtree}" != "Xno"; then
MBTREE_FLAGS="-DUSE_MBTREE"
AC_SUBST(MBTREE_FLAGS)
AC_DEFINE(USE_MBTREE)
fi

AC_ARG_ENABLE([thtable],
[AC_HELP_STRING([--enable-thtable],
[use tuple hash table lookup [default is no]])],
[thtable="$enableval"], [thtable="no"])

THTABLE_FLAGS=''
if test "X${thtable}" != "Xno"; then
AC_DEFINE(USE_THTABLE)
fi

SSE42_CPPFLAGS=''
Expand Down
2 changes: 1 addition & 1 deletion mk/vars.mk.in
Expand Up @@ -135,7 +135,7 @@ RUNPATH_SNMP_HANDLER_LIB = $(BUILD_SNMPDIR)/.libs
#DEP_LAGOPUS_OVSDB_LIB = $(BUILD_OVSDBDIR)/$(LAGOPUS_OVSDB_LIB)
#---------------------------------------------------------------------

CPPFLAGS += @OS_CPPFLAGS@ @MBTREE_FLAGS@ @SNMP_CPPFLAGS@
CPPFLAGS += @OS_CPPFLAGS@ @SNMP_CPPFLAGS@
CPPFLAGS += @FRAME_CPPFLAGS@ @HYBRID_CPPFLAGS@
CPPFLAGS += -I$(BUILD_INCDIR) -DCONFDIR='"$(CONFDIR)"'
ifneq ($(RTE_SDK),)
Expand Down
23 changes: 11 additions & 12 deletions src/agent/ofp_action.c
Expand Up @@ -768,9 +768,6 @@ ofp_action_list_set_field_encode(struct pbuf_list *pbuf_list,
uint8_t *oxm_value;
uint8_t oxm_len;

/* set_field head pointer. */
set_field_head = pbuf_putp_get(*pbuf);

/* action length. */
oxm_len = act_set_field->field[OXM_LENGTH_INDEX];
act_set_field->len = (uint16_t) (sizeof(struct ofp_action_set_field) +
Expand All @@ -780,6 +777,9 @@ ofp_action_list_set_field_encode(struct pbuf_list *pbuf_list,

ret = ofp_action_set_field_encode_list(pbuf_list, pbuf, act_set_field);
if (ret == LAGOPUS_RESULT_OK) {
/* set_field head pointer. */
set_field_head = pbuf_putp_get(*pbuf) - sizeof(struct ofp_action_set_field);

/* Encode remaining OXM payload. */
ret = ofp_set_field_encode_list(pbuf_list, pbuf, oxm_value,
(uint16_t) (act_set_field->len -
Expand Down Expand Up @@ -819,14 +819,13 @@ ofp_action_list_action_ed_prop_encode(struct pbuf_list *pbuf_list,
uint8_t *prop_head;
uint16_t length = 0;

/* head pointer. */
prop_head = pbuf_putp_get(*pbuf);

switch (ed_prop->ofp_ed_prop.type) {
case OFPPPT_PROP_PORT_NAME:
ret = ofp_ed_prop_portname_encode_list(pbuf_list, pbuf,
&ed_prop->ofp_ed_prop_portname);
if (ret == LAGOPUS_RESULT_OK) {
/* head pointer. */
prop_head = pbuf_putp_get(*pbuf) - sizeof(struct ofp_ed_prop_portname);
length = sizeof(struct ofp_ed_prop_portname);
}
break;
Expand Down Expand Up @@ -865,13 +864,13 @@ ofp_action_list_action_encap_encode(struct pbuf_list *pbuf_list,
uint16_t ed_prop_length = 0;
uint8_t *encap_head;

/* head pointer. */
encap_head = pbuf_putp_get(*pbuf);

act_encap = (struct ofp_action_encap *)&(action->ofpat);

ret = ofp_action_encap_encode_list(pbuf_list, pbuf, act_encap);
if (ret == LAGOPUS_RESULT_OK) {
/* head pointer. */
encap_head = pbuf_putp_get(*pbuf) - sizeof(struct ofp_action_encap);

if (TAILQ_EMPTY(&action->ed_prop_list) == false) {
TAILQ_FOREACH(ed_prop, &action->ed_prop_list, entry) {
ret = ofp_action_list_action_ed_prop_encode(pbuf_list,
Expand Down Expand Up @@ -922,13 +921,13 @@ ofp_action_list_action_decap_encode(struct pbuf_list *pbuf_list,
uint16_t ed_prop_length = 0;
uint8_t *decap_head;

/* head pointer. */
decap_head = pbuf_putp_get(*pbuf);

act_decap = (struct ofp_action_decap *)&(action->ofpat);

ret = ofp_action_decap_encode_list(pbuf_list, pbuf, act_decap);
if (ret == LAGOPUS_RESULT_OK) {
/* head pointer. */
decap_head = pbuf_putp_get(*pbuf) - sizeof(struct ofp_action_decap);

if (TAILQ_EMPTY(&action->ed_prop_list) == false) {
TAILQ_FOREACH(ed_prop, &action->ed_prop_list, entry) {
ret = ofp_action_list_action_ed_prop_encode(pbuf_list,
Expand Down
6 changes: 3 additions & 3 deletions src/agent/ofp_bucket.c
Expand Up @@ -152,11 +152,11 @@ ofp_bucket_list_encode(struct pbuf_list *pbuf_list,
*total_length = 0;
if (TAILQ_EMPTY(bucket_list) == false) {
TAILQ_FOREACH(bucket, bucket_list, entry) {
/* bucket head pointer. */
bucket_head = pbuf_putp_get(*pbuf);

ret = ofp_bucket_encode_list(pbuf_list, pbuf, &bucket->ofp);
if (ret == LAGOPUS_RESULT_OK) {
/* bucket head pointer. */
bucket_head = pbuf_putp_get(*pbuf) - sizeof(struct ofp_bucket);

ret = ofp_action_list_encode(pbuf_list, pbuf, &bucket->action_list,
&action_total_len);
if (ret == LAGOPUS_RESULT_OK) {
Expand Down
7 changes: 4 additions & 3 deletions src/agent/ofp_flow_handler.c
Expand Up @@ -53,12 +53,13 @@ s_flow_stats_list_encode(struct pbuf_list *pbuf_list,
if (TAILQ_EMPTY(flow_stats_list) == false) {
/* encode flow_stats list */
TAILQ_FOREACH(flow_stats, flow_stats_list, entry) {
/* flow_stats head pointer. */
flow_stats_head = pbuf_putp_get(*pbuf);

/* encode flow_stats */
res = ofp_flow_stats_encode_list(pbuf_list, pbuf, &(flow_stats->ofp));
if (res == LAGOPUS_RESULT_OK) {

/* flow_stats head pointer. */
flow_stats_head = pbuf_putp_get(*pbuf) - sizeof(struct ofp_flow_stats);

/* encode match */
res = ofp_match_list_encode(pbuf_list, pbuf, &(flow_stats->match_list),
&match_total_len);
Expand Down
4 changes: 2 additions & 2 deletions src/agent/ofp_group_desc_handler.c
Expand Up @@ -77,11 +77,11 @@ ofp_group_desc_reply_create(struct channel *channel,
if (ret == LAGOPUS_RESULT_OK) {
if (TAILQ_EMPTY(group_desc_list) == false) {
TAILQ_FOREACH(group_desc, group_desc_list, entry) {
group_desc_head = pbuf_putp_get(pbuf);

ret = ofp_group_desc_encode_list(*pbuf_list, &pbuf,
&group_desc->ofp);
if (ret == LAGOPUS_RESULT_OK) {
group_desc_head = pbuf_putp_get(pbuf) - sizeof(struct ofp_group_desc);

ret = ofp_bucket_list_encode(*pbuf_list, &pbuf,
&group_desc->bucket_list,
&bucket_total_length);
Expand Down
4 changes: 3 additions & 1 deletion src/agent/ofp_group_handler.c
Expand Up @@ -77,10 +77,12 @@ ofp_group_stats_reply_create(struct channel *channel,
if (ret == LAGOPUS_RESULT_OK) {
if (TAILQ_EMPTY(group_stats_list) == false) {
TAILQ_FOREACH(group_stats, group_stats_list, entry) {
group_stats_head = pbuf_putp_get(pbuf);
ret = ofp_group_stats_encode_list(*pbuf_list, &pbuf,
&group_stats->ofp);
if (ret == LAGOPUS_RESULT_OK) {
group_stats_head = pbuf_putp_get(pbuf) -
sizeof(struct ofp_group_stats);

ret = ofp_bucket_counter_list_encode(*pbuf_list, &pbuf,
&group_stats->bucket_counter_list,
&bucket_total_length);
Expand Down
12 changes: 9 additions & 3 deletions src/agent/ofp_match.c
Expand Up @@ -271,13 +271,18 @@ ofp_match_list_encode(struct pbuf_list *pbuf_list,

if (pbuf != NULL && match_list != NULL &&
total_length != NULL) {
match_head = pbuf_putp_get(*pbuf);

/* OMX only. */
ofp_tlv.type = OFPMT_OXM;
/* length is replaced later. */
ofp_tlv.length = 0;
ofp_tlv_encode_list(pbuf_list, pbuf, &ofp_tlv);

ret = ofp_tlv_encode_list(pbuf_list, pbuf, &ofp_tlv);
if (ret != LAGOPUS_RESULT_OK) {
lagopus_msg_warning("FAILED : ofp_tlv_encode_list.\n");
goto done;
}

match_head = pbuf_putp_get(*pbuf) - sizeof(struct ofp_tlv);
*total_length = (uint16_t) sizeof(struct ofp_tlv);

if (TAILQ_EMPTY(match_list) == false) {
Expand Down Expand Up @@ -373,5 +378,6 @@ ofp_match_list_encode(struct pbuf_list *pbuf_list,
ret = LAGOPUS_RESULT_INVALID_ARGS;
}

done:
return ret;
}
4 changes: 3 additions & 1 deletion src/agent/ofp_meter_config_handler.c
Expand Up @@ -78,11 +78,13 @@ ofp_meter_config_reply_create(struct channel *channel,
if (ret == LAGOPUS_RESULT_OK) {
if (TAILQ_EMPTY(meter_config_list) == false) {
TAILQ_FOREACH(meter_config, meter_config_list, entry) {
meter_config_head = pbuf_putp_get(pbuf);
ret = ofp_meter_config_encode_list(*pbuf_list, &pbuf,
&meter_config->ofp);

if (ret == LAGOPUS_RESULT_OK) {
meter_config_head = pbuf_putp_get(pbuf) -
sizeof(struct ofp_meter_config);

ret = ofp_band_list_encode(*pbuf_list, &pbuf,
&meter_config->band_list,
&band_total_length);
Expand Down
7 changes: 4 additions & 3 deletions src/agent/ofp_meter_handler.c
Expand Up @@ -77,12 +77,13 @@ ofp_meter_stats_reply_create(struct channel *channel,
if (ret == LAGOPUS_RESULT_OK) {
if (TAILQ_EMPTY(meter_stats_list) == false) {
TAILQ_FOREACH(meter_stats, meter_stats_list, entry) {
/* A pointer is length field in ofp_meter_stats. */
meter_stats_head = pbuf_putp_get(pbuf) + sizeof(uint32_t);

ret = ofp_meter_stats_encode_list(*pbuf_list, &pbuf,
&meter_stats->ofp);
if (ret == LAGOPUS_RESULT_OK) {
/* A pointer is length field in ofp_meter_stats. */
meter_stats_head = pbuf_putp_get(pbuf) + sizeof(uint32_t) -
sizeof(struct ofp_meter_stats);

ret = ofp_meter_band_stats_list_encode(*pbuf_list, &pbuf,
&meter_stats->meter_band_stats_list,
&band_total_length);
Expand Down
7 changes: 5 additions & 2 deletions src/agent/ofp_table_features_handler.c
Expand Up @@ -610,11 +610,13 @@ s_table_property_list_encode(struct pbuf_list *pbuf_list,
if (TAILQ_EMPTY(table_property_list) == false) {
TAILQ_FOREACH(table_property, table_property_list, entry) {
property_len = 0;
property_head = pbuf_putp_get(*pbuf);
ret = ofp_table_feature_prop_header_encode_list(pbuf_list,
pbuf,
&table_property->ofp);
if (ret == LAGOPUS_RESULT_OK) {
property_head = pbuf_putp_get(*pbuf) -
sizeof(struct ofp_table_feature_prop_header);

switch (table_property->ofp.type) {
case OFPTFPT_INSTRUCTIONS :
case OFPTFPT_INSTRUCTIONS_MISS :
Expand Down Expand Up @@ -752,7 +754,6 @@ ofp_table_features_reply_create(struct channel *channel,
if (ret == LAGOPUS_RESULT_OK) {
if (TAILQ_EMPTY(table_features_list) == false) {
TAILQ_FOREACH(table_features, table_features_list, entry) {
table_features_head = pbuf_putp_get(pbuf);
ret = ofp_table_features_encode_list(*pbuf_list,
&pbuf,
&table_features->ofp);
Expand All @@ -761,6 +762,8 @@ ofp_table_features_reply_create(struct channel *channel,
ret = LAGOPUS_RESULT_NO_MEMORY;
break;
} else {
table_features_head = pbuf_putp_get(pbuf) -
sizeof(struct ofp_table_features);
ret = s_table_property_list_encode(*pbuf_list,
&pbuf,
&table_features->table_property_list,
Expand Down
79 changes: 79 additions & 0 deletions src/agent/test/handler_test_utils.c
Expand Up @@ -644,6 +644,85 @@ check_pbuf_list_packet_create(ofp_reply_list_create_proc_t create_proc,
return res;
}

lagopus_result_t
check_pbuf_list_across_packet_create(ofp_reply_list_create_proc_t create_proc,
const char *header_data[],
const char *body_data[],
size_t nums[],
int array_len) {
lagopus_result_t res = LAGOPUS_RESULT_ANY_FAILURES;
struct channel *channel = create_data_channel();
struct pbuf_list *test_pbuf_list, *ret_pbuf_list;
struct pbuf *test_pbuf = NULL;
struct pbuf *body_pbuf = NULL;
struct pbuf *ret_pbuf = NULL;
struct ofp_header xid_header;
size_t sizeof_packet;
size_t sizeof_body;
size_t i, j;

s_xid = 0x10;
test_pbuf_list = pbuf_list_alloc();

for (i = 0; i < (size_t) array_len; i++) {
/* create packet */
for (j = 0; j < nums[i]; j++) {
if (j == 0) {
create_packet(header_data[i], &test_pbuf);
create_packet(body_data[i], &body_pbuf);
sizeof_body = (size_t) (body_pbuf->putp - body_pbuf->getp);
}
/* copy body. */
if ((size_t) (test_pbuf->putp - test_pbuf->getp) +
sizeof_body < BUF_SIZE) {
memmove(test_pbuf->getp + sizeof(struct ofp_multipart_reply) +
(sizeof_body * j),
body_pbuf->getp,
sizeof_body);
test_pbuf->putp += sizeof_body;
test_pbuf->plen = (size_t) (test_pbuf->putp - test_pbuf->getp);
} else {
TEST_FAIL_MESSAGE("over test_pbuf.");
}
}
pbuf_list_add(test_pbuf_list, test_pbuf);
}

xid_header.xid = s_xid;

/* call func & check */
res = (create_proc)(channel, &ret_pbuf_list, &xid_header);

if (res == LAGOPUS_RESULT_OK) {
i = 0;
test_pbuf = TAILQ_FIRST(&test_pbuf_list->tailq);
TAILQ_FOREACH(ret_pbuf, &ret_pbuf_list->tailq, entry) {
if (test_pbuf != NULL) {
sizeof_packet = (size_t) (test_pbuf->putp - test_pbuf->getp);
TEST_ASSERT_EQUAL_MESSAGE(sizeof_packet,
ret_pbuf->putp - ret_pbuf->getp,
"handler_test_utils.c: packet data len error.");
TEST_ASSERT_EQUAL_MESSAGE(0, memcmp(ret_pbuf->data, test_pbuf->data,
sizeof_packet),
"handler_test_utils.c: packet compare error.");
test_pbuf = TAILQ_NEXT(test_pbuf, entry);
i++;
} else {
TEST_FAIL_MESSAGE("handler_test_utils.c: test_pbuf is NULL.");
break;
}
}
TEST_ASSERT_EQUAL_MESSAGE(array_len, i, "handler_test_utils.c: "
"pbuf_list len error.");
pbuf_list_free(ret_pbuf_list);
}

/* free */
pbuf_list_free(test_pbuf_list);
s_destroy_static_data();
return res;
}

lagopus_result_t
check_packet_send(ofp_send_proc_t send_proc) {
lagopus_result_t res = LAGOPUS_RESULT_ANY_FAILURES;
Expand Down
6 changes: 6 additions & 0 deletions src/agent/test/handler_test_utils.h
Expand Up @@ -157,6 +157,12 @@ check_pbuf_list_packet_create(ofp_reply_list_create_proc_t create_proc,
const char *packet_array[],
int array_len);

lagopus_result_t
check_pbuf_list_across_packet_create(ofp_reply_list_create_proc_t create_proc,
const char *header_data[],
const char *body_data[],
size_t nums[],
int array_len);
void
data_create(ofp_data_create_proc_t create_proc,
const char packet[]);
Expand Down

0 comments on commit 6a53310

Please sign in to comment.