of-test clean-up for EA4

Change-Id: I2212e2c51674baa3f662d01396b4c92f2675dc61
diff --git a/README.md b/README.md
index f59d638..691ed64 100755
--- a/README.md
+++ b/README.md
@@ -90,34 +90,35 @@
 
 The following tests are implemented and these are their results.
 
-Test Results       | i12_1.7 | 2.0 GA | 3.0 EA0
--------            | ------- | ------ | -------
-/0Ucast            | X       | ok     | ok
-/24UnicastTagged   | ok      | ok     | ok
-/32UnicastTagged   | ok      | ok     | ok
-/24ECMPL3          | ok      | ok     | ok
-/32ECMPL3          | ok      | ok     | ok
-/24ECMPVPN         | ok      | ok     | ok
-/32ECMPVPN         | ok      | ok     | ok
-/32VPN             | ok      | ok     | ok
-/24VPN             | ok      | ok     | ok
-EcmpGroupMod       | X       | X      | ok
-PacketInArp        | ok      | ok     | ok
-MTU1500            | ok      | ok     | ok
-MplsTermination    | ok      | ok     | ok
-MplsFwd            | X       | ok     | ok
-L2FloodQinQ        | ok      | ok     | ok
-L2UnicastTagged    | ok      | ok     | ok
-L3McastToL3        | ok      | X      | ok
-L3McastToL2_1*     | ?       | ?      | ok
-L3McastToL2_2**    | ?       | ?      | ok
-L3McastToL2_3***   | ?       | ?      | ok
-L3McastToL2_4****  | ok      | ?      | ok
-L3McastToL2_5***** | ?       | ?      | ok
-FloodGroupMod      | X       | X      | ok
-PacketInUDP        | ok      | ok     | ok
-Unfiltered         | X       | ok     | X
-Untagged           | ok      | n/a    | ok
+Test Results       | i12_1.7 | 2.0 GA | 3.0 EA0 | 3.0 EA4 |
+-------            | ------- | ------ | ------- | ------- |
+/0Ucast            | X       | ok     | ok      | ok      |
+/24UnicastTagged   | ok      | ok     | ok      | ok      |
+/32UnicastTagged   | ok      | ok     | ok      | ok      |
+/24ECMPL3          | ok      | ok     | ok      | ok      |
+/32ECMPL3          | ok      | ok     | ok      | ok      |
+/24ECMPVPN         | ok      | ok     | ok      | ok      |
+/32ECMPVPN         | ok      | ok     | ok      | ok      |
+/32VPN             | ok      | ok     | ok      | ok      |
+/24VPN             | ok      | ok     | ok      | ok      |
+EcmpGroupMod       | X       | X      | ok      | ok      |
+PacketInArp        | ok      | ok     | ok      | ok      |
+MTU1500            | ok      | ok     | ok      | ok      |
+MplsTermination    | ok      | ok     | ok      | ok      |
+MplsFwd            | X       | ok     | ok      | ok      |
+L2FloodQinQ        | ok      | ok     | ok      | ok      |
+L2UnicastTagged    | ok      | ok     | ok      | ok      |
+L3McastToL3        | ok      | X      | ok      | ok      |
+L3McastToL2_1*     | ?       | ?      | ok      | ok      |
+L3McastToL2_2**    | ?       | ?      | ok      | ok      |
+L3McastToL2_3***   | ?       | ?      | ok      | ok      |
+L3McastToL2_4****  | ok      | ?      | ok      | ok      |
+L3McastToL2_5***** | ?       | ?      | ok      | ok      |
+FloodGroupMod      | X       | X      | ok      | ok      |
+PacketInUDP        | ok      | ok     | ok      | ok      |
+Unfiltered         | X       | ok     | X       | ok      |
+Untagged           | ok      | n/a    | ok      | ok      |
+PacketInIPTable    | X       | X      | ok      | ok      |
 
 *       Untag -> Untag (4094 as internal vlan)
 **      Untag -> Tag
@@ -131,13 +132,13 @@
 
 The following tests are implemented in vlan_flows.py and these are their results.
 
-Test Results                | 3.0 EA0
------------------           | -------
-L2ForwardingStackedVLAN1    | ok
-L2ForwardingStackedVLAN2    | ok
-L2ForwardingStackedVLAN3    | ok
-L2ForwardingStackedVLAN4    | ok
-L2ForwardingStackedVLAN5    | ok
+Test Results                | 3.0 EA0 | 3.0 EA4 |
+------------------------    | ------- | ------- |
+L2ForwardingStackedVLAN     | ok      | ok      |
+L2ForwardingStackedVLAN2    | ok      | ok      |
+L2ForwardingStackedVLAN3    | ok      | ok      |
+L2ForwardingStackedVLAN4    | ok      | ok      |
+L2ForwardingStackedVLAN5    | ok      | ok      |
 
 For major details on the test look the comments in the code.
 
