ofp-util: Send table_id correctly in OpenFlow 1.0 flow_mods.
authorBen Pfaff <blp@nicira.com>
Wed, 15 Jun 2011 16:43:03 +0000 (09:43 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 15 Jun 2011 17:34:13 +0000 (10:34 -0700)
This fixes "ovs-ofctl add-flow <bridge> table=<number>,..." and similar
commands.

Reported-by: Hao Zheng <hzheng@nicira.com>
lib/ofp-util.c
tests/ofproto.at

index 8721b19..7ed83d7 100644 (file)
@@ -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);
index cf4f9a1..e6def3e 100644 (file)
@@ -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