Allow decoding of Open Flow 1.1 & 1.2 Flow Removed Messages
authorSimon Horman <horms@verge.net.au>
Thu, 9 Aug 2012 08:49:54 +0000 (17:49 +0900)
committerBen Pfaff <blp@nicira.com>
Thu, 9 Aug 2012 18:43:18 +0000 (11:43 -0700)
Signed-off-by: Simon Horman <horms@verge.net.au>
[blp@nicira.com added support for hard_timeout, plus a test]
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ofp-util.c
tests/ofp-print.at

index a8030ff..edcc163 100644 (file)
@@ -1825,7 +1825,28 @@ ofputil_decode_flow_removed(struct ofputil_flow_removed *fr,
 
     ofpbuf_use_const(&b, oh, ntohs(oh->length));
     raw = ofpraw_pull_assert(&b);
-    if (raw == OFPRAW_OFPT10_FLOW_REMOVED) {
+    if (raw == OFPRAW_OFPT11_FLOW_REMOVED) {
+        const struct ofp12_flow_removed *ofr;
+        enum ofperr error;
+
+        ofr = ofpbuf_pull(&b, sizeof *ofr);
+
+        error = ofputil_pull_ofp11_match(&b, ntohs(ofr->priority),
+                                         &fr->rule, NULL);
+        if (error) {
+            return error;
+        }
+
+        fr->cookie = ofr->cookie;
+        fr->reason = ofr->reason;
+        /* XXX: ofr->table_id is ignored */
+        fr->duration_sec = ntohl(ofr->duration_sec);
+        fr->duration_nsec = ntohl(ofr->duration_nsec);
+        fr->idle_timeout = ntohs(ofr->idle_timeout);
+        fr->hard_timeout = ntohs(ofr->hard_timeout);
+        fr->packet_count = ntohll(ofr->packet_count);
+        fr->byte_count = ntohll(ofr->byte_count);
+    } else if (raw == OFPRAW_OFPT10_FLOW_REMOVED) {
         const struct ofp_flow_removed *ofr;
 
         ofr = ofpbuf_pull(&b, sizeof *ofr);
index 842869c..5be2ca1 100644 (file)
@@ -355,7 +355,7 @@ priority:0,tunnel:0,metadata:0,in_port:0000,tci(0) mac(00:23:20:83:c1:5f->ff:ff:
 ])
 AT_CLEANUP
 
-AT_SETUP([OFPT_FLOW_REMOVED])
+AT_SETUP([OFPT_FLOW_REMOVED - OF1.0])
 AT_KEYWORDS([ofp-print])
 AT_CHECK([ovs-ofctl ofp-print "\
 01 0b 00 58 00 00 00 00 00 00 00 00 00 03 50 54 \
@@ -369,6 +369,17 @@ OFPT_FLOW_REMOVED (xid=0x0): priority=65535,arp,in_port=3,vlan_tci=0x0000,dl_src
 ])
 AT_CLEANUP
 
+AT_SETUP([OFPT_FLOW_REMOVED - OF1.2])
+AT_KEYWORDS([ofp-print])
+AT_CHECK([ovs-ofctl ofp-print "\
+03 0b 00 40 00 00 00 00 fe dc ba 98 76 54 32 10 \
+80 00 01 05 00 00 00 01 00 98 96 80 00 3c 00 78 \
+00 00 00 00 00 12 d6 87 00 00 00 00 6f 68 ba 66 \
+00 01 00 0a 80 00 0c 02 10 09 00 00 00 00 00 00"], [0], [dnl
+OFPT_FLOW_REMOVED (OF1.2) (xid=0x0): dl_vlan=9 reason=hard cookie:0xfedcba9876543210 duration1.01s idle60 hard120 pkts1234567 bytes1869134438
+])
+AT_CLEANUP
+
 AT_SETUP([OFPT_PORT_STATUS - OF1.0])
 AT_KEYWORDS([ofp-print])
 AT_CHECK([ovs-ofctl ofp-print "\