@@ -145,28 +146,30 @@
 
 The following tests are implemented in pw_flows.py and these are their results.
 
-Test Results                            | 3.0 EA0
-----------------------------------      | -------
-UntaggedPWInitiation_2_Labels           | ok
-Untagged2PWInitiation_2_Labels          | ok
-UntaggedPWInitiation_3_Labels           | ok
-Untagged2PWInitiation_3_Labels          | ok
-TaggedPWInitiation_2_Labels             | ?
-Tagged2PWInitiation_2_Labels            | ?
-TaggedPWInitiation_3_Labels             | ?
-Tagged2PWInitiation_3_Labels            | ?
-DoubleTaggedPWInitiation_2_Labels       | ?
-DoubleTagged2PWInitiation_2_Labels      | ?
-DoubleTaggedPWInitiation_3_Labels       | ?
-DoubleTagged2PWInitiation_3_Labels      | ?
-IntraCO_2_Labels                        | ok
-IntraCO_3_Labels                        | ok
-InterCO                                 | ok
-UntaggedPWTermination                   | ok
-Untagged2PWTermination                  | ?
-TaggedPWTermination                     | ok
-DoubleTaggedPWTermination               | ok
+Test Results                            | 3.0 EA0 | 3.0 EA4 |
+----------------------------------      | ------- | ------- |
+UntaggedPWInitiation_2_Labels           | ok      | ok      |
+Untagged2PWInitiation_2_Labels          | ok      | ok      |
+UntaggedPWInitiation_3_Labels           | ok      | ok      |
+Untagged2PWInitiation_3_Labels          | ok      | ok      |
+TaggedPWInitiation_2_Labels             | x       | ok*     |
+Tagged2PWInitiation_2_Labels            | x       | ok*     |
+TaggedPWInitiation_3_Labels             | x       | ok*     |
+Tagged2PWInitiation_3_Labels            | x       | ok*     |
+DoubleTaggedPWInitiation_2_Labels       | x       | ok*     |
+DoubleTagged2PWInitiation_2_Labels      | x       | ok*     |
+DoubleTaggedPWInitiation_3_Labels       | x       | ok*     |
+DoubleTagged2PWInitiation_3_Labels      | x       | ok*     |
+IntraCO_2_Labels                        | ok      | ok*     |
+IntraCO_3_Labels                        | ok      | ok*     |
+InterCO                                 | ok      | ok*     |
+UntaggedPWTermination                   | ok      | ok      |
+Untagged2PWTermination                  | x       | x       |
+TaggedPWTermination                     | ok      | ok      |
+DoubleTaggedPWTermination               | ok      | ok      |
+BoSBug                                  | x       | x       |
 
+* The test may fail intermittently
 
 For major details on the test look the comments in the code.
 
@@ -174,17 +177,17 @@
 
 The following tests are implemented in ipv6_flows.py and these are their results.
 
-Test Results                | 3.0 EA0
-----------------------      | -------
-PacketInICMPv6              | ok
-PacketInIPv6Table           | ok
-_128UcastUnTagged           | ok
-_128ECMPVpn                 | ok
-_128ECMPL3                  | ok
-_64UcastUnTagged            | ok
-_64ECMPVpn                  | ok
-_64ECMPL3                   | ok
-_0UcastV6                   | ok
-_MPLSTerminationV6          | ok
+Test Results                | 3.0 EA0 | 3.0 EA4 |
+----------------------      | ------- | ------- |
+PacketInICMPv6              | ok      | ok      |
+PacketInIPv6Table           | ok      | ok      |
+_128UcastUnTagged           | ok      | ok      |
+_128ECMPVpn                 | ok      | ok      |
+_128ECMPL3                  | ok      | ok      |
+_64UcastUntagged            | ok      | ok      |
+_64ECMPVpn                  | ok      | ok      |
+_64ECMPL3                   | ok      | ok      |
+_0UcastV6                   | ok      | ok      |
+_MPLSTerminationV6          | ok      | ok      |
 
 For major details on the test look the comments in the code.
diff --git a/accton/accton_util.py b/accton/accton_util.py
index a729f79..0dafb5d 100755
--- a/accton/accton_util.py
+++ b/accton/accton_util.py
@@ -472,13 +472,13 @@
        NEXT_TABLE=10
 
     request = ofp.message.flow_add(
-		table_id=0,
-		cookie=42,
-		match=match,
-		instructions=[
-		  ofp.instruction.goto_table(NEXT_TABLE)
-		],
-		priority=0)
+        table_id=0,
+        cookie=42,
+        match=match,
+        instructions=[
+          ofp.instruction.goto_table(NEXT_TABLE)
+        ],
+        priority=0)
     logging.info("Add port table, match port %lx" % 0x10000)
     ctrl.message_send(request)
 
@@ -1087,7 +1087,7 @@
     instructions = []
     instructions.append(ofp.instruction.goto_table(60))
     if send_ctrl:
