summaryrefslogtreecommitdiff
path: root/lib/ofpbuf.c
diff options
context:
space:
mode:
authorJarno Rajahalme <jrajahalme@nicira.com>2013-12-16 08:14:52 -0800
committerJarno Rajahalme <jrajahalme@nicira.com>2013-12-16 08:14:52 -0800
commitda546e076495672ab67106bb6dbb42447c1a2d26 (patch)
treea418b4f46bc2ca413c5ef87017b0c9c9d2c25e5d /lib/ofpbuf.c
parent881d47a9fa901e71953a34367e9cd9b1f0571808 (diff)
downloadopenvswitch-da546e076495672ab67106bb6dbb42447c1a2d26.tar.gz
dpif: Allow execute to modify the packet.
Allowing the packet to be modified by execution allows less data copying for userspace action execution. Some users of the dpif_execute already expect that the packet may be modified. This patch makes this behavior uniform and makes the userspace datapath and the execution helpers modify the packet as it is being executed. Userspace action now steals the packet if given permission, as the packet is normally not needed after it. The only exception is the sample action, and this is accounted for my keeping track of any actions that could be following the userspace action. The packet in dpif_upcall is changed from a pointer to a struct, allowing the packet to be honest about it's headroom. After this change the packet can safely be pushed on over the precarious 4 byte limit earlier allowed by the netlink data preceding the packet. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/ofpbuf.c')
-rw-r--r--lib/ofpbuf.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c
index 30ae12e6d..1b18b14ad 100644
--- a/lib/ofpbuf.c
+++ b/lib/ofpbuf.c
@@ -431,6 +431,17 @@ ofpbuf_reserve(struct ofpbuf *b, size_t size)
b->data = (char*)b->data + size;
}
+/* Reserves 'size' bytes of headroom so that they can be later allocated with
+ * ofpbuf_push_uninit() without reallocating the ofpbuf. */
+void
+ofpbuf_reserve_with_tailroom(struct ofpbuf *b, size_t headroom,
+ size_t tailroom)
+{
+ ovs_assert(!b->size);
+ ofpbuf_prealloc_tailroom(b, headroom + tailroom);
+ b->data = (char*)b->data + headroom;
+}
+
/* Prefixes 'size' bytes to the head end of 'b', reallocating and copying its
* data if necessary. Returns a pointer to the first byte of the data's
* location in the ofpbuf. The new data is left uninitialized. */