ofp-parse: Handle buffer resize when parsing actions
authorSimon Horman <horms@verge.net.au>
Mon, 7 Apr 2014 16:43:04 +0000 (16:43 +0000)
committerJarno Rajahalme <>
Mon, 7 Apr 2014 15:29:59 +0000 (08:29 -0700)
commit65bfce4ae0603c8c3576acc5b3cd1ba5afff4c00
treeb92a568b34fac07b2d7352e66bf29c7b0c530679
parent42f3bacaf146f3c4fc5990f038c545ec3b70daa5
ofp-parse: Handle buffer resize when parsing actions

A call to ofpbuf_put() may cause the data of the passed to be resized and
its base address to change.  Thus the address returned by ofpbuf_put()
should be used as the base address rather than relying on the base address
prior to ofpbuf_put().

This avoids the following assertion in ofpact_update_len() from failing
when ofpbuf_put() causes a resize in parse_note(), parse_noargs_dec_ttl(),
parse_dec_ttl().

    ovs_assert(ofpact == ofpacts->frame);

This restores pointer updates removed by and resolves a regression
introduced by cf3b7538666cd1ef ("ofpbuf: Abstract 'l2' pointer and document
usage conventions.").

Test cases have also been added to exercise this buffer resize in
parse_note(), parse_noargs_dec_ttl(), parse_dec_ttl().

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
lib/ofp-parse.c
tests/ofproto-dpif.at