-        instructions.append(ofp.instruction.apply_actions(
+        instructions.append(ofp.instruction.write_actions(
                             actions=[ofp.action.output( port=ofp.OFPP_CONTROLLER,
                             max_len=ofp.OFPCML_NO_BUFFER)]))
     else:
@@ -1121,7 +1121,7 @@
     instructions = []
     instructions.append(ofp.instruction.goto_table(60))
     if send_ctrl:
-        instructions.append(ofp.instruction.apply_actions(
+        instructions.append(ofp.instruction.write_actions(
                             actions=[ofp.action.output( port=ofp.OFPP_CONTROLLER,
                             max_len=ofp.OFPCML_NO_BUFFER)]))
     else:
@@ -1149,23 +1149,23 @@
     match.oxm_list.append(ofp.oxm.eth_type(0x8847))
     match.oxm_list.append(ofp.oxm.mpls_label(label))
     match.oxm_list.append(ofp.oxm.mpls_bos(bos))
-    actions = []
-    actions = [ofp.action.dec_mpls_ttl(),
+    write_actions = []
+    write_actions.append(ofp.action.group(action_group_id))
+    apply_actions = []
+    apply_actions = [ofp.action.dec_mpls_ttl(),
                ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=1, value=vrf))]
-    if (goto_table == 29):
-            actions.append(ofp.action.group(action_group_id))
-    else:
-            actions.append(ofp.action.set_field(
+    if (goto_table != 29):
+            apply_actions.append(ofp.action.set_field(
                             ofp.oxm.exp2ByteValue(exp_type=23, value=32)))
-            actions.append(ofp.action.group(action_group_id))
-            actions.append(ofp.action.copy_ttl_in())
+            apply_actions.append(ofp.action.copy_ttl_in())
 
     request = ofp.message.flow_add(
             table_id=24,
             cookie=43,
             match=match,
             instructions=[
-                    ofp.instruction.apply_actions(actions=actions),
+                    ofp.instruction.apply_actions(actions=apply_actions),
+                    ofp.instruction.write_actions(actions=write_actions),
                     ofp.instruction.goto_table(goto_table)
                 ],
             buffer_id=ofp.OFP_NO_BUFFER,
@@ -1184,31 +1184,32 @@
     match.oxm_list.append(ofp.oxm.mpls_label(label))
     match.oxm_list.append(ofp.oxm.mpls_bos(bos))
 
-    actions = []
-    actions.append(ofp.action.dec_mpls_ttl())
+    apply_actions = []
+    write_actions = []
+    apply_actions.append(ofp.action.dec_mpls_ttl())
     if popMPLS == True:
-        actions.append(ofp.action.copy_ttl_in())
-        actions.append(ofp.action.pop_mpls(ethertype))
+        apply_actions.append(ofp.action.copy_ttl_in())
+        apply_actions.append(ofp.action.pop_mpls(ethertype))
     if bos==1 and popL2 == True:
-        actions.append(ofp.action.ofdpa_pop_l2_header())
-        actions.append(ofp.action.ofdpa_pop_cw())
-        actions.append(ofp.action.set_field(ofp.oxm.tunnel_id(tunnel_index + ofp.oxm.TUNNEL_ID_BASE)))
+        apply_actions.append(ofp.action.ofdpa_pop_l2_header())
+        apply_actions.append(ofp.action.ofdpa_pop_cw())
+        apply_actions.append(ofp.action.set_field(ofp.oxm.tunnel_id(tunnel_index + ofp.oxm.TUNNEL_ID_BASE)))
         # 0x0002nnnn is for UNI interfaces
-        actions.append(ofp.action.set_field(ofp.oxm.exp4ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_MPLS_L2_PORT, value=0x00020000 + of_port)))
-        actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_MPLS_TYPE, value=ofp.oxm.VPWS)))
-    actions.append(ofp.action.group(action_group_id))
+        apply_actions.append(ofp.action.set_field(ofp.oxm.exp4ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_MPLS_L2_PORT, value=0x00020000 + of_port)))
+        apply_actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_MPLS_TYPE, value=ofp.oxm.VPWS)))
+    write_actions.append(ofp.action.group(action_group_id))
 
     request = ofp.message.flow_add(
-        table_id=24,
-        cookie=43,
-        match=match,
-        instructions=[
-        ofp.instruction.apply_actions(actions=actions),
-        ofp.instruction.goto_table(goto_table)
-        ],
-        buffer_id=ofp.OFP_NO_BUFFER,
-        priority=1
-        )
+            table_id=24,
+            cookie=43,
+            match=match,
+            instructions=[
+                    ofp.instruction.apply_actions(actions=apply_actions),
+                    ofp.instruction.write_actions(actions=write_actions),
+                    ofp.instruction.goto_table(goto_table)
+                ],
+            buffer_id=ofp.OFP_NO_BUFFER,
+            priority=1)
     logging.info("Inserting MPLS flow , label %ld", label)
     ctrl.message_send(request)
 
