This patch adds support for OFPR_ACTION_SET as the packet-in reason when
a Packet-In message is triggered by an output action within an
action-set. By default reason code OFPR_ACTION_SET is enabled for async
messages when Openflow 1.4+ is used. A test case is included.

Signed-off-by: Shu Shen <shu.s...@radisys.com>
---

Changes in V2:
 - A new flag in_action_set is added to xlate_ctx to indicate the output action
   is part of action_set. This corrects earlier detection method.
 - Test cases for OFPR_GROUP and OFPR_ACTION_SET packet-in reasons are combined
   and coverage for OFPR_ACTION is also added.

 DESIGN.md                    |  1 +
 OPENFLOW-1.1+.md             |  2 +-
 ofproto/connmgr.c            |  5 +++
 ofproto/ofproto-dpif-xlate.c | 15 +++++++--
 tests/ofproto-dpif.at        | 72 ++++++++++++++++++++++++++++++++++++--------
 5 files changed, 80 insertions(+), 15 deletions(-)

diff --git a/DESIGN.md b/DESIGN.md
index ff5bdf4..4d94c2d 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -54,6 +54,7 @@ sent, an entry labeled "---" means that the message is 
suppressed.
     OFPR_NO_MATCH                              yes       ---
     OFPR_ACTION                                yes       ---
     OFPR_INVALID_TTL                           ---       ---
+    OFPR_ACTION_SET (OF1.4+)                   yes       ---
     OFPR_GROUP (OF1.4+)                        yes       ---
 
   OFPT_FLOW_REMOVED / NXT_FLOW_REMOVED
diff --git a/OPENFLOW-1.1+.md b/OPENFLOW-1.1+.md
index 967f906..7911406 100644
--- a/OPENFLOW-1.1+.md
+++ b/OPENFLOW-1.1+.md
@@ -197,7 +197,7 @@ OpenFlow 1.4 features are listed in the previous section.
   * More descriptive reasons for packet-in
     Distinguish OFPR_APPLY_ACTION, OFPR_ACTION_SET, OFPR_GROUP,
     OFPR_PACKET_OUT.  NO_MATCH was renamed to OFPR_TABLE_MISS.
-    (OFPR_GROUP is now supported)
+    (OFPR_ACTION_SET and OFPR_GROUP are now supported)
     [EXT-136]
     [required for OF1.4+]
 
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 3d69122..82143aa 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -1000,6 +1000,10 @@ ofconn_set_protocol(struct ofconn *ofconn, enum 
ofputil_protocol protocol)
         uint32_t *master = ofconn->master_async_config;
         uint32_t *slave = ofconn->slave_async_config;
 
+        /* OFPR_ACTION_SET is not supported before OF1.4 */
+        master[OAM_PACKET_IN] &= ~(1u << OFPR_ACTION_SET);
+        slave [OAM_PACKET_IN] &= ~(1u << OFPR_ACTION_SET);
+
         /* OFPR_GROUP is not supported before OF1.4 */
         master[OAM_PACKET_IN] &= ~(1u << OFPR_GROUP);
         slave [OAM_PACKET_IN] &= ~(1u << OFPR_GROUP);
