]> git.proxmox.com Git - ovs.git/blobdiff - tests/ofp-actions.at
System tests: Enable ALGs for userspace.
[ovs.git] / tests / ofp-actions.at
index 9fbae5e3d6d4757e2eb2688fd6e6e4b155018eac..e320a92a8f6fd996eb77cca800ed04611009efaf 100644 (file)
@@ -91,6 +91,9 @@ ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
 # actions=resubmit(10,5)
 ffff 0010 00002320 000e 000a 05 000000
 
+# actions=resubmit(10,5,ct)
+ffff 0010 00002320 002c 000a 05 000000
+
 # actions=output:NXM_NX_REG1[5..10]
 ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
 
@@ -113,12 +116,200 @@ ffff 0010 00002320 0013 000a 0014 0000
 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
 ffff 0010 00002320 0014 04d2 162e 02 00
 
+# actions=controller(reason=invalid_ttl,max_len=1234,id=5678,userdata=01.02.03.04.05,pause)
+ffff 0040 00002320 0025   000000000000 dnl
+0000 0008 04d2   0000 dnl
+0001 0008 162e   0000 dnl
+0002 0005 02   000000 dnl
+0003 0009 0102030405   00000000000000 dnl
+0004 0004   00000000
+
 # actions=dec_ttl(32768,12345,90,765,1024)
 ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
 
 # actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
 ffff 0018 00002320 001d 3039 00005BA0 00008707 0000B26E
 
+# actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678,sampling_port=56789)
+ffff 0020 00002320 0026 3039 00005BA0 00008707 0000B26E DDD50000 00000000
+
+# actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678,sampling_port=56789,egress)
+ffff 0020 00002320 0029 3039 00005BA0 00008707 0000B26E DDD50200 00000000
+
+# bad OpenFlow10 actions: OFPBAC_BAD_LEN
+& ofp_actions|WARN|OpenFlow action OFPAT_OUTPUT length 240 exceeds action buffer length 8
+& ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_LEN):
+& 00000000  00 00 00 f0 00 00 00 00-
+00 00 00 f0 00 00 00 00
+
+# bad OpenFlow10 actions: OFPBAC_BAD_LEN
+& ofp_actions|WARN|OpenFlow action OFPAT_OUTPUT length 16 not in valid range [[8,8]]
+& ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_LEN):
+& 00000000  00 00 00 10 ff fe ff ff-00 00 00 00 00 00 00 00
+00 00 00 10 ff fe ff ff 00 00 00 00 00 00 00 00
+
+# bad OpenFlow10 actions: OFPBAC_BAD_LEN
+& ofp_actions|WARN|OpenFlow action NXAST_DEC_TTL_CNT_IDS length 17 is not a multiple of 8
+ffff 0011 00002320 0015 0001 00000000 0000000000000000
+
+# bad OpenFlow10 actions: OFPBAC_BAD_OUT_PORT
+0000 0008 ffff 0000
+
+# actions=ct()
+ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0000
+
+# actions=ct(commit)
+ffff 0018 00002320 0023 0001 00000000 0000 FF 000000 0000
+
+# actions=ct(commit,force)
+ffff 0018 00002320 0023 0003 00000000 0000 FF 000000 0000
+
+# bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
+ffff 0018 00002320 0023 0002 00000000 0000 FF 000000 0000
+
+# actions=ct(table=10)
+ffff 0018 00002320 0023 0000 00000000 0000 0A 000000 0000
+
+# actions=ct(zone=10)
+ffff 0018 00002320 0023 0000 00000000 000A FF 000000 0000
+
+# actions=ct(zone=NXM_NX_REG0[0..15])
+ffff 0018 00002320 0023 0000 00010004 000F FF 000000 0000
+
+dnl Can't read 8 bits from register into 16-bit zone.
+# bad OpenFlow10 actions: OFPBAC_BAD_SET_LEN
+ffff 0018 00002320 0023 0000 00010004 0007 FF 000000 0000
+
+dnl Can't read 32 bits from register into 16-bit zone.
+# bad OpenFlow10 actions: OFPBAC_BAD_SET_LEN
+ffff 0018 00002320 0023 0000 00010004 001F FF 000000 0000
+
+# actions=ct(commit,exec(load:0xf009->NXM_NX_CT_MARK[]))
+ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
+ffff 0018 00002320 0007 001f 0001d604 000000000000f009
+
+# actions=ct(commit,force,exec(load:0xf009->NXM_NX_CT_MARK[]))
+ffff 0030 00002320 0023 0003 00000000 0000 FF 000000 0000 dnl
+ffff 0018 00002320 0007 001f 0001d604 000000000000f009
+
+# actions=ct(commit,exec(load:0->NXM_NX_CT_LABEL[64..127],load:0x1d->NXM_NX_CT_LABEL[0..63]))
+ffff 0048 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
+ffff 0018 00002320 0007 103f 0001d810 0000 0000 0000 0000 dnl
+ffff 0018 00002320 0007 003f 0001d810 0000 0000 0000 001d
+
+# bad OpenFlow10 actions: OFPBAC_BAD_SET_ARGUMENT
+& ofp_actions|WARN|cannot set CT fields outside of ct action
+ffff 0018 00002320 0007 001f 0001d604 000000000000f009
+
+# bad OpenFlow10 actions: OFPBAC_BAD_SET_ARGUMENT
+& meta_flow|WARN|destination field ct_zone is not writable
+ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
+ffff 0018 00002320 0007 000f 0001d504 000000000000f009
+
+# bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
+& ofp_actions|WARN|ct action doesn't support nested action ct
+ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
+ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0000
+
+# bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
+& ofp_actions|WARN|ct action doesn't support nested modification of reg0
+ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
+ffff 0018 00002320 0007 001f 00010004 000000000000f009
+
+# actions=ct(alg=ftp)
+ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0015
+
+# actions=ct(alg=tftp)
+ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0045
+
+# actions=ct(commit,nat(src))
+ffff 0028 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
+ffff 0010 00002320 0024 00 00 0001 0000
+
+# actions=ct(commit,nat(dst))
+ffff 0028 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
+ffff 0010 00002320 0024 00 00 0002 0000
+
+# actions=ct(nat)
+ffff 0028 00002320 0023 0000 00000000 0000 FF 000000 0000 dnl
+ffff 0010 00002320 0024 00 00 0000 0000
+
+# actions=ct(commit,nat(src=10.0.0.240,random))
+ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
+ffff 0018 00002320 0024 00 00 0011 0001 0a0000f0 00000000
+
+# actions=ct(commit,nat(src=10.0.0.240:32768-65535,random))
+ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
+ffff 0018 00002320 0024 00 00 0011 0031 0a0000f0 8000ffff
+
+# actions=ct(commit,nat(dst=10.0.0.128-10.0.0.254,hash))
+ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
+ffff 0018 00002320 0024 00 00 000a 0003 0a000080 0a0000fe
+
+# actions=ct(commit,nat(src=10.0.0.240-10.0.0.254:32768-65535,persistent))
+ffff 0038 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
+ffff 0020 00002320 0024 00 00 0005 0033 0a0000f0 0a0000fe 8000ffff 00000000
+
+# actions=ct(commit,nat(src=fe80::20c:29ff:fe88:a18b,random))
+ffff 0038 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
+ffff 0020 00002320 0024 00 00 0011 0004 fe800000 00000000 020c 29ff fe88 a18b
+
+# actions=ct(commit,nat(src=fe80::20c:29ff:fe88:1-fe80::20c:29ff:fe88:a18b,random))
+ffff 0048 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
+ffff 0030 00002320 0024 00 00 0011 000c fe800000 00000000 020c 29ff fe88 0001 fe800000 00000000 020c 29ff fe88 a18b
+
+# actions=ct(commit,nat(src=[fe80::20c:29ff:fe88:1]-[fe80::20c:29ff:fe88:a18b]:255-4096,random))
+ffff 0050 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
+ffff 0038 00002320 0024 00 00 0011 003c dnl
+fe800000 00000000 020c 29ff fe88 0001 dnl
+fe800000 00000000 020c 29ff fe88 a18b dnl
+00ff1000 00000000
+
+# actions=ct_clear
+ffff 0010 00002320 002b 000000000000
+
+# actions=output(port=1,max_len=100)
+ffff 0010 00002320 0027 0001 00000064
+
+# actions=clone(mod_vlan_vid:5,output:10)
+ffff 0020 00002320 002a 000000000000 dnl
+0001 0008 0005 0000 dnl
+0000 0008 000a 0000
+
+# actions=learn(table=2,priority=0,NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],output:NXM_OF_IN_PORT[])
+ffff 0050 00002320 002d 0000 0000 0000 0000000000000000 0000 02 00 0000 0000 00000000 0000 0000 dnl
+000c 00000802 0000 00000802 0000 dnl
+0030 00000406 0000 00000206 0000 dnl
+1010 00000002 0000 dnl
+00000000
+
+# actions=learn(table=2,idle_timeout=10,hard_timeout=20,fin_idle_timeout=2,fin_hard_timeout=4,priority=80,cookie=0x123456789abcdef0,limit=1,NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],output:NXM_OF_IN_PORT[])
+ffff 0050 00002320 002d 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 00000001 0000 0000 dnl
+000c 00000802 0000 00000802 0000 dnl
+0030 00000406 0000 00000206 0000 dnl
+1010 00000002 0000 dnl
+00000000
+
+# actions=learn(table=2,idle_timeout=10,hard_timeout=20,fin_idle_timeout=2,fin_hard_timeout=4,priority=80,cookie=0x123456789abcdef0,limit=1,result_dst=NXM_NX_REG0[8],NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],output:NXM_OF_IN_PORT[])
+ffff 0050 00002320 002d 000a 0014 0050 123456789abcdef0 0004 02 00 0002 0004 00000001 0008 0000 dnl
+00010004 dnl
+000c 00000802 0000 00000802 0000 dnl
+0030 00000406 0000 00000206 0000 dnl
+1010 00000002 0000
+
+# actions=group:5
+ffff 0010 00002320 0028 0000 00000005
+
+# bad OpenFlow10 actions: NXBRC_MUST_BE_ZERO
+ffff 0018 00002320 0025 0000 0005 0000 1122334455 000005
+
+# bad OpenFlow10 actions: NXBRC_MUST_BE_ZERO
+ffff 0018 00002320 0025 0000 0005 5000 1122334455 000000
+
+# bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
+ffff 0048 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
+ffff 0030 00002320 0024 00 00 0011 000c fe800000 00000000 020c 29ff fe88 a18b fe800000 00000000 020c 29ff fe88 0001
+
 ])
 sed '/^[[#&]]/d' < test-data > input.txt
 sed -n 's/^# //p; /^$/p' < test-data > expout
