aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEthan Jackson <ethan@nicira.com>2012-01-03 14:22:44 -0800
committerEthan Jackson <ethan@nicira.com>2012-01-10 14:30:15 -0800
commit29ebe8803c3a1ef03cbc92fbc352a2cdce5a8f55 (patch)
tree22fa2f5a59f86e647cd245d3abea701bf23d163f /lib
parent15056dc8aa9e62a96c8f9b9a6e2c90d086e3a01d (diff)
ofproto: Always clone packets in PACKET_IN message.
This patch removes an optimization which significantly complicates the code in ways which would get worse in future patches if not removed. Furthermore, future patches will have fewer cases which can take advantage of the optimization further mitigating its justification. Signed-off-by: Ethan Jackson <ethan@nicira.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/ofp-util.c29
-rw-r--r--lib/ofp-util.h3
2 files changed, 7 insertions, 25 deletions
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 42dab87f..bf7a82b6 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -1543,34 +1543,17 @@ ofputil_encode_flow_removed(const struct ofputil_flow_removed *fr,
}
/* Converts abstract ofputil_packet_in 'pin' into an OFPT_PACKET_IN message
- * and returns the message.
- *
- * If 'rw_packet' is NULL, the caller takes ownership of the newly allocated
- * returned ofpbuf.
- *
- * If 'rw_packet' is nonnull, then it must contain the same data as
- * pin->packet. 'rw_packet' is allowed to be the same ofpbuf as pin->packet.
- * It is modified in-place into an OFPT_PACKET_IN message according to 'pin',
- * and then ofputil_encode_packet_in() returns 'rw_packet'. If 'rw_packet' has
- * enough headroom to insert a "struct ofp_packet_in", this is more efficient
- * than ofputil_encode_packet_in() because it does not copy the packet
- * payload. */
+ * and returns the message. */
struct ofpbuf *
-ofputil_encode_packet_in(const struct ofputil_packet_in *pin,
- struct ofpbuf *rw_packet)
+ofputil_encode_packet_in(const struct ofputil_packet_in *pin)
{
int total_len = pin->packet->size;
struct ofp_packet_in opi;
+ struct ofpbuf *rw_packet;
- if (rw_packet) {
- if (pin->send_len < rw_packet->size) {
- rw_packet->size = pin->send_len;
- }
- } else {
- rw_packet = ofpbuf_clone_data_with_headroom(
- pin->packet->data, MIN(pin->send_len, pin->packet->size),
- offsetof(struct ofp_packet_in, data));
- }
+ rw_packet = ofpbuf_clone_data_with_headroom(
+ pin->packet->data, MIN(pin->send_len, pin->packet->size),
+ offsetof(struct ofp_packet_in, data));
/* Add OFPT_PACKET_IN. */
memset(&opi, 0, sizeof opi);
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index 8fa729e9..adff0d9b 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -222,8 +222,7 @@ struct ofputil_packet_in {
int send_len;
};
-struct ofpbuf *ofputil_encode_packet_in(const struct ofputil_packet_in *,
- struct ofpbuf *rw_packet);
+struct ofpbuf *ofputil_encode_packet_in(const struct ofputil_packet_in *);
/* OpenFlow protocol utility functions. */
void *make_openflow(size_t openflow_len, uint8_t type, struct ofpbuf **);