@@ -1483,16 +1484,16 @@
                      <pause>symmetric</pause>
                    </advertised-peer>
                 </features>
-			  <ofdpa10:vtep xmlns:ofdpa10="urn:bcm:ofdpa10:accton01">
-				<ofdpa10:src-ip>SRC_IP</ofdpa10:src-ip>
-				<ofdpa10:dest-ip>DST_IP</ofdpa10:dest-ip>
-				<ofdpa10:udp-src-port>UDP_SRC_PORT</ofdpa10:udp-src-port>
-				<ofdpa10:vni xc:operation="OPERATION">
+              <ofdpa10:vtep xmlns:ofdpa10="urn:bcm:ofdpa10:accton01">
+                <ofdpa10:src-ip>SRC_IP</ofdpa10:src-ip>
+                <ofdpa10:dest-ip>DST_IP</ofdpa10:dest-ip>
+                <ofdpa10:udp-src-port>UDP_SRC_PORT</ofdpa10:udp-src-port>
+                <ofdpa10:vni xc:operation="OPERATION">
                     <ofdpa10:id>VNID</ofdpa10:id>
                 </ofdpa10:vni>
-				<ofdpa10:nexthop-id>NEXT_HOP_ID</ofdpa10:nexthop-id>
-				<ofdpa10:ttl>TTL</ofdpa10:ttl>
-			  </ofdpa10:vtep>
+                <ofdpa10:nexthop-id>NEXT_HOP_ID</ofdpa10:nexthop-id>
+                <ofdpa10:ttl>TTL</ofdpa10:ttl>
+              </ofdpa10:vtep>
              </port>
             </resources>
             <logical-switches>
@@ -1596,7 +1597,7 @@
             logging.info("Fail to set xml %s", xml)
             return False
 
-	#return m.get_config(source='running').data_xml
+    #return m.get_config(source='running').data_xml
     return True
 
 def send_delete_config(switch_ip, xml, target='runing'):
@@ -1613,14 +1614,14 @@
             logging.info("Fail to set xml %s", xml)
             return False
 
-	#return m.get_config(source='running').data_xml
+    #return m.get_config(source='running').data_xml
     return True
 
 def get_edit_config(switch_ip, target='runing'):
     NETCONF_ACCOUNT="netconfuser"
     NETCONF_PASSWD="netconfuser"
     with manager.connect_ssh(host=switch_ip, port=830, username=NETCONF_ACCOUNT, password=NETCONF_PASSWD, hostkey_verify=False ) as m:
-	    return m.get_config(source='running').data_xml
+        return m.get_config(source='running').data_xml
 
 
 """
@@ -1665,8 +1666,7 @@
     action=[]
     action.append(ofp.action.set_field(ofp.oxm.eth_src(src_mac)))
     action.append(ofp.action.set_field(ofp.oxm.eth_dst(dst_mac)))
-    if vid != 1:
-        action.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vid)))
+    action.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vid)))
     action.append(ofp.action.group(ref_gid))
 
     buckets = [ofp.bucket(actions=action)]
@@ -1814,20 +1814,21 @@
     match.oxm_list.append(ofp.oxm.tunnel_id(tunnel_index + ofp.oxm.TUNNEL_ID_BASE))
 
 
-    action = []
-    action.append(ofp.action.group(ref_gid))
+    write_actions = []
+    write_actions.append(ofp.action.group(ref_gid))
+    apply_actions = []
     assert(qos_index>=0)
-    action.append(ofp.action.set_field(ofp.oxm.exp1ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_QOS_INDEX, value=qos_index)))
+    apply_actions.append(ofp.action.set_field(ofp.oxm.exp1ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_QOS_INDEX, value=qos_index)))
 
     request = ofp.message.flow_add(
             table_id=MPLS_L2_PORT_FLOW_TABLE,
             cookie=42,
             match=match,
             instructions=[
-                    ofp.instruction.write_actions(
-                        actions=action
-                        ),
-                    ofp.instruction.goto_table(MPLS_L2_PORT_PCP_TRUST_FLOW_TABLE)                ],
+                    ofp.instruction.apply_actions(actions=apply_actions),
+                    ofp.instruction.write_actions(actions=write_actions),
+                    ofp.instruction.goto_table(MPLS_L2_PORT_PCP_TRUST_FLOW_TABLE)
+                    ],
             buffer_id=ofp.OFP_NO_BUFFER,
             priority=1)
     logging.info("Inserting flow %d mpls_l2_port, %d tunnel_id, action %x group and go to table %d", mpls_l2_port, tunnel_id, ref_gid, MPLS_L2_PORT_DSCP_TRUST_FLOW_TABLE)
@@ -1838,13 +1839,13 @@
 
 def add_mpls_forwarding_group(ctrl, subtype, index, ref_gids,
                               watch_port=None,
-							  watch_group=ofp.OFPP_ANY,
-							  push_vlan=None,
+                              watch_group=ofp.OFPP_ANY,
+                              push_vlan=None,
                               pop_vlan=None,
                               set_vid=None):
     assert(subtype == OFDPA_MPLS_GROUP_SUBTYPE_FAST_FAILOVER_GROUP
-	       or subtype == OFDPA_MPLS_GROUP_SUBTYPE_ECMP
-		   or subtype == OFDPA_MPLS_GROUP_SUBTYPE_L2_TAG)
+           or subtype == OFDPA_MPLS_GROUP_SUBTYPE_ECMP
+           or subtype == OFDPA_MPLS_GROUP_SUBTYPE_L2_TAG)
 
     buckets=[]
     if subtype == OFDPA_MPLS_GROUP_SUBTYPE_FAST_FAILOVER_GROUP:
diff --git a/ofdpa/flows.py b/ofdpa/flows.py
index 53e0edd..b888105 100755
--- a/ofdpa/flows.py
+++ b/ofdpa/flows.py
@@ -143,7 +143,7 @@
 
 class PacketInIPTable( base_tests.SimpleDataPlane ):
     """