@@ -191,6 +382,9 @@ AT_DATA([test-data], [dnl
 # actions=mod_nw_tos:48
 0007 0008 30 000000
 
+# actions=mod_nw_ecn:2
+0008 0008 02 000000
+
 # actions=mod_tp_src:80
 0009 0008 0050 0000
 
@@ -252,6 +446,9 @@ ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
 # actions=resubmit(10,5)
 ffff 0010 00002320 000e 000a 05 000000
 
+# actions=resubmit(10,5,ct)
+ffff 0010 00002320 002c 000a 05 000000
+
 # actions=output:NXM_NX_REG1[5..10]
 ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
 
@@ -281,6 +478,11 @@ ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
 # actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
 ffff 0018 00002320 001d 3039 00005BA0 00008707 0000B26E
 
+# bad OpenFlow11 actions: OFPBAC_BAD_OUT_PORT
+& ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_OUT_PORT):
+& 00000000  00 00 00 10 ff ff ff ff-00 00 00 00 00 00 00 00
+0000 0010 ffffffff 0000 000000000000
+
 ])
 sed '/^[[#&]]/d' < test-data > input.txt
 sed -n 's/^# //p; /^$/p' < test-data > expout
@@ -502,6 +704,60 @@ AT_CHECK(
   [0], [expout], [experr])
 AT_CLEANUP
 
