[ovs-dev] [PATCH] ofp-util: Send table_id correctly in OpenFlow 1.0 flow_mods.

Ben Pfaff blp at nicira.com
Wed Jun 15 16:43:07 UTC 2011


This fixes "ovs-ofctl add-flow <bridge> table=<number>,..." and similar
commands.

Reported-by: Hao Zheng <hzheng at nicira.com>
---
 lib/ofp-util.c   |    2 +-
 tests/ofproto.at |    8 ++++++++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 8721b19..7ed83d7 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -974,7 +974,7 @@ ofputil_encode_flow_mod(const struct flow_mod *fm,
         ofm = put_openflow(sizeof *ofm, OFPT_FLOW_MOD, msg);
         ofputil_cls_rule_to_match(&fm->cr, &ofm->match);
         ofm->cookie = fm->cookie;
-        ofm->command = htons(fm->command);
+        ofm->command = htons(command);
         ofm->idle_timeout = htons(fm->idle_timeout);
         ofm->hard_timeout = htons(fm->hard_timeout);
         ofm->priority = htons(fm->cr.priority);
diff --git a/tests/ofproto.at b/tests/ofproto.at
index cf4f9a1..e6def3e 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -48,6 +48,10 @@ AT_CHECK([ovs-ofctl dump-flows br0 | STRIP_XIDS], [0], [NXST_FLOW reply:
 ])
 AT_CHECK([echo 'in_port=1,actions=0' | ovs-ofctl add-flows br0 -])
 AT_CHECK([ovs-ofctl add-flow br0 in_port=0,actions=1])
+# Check that a table_id is really sent:
+AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=0,actions=1 2>&1 | STRIP_XIDS | sed 1q], [0], [dnl
+OFPT_ERROR: type OFPET_FLOW_MOD_FAILED, code NXFMFC_BAD_TABLE_ID
+])
 AT_CHECK([ovs-ofctl dump-flows br0 | STRIP_XIDS | STRIP_DURATION | sort], [0], [dnl
  cookie=0x0, duration=?s, table=0, n_packets=0, n_bytes=0, in_port=0 actions=output:1
  cookie=0x0, duration=?s, table=0, n_packets=0, n_bytes=0, in_port=1 actions=output:0
@@ -68,6 +72,10 @@ AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | STRIP_XIDS], [0], [OFPST_FLOW
 ])
 AT_CHECK([echo 'in_port=1,actions=0' | ovs-ofctl -F openflow10 add-flows br0 -])
 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=0,actions=1])
+# Check that a table_id is really sent:
+AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=0,actions=1 2>&1 | STRIP_XIDS | sed 1q], [0], [dnl
+OFPT_ERROR: type OFPET_FLOW_MOD_FAILED, code NXFMFC_BAD_TABLE_ID
+])
 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | STRIP_XIDS | STRIP_DURATION | sort], [0], [dnl
  cookie=0x0, duration=?s, table=0, n_packets=0, n_bytes=0, in_port=0 actions=output:1
  cookie=0x0, duration=?s, table=0, n_packets=0, n_bytes=0, in_port=1 actions=output:0
-- 
1.7.4.4




More information about the dev mailing list