-        Verify Packet-in message from IP table when controller action is used
+    Verify Packet-in message from IP table when controller action is used
     Send a packet to each dataplane port and verify that a packet
     in message is received from the controller for each
     #todo verify you stop receiving after adding rule
@@ -327,7 +327,7 @@
             vlan_id = 18
             for port in ports:
                 L2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
-                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 Groups.put( L2gid )
                 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
                         True )
@@ -378,7 +378,7 @@
                 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
                         src_mac=intf_src_mac, dst_mac=dst_mac )
                 # add vlan flow table
-                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
                 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
                 # add unicast routing flow
@@ -445,7 +445,7 @@
                 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
                 do_barrier( self.controller )
                 # add vlan flow table
-                add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=2,
+                add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=2,
                         flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
                 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
@@ -513,7 +513,7 @@
                 ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] )
                 do_barrier( self.controller )
                 # add vlan flow table
-                add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=0,
+                add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
                         flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
                 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
@@ -578,7 +578,7 @@
                         src_mac=intf_src_mac, dst_mac=dst_mac )
                 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
                 # add vlan flow table
-                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
                 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
                 # add unicast routing flow
@@ -644,7 +644,7 @@
                 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
                 do_barrier( self.controller )
                 # add vlan flow table
-                add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=0,
+                add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
                         flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
                 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
@@ -711,7 +711,7 @@
                 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] )
                 do_barrier( self.controller )
                 # add vlan flow table
-                add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=0,
+                add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
                         flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
                 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
@@ -828,7 +828,7 @@
                         src_mac=intf_src_mac, dst_mac=dst_mac )
                 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
                 # add vlan flow table
-                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
                 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
                 # add unicast routing flow
@@ -1003,17 +1003,6 @@
 
                 verify_no_other_packets( self )
 
-            parsed_pkt = simple_udp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=vlan_id,
-                    eth_dst=dst_mac_str, eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str,
-                    ip_dst=dst_ip_str )
-            pkt = str( parsed_pkt )
-            self.dataplane.send( port1, pkt )
-            for port in config[ "port_map" ].keys( ):
-                if port == port2 or port == port1:
-                    verify_no_packet( self, pkt, port )
-                    continue
-                verify_packet( self, pkt, port )
-            verify_no_other_packets( self )
         finally:
             delete_all_flows( self.controller )
             delete_groups( self.controller, Groups )
@@ -1388,7 +1377,7 @@
                 ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller,
                         subtype=OFDPA_MPLS_GROUP_SUBTYPE_ECMP, index=id, ref_gids=[mpls_label_gid] )
                 # add vlan flow table
-                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
                 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
                 #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 )
@@ -1462,7 +1451,7 @@
                 # add L3 ecmp group
                 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
                 # add vlan flow table
-                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
                 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
                 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label )
@@ -1529,7 +1518,7 @@
                 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
                         src_mac=intf_src_mac, dst_mac=dst_mac )
                 # add vlan flow table
-                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
                 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
                 # add unicast routing flow
@@ -1589,7 +1578,7 @@
                 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id,
                         src_mac=intf_src_mac, dst_mac=dst_mac )
                 # add vlan flow table
-                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
                 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
                 # add unicast routing flow
@@ -1802,7 +1791,7 @@
                 Groups._put( l3_msg.group_id )
                 ecmp_msg = add_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_msg.group_id ] )
                 # add vlan flow table
-                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
                 # add termination flow
                 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
                 # add unicast routing flow
@@ -1894,8 +1883,8 @@
             ports = sorted( config[ "port_map" ].keys( ) )
             for port in ports:
                 vlan_id = Untagged.MAX_INTERNAL_VLAN - port
