ovs-ofctl: Avoid printing false differences on "ovs-ofctl diff-flows".
[openvswitch] / tests / ovs-ofctl.at
index 08026ec8a2f66632c57fa120eb3dace9a64f2417..b1b4c6c17c2211ff5fe0c0ee7b9c6b77230de00a 100644 (file)
@@ -1308,6 +1308,26 @@ OXM_OF_ETH_SRC(020898456ddb)
 OXM_OF_ETH_TYPE(0800)
 OXM_OF_ETH_TYPE(0800) OXM_OF_IN_PORT(00000012)
 
+# vlan
+OXM_OF_VLAN_VID(1009) OXM_OF_VLAN_VID(1009) # Duplicate Field
+OXM_OF_VLAN_VID(f009)           # Bad Value
+OXM_OF_VLAN_PCP(00)             # Bad Pre-Requisite
+OXM_OF_VLAN_VID(0000)           # Packets without 802.1Q header or with VID=0
+OXM_OF_VLAN_VID(1123)           # Packets with VID=123, any PCP
+OXM_OF_VLAN_VID(1123) OXM_OF_VLAN_PCP(01) # Packets with VID=123, PCP=1.
+OXM_OF_VLAN_VID(0123)           # Does not make sense (but supported anyway)
+OXM_OF_VLAN_VID_W(0123/0123)      # Does not make sense (but supported anyway)
+OXM_OF_VLAN_VID_W(1123/0123)      # Does not make sense (but supported anyway)
+OXM_OF_VLAN_VID_W(0123/1123)      # Does not make sense (but supported anyway)
+OXM_OF_VLAN_VID(0123) OXM_OF_VLAN_PCP(01)  #Bad Pre-Requisite
+OXM_OF_VLAN_VID_W(1123/1fff)    # Packets with VID=123, any PCP.
+OXM_OF_VLAN_VID_W(1123/ffff)    # Packets with VID=123, any PCP.
+OXM_OF_VLAN_VID_W(1123/0000)    # Packets with or without 802.1Q header
+OXM_OF_VLAN_VID_W(1123/1f0f),   # Packets with # VID=123 (masked)
+OXM_OF_VLAN_VID_W(1123/1f0f), OXM_OF_VLAN_PCP(01)  # Packets with VID=123 (masked), any PCP.
+OXM_OF_VLAN_VID_W(1000/1000)    # Packets with any VID, any PCP
+OXM_OF_VLAN_VID_W(1000/1000), OXM_OF_VLAN_PCP(01)  # Packets with any VID, PCP=1.
+
 # IP ECN
 OXM_OF_ETH_TYPE(0800) OXM_OF_IP_ECN(03)
 OXM_OF_ETH_TYPE(0800) OXM_OF_IP_ECN(06)
@@ -1483,6 +1503,26 @@ OXM_OF_ETH_SRC(020898456ddb)
 OXM_OF_ETH_TYPE(0800)
 OXM_OF_IN_PORT(00000012), OXM_OF_ETH_TYPE(0800)
 
+# vlan
+nx_pull_match() returned error OFPBMC_DUP_FIELD
+nx_pull_match() returned error OFPBMC_BAD_VALUE
+nx_pull_match() returned error OFPBMC_BAD_PREREQ
+OXM_OF_VLAN_VID(0000)
+OXM_OF_VLAN_VID(1123)
+OXM_OF_VLAN_VID(1123), OXM_OF_VLAN_PCP(01)
+OXM_OF_VLAN_VID(0123)
+OXM_OF_VLAN_VID_W(0123/0123)
+OXM_OF_VLAN_VID_W(0123/0123)
+OXM_OF_VLAN_VID_W(0123/1123)
+nx_pull_match() returned error OFPBMC_BAD_PREREQ
+OXM_OF_VLAN_VID(1123)
+OXM_OF_VLAN_VID(1123)
+<any>
+OXM_OF_VLAN_VID_W(1103/1f0f)
+OXM_OF_VLAN_VID_W(1103/1f0f), OXM_OF_VLAN_PCP(01)
+OXM_OF_VLAN_VID_W(1000/1000)
+OXM_OF_VLAN_VID_W(1000/1000), OXM_OF_VLAN_PCP(01)
+
 # IP ECN
 OXM_OF_ETH_TYPE(0800), OXM_OF_IP_ECN(03)
 nx_pull_match() returned error OFPBMC_BAD_VALUE
@@ -1654,6 +1694,7 @@ dnl [1]
 AT_CHECK([ovs-ofctl check-vlan 0000 0000], [0], [dnl
  -> 0000/0000
 NXM: <any> -> 0000/0000
+OXM: <any> -> 0000/0000,--
 OF1.0: 0000/1,00/1 -> 0000/0000
 OF1.1: 0000/1,00/1 -> 0000/0000
 ])
@@ -1662,6 +1703,7 @@ dnl [2]
 AT_CHECK([ovs-ofctl check-vlan 0000 ffff], [0], [dnl
 vlan_tci=0x0000 -> 0000/ffff
 NXM: NXM_OF_VLAN_TCI(0000) -> 0000/ffff
+OXM: OXM_OF_VLAN_VID(0000) -> 0000/1fff,--
 OF1.0: ffff/0,00/1 -> 0000/ffff
 OF1.1: ffff/0,00/1 -> 0000/ffff
 ])
@@ -1670,6 +1712,7 @@ dnl [3]
 AT_CHECK([ovs-ofctl check-vlan 1abc 1fff], [0], [dnl
 dl_vlan=2748 -> 1abc/1fff
 NXM: NXM_OF_VLAN_TCI_W(1abc/1fff) -> 1abc/1fff
+OXM: OXM_OF_VLAN_VID(1abc) -> 1abc/1fff,--
 OF1.0: 0abc/0,00/1 -> 1abc/1fff
 OF1.1: 0abc/0,00/1 -> 1abc/1fff
 ])
