remove eapol rule when vlan rules are pushed.

reinstall eapol rule when vlan rule is removed.

Change-Id: I6e5f502206dacd915127d38d9309e34b20f46de4
diff --git a/app/src/main/java/org/onosproject/olt/impl/Olt.java b/app/src/main/java/org/onosproject/olt/impl/Olt.java
index 5e3d36c..16e8a9e 100644
--- a/app/src/main/java/org/onosproject/olt/impl/Olt.java
+++ b/app/src/main/java/org/onosproject/olt/impl/Olt.java
@@ -150,7 +150,8 @@
                 .flatMap(did -> deviceService.getPorts(did).stream())
                 .filter(p -> !oltData.get(p.element().id()).uplink().equals(p.number()))
                 .filter(p -> p.isEnabled())
-                .forEach(p -> processFilteringObjectives((DeviceId) p.element().id(), p, true));
+                .forEach(p -> processFilteringObjectives((DeviceId) p.element().id(),
+                                                         p.number(), true));
 
         deviceService.addListener(deviceListener);
 
@@ -232,6 +233,7 @@
                                            deviceId,
                                            deviceVlan,
                                            subscriberVlan));
+                processFilteringObjectives(deviceId, subscriberPort, true);
             } else if (downStatus != null) {
                 log.error("Subscriber with vlan {} on device {} " +
                                   "on port {} failed downstream uninstallation: {}",
@@ -333,6 +335,8 @@
                                            deviceId,
                                            deviceVlan,
                                            subscriberVlan));
+
+                processFilteringObjectives(deviceId, subscriberPort, false);
             } else if (downStatus != null) {
                 log.error("Subscriber with vlan {} on device {} " +
                                   "on port {} failed downstream installation: {}",
@@ -346,11 +350,11 @@
 
     }
 
-    private void processFilteringObjectives(DeviceId devId, Port port, boolean install) {
+    private void processFilteringObjectives(DeviceId devId, PortNumber port, boolean install) {
         DefaultFilteringObjective.Builder builder = DefaultFilteringObjective.builder();
 
         FilteringObjective eapol = (install ? builder.permit() : builder.deny())
-                .withKey(Criteria.matchInPort(port.number()))
+                .withKey(Criteria.matchInPort(port))
                 .addCondition(Criteria.matchEthType(EthType.EtherType.EAPOL.ethType()))
                 .withMeta(DefaultTrafficTreatment.builder()
                                   .setOutput(PortNumber.CONTROLLER).build())
@@ -388,7 +392,7 @@
                 case PORT_ADDED:
                     if (!oltData.get(devId).uplink().equals(event.port().number()) &&
                             event.port().isEnabled()) {
-                        processFilteringObjectives(devId, event.port(), true);
+                        processFilteringObjectives(devId, event.port().number(), true);
                     }
                     break;
                 case PORT_REMOVED:
@@ -398,7 +402,7 @@
                                           olt.vlan());
                     if (!oltData.get(devId).uplink().equals(event.port().number()) &&
                             event.port().isEnabled()) {
-                        processFilteringObjectives(devId, event.port(), false);
+                        processFilteringObjectives(devId, event.port().number(), false);
                     }
                     break;
                 case PORT_UPDATED:
@@ -406,9 +410,9 @@
                         break;
                     }
                     if (event.port().isEnabled()) {
-                        processFilteringObjectives(devId, event.port(), true);
+                        processFilteringObjectives(devId, event.port().number(), true);
                     } else {
-                        processFilteringObjectives(devId, event.port(), false);
+                        processFilteringObjectives(devId, event.port().number(), false);
                     }
                     break;
                 case DEVICE_ADDED:
@@ -471,7 +475,8 @@
         ports.stream()
                 .filter(p -> !oltData.get(p.element().id()).uplink().equals(p.number()))
                 .filter(p -> p.isEnabled())
-                .forEach(p -> processFilteringObjectives((DeviceId) p.element().id(), p, true));
+                .forEach(p -> processFilteringObjectives((DeviceId) p.element().id(),
+                                                         p.number(), true));
 
     }