-                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
-                add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
+                add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+                add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
                 for other_port in ports:
                     if other_port == port:
                         continue
diff --git a/ofdpa/ipv6_flows.py b/ofdpa/ipv6_flows.py
index a7161a5..a20b6d9 100644
--- a/ofdpa/ipv6_flows.py
+++ b/ofdpa/ipv6_flows.py
@@ -100,6 +100,7 @@
                 add_one_vlan_table_flow(
                     ctrl=self.controller,
                     of_port=in_port,
+                    out_vlan_id=1,
                     vlan_id=vlan_id,
                     flag=VLAN_TABLE_FLAG_ONLY_TAG
                     )
@@ -217,7 +218,6 @@
                     )
             tcpv6_pkt = str( parsed_tcpv6_pkt )
             self.dataplane.send(in_port, tcpv6_pkt)
-            print_port_stats(self, in_port)
             parsed_tcpv6_pkt = simple_tcpv6_packet(
                     pktlen=100,
                     eth_dst=dst_mac_str,
@@ -226,8 +226,6 @@
                     ipv6_src=sip,
                     ipv6_hlim=63
                     )
-            time.sleep(2)
-            print_port_stats(self, in_port)
             tcpv6_pkt = str( parsed_tcpv6_pkt )
             verify_packet(self, tcpv6_pkt, out_port )
             verify_no_packet(self, tcpv6_pkt, in_port )
@@ -352,7 +350,6 @@
                     )
             tcpv6_pkt = str( parsed_tcpv6_pkt )
             self.dataplane.send(in_port, tcpv6_pkt)
-            print_port_stats(self, in_port)
             parsed_mplsv6_pkt = mplsv6_packet(
                     pktlen=104,
                     eth_dst=dst_mac_str,
@@ -363,8 +360,6 @@
                     label=[ label ]
                     )
             mplsv6_pkt = str( parsed_mplsv6_pkt )
-            time.sleep(2)
-            print_port_stats(self, in_port)
             verify_packet(self, mplsv6_pkt, out_port )
             verify_no_packet(self, mplsv6_pkt, in_port )
             verify_no_other_packets(self)
@@ -377,7 +372,6 @@
 class _128ECMPL3( base_tests.SimpleDataPlane ):
     """ Verifies /128 IP routing and ECMP """
 
-
     def runTest( self ):
         try:
 
@@ -474,7 +468,6 @@
                     )
             tcpv6_pkt = str( parsed_tcpv6_pkt )
             self.dataplane.send(in_port, tcpv6_pkt)
-            print_port_stats(self, in_port)
             parsed_tcpv6_pkt = simple_tcpv6_packet(
                     pktlen=100,
                     eth_dst=dst_mac_str,
@@ -484,8 +477,6 @@
                     ipv6_hlim=63
                     )
             tcpv6_pkt = str( parsed_tcpv6_pkt )
-            time.sleep(2)
-            print_port_stats(self, in_port)
             verify_packet(self, tcpv6_pkt, out_port )
             verify_no_packet(self, tcpv6_pkt, in_port )
             verify_no_other_packets(self)
@@ -587,7 +578,6 @@
                     )
             tcpv6_pkt = str( parsed_tcpv6_pkt )
             self.dataplane.send(in_port, tcpv6_pkt)
-            print_port_stats(self, in_port)
             parsed_tcpv6_pkt = simple_tcpv6_packet(
                     pktlen=100,
                     eth_dst=dst_mac_str,
@@ -596,8 +586,6 @@
                     ipv6_src=sip,
                     ipv6_hlim=63
                     )
-            time.sleep(2)
-            print_port_stats(self, in_port)
             tcpv6_pkt = str( parsed_tcpv6_pkt )
             verify_packet(self, tcpv6_pkt, out_port )
             verify_no_packet(self, tcpv6_pkt, in_port )
@@ -721,7 +709,6 @@
                     )
             tcpv6_pkt = str( parsed_tcpv6_pkt )
             self.dataplane.send(in_port, tcpv6_pkt)
-            print_port_stats(self, in_port)
             parsed_mplsv6_pkt = mplsv6_packet(
                     pktlen=104,
                     eth_dst=dst_mac_str,
@@ -732,8 +719,6 @@
                     label=[ label ]
                     )
             mplsv6_pkt = str( parsed_mplsv6_pkt )
-            time.sleep(2)
-            print_port_stats(self, in_port)
             verify_packet(self, mplsv6_pkt, out_port )
             verify_no_packet(self, mplsv6_pkt, in_port )
             verify_no_other_packets(self)
@@ -824,6 +809,7 @@
             add_one_vlan_table_flow(
                 ctrl=self.controller,
                 of_port=in_port,
+                out_vlan_id=1,
                 vlan_id=vlan_id,
                 flag=VLAN_TABLE_FLAG_ONLY_TAG
                 )
