From: Simon Horman Date: Wed, 30 Oct 2013 09:17:15 +0000 (+0900) Subject: ofproto: Add group desc and stats tests X-Git-Tag: sliver-openvswitch-2.0.90-1~6^2~13 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;ds=sidebyside;h=2134b5ec7df738baef77214a7044fa36d5121238;p=sliver-openvswitch.git ofproto: Add group desc and stats tests Lightly exercise group desc and stats Signed-off-by: Simon Horman [blp@nicira.com found that a new test segfaulted and folded in fixes] Signed-off-by: Ben Pfaff --- diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c index 9e5a18cd0..915dc90a0 100644 --- a/lib/ofp-parse.c +++ b/lib/ofp-parse.c @@ -2332,7 +2332,12 @@ parse_ofp_group_mod_file(const char *file_name, uint16_t command, char *error; if (*n_gms >= allocated_gms) { + size_t i; + *gms = x2nrealloc(*gms, &allocated_gms, sizeof **gms); + for (i = 0; i < *n_gms; i++) { + list_moved(&(*gms)[i].buckets); + } } error = parse_ofp_group_mod_str(&(*gms)[*n_gms], command, ds_cstr(&s), &usable); diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 4109e1b3e..9645e04e1 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -6162,11 +6162,11 @@ ofputil_encode_group_mod(enum ofp_version ofp_version, case OFP13_VERSION: { b = ofpraw_alloc(OFPRAW_OFPT11_GROUP_MOD, ofp_version, 0); start_ogm = b->size; - ofpbuf_put_uninit(b, sizeof *ogm); + ofpbuf_put_zeros(b, sizeof *ogm); LIST_FOR_EACH (bucket, list_node, &gm->buckets) { start_bucket = b->size; - ofpbuf_put_uninit(b, sizeof *ob); + ofpbuf_put_zeros(b, sizeof *ob); if (bucket->ofpacts && bucket->ofpacts_len) { ofpacts_put_openflow_actions(bucket->ofpacts, bucket->ofpacts_len, b, @@ -6181,7 +6181,6 @@ ofputil_encode_group_mod(enum ofp_version ofp_version, ogm = ofpbuf_at_assert(b, start_ogm, sizeof *ogm); ogm->command = htons(gm->command); ogm->type = gm->type; - ogm->pad = 0; ogm->group_id = htonl(gm->group_id); break; diff --git a/tests/ofproto.at b/tests/ofproto.at index 5adb421fb..13a596ced 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -174,6 +174,19 @@ OFPT_QUEUE_GET_CONFIG_REQUEST (OF1.2) (xid=0x2): port=10 OVS_VSWITCHD_STOP AT_CLEANUP +dnl This is really bare-bones. +dnl It at least checks request and reply serialization and deserialization. +AT_SETUP([ofproto - group description]) +OVS_VSWITCHD_START +AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10]) +AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout]) +AT_CHECK([STRIP_XIDS stdout], [0], [dnl +OFPST_GROUP_DESC reply (OF1.1): + group_id=1234,type=all,bucket=actions=output:10 +]) +OVS_VSWITCHD_STOP +AT_CLEANUP + dnl This is really bare-bones. dnl It at least checks request and reply serialization and deserialization. AT_SETUP([ofproto - group features]) @@ -188,6 +201,30 @@ OFPST_GROUP_FEATURES reply (OF1.2): OVS_VSWITCHD_STOP AT_CLEANUP +dnl This is really bare-bones. +dnl It at least checks request and reply serialization and deserialization. +AT_SETUP([ofproto - group stats]) +OVS_VSWITCHD_START +AT_DATA([groups.txt], [dnl +group_id=1234,type=all,bucket=output:10 +group_id=1235,type=all,bucket=output:10 +]) +AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt]) +AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1234']) +AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-group-stats br0 group_id=1234], [0], [stdout]) +AT_CHECK([STRIP_XIDS stdout | sort], [0], [dnl + group_id=1234,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0 +OFPST_GROUP reply (OF1.1): +]) +AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-group-stats br0], [0], [stdout]) +AT_CHECK([STRIP_XIDS stdout | sort], [0], [dnl + group_id=1234,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0 + group_id=1235,ref_count=0,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0 +OFPST_GROUP reply (OF1.1): +]) +OVS_VSWITCHD_STOP +AT_CLEANUP + AT_SETUP([ofproto - mod-port (OpenFlow 1.0)]) OVS_VSWITCHD_START for command_config_state in \