X-Git-Url: http://git.cascardo.info/?a=blobdiff_plain;f=lib%2Fofpbuf.c;h=1d3cd0330cdbd4d7f57c355910c73e1e0d8d74d2;hb=914624f81740a2502438c6b3c89478597ea78426;hp=446593dfba416a886a5531d3a612e67b03166916;hpb=143859ec63d45e5184356984dbf10c142e0ded39;p=cascardo%2Fovs.git diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c index 446593dfb..1d3cd0330 100644 --- a/lib/ofpbuf.c +++ b/lib/ofpbuf.c @@ -28,6 +28,7 @@ ofpbuf_init__(struct ofpbuf *b, size_t allocated, enum ofpbuf_source source) b->allocated = allocated; b->source = source; b->frame = NULL; + b->l2_pad_size = 0; b->l2_5_ofs = b->l3_ofs = b->l4_ofs = UINT16_MAX; list_poison(&b->list_node); } @@ -117,9 +118,6 @@ void ofpbuf_init_dpdk(struct ofpbuf *b, size_t allocated) { ofpbuf_init__(b, allocated, OFPBUF_DPDK); -#ifdef DPDK_NETDEV - b->dpdk_buf = b; -#endif } /* Initializes 'b' as an empty ofpbuf with an initial capacity of 'size' @@ -139,8 +137,9 @@ ofpbuf_uninit(struct ofpbuf *b) free(ofpbuf_base(b)); } else if (b->source == OFPBUF_DPDK) { #ifdef DPDK_NETDEV - ovs_assert(b != b->dpdk_buf); - free_dpdk_buf(b); + /* If this ofpbuf was allocated by DPDK it must have been + * created as a dpif_packet */ + free_dpdk_buf((struct dpif_packet*) b); #else ovs_assert(b->source != OFPBUF_DPDK); #endif @@ -201,6 +200,7 @@ ofpbuf_clone_with_headroom(const struct ofpbuf *buffer, size_t headroom) new_buffer->frame = (char *) buffer->frame + data_delta; } + new_buffer->l2_pad_size = buffer->l2_pad_size; new_buffer->l2_5_ofs = buffer->l2_5_ofs; new_buffer->l3_ofs = buffer->l3_ofs; new_buffer->l4_ofs = buffer->l4_ofs; @@ -315,8 +315,8 @@ ofpbuf_prealloc_headroom(struct ofpbuf *b, size_t size) } } -/* Trims the size of 'b' to fit its actual content, reducing its tailroom to - * 0. Its headroom, if any, is preserved. +/* Trims the size of 'b' to fit its actual content, reducing its headroom and + * tailroom to 0, if any. * * Buffers not obtained from malloc() are not resized, since that wouldn't save * any memory. */ @@ -431,8 +431,9 @@ ofpbuf_reserve(struct ofpbuf *b, size_t size) ofpbuf_set_data(b, (char*)ofpbuf_data(b) + size); } -/* Reserves 'size' bytes of headroom so that they can be later allocated with - * ofpbuf_push_uninit() without reallocating the ofpbuf. */ +/* Reserves 'headroom' bytes at the head and 'tailroom' at the end so that + * they can be later allocated with ofpbuf_push_uninit() or + * ofpbuf_put_uninit() without reallocating the ofpbuf. */ void ofpbuf_reserve_with_tailroom(struct ofpbuf *b, size_t headroom, size_t tailroom)