@@ -1678,6 +1721,7 @@ dnl [4]
 AT_CHECK([ovs-ofctl check-vlan b000 f000], [0], [dnl
 dl_vlan_pcp=5 -> b000/f000
 NXM: NXM_OF_VLAN_TCI_W(b000/f000) -> b000/f000
+OXM: OXM_OF_VLAN_VID_W(1000/1000), OXM_OF_VLAN_PCP(05) -> 1000/1000,05
 OF1.0: 0000/1,05/0 -> b000/f000
 OF1.1: fffe/0,05/0 -> b000/f000
 ])
@@ -1686,6 +1730,7 @@ dnl [5]
 AT_CHECK([ovs-ofctl check-vlan babc ffff], [0], [dnl
 dl_vlan=2748,dl_vlan_pcp=5 -> babc/ffff
 NXM: NXM_OF_VLAN_TCI(babc) -> babc/ffff
+OXM: OXM_OF_VLAN_VID(1abc), OXM_OF_VLAN_PCP(05) -> 1abc/1fff,05
 OF1.0: 0abc/0,05/0 -> babc/ffff
 OF1.1: 0abc/0,05/0 -> babc/ffff
 ])
@@ -1694,6 +1739,7 @@ dnl [6]
 AT_CHECK([ovs-ofctl check-vlan 0000 0fff], [0], [dnl
 vlan_tci=0x0000/0x0fff -> 0000/0fff
 NXM: NXM_OF_VLAN_TCI_W(0000/0fff) -> 0000/0fff
+OXM: OXM_OF_VLAN_VID_W(0000/0fff) -> 0000/0fff,--
 OF1.0: 0000/0,00/1 -> 1000/1fff
 OF1.1: 0000/0,00/1 -> 1000/1fff
 ])
@@ -1702,6 +1748,7 @@ dnl [7]
 AT_CHECK([ovs-ofctl check-vlan 0000 f000], [0], [dnl
 vlan_tci=0x0000/0xf000 -> 0000/f000
 NXM: NXM_OF_VLAN_TCI_W(0000/f000) -> 0000/f000
+OXM: OXM_OF_VLAN_VID_W(0000/1000) -> 0000/1000,--
 OF1.0: ffff/0,00/1 -> 0000/ffff
 OF1.1: ffff/0,00/1 -> 0000/ffff
 ])
@@ -1710,6 +1757,7 @@ dnl [8]
 AT_CHECK([ovs-ofctl check-vlan 0000 efff], [0], [dnl
 vlan_tci=0x0000/0xefff -> 0000/efff
 NXM: NXM_OF_VLAN_TCI_W(0000/efff) -> 0000/efff
+OXM: OXM_OF_VLAN_VID_W(0000/0fff) -> 0000/0fff,--
 OF1.0: 0000/0,00/0 -> 1000/ffff
 OF1.1: 0000/0,00/0 -> 1000/ffff
 ])
@@ -1718,6 +1766,7 @@ dnl [9]
 AT_CHECK([ovs-ofctl check-vlan 1001 1001], [0], [dnl
 vlan_tci=0x1001/0x1001 -> 1001/1001
 NXM: NXM_OF_VLAN_TCI_W(1001/1001) -> 1001/1001
+OXM: OXM_OF_VLAN_VID_W(1001/1001) -> 1001/1001,--
 OF1.0: 0001/0,00/1 -> 1001/1fff
 OF1.1: 0001/0,00/1 -> 1001/1fff
 ])
@@ -1726,6 +1775,7 @@ dnl [10]
 AT_CHECK([ovs-ofctl check-vlan 3000 3000], [0], [dnl
 vlan_tci=0x3000/0x3000 -> 3000/3000
 NXM: NXM_OF_VLAN_TCI_W(3000/3000) -> 3000/3000
+OXM: OXM_OF_VLAN_VID_W(1000/1000), OXM_OF_VLAN_PCP(01) -> 1000/1000,01
 OF1.0: 0000/1,01/0 -> 3000/f000
 OF1.1: fffe/0,01/0 -> 3000/f000
 ])
@@ -1912,3 +1962,28 @@ AT_CHECK([ovs-ofctl diff-flows add-flows.txt br0 | sort], [0], [expout])
 
 OVS_VSWITCHD_STOP
 AT_CLEANUP
+
+dnl ofpacts that differ bytewise don't necessarily differ when
+dnl converted to another representation, such as OpenFlow 1.0
+dnl or to a string.  "resubmit(,1)" is an example of an action
+dnl of this type: "ofpact_resubmit"s can differ in their "compat"
+dnl values even though this doesn't affect the string format.
+dnl
+dnl This test checks that "ovs-ofctl diff-flows" doesn't report
+dnl false ofpacts differences.
+AT_SETUP([ovs-ofctl diff-flows - suppress false differences])
+OVS_VSWITCHD_START
+AT_DATA([flows.txt], [actions=resubmit(,1)
+])
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
+AT_CHECK([ovs-ofctl add-flow br0 idle_timeout=60,dl_vlan=9,actions=output:1])
+AT_CHECK([ovs-ofctl diff-flows br0 flows.txt], [2], [dnl
+-dl_vlan=9 idle_timeout=60 actions=output:1
+])
+AT_CHECK([ovs-ofctl add-flow br0 hard_timeout=120,cookie=1234,dl_vlan=9,actions=output:1])
+AT_CHECK([ovs-ofctl diff-flows flows.txt br0], [2], [dnl
++dl_vlan=9 cookie=0x4d2 hard_timeout=120 actions=output:1
+])
+OVS_VSWITCHD_STOP
+AT_CLEANUP