@@ -831,6 +817,7 @@
             add_one_vlan_table_flow(
                 ctrl=self.controller,
                 of_port=in_port,
+                out_vlan_id=1,
                 vlan_id=vlan_id,
                 flag=VLAN_TABLE_FLAG_ONLY_UNTAG
                 )
@@ -843,7 +830,6 @@
                     )
             tcpv6_pkt = str( parsed_tcpv6_pkt )
             self.dataplane.send(in_port, tcpv6_pkt)
-            print_port_stats(self, in_port)
             parsed_tcpv6_pkt = simple_tcpv6_packet(
                     pktlen=100,
                     eth_dst=dst_mac_str,
@@ -853,8 +839,6 @@
                     ipv6_hlim=63
                     )
             tcpv6_pkt = str( parsed_tcpv6_pkt )
-            time.sleep(2)
-            print_port_stats(self, in_port)
             verify_packet(self, tcpv6_pkt, out_port )
             verify_no_packet(self, tcpv6_pkt, in_port )
             verify_no_other_packets(self)
@@ -955,7 +939,6 @@
                     )
             tcpv6_pkt = str( parsed_tcpv6_pkt )
             self.dataplane.send(in_port, tcpv6_pkt)
-            print_port_stats(self, in_port)
             parsed_tcpv6_pkt = simple_tcpv6_packet(
                     pktlen=100,
                     eth_dst=dst_mac_str,
@@ -964,8 +947,6 @@
                     ipv6_src=sip,
                     ipv6_hlim=63
                     )
-            time.sleep(2)
-            print_port_stats(self, in_port)
             tcpv6_pkt = str( parsed_tcpv6_pkt )
             verify_packet(self, tcpv6_pkt, out_port )
             verify_no_packet(self, tcpv6_pkt, in_port )
@@ -1075,7 +1056,6 @@
                     )
             mplsv6_pkt = str( parsed_mplsv6_pkt )
             self.dataplane.send(in_port, mplsv6_pkt)
-            print_port_stats(self, in_port)
             parsed_tcpv6_pkt = simple_tcpv6_packet(
                     pktlen=100,
                     eth_dst=dst_mac_str,
@@ -1085,8 +1065,6 @@
                     ipv6_hlim=63
                     )
             tcpv6_pkt = str( parsed_tcpv6_pkt )
-            time.sleep(2)
-            print_port_stats(self, in_port)
             verify_packet(self, tcpv6_pkt, out_port )
             verify_no_packet(self, tcpv6_pkt, in_port )
             verify_no_other_packets(self)
