ofpbuf: Implement unsupported feature in ofpbuf_trim().
authorBen Pfaff <blp@nicira.com>
Wed, 14 Jul 2010 17:05:53 +0000 (10:05 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 14 Jul 2010 22:00:08 +0000 (15:00 -0700)
commit1f5cbaa3ba28794ffbaad170cd6f8597dcd25f94
tree3467385812753c7d1afd6f1e62aec64383f5fc09
parentf057cddae23839523fb353b710c69ee01d45d196
ofpbuf: Implement unsupported feature in ofpbuf_trim().

Until now, ofpbuf_trim() has not handled the case where the ofpbuf has
nonzero headroom.  This causes an assertion failure when pinsched_send()
queues a packet to be sent later, because such packets have been
guaranteed to have nonzero headroom since commit 43253595 "ofproto: Avoid
buffer copy in OFPT_PACKET_IN path."  This commit fixes the problem by
implementing the until-now unsupported case.

This commit factors code out of ofpbuf_prealloc_tailroom() into two new
functions, ofpbuf_rebase__() and ofpbuf_resize_tailroom__(), and uses the
latter to implement both ofpbuf_prealloc_tailroom() and ofpbuf_trim().
ofpbuf_rebase__() isn't used on its own at all, but it seems potentially
useful so I made it an independent function.

Reported-by: Tom Everman <teverman@google.com>
lib/ofpbuf.c