From eefbf18198a131d479762b1d37be3552e7271acb Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Thu, 9 Aug 2012 17:49:54 +0900 Subject: [PATCH] Allow decoding of Open Flow 1.1 & 1.2 Flow Removed Messages Signed-off-by: Simon Horman [blp@nicira.com added support for hard_timeout, plus a test] Signed-off-by: Ben Pfaff --- lib/ofp-util.c | 23 ++++++++++++++++++++++- tests/ofp-print.at | 13 ++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/lib/ofp-util.c b/lib/ofp-util.c index a8030ff58..edcc1636d 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -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); diff --git a/tests/ofp-print.at b/tests/ofp-print.at index 842869c27..5be2ca1a7 100644 --- a/tests/ofp-print.at +++ b/tests/ofp-print.at @@ -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 "\ -- 2.43.0