Fixing metadata for FTTB flows

Change-Id: I76a46626a1b42b0e15d04d86405b1309be30ef8c
diff --git a/impl/src/main/java/org/opencord/olt/impl/OltFlowService.java b/impl/src/main/java/org/opencord/olt/impl/OltFlowService.java
index 3a2c818..ebe0505 100644
--- a/impl/src/main/java/org/opencord/olt/impl/OltFlowService.java
+++ b/impl/src/main/java/org/opencord/olt/impl/OltFlowService.java
@@ -615,6 +615,7 @@
         // side is still up as nothing changed, so no need to add/remove flows, when and if the UNI comes up
         // we will re-push the EAPOL flow to require the subscriber to auth again.
         // When the subscriber is admin removed from REST or CLI we ignore the port status.
+        // Check the admin Status of the port
         if (!isPortPresent || sub.port.isEnabled() || sub.status == DiscoveredSubscriber.Status.ADMIN_REMOVED) {
 
             handleSubscriberDhcpFlows(sub.device.id(), sub.port, FlowOperation.REMOVE, si);
@@ -1836,7 +1837,7 @@
         }
 
         VlanId innerVlan = null;
-
+        treatmentBuilder.setOutput(nniPort.number());
         if (serviceName.equals(FTTB_SERVICE_DPU_MGMT_TRAFFIC) || serviceName.equals(FTTB_SERVICE_DPU_ANCP_TRAFFIC)) {
             MacAddress mac = FttbUtils.getMacAddressFromDhcpEnabledUti(
                     hostService, si, deviceId, port);
@@ -1848,15 +1849,15 @@
             }
 
             selectorBuilder.matchEthSrc(mac);
-            innerVlan = VlanId.NONE;
+
+            treatmentBuilder.writeMetadata(OltFlowServiceUtils.createMetadata(VlanId.NONE,
+                    uti.getTechnologyProfileId(), nniPort.number()), 0L);
 
         } else if (serviceName.equals(FTTB_SERVICE_SUBSCRIBER_TRAFFIC)) {
-            innerVlan = VlanId.ANY;
+            treatmentBuilder.writeMetadata(OltFlowServiceUtils.createMetadata(VlanId.ANY,
+                    uti.getTechnologyProfileId(), nniPort.number()), 0L);
         }
 
-        treatmentBuilder.setOutput(nniPort.number()).writeMetadata(OltFlowServiceUtils.createMetadata(innerVlan,
-                uti.getTechnologyProfileId(), nniPort.number()), 0L);
-
         DefaultForwardingObjective.Builder flowBuilder = createForwardingObjectiveBuilder(selectorBuilder.build(),
                 treatmentBuilder.build(), MIN_PRIORITY,
                 annotationBuilder.build());
@@ -1909,16 +1910,17 @@
 
             selectorBuilder.matchEthDst(mac);
             innerVlan = VlanId.NONE;
+            treatmentBuilder.writeMetadata(OltFlowServiceUtils.createMetadata(innerVlan,
+                    uti.getTechnologyProfileId(),
+                    port.number()), 0);
 
         } else if (serviceName.equals(FTTB_SERVICE_SUBSCRIBER_TRAFFIC)) {
-            innerVlan = VlanId.ANY;
-            selectorBuilder.matchMetadata(uti.getPonSTag().toShort());
+            selectorBuilder.matchMetadata(uti.getPonCTag().toShort());
+            treatmentBuilder.writeMetadata(OltFlowServiceUtils.createMetadata(VlanId.ANY,
+                    uti.getTechnologyProfileId(),
+                    port.number()), 0);
         }
 
-        treatmentBuilder.writeMetadata(OltFlowServiceUtils.createMetadata(innerVlan,
-                uti.getTechnologyProfileId(),
-                port.number()), 0);
-
         DefaultForwardingObjective.Builder flowBuilder = createForwardingObjectiveBuilder(selectorBuilder.build(),
                 treatmentBuilder.build(), MIN_PRIORITY, annotationBuilder.build());