+dnl Our primary goal here is to verify OpenFlow 1.2-specific changes,
+dnl so the list of tests is short.
+AT_SETUP([OpenFlow 1.2 action translation])
+AT_KEYWORDS([ofp-actions OF1.2])
+AT_DATA([test-data], [dnl
+# actions=LOCAL
+0000 0010 fffffffe 04d2 000000000000
+
+# bad OpenFlow12 actions: OFPBAC_BAD_SET_MASK
+& ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_SET_MASK):
+& 00000000  00 19 00 18 80 00 09 0c-00 00 00 00 12 34 00 00
+& 00000010  00 00 ff ff 00 00 00 00-
+0019 0018 8000090c 000000001234 00000000ffff 00000000
+
+])
+sed '/^[[#&]]/d' < test-data > input.txt
+sed -n 's/^# //p; /^$/p' < test-data > expout
+sed -n 's/^& //p' < test-data > experr
+AT_CAPTURE_FILE([input.txt])
+AT_CAPTURE_FILE([expout])
+AT_CAPTURE_FILE([experr])
+AT_CHECK(
+  [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow12 < input.txt],
+  [0], [expout], [experr])
+AT_CLEANUP
+
+dnl Our primary goal here is to verify OpenFlow 1.3-specific changes,
+dnl so the list of tests is short.
+AT_SETUP([OpenFlow 1.3 action translation])
+AT_KEYWORDS([ofp-actions OF1.3])
+AT_DATA([test-data], [dnl
+# actions=LOCAL
+0000 0010 fffffffe 04d2 000000000000
+
+dnl Check the Nicira extension form of "move".
+# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
+ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
+
+dnl Check the ONF extension form of "copy_field".
+# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
+ffff 0020 4f4e4600 0c80 0000 0010 0000 0000 0000 00000002 00000802 00000000
+
+])
+sed '/^[[#&]]/d' < test-data > input.txt
+sed -n 's/^# //p; /^$/p' < test-data > expout
+sed -n 's/^& //p' < test-data > experr
+AT_CAPTURE_FILE([input.txt])
+AT_CAPTURE_FILE([expout])
+AT_CAPTURE_FILE([experr])
+AT_CHECK(
+  [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow13 < input.txt],
+  [0], [expout], [experr])
+AT_CLEANUP
+
 dnl Our primary goal here is to verify that OpenFlow 1.5-specific changes,
 dnl so the list of tests is short.
 AT_SETUP([OpenFlow 1.5 action translation])
@@ -511,14 +767,10 @@ AT_DATA([test-data], [dnl
 0000 0010 fffffffe 04d2 000000000000
 
 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
-001c 0018 0010 0000 0000 0008 00000002 00000802 00000000
+001c 0018 0010 0000 0000 0000 00000002 00000802 00000000
 
-dnl This action has a lot more wrong with it than the hasmask bit, but
-dnl the current OVS implementation checks for that first.
-# bad OpenFlow15 actions: OFPBAC_BAD_SET_MASK
-& ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_SET_MASK):
-& 00000000  00 19 00 08 00 00 01 00-
-0019 0008 0000 0100
+# actions=set_field:00:00:00:00:12:34/00:00:00:00:ff:ff->eth_src
+0019 0018 8000090c 000000001234 00000000ffff 00000000
 
 ])
 sed '/^[[#&]]/d' < test-data > input.txt
@@ -543,3 +795,98 @@ ovs-ofctl: none of the usable flow formats (OpenFlow10,NXM) is among the allowed
 ])
 OVS_VSWITCHD_STOP
 AT_CLEANUP
