ofp-actions: Support "copy_field" ONF extension to OpenFlow 1.3.
[cascardo/ovs.git] / lib / ofpbuf.c
index 446593d..1d3cd03 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);
 }
@@ -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)