[ovs-dev] [PATCH] ofp-actions: Treat OFPACT_REG_MOVE with reg/metadata src as set action

Thomas Graf tgraf at noironetworks.com
Wed Aug 13 13:34:27 UTC 2014


This makes the following work:
add-group br0 group_id=1234,type=all, \
              bucket=output:10,move:NXM_NX_REG1[]->NXM_OF_IP_SRC[], \
			  bucket=output:11
add-flow br0 ip actions=load:0xffffffff->NXM_NX_REG1[],group:1234

Signed-off-by: Thomas Graf <tgraf at noironetworks.com>
---
 lib/ofp-actions.c     | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 tests/ofproto-dpif.at | 14 ++++++++++
 2 files changed, 89 insertions(+), 1 deletion(-)

diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index ed30ec2..a06ff3f 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -4273,6 +4273,76 @@ ofpacts_pull_openflow_actions(struct ofpbuf *openflow,
 
 /* OpenFlow 1.1 actions. */
 
+static bool ofpact_reg_move_has_const_src(const struct ofpact *a)
+{
+    const struct ofpact_reg_move *rm = ofpact_get_REG_MOVE(a);
+
+    switch (rm->src.field->id) {
+    case MFF_DP_HASH:
+    case MFF_RECIRC_ID:
+    case MFF_TUN_ID:
+    case MFF_TUN_SRC:
+    case MFF_TUN_DST:
+    case MFF_TUN_FLAGS:
+    case MFF_TUN_TTL:
+    case MFF_TUN_TOS:
+    case MFF_IN_PORT:
+    case MFF_IN_PORT_OXM:
+    case MFF_SKB_PRIORITY:
+    case MFF_PKT_MARK:
+    case MFF_ETH_SRC:
+    case MFF_ETH_DST:
+    case MFF_ETH_TYPE:
+    case MFF_VLAN_TCI:
+    case MFF_DL_VLAN:
+    case MFF_VLAN_VID:
+    case MFF_DL_VLAN_PCP:
+    case MFF_VLAN_PCP:
+    case MFF_MPLS_LABEL:
+    case MFF_MPLS_TC:
+    case MFF_MPLS_BOS:
+    case MFF_IPV4_SRC:
+    case MFF_IPV4_DST:
+    case MFF_IPV6_SRC:
+    case MFF_IPV6_DST:
+    case MFF_IPV6_LABEL:
+    case MFF_IP_PROTO:
+    case MFF_IP_DSCP:
+    case MFF_IP_DSCP_SHIFTED:
+    case MFF_IP_ECN:
+    case MFF_IP_TTL:
+    case MFF_IP_FRAG:
+    case MFF_ARP_OP:
+    case MFF_ARP_SPA:
+    case MFF_ARP_TPA:
+    case MFF_ARP_SHA:
+    case MFF_ND_SLL:
+    case MFF_ARP_THA:
+    case MFF_ND_TLL:
+    case MFF_TCP_SRC:
+    case MFF_UDP_SRC:
+    case MFF_SCTP_SRC:
+    case MFF_TCP_DST:
+    case MFF_UDP_DST:
+    case MFF_SCTP_DST:
+    case MFF_TCP_FLAGS:
+    case MFF_ICMPV4_TYPE:
+    case MFF_ICMPV6_TYPE:
+    case MFF_ICMPV4_CODE:
+    case MFF_ICMPV6_CODE:
+    case MFF_ND_TARGET:
+        return false;
+
+    case MFF_METADATA:
+    CASE_MFF_REGS:
+    CASE_MFF_XREGS:
+        return true;
+
+    case MFF_N_IDS:
+    default:
+        OVS_NOT_REACHED();
+    }
+}
 
 /* True if an action sets the value of a field
  * in a way that is compatibile with the action set.
@@ -4300,6 +4370,11 @@ ofpact_is_set_action(const struct ofpact *a)
     case OFPACT_SET_VLAN_PCP:
     case OFPACT_SET_VLAN_VID:
         return true;
+    case OFPACT_REG_MOVE:
+        if (ofpact_reg_move_has_const_src(a)) {
+            return true;
+        }
+        /* fall through */
     case OFPACT_BUNDLE:
     case OFPACT_CLEAR_ACTIONS:
     case OFPACT_CONTROLLER:
@@ -4320,7 +4395,6 @@ ofpact_is_set_action(const struct ofpact *a)
     case OFPACT_POP_QUEUE:
     case OFPACT_PUSH_MPLS:
     case OFPACT_PUSH_VLAN:
-    case OFPACT_REG_MOVE:
     case OFPACT_RESUBMIT:
     case OFPACT_SAMPLE:
     case OFPACT_STACK_POP:
diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
index 3b434f8..ee1ab4c 100644
--- a/tests/ofproto-dpif.at
+++ b/tests/ofproto-dpif.at
@@ -263,6 +263,20 @@ Datapath actions: set(ipv4(src=192.168.3.90,dst=192.168.0.2,proto=1,tos=0,ttl=12
 OVS_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([ofproto-dpif - const src move action in group bucket])
+OVS_VSWITCHD_START
+ADD_OF_PORTS([br0], [1], [10], [11])
+AT_CHECK([ovs-ofctl -O OpenFlow12 add-group br0 'group_id=1234,type=all,bucket=output:10,move:NXM_NX_REG1[[]]->NXM_OF_IP_SRC[[]],bucket=output:11'])
+AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 'ip actions=write_actions(load:0xffffffff->NXM_NX_REG1[[]],group:1234)'])
+AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=1,nw_tos=0,nw_ttl=128,icmp_type=8,icmp_code=0'], [0], [stdout])
+AT_CHECK([tail -2 stdout], [0],
+  [Megaflow: recirc_id=0,skb_priority=0,icmp,in_port=1,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,nw_ecn=0,nw_ttl=128
+Datapath actions: set(ipv4(src=255.255.255.255,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no)),10,set(ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no)),11
+])
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+
 AT_SETUP([ofproto-dpif - indirect group in action set])
 OVS_VSWITCHD_START
 ADD_OF_PORTS([br0], [1], [10])
-- 
1.9.3




More information about the dev mailing list