Signed-off-by: Simon Horman <ho...@verge.net.au> ---
v4 * No change v3 * Differentiate versions using oh->version rather than relying on a separate code for each version of the Packet Out message. v2 * No change --- lib/ofp-print.c | 4 ++-- lib/ofp-util.c | 35 +++++++++++++++++++++++------------ lib/ofp-util.h | 2 +- ofproto/ofproto.c | 4 ++-- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/lib/ofp-print.c b/lib/ofp-print.c index f8867c3..252c9f2 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -148,7 +148,7 @@ ofp_print_packet_in(struct ds *string, const struct ofp_header *oh, } static void -ofp_print_packet_out(struct ds *string, const struct ofp_packet_out *opo, +ofp_print_packet_out(struct ds *string, const struct ofp_header *oh, int verbosity) { struct ofputil_packet_out po; @@ -156,7 +156,7 @@ ofp_print_packet_out(struct ds *string, const struct ofp_packet_out *opo, enum ofperr error; ofpbuf_init(&ofpacts, 64); - error = ofputil_decode_packet_out(&po, opo, &ofpacts); + error = ofputil_decode_packet_out(&po, oh, &ofpacts); if (error) { ofpbuf_uninit(&ofpacts); ofp_print_error(string, error); diff --git a/lib/ofp-util.c b/lib/ofp-util.c index cdbb303..09739b2 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -2705,28 +2705,39 @@ ofputil_packet_in_reason_from_string(const char *s, * Returns 0 if successful, otherwise an OFPERR_* value. */ enum ofperr ofputil_decode_packet_out(struct ofputil_packet_out *po, - const struct ofp_packet_out *opo, + const struct ofp_header *oh, struct ofpbuf *ofpacts) { - enum ofperr error; struct ofpbuf b; - po->buffer_id = ntohl(opo->buffer_id); - po->in_port = ntohs(opo->in_port); + memset(po, 0, sizeof *po); + + ofpbuf_use_const(&b, oh, ntohs(oh->length)); + + if (oh->version == OFP10_VERSION) { + const struct ofp_packet_out *opo = (const struct ofp_packet_out *) oh; + enum ofperr error; + + ofpbuf_pull(&b, sizeof *opo); + + po->buffer_id = ntohl(opo->buffer_id); + po->in_port = ntohs(opo->in_port); + + error = ofpacts_pull_openflow10(&b, ntohs(opo->actions_len), ofpacts); + if (error) { + return error; + } + } else { + NOT_REACHED(); + } + if (po->in_port >= OFPP_MAX && po->in_port != OFPP_LOCAL && po->in_port != OFPP_NONE && po->in_port != OFPP_CONTROLLER) { VLOG_WARN_RL(&bad_ofmsg_rl, "packet-out has bad input port %#"PRIx16, - po->in_port); + po->in_port); return OFPERR_NXBRC_BAD_IN_PORT; } - ofpbuf_use_const(&b, opo, ntohs(opo->header.length)); - ofpbuf_pull(&b, sizeof *opo); - - error = ofpacts_pull_openflow10(&b, ntohs(opo->actions_len), ofpacts); - if (error) { - return error; - } po->ofpacts = ofpacts->data; po->ofpacts_len = ofpacts->size; diff --git a/lib/ofp-util.h b/lib/ofp-util.h index 0f5b3cd..33e6a95 100644 --- a/lib/ofp-util.h +++ b/lib/ofp-util.h @@ -376,7 +376,7 @@ struct ofputil_packet_out { }; enum ofperr ofputil_decode_packet_out(struct ofputil_packet_out *, - const struct ofp_packet_out *, + const struct ofp_header *, struct ofpbuf *ofpacts); struct ofpbuf *ofputil_encode_packet_out(const struct ofputil_packet_out *); diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 745266e..2a95636 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1999,7 +1999,7 @@ reject_slave_controller(struct ofconn *ofconn) } static enum ofperr -handle_packet_out(struct ofconn *ofconn, const struct ofp_packet_out *opo) +handle_packet_out(struct ofconn *ofconn, const struct ofp_header *oh) { struct ofproto *p = ofconn_get_ofproto(ofconn); struct ofputil_packet_out po; @@ -2018,7 +2018,7 @@ handle_packet_out(struct ofconn *ofconn, const struct ofp_packet_out *opo) /* Decode message. */ ofpbuf_use_stub(&ofpacts, ofpacts_stub, sizeof ofpacts_stub); - error = ofputil_decode_packet_out(&po, opo, &ofpacts); + error = ofputil_decode_packet_out(&po, oh, &ofpacts); if (error) { goto exit_free_ofpacts; } -- 1.7.10.2.484.gcd07cc5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev