[VOL-4714] Adding option to remove all the flows when an ONU is disabled
Change-Id: Icb03c38f813aaed87fe90b001081faca185a2e12
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 55d8964..080aa34 100644
--- a/impl/src/main/java/org/opencord/olt/impl/OltFlowService.java
+++ b/impl/src/main/java/org/opencord/olt/impl/OltFlowService.java
@@ -111,34 +111,13 @@
import static org.opencord.olt.impl.OltUtils.flowOpToString;
import static org.opencord.olt.impl.OltUtils.getPortName;
import static org.opencord.olt.impl.OltUtils.portWithName;
-import static org.opencord.olt.impl.OsgiPropertyConstants.DEFAULT_TP_ID;
-import static org.opencord.olt.impl.OsgiPropertyConstants.DEFAULT_TP_ID_DEFAULT;
-import static org.opencord.olt.impl.OsgiPropertyConstants.DOWNSTREAM_OLT;
-import static org.opencord.olt.impl.OsgiPropertyConstants.DOWNSTREAM_ONU;
-import static org.opencord.olt.impl.OsgiPropertyConstants.ENABLE_DHCP_ON_NNI;
-import static org.opencord.olt.impl.OsgiPropertyConstants.ENABLE_DHCP_ON_NNI_DEFAULT;
-import static org.opencord.olt.impl.OsgiPropertyConstants.ENABLE_DHCP_V4;
-import static org.opencord.olt.impl.OsgiPropertyConstants.ENABLE_DHCP_V4_DEFAULT;
-import static org.opencord.olt.impl.OsgiPropertyConstants.ENABLE_DHCP_V6;
-import static org.opencord.olt.impl.OsgiPropertyConstants.ENABLE_DHCP_V6_DEFAULT;
-import static org.opencord.olt.impl.OsgiPropertyConstants.ENABLE_EAPOL;
-import static org.opencord.olt.impl.OsgiPropertyConstants.ENABLE_EAPOL_DEFAULT;
-import static org.opencord.olt.impl.OsgiPropertyConstants.ENABLE_IGMP_ON_NNI;
-import static org.opencord.olt.impl.OsgiPropertyConstants.ENABLE_IGMP_ON_NNI_DEFAULT;
-import static org.opencord.olt.impl.OsgiPropertyConstants.ENABLE_PPPOE_ON_NNI;
-import static org.opencord.olt.impl.OsgiPropertyConstants.ENABLE_PPPOE_ON_NNI_DEFAULT;
-import static org.opencord.olt.impl.OsgiPropertyConstants.ENABLE_PPPOE;
-import static org.opencord.olt.impl.OsgiPropertyConstants.ENABLE_PPPOE_DEFAULT;
+import static org.opencord.olt.impl.OsgiPropertyConstants.*;
import static org.opencord.olt.impl.fttb.FttbUtils.FTTB_FLOW_DIRECTION;
import static org.opencord.olt.impl.fttb.FttbUtils.FTTB_FLOW_DOWNSTREAM;
import static org.opencord.olt.impl.fttb.FttbUtils.FTTB_FLOW_UPSTREAM;
import static org.opencord.olt.impl.fttb.FttbUtils.FTTB_SERVICE_DPU_ANCP_TRAFFIC;
import static org.opencord.olt.impl.fttb.FttbUtils.FTTB_SERVICE_DPU_MGMT_TRAFFIC;
import static org.opencord.olt.impl.fttb.FttbUtils.FTTB_SERVICE_NAME;
-import static org.opencord.olt.impl.OsgiPropertyConstants.UPSTREAM_OLT;
-import static org.opencord.olt.impl.OsgiPropertyConstants.UPSTREAM_ONU;
-import static org.opencord.olt.impl.OsgiPropertyConstants.WAIT_FOR_REMOVAL;
-import static org.opencord.olt.impl.OsgiPropertyConstants.WAIT_FOR_REMOVAL_DEFAULT;
import static org.opencord.olt.impl.fttb.FttbUtils.FTTB_SERVICE_SUBSCRIBER_TRAFFIC;
@Component(immediate = true, property = {
@@ -151,7 +130,8 @@
ENABLE_PPPOE + ":Boolean=" + ENABLE_PPPOE_DEFAULT,
DEFAULT_TP_ID + ":Integer=" + DEFAULT_TP_ID_DEFAULT,
// FIXME remove this option as potentially dangerous in production
- WAIT_FOR_REMOVAL + ":Boolean=" + WAIT_FOR_REMOVAL_DEFAULT
+ WAIT_FOR_REMOVAL + ":Boolean=" + WAIT_FOR_REMOVAL_DEFAULT,
+ REMOVE_FLOWS_ON_DISABLE + ":Boolean=" + REMOVE_FLOWS_ON_DISABLE_DEFAULT
})
public class OltFlowService implements OltFlowServiceInterface {
@@ -279,6 +259,11 @@
protected boolean waitForRemoval = WAIT_FOR_REMOVAL_DEFAULT;
+ /**
+ * Removes all the flows on an ONU disable.
+ **/
+ protected boolean removeFlowsOnDisable = REMOVE_FLOWS_ON_DISABLE_DEFAULT;
+
protected InternalFlowListener internalFlowListener;
@Activate
@@ -620,7 +605,8 @@
// 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) {
+ if ((!isPortPresent || sub.port.isEnabled() || sub.status == DiscoveredSubscriber.Status.ADMIN_REMOVED)
+ || removeFlowsOnDisable) {
handleSubscriberDhcpFlows(sub.device.id(), sub.port, FlowOperation.REMOVE, si);
diff --git a/impl/src/main/java/org/opencord/olt/impl/OsgiPropertyConstants.java b/impl/src/main/java/org/opencord/olt/impl/OsgiPropertyConstants.java
index 089edbc..d03eab4 100644
--- a/impl/src/main/java/org/opencord/olt/impl/OsgiPropertyConstants.java
+++ b/impl/src/main/java/org/opencord/olt/impl/OsgiPropertyConstants.java
@@ -64,6 +64,10 @@
public static final String WAIT_FOR_REMOVAL = "waitForRemoval";
public static final boolean WAIT_FOR_REMOVAL_DEFAULT = true;
+ public static final String REMOVE_FLOWS_ON_DISABLE = "removeFlowsOnDisable";
+
+ public static final boolean REMOVE_FLOWS_ON_DISABLE_DEFAULT = true;
+
public static final String REQUIRED_DRIVERS_PROPERTY_DELAY = "requiredDriversPropertyDelay";
public static final int REQUIRED_DRIVERS_PROPERTY_DELAY_DEFAULT = 5;