[ovs-dev] [PATCH 18/47] ofp-util: Prepare Packet Out decoder for other Open Flow versions

Simon Horman horms at verge.net.au
Wed Aug 1 07:02:01 UTC 2012


Signed-off-by: Simon Horman <horms at verge.net.au>

---

v9
* No change

v8
* No change

v7
* Manual Rebase
* Only use OFPERR_NXBRC_BAD_IN_PORT in the case of OFPRAW_OFPT10_PACKET_OUT

v6
* No change

v5
* No change

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

Conflicts:
	lib/ofp-util.c
---
 lib/ofp-util.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 867da0e..44152c3 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -2169,29 +2169,36 @@ ofputil_decode_packet_out(struct ofputil_packet_out *po,
                           const struct ofp_header *oh,
                           struct ofpbuf *ofpacts)
 {
-    const struct ofp_packet_out *opo;
-    enum ofperr error;
     enum ofpraw raw;
     struct ofpbuf b;
+    enum ofperr bad_in_port_err = OFPERR_OFPET_BAD_REQUEST;
 
     ofpbuf_use_const(&b, oh, ntohs(oh->length));
     raw = ofpraw_pull_assert(&b);
-    assert(raw == OFPRAW_OFPT10_PACKET_OUT);
 
-    opo = ofpbuf_pull(&b, sizeof *opo);
-    po->buffer_id = ntohl(opo->buffer_id);
-    po->in_port = ntohs(opo->in_port);
+    if (raw == OFPRAW_OFPT10_PACKET_OUT) {
+        enum ofperr error;
+        const struct ofp_packet_out *opo = 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;
+        }
+        bad_in_port_err = OFPERR_NXBRC_BAD_IN_PORT;
+    } 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);
-        return OFPERR_NXBRC_BAD_IN_PORT;
+        return bad_in_port_err;
     }
 
-    error = ofpacts_pull_openflow10(&b, ntohs(opo->actions_len), ofpacts);
-    if (error) {
-        return error;
-    }
     po->ofpacts = ofpacts->data;
     po->ofpacts_len = ofpacts->size;
 
-- 
1.7.10.2.484.gcd07cc5




More information about the dev mailing list