diff --git a/ofdpa/pw_flows.py b/ofdpa/pw_flows.py
index 564ca56..01fabb9 100644
--- a/ofdpa/pw_flows.py
+++ b/ofdpa/pw_flows.py
@@ -2,6 +2,7 @@
 Check README file
 """
 import Queue
+import time
 
 from oftest import config
 import inspect
@@ -1699,3 +1700,133 @@
             delete_groups( self.controller, Groups )
             delete_groups( self.controller, Groups2 )
             delete_all_groups( self.controller )
+
+class BoSBug( base_tests.SimpleDataPlane ):
+    """
+    This test is meant to verify the forwarding of the default traffic
+    when the rule for the PW transport (BoS=0) has been installed in the
+    switch, together with the rule for the transport of default routing
+    traffic. There is a bug in OFDPA 3.0EA4, which requires BOS=0 flow
+    to be installed before BOS=1 flow to generate correct packets. Incoming
+    packet has 1 label, and there is no VLAN tag in the incoming packet.
+    The expected behvior is the Pop of the outer MPLS label and plain IP
+    packet should exit from the switch.
+    """
+    def runTest( self ):
+        Groups = Queue.LifoQueue( )
+        try:
+            if len( config[ "port_map" ] ) < 1:
+                logging.info( "Port count less than 1, can't run this case" )
+                assert (False)
+                return
+            ports           = config[ "port_map" ].keys( )
+            in_port         = ports[0]
+            out_port        = ports[1]
+            out_vlan        = 4094
+            src_mac         = [ 0x00, 0x00, 0x00, 0x00, 0x11, 0x01 ]
+            src_mac_str     = ':'.join( [ '%02X' % x for x in src_mac ] )
+            dst_mac         = [ 0x00, 0x00, 0x00, 0x11, 0x11, 0x01 ]
+            dst_mac_str     = ':'.join( [ '%02X' % x for x in dst_mac ] )
+            mpls_label      = 100
+            # Add l2 interface group, we have to pop the VLAN;
+            l2_intf_gid, l2_intf_msg = add_one_l2_interface_group(
+                ctrl=self.controller,
+                port=out_port,
+                vlan_id=out_vlan,
+                is_tagged=False,
+                send_barrier=False
+                )
+            Groups._put( l2_intf_gid )
+            # add MPLS interface group
+            mpls_intf_gid, mpls_intf_msg = add_mpls_intf_group(
+                ctrl=self.controller,
+                ref_gid=l2_intf_gid,
+                dst_mac=dst_mac,
+                src_mac=src_mac,
+                vid=out_vlan,
+                index=in_port
+                )
+            Groups._put( mpls_intf_gid )
+            # Add L3 Unicast  group
+            l3_msg = add_l3_unicast_group(
+                ctrl=self.controller,
+                port=out_port,
+                vlanid=out_vlan,
+                id=in_port,
+                src_mac=src_mac,
+                dst_mac=dst_mac
+                )
+            Groups._put( l3_msg.group_id )
+            # Add L3 ecmp group
+            ecmp_msg = add_l3_ecmp_group(
+                ctrl=self.controller,
+                id=in_port,
+                l3_ucast_groups=[ l3_msg.group_id ]
+                )
+            Groups._put( ecmp_msg.group_id )
+            # Add MPLS flow with BoS=1
+            add_mpls_flow(
+                ctrl=self.controller,
+                action_group_id=ecmp_msg.group_id,
+                label=mpls_label
+                )
+            # add MPLS flow with BoS=0
+            add_mpls_flow_pw(
+                ctrl=self.controller,
+                action_group_id=mpls_intf_gid,
+                label=mpls_label,
+                ethertype=0x8847,
+                tunnel_index=1,
+                bos=0
+                )
+            # add Termination flow
+            add_termination_flow(
+                ctrl=self.controller,
+                in_port=in_port,
+                eth_type=0x8847,
+                dst_mac=src_mac,
+                vlanid=out_vlan,
+                goto_table=23
+                )
+            # add VLAN flows
+            add_one_vlan_table_flow(
+                ctrl=self.controller,
+                of_port=in_port,
+                vlan_id=out_vlan,
+                flag=VLAN_TABLE_FLAG_ONLY_TAG,
+                )
+            add_one_vlan_table_flow(
+                ctrl=self.controller,
+                of_port=in_port,
+                vlan_id=out_vlan,
+                flag=VLAN_TABLE_FLAG_ONLY_UNTAG
+                )
+            # Packet generation with sleep
+            time.sleep(2)
+            label = (mpls_label, 0, 1, 32)
+            parsed_pkt = mpls_packet(
+                pktlen=104,
+                vlan_vid=out_vlan,
+                ip_ttl=63,
+                eth_dst=src_mac_str,
+                label=[ label]
+            )
+            pkt = str( parsed_pkt )
+            self.dataplane.send( in_port, pkt )
+            # we geneate the expected pw packet
+            parsed_pkt = simple_tcp_packet(
+                pktlen=100,
+                vlan_vid=out_vlan,
+                ip_ttl=31,
+                eth_dst=dst_mac_str,
+                eth_src=src_mac_str,
+            )
+            pkt = str( parsed_pkt )
+            # Assertions
+            verify_packet( self, pkt, out_port )
+            verify_no_packet( self, pkt, in_port )
+            verify_no_other_packets( self )
+        finally:
+            delete_all_flows( self.controller )
+            delete_groups( self.controller, Groups )
+            delete_all_groups( self.controller )
\ No newline at end of file
diff --git a/ofdpa/utils.py b/ofdpa/utils.py
index f4236a2..253c037 100644
--- a/ofdpa/utils.py
+++ b/ofdpa/utils.py
@@ -148,9 +148,9 @@
 
         L2_Groups = []
         # add vlan flows table
-        add_one_vlan_table_flow( controller, in_port, port_to_in_vlan[in_port], flag=VLAN_TABLE_FLAG_ONLY_TAG )
+        add_one_vlan_table_flow( controller, in_port, 1, port_to_in_vlan[in_port], flag=VLAN_TABLE_FLAG_ONLY_TAG )
         if not is_ingress_tagged:
-            add_one_vlan_table_flow( controller, in_port, port_to_in_vlan[in_port], flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
+            add_one_vlan_table_flow( controller, in_port, 1, port_to_in_vlan[in_port], flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
         elif is_vlan_translated:
             add_one_vlan_table_flow_translation( controller, in_port, port_to_in_vlan[in_port], port_to_out_vlan[in_port], flag=VLAN_TABLE_FLAG_ONLY_TAG)
         # add termination flow
@@ -279,7 +279,7 @@
         # add termination flow
         add_termination_flow( controller, port, 0x0800, switch_mac, port_to_in_vlan[port] )
         # add vlan flow table
-        add_one_vlan_table_flow( controller, port, port_to_in_vlan[port], flag=VLAN_TABLE_FLAG_ONLY_TAG )
+        add_one_vlan_table_flow( controller, port, 1, port_to_in_vlan[port], flag=VLAN_TABLE_FLAG_ONLY_TAG )
 
     return (
         port_to_in_vlan,