@@ -1252,6 +1256,7 @@ ofconn_flush(struct ofconn *ofconn)
          * reasons itself. */
         master[OAM_PACKET_IN] = ((1u << OFPR_NO_MATCH)
                                  | (1u << OFPR_ACTION)
+                                 | (1u << OFPR_ACTION_SET)
                                  | (1u << OFPR_GROUP));
         master[OAM_PORT_STATUS] = ((1u << OFPPR_ADD)
                                    | (1u << OFPPR_DELETE)
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 0786513..8a47531 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -196,6 +196,7 @@ struct xlate_ctx {
     int recurse;                /* Current resubmit nesting depth. */
     int resubmits;              /* Total number of resubmits. */
     bool in_group;              /* Currently translating ofgroup, if true. */
+    bool in_action_set;         /* Currently translating action_set, if true. 
*/
 
     uint32_t orig_skb_priority; /* Priority when packet arrived. */
     uint8_t table_id;           /* OpenFlow table ID where flow was found. */
@@ -3429,8 +3430,15 @@ xlate_output_action(struct xlate_ctx *ctx,
         flood_packets(ctx, true);
         break;
     case OFPP_CONTROLLER:
-        execute_controller_action(ctx, max_len,
-                                  ctx->in_group ? OFPR_GROUP : OFPR_ACTION, 0);
+        {
+            enum ofp_packet_in_reason reason = OFPR_ACTION;
+            if (ctx->in_group){
+                    reason = OFPR_GROUP;
+            }else if (ctx->in_action_set){
+                    reason = OFPR_ACTION_SET;
+            }
+            execute_controller_action(ctx, max_len, reason, 0);
+        }
         break;
     case OFPP_NONE:
         break;
@@ -3712,9 +3720,11 @@ xlate_action_set(struct xlate_ctx *ctx)
     uint64_t action_list_stub[1024 / 64];
     struct ofpbuf action_list;
 
+    ctx->in_action_set = true;
     ofpbuf_use_stub(&action_list, action_list_stub, sizeof action_list_stub);
     ofpacts_execute_action_set(&action_list, &ctx->action_set);
     do_xlate_actions(ofpbuf_data(&action_list), ofpbuf_size(&action_list), 
ctx);
+    ctx->in_action_set = false;
     ofpbuf_uninit(&action_list);
 }
 
@@ -4398,6 +4408,7 @@ xlate_actions(struct xlate_in *xin, struct xlate_out 
*xout)
     ctx.recurse = 0;
     ctx.resubmits = 0;
     ctx.in_group = false;
+    ctx.in_action_set = false;
     ctx.orig_skb_priority = flow->skb_priority;
     ctx.table_id = 0;
     ctx.exit = false;
diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
index e479e13..defb5fc 100644
--- a/tests/ofproto-dpif.at
+++ b/tests/ofproto-dpif.at
@@ -2826,17 +2826,20 @@ OVS_VSWITCHD_STOP
 AT_CLEANUP
 
 
-
-AT_SETUP([ofproto-dpif - packet-in reason in group table (Openflow 1.3)])
+AT_SETUP([ofproto-dpif - packet-in reasons (Openflow 1.3)])
 OVS_VSWITCHD_START([dnl
    add-port br0 p1 -- set Interface p1 type=dummy
 ])
 ON_EXIT([kill `cat ovs-ofctl.pid`])
 
 AT_CAPTURE_FILE([ofctl_monitor.log])
-# A table-miss flow has priority 0 and no match
+AT_DATA([flows.txt], [dnl
+table=0 in_port=1 actions=write_actions(output(CONTROLLER)),goto_table(1)
+table=1 actions=output(CONTROLLER),goto_table(2)
+table=2 actions=group:1234
+])
 AT_CHECK([ovs-ofctl --protocols=OpenFlow13 add-group br0 
'group_id=1234,type=all,bucket=output:10,bucket=output:CONTROLLER'])
-AT_CHECK([ovs-ofctl --protocols=OpenFlow13 add-flow br0 'in_port=1 
actions=group:1234'])
+AT_CHECK([ovs-ofctl --protocols=OpenFlow13 add-flows br0 flows.txt])
 
 dnl Singleton controller action.
 AT_CHECK([ovs-ofctl monitor -P openflow10 --protocols=OpenFlow13 br0 65534 
--detach --no-chdir --pidfile 2> ofctl_monitor.log])
@@ -2850,12 +2853,30 @@ ovs-appctl -t ovs-ofctl exit
 AT_CHECK([ovs-appctl time/warp 5000], [0], [ignore])
 
 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
+OFPT_PACKET_IN (OF1.3) (xid=0x0): table_id=1 cookie=0x0 total_len=60 in_port=1 
(via action) data_len=60 (unbuffered)
+tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
+dnl
+OFPT_PACKET_IN (OF1.3) (xid=0x0): table_id=2 cookie=0x0 total_len=60 in_port=1 
(via action) data_len=60 (unbuffered)
+tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
+dnl
 OFPT_PACKET_IN (OF1.3) (xid=0x0): cookie=0x0 total_len=60 in_port=1 (via 
action) data_len=60 (unbuffered)
 
tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
 dnl
+OFPT_PACKET_IN (OF1.3) (xid=0x0): table_id=1 cookie=0x0 total_len=60 in_port=1 
(via action) data_len=60 (unbuffered)
+tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
+dnl
+OFPT_PACKET_IN (OF1.3) (xid=0x0): table_id=2 cookie=0x0 total_len=60 in_port=1 
(via action) data_len=60 (unbuffered)
+tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
+dnl
 OFPT_PACKET_IN (OF1.3) (xid=0x0): cookie=0x0 total_len=60 in_port=1 (via 
action) data_len=60 (unbuffered)
 
tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
 dnl
+OFPT_PACKET_IN (OF1.3) (xid=0x0): table_id=1 cookie=0x0 total_len=60 in_port=1 
(via action) data_len=60 (unbuffered)
+tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
+dnl
+OFPT_PACKET_IN (OF1.3) (xid=0x0): table_id=2 cookie=0x0 total_len=60 in_port=1 
(via action) data_len=60 (unbuffered)
+tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
+dnl
 OFPT_PACKET_IN (OF1.3) (xid=0x0): cookie=0x0 total_len=60 in_port=1 (via 
action) data_len=60 (unbuffered)
 
tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
 ])
@@ -2863,7 +2884,9 @@ 
tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,
 AT_CHECK([ovs-appctl time/warp 5000], [0], [ignore])
 
 AT_CHECK([ovs-ofctl --protocols=OpenFlow13 dump-flows br0 | ofctl_strip | 
sort], [0], [dnl
- n_packets=3, n_bytes=180, in_port=1 actions=group:1234
+ n_packets=3, n_bytes=180, in_port=1 
actions=write_actions(CONTROLLER:65535),goto_table:1
+ table=1, n_packets=3, n_bytes=180, actions=CONTROLLER:65535,goto_table:2
+ table=2, n_packets=3, n_bytes=180, actions=group:1234
 OFPST_FLOW reply (OF1.3):
 ])
 
@@ -2871,16 +2894,20 @@ OVS_VSWITCHD_STOP
 AT_CLEANUP
 
 
-AT_SETUP([ofproto-dpif - packet-in reason in group table (Openflow 1.4)])
+AT_SETUP([ofproto-dpif - packet-in reasons (Openflow 1.4)])
 OVS_VSWITCHD_START([dnl
    add-port br0 p1 -- set Interface p1 type=dummy
 ])
 ON_EXIT([kill `cat ovs-ofctl.pid`])
 
 AT_CAPTURE_FILE([ofctl_monitor.log])
-# A table-miss flow has priority 0 and no match
+AT_DATA([flows.txt], [dnl
+table=0 in_port=1 actions=write_actions(output(CONTROLLER)),goto_table(1)
+table=1 actions=output(CONTROLLER),goto_table(2)
+table=2 actions=group:1234
+])
 AT_CHECK([ovs-ofctl --protocols=OpenFlow14 add-group br0 
'group_id=1234,type=all,bucket=output:10,bucket=output:CONTROLLER'])
-AT_CHECK([ovs-ofctl --protocols=OpenFlow14 add-flow br0 'in_port=1 
actions=group:1234'])
+AT_CHECK([ovs-ofctl --protocols=OpenFlow14 add-flows br0 flows.txt])
 
 dnl Singleton controller action.
 AT_CHECK([ovs-ofctl monitor -P openflow10 --protocols=OpenFlow14 br0 65534 
--detach --no-chdir --pidfile 2> ofctl_monitor.log])
@@ -2894,26 +2921,47 @@ ovs-appctl -t ovs-ofctl exit
 AT_CHECK([ovs-appctl time/warp 5000], [0], [ignore])
 
 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
-OFPT_PACKET_IN (OF1.4) (xid=0x0): cookie=0x0 total_len=60 in_port=1 (via 
group) data_len=60 (unbuffered)
+OFPT_PACKET_IN (OF1.4) (xid=0x0): table_id=1 cookie=0x0 total_len=60 in_port=1 
(via action) data_len=60 (unbuffered)
+tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
+dnl
+OFPT_PACKET_IN (OF1.4) (xid=0x0): table_id=2 cookie=0x0 total_len=60 in_port=1 
(via group) data_len=60 (unbuffered)
+tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
+dnl
+OFPT_PACKET_IN (OF1.4) (xid=0x0): cookie=0x0 total_len=60 in_port=1 (via 
action_set) data_len=60 (unbuffered)
+tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
+dnl
+OFPT_PACKET_IN (OF1.4) (xid=0x0): table_id=1 cookie=0x0 total_len=60 in_port=1 
(via action) data_len=60 (unbuffered)
+tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
+dnl
+OFPT_PACKET_IN (OF1.4) (xid=0x0): table_id=2 cookie=0x0 total_len=60 in_port=1 
(via group) data_len=60 (unbuffered)
+tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
+dnl
+OFPT_PACKET_IN (OF1.4) (xid=0x0): cookie=0x0 total_len=60 in_port=1 (via 
action_set) data_len=60 (unbuffered)
+tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
+dnl
+OFPT_PACKET_IN (OF1.4) (xid=0x0): table_id=1 cookie=0x0 total_len=60 in_port=1 
(via action) data_len=60 (unbuffered)
 
tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
 dnl
-OFPT_PACKET_IN (OF1.4) (xid=0x0): cookie=0x0 total_len=60 in_port=1 (via 
group) data_len=60 (unbuffered)
+OFPT_PACKET_IN (OF1.4) (xid=0x0): table_id=2 cookie=0x0 total_len=60 in_port=1 
(via group) data_len=60 (unbuffered)
 
tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
 dnl
-OFPT_PACKET_IN (OF1.4) (xid=0x0): cookie=0x0 total_len=60 in_port=1 (via 
group) data_len=60 (unbuffered)
+OFPT_PACKET_IN (OF1.4) (xid=0x0): cookie=0x0 total_len=60 in_port=1 (via 
action_set) data_len=60 (unbuffered)
 
tcp,in_port=0,vlan_tci=0x0000,dl_src=10:11:11:11:11:11,dl_dst=50:54:00:00:00:07,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=8,tp_dst=10,tcp_flags=syn
 tcp_csum:0
 ])
 
 AT_CHECK([ovs-appctl time/warp 5000], [0], [ignore])
 
 AT_CHECK([ovs-ofctl --protocols=OpenFlow14 dump-flows br0 | ofctl_strip | 
sort], [0], [dnl
- n_packets=3, n_bytes=180, in_port=1 actions=group:1234
+ n_packets=3, n_bytes=180, in_port=1 
actions=write_actions(CONTROLLER:65535),goto_table:1
+ table=1, n_packets=3, n_bytes=180, actions=CONTROLLER:65535,goto_table:2
+ table=2, n_packets=3, n_bytes=180, actions=group:1234
 OFPST_FLOW reply (OF1.4):
 ])
 
 OVS_VSWITCHD_STOP
 AT_CLEANUP
 
+
 AT_SETUP([ofproto-dpif - ARP modification slow-path])
 OVS_VSWITCHD_START
 ADD_OF_PORTS([br0], [1], [2])
-- 
1.9.1

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to