[ovs-dev] [PATCH 1/4] ofpbuf: simplify ofpbuf_l4_size()

Ben Pfaff blp at nicira.com
Tue Mar 3 18:36:49 UTC 2015


On Tue, Mar 03, 2015 at 10:33:43AM -0800, Jarno Rajahalme wrote:
> 
> > On Mar 3, 2015, at 8:29 AM, Ben Pfaff <blp at nicira.com> wrote:
> > 
> > On Mon, Mar 02, 2015 at 10:51:27AM -0800, Pravin B Shelar wrote:
> >> static inline size_t ofpbuf_l4_size(const struct ofpbuf *b)
> >> {
> >> -    return b->l4_ofs != UINT16_MAX
> >> -        ? (const char *)ofpbuf_tail(b) - (const char *)ofpbuf_l4(b)
> >> -        - ofpbuf_l2_pad_size(b)
> >> -        : 0;
> >> +    return b->l4_ofs != UINT16_MAX ? ofpbuf_size(b) - b->l4_ofs : 0;
> >> }
> > 
> > I think that this change makes the new assumption that b->frame ==
> > b->data.  I have a hard time deciding whether that's important.
> 
> A lot of our packet handling code already makes that assumption. Maybe we should document this?

It's sort of documented in ofpbuf.h, but it's too wishy-washy for me to
comfortably assume it's always true:

 *    Additionally, we assume in many places that the 'frame' and 'data' are
 *    the same for packets.



More information about the dev mailing list