+
+AT_SETUP([reg_load <-> set_field translation corner case])
+AT_KEYWORDS([ofp-actions])
+OVS_VSWITCHD_START
+dnl In OpenFlow 1.3, set_field always sets all the bits in the field,
+dnl but when we translate to NXAST_LOAD we need to only set the bits that
+dnl actually exist (e.g. mpls_label only has 20 bits) otherwise OVS rejects
+dnl the "load" action as invalid.  Check that we do this correctly.
+AT_CHECK([ovs-ofctl -O OpenFlow13 add-flow br0 mpls,actions=set_field:10-\>mpls_label])
+AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
+NXST_FLOW reply:
+ mpls actions=load:0xa->OXM_OF_MPLS_LABEL[[]]
+])
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+AT_SETUP([enqueue action for OF1.1+])
+AT_KEYWORDS([ofp-actions])
+OVS_VSWITCHD_START
+dnl OpenFlow 1.0 has an "enqueue" action.  For OpenFlow 1.1+, we translate
+dnl it to a series of actions that accomplish the same thing.
+AT_CHECK([ovs-ofctl -O OpenFlow10 add-flow br0 'actions=enqueue(123,456)'])
+AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
+NXST_FLOW reply:
+ actions=enqueue:123:456
+])
+AT_CHECK([ovs-ofctl -O OpenFlow13 dump-flows br0 | ofctl_strip], [0], [dnl
+OFPST_FLOW reply (OF1.3):
+ reset_counts actions=set_queue:456,output:123,pop_queue
+])
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+AT_SETUP([mod_nw_ttl action for OF1.0])
+AT_KEYWORDS([ofp-actions])
+OVS_VSWITCHD_START
+dnl OpenFlow 1.1+ have a mod_nw_ttl action.  For OpenFlow 1.0, we translate
+dnl it to an Open vSwitch extension.
+AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=mod_nw_ttl:123'])
+AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
+NXST_FLOW reply:
+ ip actions=load:0x7b->NXM_NX_IP_TTL[[]]
+])
+AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
+OFPST_FLOW reply (OF1.1):
+ ip actions=mod_nw_ttl:123
+])
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+AT_SETUP([mod_nw_ecn action translation])
+AT_KEYWORDS([ofp-actions])
+OVS_VSWITCHD_START
+
+dnl OpenFlow 1.1, but no other version, has a "mod_nw_ecn" action.
+dnl Check that we translate it properly for OF1.0 and OF1.2.
+dnl (OF1.3+ should be the same as OF1.2.)
+AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=mod_nw_ecn:2'])
+AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
+NXST_FLOW reply:
+ ip actions=load:0x2->NXM_NX_IP_ECN[[]]
+])
+AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
+OFPST_FLOW reply (OF1.1):
+ ip actions=mod_nw_ecn:2
+])
+AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [dnl
+OFPST_FLOW reply (OF1.2):
+ ip actions=set_field:2->nw_ecn
+])
+
+dnl Check that OF1.2+ set_field to set ECN is translated into the OF1.1
+dnl mod_nw_ecn action.
+dnl
+dnl We don't do anything equivalent for OF1.0 reg_load because we prefer
+dnl that anything that comes in as reg_load gets translated back to reg_load
+dnl on output.  Perhaps this is somewhat inconsistent but it's what OVS
+dnl has done for multiple versions.
+AT_CHECK([ovs-ofctl del-flows br0])
+AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 'ip,actions=set_field:2->ip_ecn'])
+AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
+OFPST_FLOW reply (OF1.1):
+ ip actions=mod_nw_ecn:2
+])
+
+dnl Check that OF1.2+ set_field to set ECN is translated for earlier OF
+dnl versions.
+AT_CHECK([ovs-ofctl del-flows br0])
+AT_CHECK([ovs-ofctl -O OpenFlow10 add-flow br0 'ip,actions=set_field:2->ip_ecn'])
+AT_CHECK([ovs-ofctl del-flows br0])
+AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=set_field:2->ip_ecn'])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+