list: Rename struct list to struct ovs_list
[cascardo/ovs.git] / lib / ofpbuf.c
index 1f4b61d..4946e6f 100644 (file)
@@ -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);
 }
@@ -134,8 +135,15 @@ ofpbuf_uninit(struct ofpbuf *b)
     if (b) {
         if (b->source == OFPBUF_MALLOC) {
             free(ofpbuf_base(b));
+        } else if (b->source == OFPBUF_DPDK) {
+#ifdef DPDK_NETDEV
+            /* 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
         }
-        ovs_assert(b->source != OFPBUF_DPDK);
     }
 }
 
@@ -192,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;
@@ -306,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. */
@@ -422,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)
@@ -507,7 +517,7 @@ ofpbuf_to_string(const struct ofpbuf *b, size_t maxbytes)
 /* Removes each of the "struct ofpbuf"s on 'list' from the list and frees
  * them.  */
 void
-ofpbuf_list_delete(struct list *list)
+ofpbuf_list_delete(struct ovs_list *list)
 {
     struct ofpbuf *b, *next;