From: Simon Horman Date: Tue, 7 Aug 2012 21:49:45 +0000 (+0900) Subject: ofp-util: Allow decoding of Open Flow 1.1 and 1.2 Packet Out Messages X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb5ee596d9cb52885fdb65ab3b534f64f22bb149;p=openvswitch ofp-util: Allow decoding of Open Flow 1.1 and 1.2 Packet Out Messages Signed-off-by: Simon Horman Signed-off-by: Ben Pfaff --- diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 64eb5ca6..6b92dcdb 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -2149,13 +2149,31 @@ ofputil_decode_packet_out(struct ofputil_packet_out *po, const struct ofp_header *oh, struct ofpbuf *ofpacts) { + enum ofperr bad_in_port_err; enum ofpraw raw; struct ofpbuf b; ofpbuf_use_const(&b, oh, ntohs(oh->length)); raw = ofpraw_pull_assert(&b); - if (raw == OFPRAW_OFPT10_PACKET_OUT) { + if (raw == OFPRAW_OFPT11_PACKET_OUT) { + enum ofperr error; + const struct ofp11_packet_out *opo = ofpbuf_pull(&b, sizeof *opo); + + po->buffer_id = ntohl(opo->buffer_id); + error = ofputil_port_from_ofp11(opo->in_port, &po->in_port); + if (error) { + return error; + } + + error = ofpacts_pull_openflow11_actions(&b, ntohs(opo->actions_len), + ofpacts); + if (error) { + return error; + } + + bad_in_port_err = OFPERR_OFPBMC_BAD_VALUE; + } else if (raw == OFPRAW_OFPT10_PACKET_OUT) { enum ofperr error; const struct ofp_packet_out *opo = ofpbuf_pull(&b, sizeof *opo); @@ -2166,6 +2184,8 @@ ofputil_decode_packet_out(struct ofputil_packet_out *po, if (error) { return error; } + + bad_in_port_err = OFPERR_NXBRC_BAD_IN_PORT; } else { NOT_REACHED(); } @@ -2174,7 +2194,7 @@ ofputil_decode_packet_out(struct ofputil_packet_out *po, && 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); - return OFPERR_NXBRC_BAD_IN_PORT; + return bad_in_port_err; } po->ofpacts = ofpacts->data; diff --git a/tests/ofp-print.at b/tests/ofp-print.at index 2c4e6c57..842869c2 100644 --- a/tests/ofp-print.at +++ b/tests/ofp-print.at @@ -406,7 +406,7 @@ OFPT_PORT_STATUS (OF1.1) (xid=0x0): MOD: 3(eth0): addr:50:54:00:00:00:01 ]) AT_CLEANUP -AT_SETUP([OFPT_PACKET_OUT]) +AT_SETUP([OFPT_PACKET_OUT - OF1.0]) AT_KEYWORDS([ofp-print]) AT_CHECK([ovs-ofctl ofp-print "\ 01 0d 00 54 00 00 00 00 00 00 01 14 00 01 00 08 \ @@ -420,6 +420,17 @@ OFPT_PACKET_OUT (xid=0x0): in_port=1 actions=output:3 buffer=0x00000114 ]) AT_CLEANUP +AT_SETUP([OFPT_PACKET_OUT - OF1.1]) +AT_KEYWORDS([ofp-print]) +AT_CHECK([ovs-ofctl ofp-print "\ +03 0d 00 28 88 58 df c5 ff ff ff 00 ff ff ff fe \ +00 10 00 00 00 00 00 00 00 00 00 10 ff ff ff fb \ +05 dc 00 00 00 00 00 00 \ +"], [0], [dnl +OFPT_PACKET_OUT (OF1.2) (xid=0x8858dfc5): in_port=LOCAL actions=FLOOD buffer=0xffffff00 +]) +AT_CLEANUP + # The flow is formatted with cls_rule_format() for the low-verbosity case. AT_SETUP([OFPT_FLOW_MOD - OF1.0 - low verbosity]) AT_KEYWORDS([ofp-print])