diff options
author | Li Wei <liwei.solomon@gmail.com> | 2019-03-20 20:16:18 +0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2019-03-25 13:34:27 -0700 |
commit | 030cad7989ed1640216145ddaae66f44c2e63ff6 (patch) | |
tree | 66213caac785bc10dc198e76a7df93420244d5ef | |
parent | db2fc3b1caf5477cbd872b9f64115835412238b4 (diff) | |
download | openvswitch-030cad7989ed1640216145ddaae66f44c2e63ff6.tar.gz |
ofproto: fix the bug of bucket counter is not updated
After inserting/removing a bucket, we don't update the bucket counter.
When we call ovs-ofctl dump-group-stats br-int, a panic happened.
Reproduce steps:
1. ovs-ofctl -O OpenFlow15 add-group br-int "group_id=1, type=select, selection_method=hash bucket=bucket_id=1,weight:100,actions=output:1"
2. ovs-ofctl insert-buckets br-int "group_id=1, command_bucket_id=last, bucket=bucket_id=7,weight:800,actions=output:1"
3. ovs-ofctl dump-group-stats br-int
gdb) bt
at ../sysdeps/posix/libc_fatal.c:175
ar_ptr=<optimized out>) at malloc.c:5049
group_id=<optimized out>, cb=cb@entry=0x55cab8fd6cd0 <append_group_stats>) at ofproto/ofproto.c:6790
Signed-off-by: solomon <liwei.solomon@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
-rw-r--r-- | ofproto/ofproto.c | 2 | ||||
-rw-r--r-- | tests/ofproto.at | 16 |
2 files changed, 18 insertions, 0 deletions
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 50df9dc9c..00afaf7e8 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -6984,6 +6984,8 @@ modify_group_start(struct ofproto *ofproto, struct ofproto_group_mod *ogm) *CONST_CAST(long long int *, &(new_group->created)) = old_group->created; *CONST_CAST(long long int *, &(new_group->modified)) = time_msec(); + *CONST_CAST(uint32_t *, &(new_group->n_buckets)) = + ovs_list_size(&(new_group->buckets)); group_collection_add(&ogm->old_groups, old_group); /* Mark the old group for deletion. */ diff --git a/tests/ofproto.at b/tests/ofproto.at index a61dc3d3f..1324d6d97 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -1165,6 +1165,22 @@ OFPST_GROUP reply (OF1.5): OVS_VSWITCHD_STOP AT_CLEANUP +dnl This is used to find that the bucket counter is not updated. +AT_SETUP([ofproto - group stats after insert a new bucket (OpenFlow 1.5)]) +OVS_VSWITCHD_START +AT_DATA([groups.txt], [dnl +group_id=1234,type=select,selection_method=hash bucket=bucket_id=1,weight:100,actions=output:10 +]) +AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-groups br0 groups.txt]) +AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 'group_id=1234, command_bucket_id=last, bucket=bucket_id=2,weight:100,actions=output:10']) +AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-group-stats br0 group_id=1234], [0], [stdout]) +AT_CHECK([strip_xids < stdout | sed 's/duration=[[0-9.]]*s/duration=?s/' | sort], [0], [dnl + group_id=1234,duration=?s,ref_count=0,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0,bucket1:packet_count=0,byte_count=0 +OFPST_GROUP reply (OF1.5): +]) +OVS_VSWITCHD_STOP +AT_CLEANUP + dnl This found a use-after-free error in bridge destruction in the dnl presence of groups. AT_SETUP([ofproto - group add then bridge delete (OpenFlow 1.3)]) |